| 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 4212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4223 local_embedder_heap_tracer()->ShouldFinalizeIncrementalMarking()))) { | 4223 local_embedder_heap_tracer()->ShouldFinalizeIncrementalMarking()))) { |
| 4224 FinalizeIncrementalMarking(gc_reason); | 4224 FinalizeIncrementalMarking(gc_reason); |
| 4225 } else if (incremental_marking()->IsComplete() || | 4225 } else if (incremental_marking()->IsComplete() || |
| 4226 (mark_compact_collector()->marking_deque()->IsEmpty() && | 4226 (mark_compact_collector()->marking_deque()->IsEmpty() && |
| 4227 local_embedder_heap_tracer() | 4227 local_embedder_heap_tracer() |
| 4228 ->ShouldFinalizeIncrementalMarking())) { | 4228 ->ShouldFinalizeIncrementalMarking())) { |
| 4229 CollectAllGarbage(current_gc_flags_, gc_reason); | 4229 CollectAllGarbage(current_gc_flags_, gc_reason); |
| 4230 } | 4230 } |
| 4231 } | 4231 } |
| 4232 | 4232 |
| 4233 bool Heap::TryFinalizeIdleIncrementalMarking( | |
| 4234 double idle_time_in_ms, GarbageCollectionReason gc_reason) { | |
| 4235 size_t size_of_objects = static_cast<size_t>(SizeOfObjects()); | |
| 4236 double final_incremental_mark_compact_speed_in_bytes_per_ms = | |
| 4237 tracer()->FinalIncrementalMarkCompactSpeedInBytesPerMillisecond(); | |
| 4238 if (incremental_marking()->IsReadyToOverApproximateWeakClosure() || | |
| 4239 (!incremental_marking()->finalize_marking_completed() && | |
| 4240 mark_compact_collector()->marking_deque()->IsEmpty() && | |
| 4241 local_embedder_heap_tracer()->ShouldFinalizeIncrementalMarking() && | |
| 4242 gc_idle_time_handler_->ShouldDoOverApproximateWeakClosure( | |
| 4243 idle_time_in_ms))) { | |
| 4244 FinalizeIncrementalMarking(gc_reason); | |
| 4245 return true; | |
| 4246 } else if (incremental_marking()->IsComplete() || | |
| 4247 (mark_compact_collector()->marking_deque()->IsEmpty() && | |
| 4248 local_embedder_heap_tracer() | |
| 4249 ->ShouldFinalizeIncrementalMarking() && | |
| 4250 gc_idle_time_handler_->ShouldDoFinalIncrementalMarkCompact( | |
| 4251 idle_time_in_ms, size_of_objects, | |
| 4252 final_incremental_mark_compact_speed_in_bytes_per_ms))) { | |
| 4253 CollectAllGarbage(current_gc_flags_, gc_reason); | |
| 4254 return true; | |
| 4255 } | |
| 4256 return false; | |
| 4257 } | |
| 4258 | |
| 4259 void Heap::RegisterReservationsForBlackAllocation(Reservation* reservations) { | 4233 void Heap::RegisterReservationsForBlackAllocation(Reservation* reservations) { |
| 4260 // TODO(hpayer): We do not have to iterate reservations on black objects | 4234 // TODO(hpayer): We do not have to iterate reservations on black objects |
| 4261 // for marking. We just have to execute the special visiting side effect | 4235 // for marking. We just have to execute the special visiting side effect |
| 4262 // code that adds objects to global data structures, e.g. for array buffers. | 4236 // code that adds objects to global data structures, e.g. for array buffers. |
| 4263 | 4237 |
| 4264 if (incremental_marking()->black_allocation()) { | 4238 if (incremental_marking()->black_allocation()) { |
| 4265 // Iterate black objects in old space, code space, map space, and large | 4239 // Iterate black objects in old space, code space, map space, and large |
| 4266 // object space for side effects. | 4240 // object space for side effects. |
| 4267 for (int i = OLD_SPACE; i < Serializer::kNumberOfSpaces; i++) { | 4241 for (int i = OLD_SPACE; i < Serializer::kNumberOfSpaces; i++) { |
| 4268 const Heap::Reservation& res = reservations[i]; | 4242 const Heap::Reservation& res = reservations[i]; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4325 switch (action.type) { | 4299 switch (action.type) { |
| 4326 case DONE: | 4300 case DONE: |
| 4327 result = true; | 4301 result = true; |
| 4328 break; | 4302 break; |
| 4329 case DO_INCREMENTAL_STEP: { | 4303 case DO_INCREMENTAL_STEP: { |
| 4330 const double remaining_idle_time_in_ms = | 4304 const double remaining_idle_time_in_ms = |
| 4331 incremental_marking()->AdvanceIncrementalMarking( | 4305 incremental_marking()->AdvanceIncrementalMarking( |
| 4332 deadline_in_ms, IncrementalMarking::NO_GC_VIA_STACK_GUARD, | 4306 deadline_in_ms, IncrementalMarking::NO_GC_VIA_STACK_GUARD, |
| 4333 IncrementalMarking::FORCE_COMPLETION, StepOrigin::kTask); | 4307 IncrementalMarking::FORCE_COMPLETION, StepOrigin::kTask); |
| 4334 if (remaining_idle_time_in_ms > 0.0) { | 4308 if (remaining_idle_time_in_ms > 0.0) { |
| 4335 TryFinalizeIdleIncrementalMarking( | 4309 FinalizeIncrementalMarkingIfComplete( |
| 4336 remaining_idle_time_in_ms, | |
| 4337 GarbageCollectionReason::kFinalizeMarkingViaTask); | 4310 GarbageCollectionReason::kFinalizeMarkingViaTask); |
| 4338 } | 4311 } |
| 4339 result = incremental_marking()->IsStopped(); | 4312 result = incremental_marking()->IsStopped(); |
| 4340 break; | 4313 break; |
| 4341 } | 4314 } |
| 4342 case DO_FULL_GC: { | 4315 case DO_FULL_GC: { |
| 4343 DCHECK(contexts_disposed_ > 0); | 4316 DCHECK(contexts_disposed_ > 0); |
| 4344 HistogramTimerScope scope(isolate_->counters()->gc_context()); | 4317 HistogramTimerScope scope(isolate_->counters()->gc_context()); |
| 4345 TRACE_EVENT0("v8", "V8.GCContext"); | 4318 TRACE_EVENT0("v8", "V8.GCContext"); |
| 4346 CollectAllGarbage(kNoGCFlags, GarbageCollectionReason::kContextDisposal); | 4319 CollectAllGarbage(kNoGCFlags, GarbageCollectionReason::kContextDisposal); |
| (...skipping 2072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6419 case LO_SPACE: | 6392 case LO_SPACE: |
| 6420 return "LO_SPACE"; | 6393 return "LO_SPACE"; |
| 6421 default: | 6394 default: |
| 6422 UNREACHABLE(); | 6395 UNREACHABLE(); |
| 6423 } | 6396 } |
| 6424 return NULL; | 6397 return NULL; |
| 6425 } | 6398 } |
| 6426 | 6399 |
| 6427 } // namespace internal | 6400 } // namespace internal |
| 6428 } // namespace v8 | 6401 } // namespace v8 |
| OLD | NEW |