Commit f5626ee2 authored by Steve Blackburn's avatar Steve Blackburn Committed by Commit Bot

Make the alignment of code explicit

Bug: v8:9533
Change-Id: I09a929839ca5cbad3f1a3154c6f143b242095ffa
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1995276Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Steve Blackburn <steveblackburn@google.com>
Cr-Commit-Position: refs/heads/master@{#65844}
parent 0e7cb821
......@@ -757,7 +757,12 @@ inline std::ostream& operator<<(std::ostream& os, AllocationType kind) {
}
// TODO(ishell): review and rename kWordAligned to kTaggedAligned.
enum AllocationAlignment { kWordAligned, kDoubleAligned, kDoubleUnaligned };
enum AllocationAlignment {
kWordAligned,
kDoubleAligned,
kDoubleUnaligned,
kCodeAligned
};
enum class AccessMode { ATOMIC, NON_ATOMIC };
......
......@@ -127,12 +127,15 @@ MaybeHandle<Code> Factory::CodeBuilder::BuildInternal(
HeapObject result;
AllocationType allocation_type =
is_executable_ ? AllocationType::kCode : AllocationType::kReadOnly;
AllocationAlignment alignment = is_executable_
? AllocationAlignment::kCodeAligned
: AllocationAlignment::kWordAligned;
if (retry_allocation_or_fail) {
result = heap->AllocateRawWith<Heap::kRetryOrFail>(object_size,
allocation_type);
result = heap->AllocateRawWith<Heap::kRetryOrFail>(
object_size, allocation_type, AllocationOrigin::kRuntime, alignment);
} else {
result = heap->AllocateRawWith<Heap::kLightRetry>(object_size,
allocation_type);
result = heap->AllocateRawWith<Heap::kLightRetry>(
object_size, allocation_type, AllocationOrigin::kRuntime, alignment);
// Return an empty handle if we cannot allocate the code object.
if (result.is_null()) return MaybeHandle<Code>();
}
......@@ -2496,7 +2499,8 @@ Handle<Code> Factory::CopyCode(Handle<Code> code) {
int obj_size = code->Size();
CodePageCollectionMemoryModificationScope code_allocation(heap);
HeapObject result = heap->AllocateRawWith<Heap::kRetryOrFail>(
obj_size, AllocationType::kCode);
obj_size, AllocationType::kCode, AllocationOrigin::kRuntime,
AllocationAlignment::kCodeAligned);
// Copy code object.
Address old_addr = code->address();
......
......@@ -160,6 +160,8 @@ AllocationResult Heap::AllocateRaw(int size_in_bytes, AllocationType type,
AllocationAlignment alignment) {
DCHECK(AllowHandleAllocation::IsAllowed());
DCHECK(AllowHeapAllocation::IsAllowed());
DCHECK_IMPLIES(type == AllocationType::kCode,
alignment == AllocationAlignment::kCodeAligned);
DCHECK_EQ(gc_state_, NOT_IN_GC);
#ifdef V8_ENABLE_ALLOCATION_TIMEOUT
if (FLAG_random_gc_interval > 0 || FLAG_gc_interval >= 0) {
......
......@@ -86,7 +86,10 @@ Handle<Object> HeapTester::TestAllocateAfterFailures() {
// Code space.
heap::SimulateFullSpace(heap->code_space());
size = CcTest::i_isolate()->builtins()->builtin(Builtins::kIllegal).Size();
obj = heap->AllocateRaw(size, AllocationType::kCode).ToObjectChecked();
obj =
heap->AllocateRaw(size, AllocationType::kCode, AllocationOrigin::kRuntime,
AllocationAlignment::kCodeAligned)
.ToObjectChecked();
heap->CreateFillerObjectAt(obj.address(), size, ClearRecordedSlots::kNo);
return CcTest::i_isolate()->factory()->true_value();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment