OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/heap/heap.h" | 5 #include "src/heap/heap.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/assembler-inl.h" | 9 #include "src/assembler-inl.h" |
10 #include "src/ast/context-slot-cache.h" | 10 #include "src/ast/context-slot-cache.h" |
(...skipping 4220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4231 local_embedder_heap_tracer()->ShouldFinalizeIncrementalMarking()))) { | 4231 local_embedder_heap_tracer()->ShouldFinalizeIncrementalMarking()))) { |
4232 FinalizeIncrementalMarking(gc_reason); | 4232 FinalizeIncrementalMarking(gc_reason); |
4233 } else if (incremental_marking()->IsComplete() || | 4233 } else if (incremental_marking()->IsComplete() || |
4234 (mark_compact_collector()->marking_deque()->IsEmpty() && | 4234 (mark_compact_collector()->marking_deque()->IsEmpty() && |
4235 local_embedder_heap_tracer() | 4235 local_embedder_heap_tracer() |
4236 ->ShouldFinalizeIncrementalMarking())) { | 4236 ->ShouldFinalizeIncrementalMarking())) { |
4237 CollectAllGarbage(current_gc_flags_, gc_reason, current_gc_callback_flags_); | 4237 CollectAllGarbage(current_gc_flags_, gc_reason, current_gc_callback_flags_); |
4238 } | 4238 } |
4239 } | 4239 } |
4240 | 4240 |
4241 void Heap::RegisterReservationsForBlackAllocation(Reservation* reservations) { | 4241 void Heap::RegisterDeserializedObjectsForBlackAllocation( |
| 4242 Reservation* reservations, List<HeapObject*>* large_objects) { |
4242 // TODO(hpayer): We do not have to iterate reservations on black objects | 4243 // TODO(hpayer): We do not have to iterate reservations on black objects |
4243 // for marking. We just have to execute the special visiting side effect | 4244 // for marking. We just have to execute the special visiting side effect |
4244 // code that adds objects to global data structures, e.g. for array buffers. | 4245 // code that adds objects to global data structures, e.g. for array buffers. |
4245 | 4246 |
4246 if (incremental_marking()->black_allocation()) { | 4247 if (!incremental_marking()->black_allocation()) return; |
4247 // Iterate black objects in old space, code space, map space, and large | 4248 |
4248 // object space for side effects. | 4249 // Iterate black objects in old space, code space, map space, and large |
4249 for (int i = OLD_SPACE; i < Serializer::kNumberOfSpaces; i++) { | 4250 // object space for side effects. |
4250 const Heap::Reservation& res = reservations[i]; | 4251 for (int i = OLD_SPACE; i < Serializer::kNumberOfSpaces; i++) { |
4251 for (auto& chunk : res) { | 4252 const Heap::Reservation& res = reservations[i]; |
4252 Address addr = chunk.start; | 4253 for (auto& chunk : res) { |
4253 while (addr < chunk.end) { | 4254 Address addr = chunk.start; |
4254 HeapObject* obj = HeapObject::FromAddress(addr); | 4255 while (addr < chunk.end) { |
4255 // There might be grey objects due to black to grey transitions in | 4256 HeapObject* obj = HeapObject::FromAddress(addr); |
4256 // incremental marking. E.g. see VisitNativeContextIncremental. | 4257 // There might be grey objects due to black to grey transitions in |
4257 DCHECK( | 4258 // incremental marking. E.g. see VisitNativeContextIncremental. |
4258 ObjectMarking::IsBlackOrGrey(obj, MarkingState::Internal(obj))); | 4259 DCHECK(ObjectMarking::IsBlackOrGrey(obj, MarkingState::Internal(obj))); |
4259 if (ObjectMarking::IsBlack(obj, MarkingState::Internal(obj))) { | 4260 if (ObjectMarking::IsBlack(obj, MarkingState::Internal(obj))) { |
4260 incremental_marking()->IterateBlackObject(obj); | 4261 incremental_marking()->IterateBlackObject(obj); |
4261 } | |
4262 addr += obj->Size(); | |
4263 } | 4262 } |
| 4263 addr += obj->Size(); |
4264 } | 4264 } |
4265 } | 4265 } |
4266 // We potentially deserialized wrappers which require registering with the | 4266 } |
4267 // embedder as the marker will not find them. | 4267 // We potentially deserialized wrappers which require registering with the |
4268 local_embedder_heap_tracer()->RegisterWrappersWithRemoteTracer(); | 4268 // embedder as the marker will not find them. |
| 4269 local_embedder_heap_tracer()->RegisterWrappersWithRemoteTracer(); |
| 4270 |
| 4271 // Large object space doesn't use reservations, so it needs custom handling. |
| 4272 for (HeapObject* object : *large_objects) { |
| 4273 incremental_marking()->IterateBlackObject(object); |
4269 } | 4274 } |
4270 } | 4275 } |
4271 | 4276 |
4272 void Heap::NotifyObjectLayoutChange(HeapObject* object, | 4277 void Heap::NotifyObjectLayoutChange(HeapObject* object, |
4273 const DisallowHeapAllocation&) { | 4278 const DisallowHeapAllocation&) { |
4274 if (FLAG_incremental_marking && incremental_marking()->IsMarking()) { | 4279 if (FLAG_incremental_marking && incremental_marking()->IsMarking()) { |
4275 incremental_marking()->WhiteToGreyAndPush(object); | 4280 incremental_marking()->WhiteToGreyAndPush(object); |
4276 } | 4281 } |
4277 #ifdef VERIFY_HEAP | 4282 #ifdef VERIFY_HEAP |
4278 DCHECK(pending_layout_change_object_ == nullptr); | 4283 DCHECK(pending_layout_change_object_ == nullptr); |
(...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5370 } | 5375 } |
5371 return true; | 5376 return true; |
5372 } | 5377 } |
5373 | 5378 |
5374 // This function returns either kNoLimit, kSoftLimit, or kHardLimit. | 5379 // This function returns either kNoLimit, kSoftLimit, or kHardLimit. |
5375 // The kNoLimit means that either incremental marking is disabled or it is too | 5380 // The kNoLimit means that either incremental marking is disabled or it is too |
5376 // early to start incremental marking. | 5381 // early to start incremental marking. |
5377 // The kSoftLimit means that incremental marking should be started soon. | 5382 // The kSoftLimit means that incremental marking should be started soon. |
5378 // The kHardLimit means that incremental marking should be started immediately. | 5383 // The kHardLimit means that incremental marking should be started immediately. |
5379 Heap::IncrementalMarkingLimit Heap::IncrementalMarkingLimitReached() { | 5384 Heap::IncrementalMarkingLimit Heap::IncrementalMarkingLimitReached() { |
5380 if (!incremental_marking()->CanBeActivated() || | 5385 // Code using an AlwaysAllocateScope assumes that the GC state does not |
| 5386 // change; that implies that no marking steps must be performed. |
| 5387 if (!incremental_marking()->CanBeActivated() || always_allocate() || |
5381 PromotedSpaceSizeOfObjects() <= | 5388 PromotedSpaceSizeOfObjects() <= |
5382 IncrementalMarking::kActivationThreshold) { | 5389 IncrementalMarking::kActivationThreshold) { |
5383 // Incremental marking is disabled or it is too early to start. | 5390 // Incremental marking is disabled or it is too early to start. |
5384 return IncrementalMarkingLimit::kNoLimit; | 5391 return IncrementalMarkingLimit::kNoLimit; |
5385 } | 5392 } |
5386 if ((FLAG_stress_compaction && (gc_count_ & 1) != 0) || | 5393 if ((FLAG_stress_compaction && (gc_count_ & 1) != 0) || |
5387 HighMemoryPressure()) { | 5394 HighMemoryPressure()) { |
5388 // If there is high memory pressure or stress testing is enabled, then | 5395 // If there is high memory pressure or stress testing is enabled, then |
5389 // start marking immediately. | 5396 // start marking immediately. |
5390 return IncrementalMarkingLimit::kHardLimit; | 5397 return IncrementalMarkingLimit::kHardLimit; |
(...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6391 case LO_SPACE: | 6398 case LO_SPACE: |
6392 return "LO_SPACE"; | 6399 return "LO_SPACE"; |
6393 default: | 6400 default: |
6394 UNREACHABLE(); | 6401 UNREACHABLE(); |
6395 } | 6402 } |
6396 return NULL; | 6403 return NULL; |
6397 } | 6404 } |
6398 | 6405 |
6399 } // namespace internal | 6406 } // namespace internal |
6400 } // namespace v8 | 6407 } // namespace v8 |
OLD | NEW |