diff options
Diffstat (limited to 'deps/v8/src/heap/memory-chunk-layout.cc')
-rw-r--r-- | deps/v8/src/heap/memory-chunk-layout.cc | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/deps/v8/src/heap/memory-chunk-layout.cc b/deps/v8/src/heap/memory-chunk-layout.cc index e81aaec8f3..1fb265f39f 100644 --- a/deps/v8/src/heap/memory-chunk-layout.cc +++ b/deps/v8/src/heap/memory-chunk-layout.cc @@ -24,6 +24,12 @@ size_t MemoryChunkLayout::CodePageGuardSize() { } intptr_t MemoryChunkLayout::ObjectStartOffsetInCodePage() { + // The first page also includes padding for code alignment. + return ObjectPageOffsetInCodePage() + + InstructionStream::kCodeAlignmentMinusCodeHeader; +} + +intptr_t MemoryChunkLayout::ObjectPageOffsetInCodePage() { // We are guarding code pages: the first OS page after the header // will be protected as non-writable. return CodePageGuardStartOffset() + CodePageGuardSize(); @@ -46,11 +52,19 @@ intptr_t MemoryChunkLayout::ObjectStartOffsetInDataPage() { ALIGN_TO_ALLOCATION_ALIGNMENT(kDoubleSize)); } +intptr_t MemoryChunkLayout::ObjectStartOffsetInReadOnlyPage() { + return RoundUp(BasicMemoryChunk::kHeaderSize, + ALIGN_TO_ALLOCATION_ALIGNMENT(kDoubleSize)); +} + size_t MemoryChunkLayout::ObjectStartOffsetInMemoryChunk( AllocationSpace space) { if (space == CODE_SPACE || space == CODE_LO_SPACE) { return ObjectStartOffsetInCodePage(); } + if (space == RO_SPACE) { + return ObjectStartOffsetInReadOnlyPage(); + } return ObjectStartOffsetInDataPage(); } @@ -60,16 +74,26 @@ size_t MemoryChunkLayout::AllocatableMemoryInDataPage() { return memory; } +size_t MemoryChunkLayout::AllocatableMemoryInReadOnlyPage() { + size_t memory = MemoryChunk::kPageSize - ObjectStartOffsetInReadOnlyPage(); + DCHECK_LE(kMaxRegularHeapObjectSize, memory); + return memory; +} + size_t MemoryChunkLayout::AllocatableMemoryInMemoryChunk( AllocationSpace space) { if (space == CODE_SPACE) { return AllocatableMemoryInCodePage(); } + if (space == RO_SPACE) { + return AllocatableMemoryInReadOnlyPage(); + } return AllocatableMemoryInDataPage(); } int MemoryChunkLayout::MaxRegularCodeObjectSize() { - int size = static_cast<int>(AllocatableMemoryInCodePage() / 2); + int size = static_cast<int>( + RoundDown(AllocatableMemoryInCodePage() / 2, kTaggedSize)); DCHECK_LE(size, kMaxRegularHeapObjectSize); return size; } |