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/ast/context-slot-cache.h" | 9 #include "src/ast/context-slot-cache.h" |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 4158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4169 if (FLAG_predictable) return; | 4169 if (FLAG_predictable) return; |
4170 | 4170 |
4171 if (ShouldReduceMemory() || | 4171 if (ShouldReduceMemory() || |
4172 ((allocation_throughput != 0) && | 4172 ((allocation_throughput != 0) && |
4173 (allocation_throughput < kLowAllocationThroughput))) { | 4173 (allocation_throughput < kLowAllocationThroughput))) { |
4174 new_space_->Shrink(); | 4174 new_space_->Shrink(); |
4175 UncommitFromSpace(); | 4175 UncommitFromSpace(); |
4176 } | 4176 } |
4177 } | 4177 } |
4178 | 4178 |
4179 bool Heap::MarkingDequesAreEmpty() { | |
4180 return mark_compact_collector()->marking_deque()->IsEmpty() && | |
4181 local_embedder_heap_tracer()->NumberOfWrappersToTrace() == 0; | |
4182 } | |
4183 | |
4184 void Heap::FinalizeIncrementalMarkingIfComplete( | 4179 void Heap::FinalizeIncrementalMarkingIfComplete( |
4185 GarbageCollectionReason gc_reason) { | 4180 GarbageCollectionReason gc_reason) { |
4186 if (incremental_marking()->IsMarking() && | 4181 if (incremental_marking()->IsMarking() && |
4187 (incremental_marking()->IsReadyToOverApproximateWeakClosure() || | 4182 (incremental_marking()->IsReadyToOverApproximateWeakClosure() || |
4188 (!incremental_marking()->finalize_marking_completed() && | 4183 (!incremental_marking()->finalize_marking_completed() && |
4189 MarkingDequesAreEmpty()))) { | 4184 mark_compact_collector()->marking_deque()->IsEmpty() && |
| 4185 local_embedder_heap_tracer()->ShouldFinalizeIncrementalMarking()))) { |
4190 FinalizeIncrementalMarking(gc_reason); | 4186 FinalizeIncrementalMarking(gc_reason); |
4191 } else if (incremental_marking()->IsComplete() || MarkingDequesAreEmpty()) { | 4187 } else if (incremental_marking()->IsComplete() || |
| 4188 (mark_compact_collector()->marking_deque()->IsEmpty() && |
| 4189 local_embedder_heap_tracer() |
| 4190 ->ShouldFinalizeIncrementalMarking())) { |
4192 CollectAllGarbage(current_gc_flags_, gc_reason); | 4191 CollectAllGarbage(current_gc_flags_, gc_reason); |
4193 } | 4192 } |
4194 } | 4193 } |
4195 | 4194 |
4196 bool Heap::TryFinalizeIdleIncrementalMarking( | 4195 bool Heap::TryFinalizeIdleIncrementalMarking( |
4197 double idle_time_in_ms, GarbageCollectionReason gc_reason) { | 4196 double idle_time_in_ms, GarbageCollectionReason gc_reason) { |
4198 size_t size_of_objects = static_cast<size_t>(SizeOfObjects()); | 4197 size_t size_of_objects = static_cast<size_t>(SizeOfObjects()); |
4199 double final_incremental_mark_compact_speed_in_bytes_per_ms = | 4198 double final_incremental_mark_compact_speed_in_bytes_per_ms = |
4200 tracer()->FinalIncrementalMarkCompactSpeedInBytesPerMillisecond(); | 4199 tracer()->FinalIncrementalMarkCompactSpeedInBytesPerMillisecond(); |
4201 if (incremental_marking()->IsReadyToOverApproximateWeakClosure() || | 4200 if (incremental_marking()->IsReadyToOverApproximateWeakClosure() || |
4202 (!incremental_marking()->finalize_marking_completed() && | 4201 (!incremental_marking()->finalize_marking_completed() && |
4203 MarkingDequesAreEmpty() && | 4202 mark_compact_collector()->marking_deque()->IsEmpty() && |
| 4203 local_embedder_heap_tracer()->ShouldFinalizeIncrementalMarking() && |
4204 gc_idle_time_handler_->ShouldDoOverApproximateWeakClosure( | 4204 gc_idle_time_handler_->ShouldDoOverApproximateWeakClosure( |
4205 idle_time_in_ms))) { | 4205 idle_time_in_ms))) { |
4206 FinalizeIncrementalMarking(gc_reason); | 4206 FinalizeIncrementalMarking(gc_reason); |
4207 return true; | 4207 return true; |
4208 } else if (incremental_marking()->IsComplete() || | 4208 } else if (incremental_marking()->IsComplete() || |
4209 (MarkingDequesAreEmpty() && | 4209 (mark_compact_collector()->marking_deque()->IsEmpty() && |
| 4210 local_embedder_heap_tracer() |
| 4211 ->ShouldFinalizeIncrementalMarking() && |
4210 gc_idle_time_handler_->ShouldDoFinalIncrementalMarkCompact( | 4212 gc_idle_time_handler_->ShouldDoFinalIncrementalMarkCompact( |
4211 idle_time_in_ms, size_of_objects, | 4213 idle_time_in_ms, size_of_objects, |
4212 final_incremental_mark_compact_speed_in_bytes_per_ms))) { | 4214 final_incremental_mark_compact_speed_in_bytes_per_ms))) { |
4213 CollectAllGarbage(current_gc_flags_, gc_reason); | 4215 CollectAllGarbage(current_gc_flags_, gc_reason); |
4214 return true; | 4216 return true; |
4215 } | 4217 } |
4216 return false; | 4218 return false; |
4217 } | 4219 } |
4218 | 4220 |
4219 void Heap::RegisterReservationsForBlackAllocation(Reservation* reservations) { | 4221 void Heap::RegisterReservationsForBlackAllocation(Reservation* reservations) { |
(...skipping 2279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6499 } | 6501 } |
6500 | 6502 |
6501 | 6503 |
6502 // static | 6504 // static |
6503 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6505 int Heap::GetStaticVisitorIdForMap(Map* map) { |
6504 return StaticVisitorBase::GetVisitorId(map); | 6506 return StaticVisitorBase::GetVisitorId(map); |
6505 } | 6507 } |
6506 | 6508 |
6507 } // namespace internal | 6509 } // namespace internal |
6508 } // namespace v8 | 6510 } // namespace v8 |
OLD | NEW |