/
githubmirror
/
node
Обзор
Документация
Войти
/
githubmirror
/
node
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
deps/v8/src/heap/memory-chunk-layout.h
71 строка
2 KB
Michaël Zasso
deps: update V8 to 13.6.233.8
02 май 2025, 16:06
Не верифицирован
02 май 2025, 16:06
918fe04
Код
Авторство
О чём код?
// Copyright 2020 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef V8_HEAP_MEMORY_CHUNK_LAYOUT_H_ #define V8_HEAP_MEMORY_CHUNK_LAYOUT_H_ #include "src/common/globals.h" #include "src/heap/memory-chunk.h" #include "src/objects/instruction-stream.h" namespace v8::internal { class V8_EXPORT_PRIVATE MemoryChunkLayout final { public: // Code pages have padding on the first page for code alignment, so the // ObjectStartOffset will not be page aligned. static constexpr intptr_t ObjectStartOffsetInCodePage() { // The instruction stream data (so after the header) should be aligned to // kCodeAlignment. return RoundUp(sizeof(MemoryChunk) + InstructionStream::kHeaderSize, kCodeAlignment) - InstructionStream::kHeaderSize; } static constexpr size_t AllocatableMemoryInCodePage() { return kRegularPageSize - ObjectStartOffsetInCodePage(); } static constexpr size_t ObjectStartOffsetInDataPage() { return RoundUp(sizeof(MemoryChunk), ALIGN_TO_ALLOCATION_ALIGNMENT(kDoubleSize)); } static constexpr size_t AllocatableMemoryInDataPage() { constexpr size_t kAllocatableMemoryInDataPage = kRegularPageSize - ObjectStartOffsetInDataPage(); static_assert(kMaxRegularHeapObjectSize <= kAllocatableMemoryInDataPage); return kAllocatableMemoryInDataPage; } static constexpr size_t ObjectStartOffsetInMemoryChunk( AllocationSpace space) { if (IsAnyCodeSpace(space)) { return ObjectStartOffsetInCodePage(); } // Read-only pages use the same layout as regular pages. return ObjectStartOffsetInDataPage(); } static constexpr size_t AllocatableMemoryInMemoryChunk( AllocationSpace space) { DCHECK_NE(space, CODE_LO_SPACE); if (space == CODE_SPACE) { return AllocatableMemoryInCodePage(); } // Read-only pages use the same layout as regular pages. return AllocatableMemoryInDataPage(); } static constexpr int MaxRegularCodeObjectSize() { constexpr int kMaxRegularCodeObjectSize = static_cast<int>( RoundDown(AllocatableMemoryInCodePage() / 2, kTaggedSize)); static_assert(kMaxRegularCodeObjectSize <= kMaxRegularHeapObjectSize); return kMaxRegularCodeObjectSize; } }; } // namespace v8::internal #endif // V8_HEAP_MEMORY_CHUNK_LAYOUT_H_