| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 78680c1 commit ae1fa98
18 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -205,6 +205,10 @@ | |||
| 205 | 205 | // PPC has large (64KB) physical pages. | |
| 206 | 206 | const int kPageSizeBits = 19; | |
| 207 | 207 | #else | |
| 208 | + // Arm64 supports up to 64k OS pages on Linux, however 4k pages are more common | ||
| 209 | + // so we keep the V8 page size at 256k. Nonetheless, we need to make sure we | ||
| 210 | + // don't decrease it further in the future due to reserving 3 OS pages for every | ||
| 211 | + // executable V8 page. | ||
| 208 | 212 | const int kPageSizeBits = 18; | |
| 209 | 213 | #endif | |
| 210 | 214 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,7 +27,7 @@ class AllocationBuilder final { | |||
| 27 | 27 | // Primitive allocation of static size. | |
| 28 | 28 | void Allocate(int size, AllocationType allocation = AllocationType::kYoung, | |
| 29 | 29 | Type type = Type::Any()) { | |
| 30 | - DCHECK_LE(size, kMaxRegularHeapObjectSize); | ||
| 30 | + DCHECK_LE(size, Heap::MaxRegularHeapObjectSize(allocation)); | ||
| 31 | 31 | effect_ = graph()->NewNode( | |
| 32 | 32 | common()->BeginRegion(RegionObservability::kNotObservable), effect_); | |
| 33 | 33 | allocation_ = | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -98,6 +98,10 @@ Reduction MemoryLowering::ReduceAllocateRaw( | |||
| 98 | 98 | DCHECK_EQ(IrOpcode::kAllocateRaw, node->opcode()); | |
| 99 | 99 | DCHECK_IMPLIES(allocation_folding_ == AllocationFolding::kDoAllocationFolding, | |
| 100 | 100 | state_ptr != nullptr); | |
| 101 | + // Code objects may have a maximum size smaller than kMaxHeapObjectSize due to | ||
| 102 | + // guard pages. If we need to support allocating code here we would need to | ||
| 103 | + // call MemoryChunkLayout::MaxRegularCodeObjectSize() at runtime. | ||
| 104 | + DCHECK_NE(allocation_type, AllocationType::kCode); | ||
| 101 | 105 | Node* value; | |
| 102 | 106 | Node* size = node->InputAt(0); | |
| 103 | 107 | Node* effect = node->InputAt(1); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -955,7 +955,8 @@ void Code::CodeVerify(Isolate* isolate) { | |||
| 955 | 955 | // everything is set up. | |
| 956 | 956 | // CHECK_EQ(ReadOnlyHeap::Contains(*this), !IsExecutable()); | |
| 957 | 957 | relocation_info().ObjectVerify(isolate); | |
| 958 | - CHECK(Code::SizeFor(body_size()) <= kMaxRegularHeapObjectSize || | ||
| 958 | + CHECK(Code::SizeFor(body_size()) <= | ||
| 959 | + MemoryChunkLayout::MaxRegularCodeObjectSize() || | ||
| 959 | 960 | isolate->heap()->InSpace(*this, CODE_LO_SPACE)); | |
| 960 | 961 | Address last_gc_pc = kNullAddress; | |
| 961 | 962 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -721,7 +721,8 @@ template <typename Impl> | |||
| 721 | 721 | HeapObject FactoryBase<Impl>::AllocateRawArray(int size, | |
| 722 | 722 | AllocationType allocation) { | |
| 723 | 723 | HeapObject result = AllocateRaw(size, allocation); | |
| 724 | - if (size > kMaxRegularHeapObjectSize && FLAG_use_marking_progress_bar) { | ||
| 724 | + if ((size > Heap::MaxRegularHeapObjectSize(allocation)) && | ||
| 725 | + FLAG_use_marking_progress_bar) { | ||
| 725 | 726 | MemoryChunk* chunk = MemoryChunk::FromHeapObject(result); | |
| 726 | 727 | chunk->SetFlag<AccessMode::ATOMIC>(MemoryChunk::HAS_PROGRESS_BAR); | |
| 727 | 728 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -346,7 +346,8 @@ MaybeHandle<FixedArray> Factory::TryNewFixedArray( | |||
| 346 | 346 | AllocationResult allocation = heap->AllocateRaw(size, allocation_type); | |
| 347 | 347 | HeapObject result; | |
| 348 | 348 | if (!allocation.To(&result)) return MaybeHandle<FixedArray>(); | |
| 349 | - if (size > kMaxRegularHeapObjectSize && FLAG_use_marking_progress_bar) { | ||
| 349 | + if ((size > Heap::MaxRegularHeapObjectSize(allocation_type)) && | ||
| 350 | + FLAG_use_marking_progress_bar) { | ||
| 350 | 351 | MemoryChunk* chunk = MemoryChunk::FromHeapObject(result); | |
| 351 | 352 | chunk->SetFlag<AccessMode::ATOMIC>(MemoryChunk::HAS_PROGRESS_BAR); | |
| 352 | 353 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -192,7 +192,9 @@ AllocationResult Heap::AllocateRaw(int size_in_bytes, AllocationType type, | |||
| 192 | 192 | IncrementObjectCounters(); | |
| 193 | 193 | #endif | |
| 194 | 194 | ||
| 195 | - bool large_object = size_in_bytes > kMaxRegularHeapObjectSize; | ||
| 195 | + size_t large_object_threshold = MaxRegularHeapObjectSize(type); | ||
| 196 | + bool large_object = | ||
| 197 | + static_cast<size_t>(size_in_bytes) > large_object_threshold; | ||
| 196 | 198 | ||
| 197 | 199 | HeapObject object; | |
| 198 | 200 | AllocationResult allocation; | |
@@ -279,7 +281,7 @@ HeapObject Heap::AllocateRawWith(int size, AllocationType allocation, | |||
| 279 | 281 | Address* limit = heap->NewSpaceAllocationLimitAddress(); | |
| 280 | 282 | if (allocation == AllocationType::kYoung && | |
| 281 | 283 | alignment == AllocationAlignment::kWordAligned && | |
| 282 | - size <= kMaxRegularHeapObjectSize && | ||
| 284 | + size <= MaxRegularHeapObjectSize(allocation) && | ||
| 283 | 285 | (*limit - *top >= static_cast<unsigned>(size)) && | |
| 284 | 286 | V8_LIKELY(!FLAG_single_generation && FLAG_inline_new && | |
| 285 | 287 | FLAG_gc_interval == 0)) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4963,6 +4963,14 @@ bool Heap::AllocationLimitOvershotByLargeMargin() { | |||
| 4963 | 4963 | return v8_overshoot >= v8_margin || global_overshoot >= global_margin; | |
| 4964 | 4964 | } | |
| 4965 | 4965 | ||
| 4966 | + // static | ||
| 4967 | + int Heap::MaxRegularHeapObjectSize(AllocationType allocation) { | ||
| 4968 | + if (allocation == AllocationType::kCode) { | ||
| 4969 | + return MemoryChunkLayout::MaxRegularCodeObjectSize(); | ||
| 4970 | + } | ||
| 4971 | + return kMaxRegularHeapObjectSize; | ||
| 4972 | + } | ||
| 4973 | + | ||
| 4966 | 4974 | bool Heap::ShouldOptimizeForLoadTime() { | |
| 4967 | 4975 | return isolate()->rail_mode() == PERFORMANCE_LOAD && | |
| 4968 | 4976 | !AllocationLimitOvershotByLargeMargin() && | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -481,7 +481,7 @@ class Heap { | |||
| 481 | 481 | ||
| 482 | 482 | bool IsImmovable(HeapObject object); | |
| 483 | 483 | ||
| 484 | - static bool IsLargeObject(HeapObject object); | ||
| 484 | + V8_EXPORT_PRIVATE static bool IsLargeObject(HeapObject object); | ||
| 485 | 485 | ||
| 486 | 486 | // This method supports the deserialization allocator. All allocations | |
| 487 | 487 | // are word-aligned. The method should never fail to allocate since the | |
@@ -1316,6 +1316,14 @@ class Heap { | |||
| 1316 | 1316 | // more eager to finalize incremental marking. | |
| 1317 | 1317 | bool AllocationLimitOvershotByLargeMargin(); | |
| 1318 | 1318 | ||
| 1319 | + // Return the maximum size objects can be before having to allocate them as | ||
| 1320 | + // large objects. This takes into account allocating in the code space for | ||
| 1321 | + // which the size of the allocatable space per V8 page may depend on the OS | ||
| 1322 | + // page size at runtime. You may use kMaxRegularHeapObjectSize as a constant | ||
| 1323 | + // instead if you know the allocation isn't in the code spaces. | ||
| 1324 | + V8_EXPORT_PRIVATE static int MaxRegularHeapObjectSize( | ||
| 1325 | + AllocationType allocation); | ||
| 1326 | + | ||
| 1319 | 1327 | // =========================================================================== | |
| 1320 | 1328 | // Prologue/epilogue callback methods.======================================== | |
| 1321 | 1329 | // =========================================================================== | |
@@ -1404,8 +1412,10 @@ class Heap { | |||
| 1404 | 1412 | // Heap object allocation tracking. ========================================== | |
| 1405 | 1413 | // =========================================================================== | |
| 1406 | 1414 | ||
| 1407 | - void AddHeapObjectAllocationTracker(HeapObjectAllocationTracker* tracker); | ||
| 1408 | - void RemoveHeapObjectAllocationTracker(HeapObjectAllocationTracker* tracker); | ||
| 1415 | + V8_EXPORT_PRIVATE void AddHeapObjectAllocationTracker( | ||
| 1416 | + HeapObjectAllocationTracker* tracker); | ||
| 1417 | + V8_EXPORT_PRIVATE void RemoveHeapObjectAllocationTracker( | ||
| 1418 | + HeapObjectAllocationTracker* tracker); | ||
| 1409 | 1419 | bool has_heap_object_allocation_tracker() const { | |
| 1410 | 1420 | return !allocation_trackers_.empty(); | |
| 1411 | 1421 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -47,7 +47,6 @@ intptr_t MemoryChunkLayout::ObjectEndOffsetInCodePage() { | |||
| 47 | 47 | ||
| 48 | 48 | size_t MemoryChunkLayout::AllocatableMemoryInCodePage() { | |
| 49 | 49 | size_t memory = ObjectEndOffsetInCodePage() - ObjectStartOffsetInCodePage(); | |
| 50 | - DCHECK_LE(kMaxRegularHeapObjectSize, memory); | ||
| 51 | 50 | return memory; | |
| 52 | 51 | } | |
| 53 | 52 | ||
@@ -77,6 +76,12 @@ size_t MemoryChunkLayout::AllocatableMemoryInMemoryChunk( | |||
| 77 | 76 | return AllocatableMemoryInDataPage(); | |
| 78 | 77 | } | |
| 79 | 78 | ||
| 79 | + int MemoryChunkLayout::MaxRegularCodeObjectSize() { | ||
| 80 | + int size = static_cast<int>(AllocatableMemoryInCodePage() / 2); | ||
| 81 | + DCHECK_LE(size, kMaxRegularHeapObjectSize); | ||
| 82 | + return size; | ||
| 83 | + } | ||
| 84 | + | ||
| 80 | 85 | #ifdef THREAD_SANITIZER | |
| 81 | 86 | void MemoryChunk::SynchronizedHeapLoad() { | |
| 82 | 87 | CHECK(reinterpret_cast<Heap*>(base::Acquire_Load( | |
| Back | FazBrowse Home | New Git URL |
0 commit comments