| 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 4157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4168 if (FLAG_predictable) return; | 4168 if (FLAG_predictable) return; |
| 4169 | 4169 |
| 4170 if (ShouldReduceMemory() || | 4170 if (ShouldReduceMemory() || |
| 4171 ((allocation_throughput != 0) && | 4171 ((allocation_throughput != 0) && |
| 4172 (allocation_throughput < kLowAllocationThroughput))) { | 4172 (allocation_throughput < kLowAllocationThroughput))) { |
| 4173 new_space_.Shrink(); | 4173 new_space_.Shrink(); |
| 4174 UncommitFromSpace(); | 4174 UncommitFromSpace(); |
| 4175 } | 4175 } |
| 4176 } | 4176 } |
| 4177 | 4177 |
| 4178 bool Heap::MarkingDequesAreEmpty() { |
| 4179 return mark_compact_collector()->marking_deque()->IsEmpty() && |
| 4180 (!UsingEmbedderHeapTracer() || |
| 4181 (mark_compact_collector()->wrappers_to_trace() == 0 && |
| 4182 mark_compact_collector() |
| 4183 ->embedder_heap_tracer() |
| 4184 ->NumberOfWrappersToTrace() == 0)); |
| 4185 } |
| 4178 | 4186 |
| 4179 void Heap::FinalizeIncrementalMarkingIfComplete(const char* comment) { | 4187 void Heap::FinalizeIncrementalMarkingIfComplete(const char* comment) { |
| 4180 if (incremental_marking()->IsMarking() && | 4188 if (incremental_marking()->IsMarking() && |
| 4181 (incremental_marking()->IsReadyToOverApproximateWeakClosure() || | 4189 (incremental_marking()->IsReadyToOverApproximateWeakClosure() || |
| 4182 (!incremental_marking()->finalize_marking_completed() && | 4190 (!incremental_marking()->finalize_marking_completed() && |
| 4183 mark_compact_collector()->marking_deque()->IsEmpty()))) { | 4191 MarkingDequesAreEmpty()))) { |
| 4184 FinalizeIncrementalMarking(comment); | 4192 FinalizeIncrementalMarking(comment); |
| 4185 } else if (incremental_marking()->IsComplete() || | 4193 } else if (incremental_marking()->IsComplete() || |
| 4186 (mark_compact_collector()->marking_deque()->IsEmpty())) { | 4194 (mark_compact_collector()->marking_deque()->IsEmpty())) { |
| 4187 CollectAllGarbage(current_gc_flags_, comment); | 4195 CollectAllGarbage(current_gc_flags_, comment); |
| 4188 } | 4196 } |
| 4189 } | 4197 } |
| 4190 | 4198 |
| 4191 | 4199 |
| 4192 bool Heap::TryFinalizeIdleIncrementalMarking(double idle_time_in_ms) { | 4200 bool Heap::TryFinalizeIdleIncrementalMarking(double idle_time_in_ms) { |
| 4193 size_t size_of_objects = static_cast<size_t>(SizeOfObjects()); | 4201 size_t size_of_objects = static_cast<size_t>(SizeOfObjects()); |
| 4194 double final_incremental_mark_compact_speed_in_bytes_per_ms = | 4202 double final_incremental_mark_compact_speed_in_bytes_per_ms = |
| 4195 tracer()->FinalIncrementalMarkCompactSpeedInBytesPerMillisecond(); | 4203 tracer()->FinalIncrementalMarkCompactSpeedInBytesPerMillisecond(); |
| 4196 if (incremental_marking()->IsReadyToOverApproximateWeakClosure() || | 4204 if (incremental_marking()->IsReadyToOverApproximateWeakClosure() || |
| 4197 (!incremental_marking()->finalize_marking_completed() && | 4205 (!incremental_marking()->finalize_marking_completed() && |
| 4198 mark_compact_collector()->marking_deque()->IsEmpty() && | 4206 MarkingDequesAreEmpty() && |
| 4199 gc_idle_time_handler_->ShouldDoOverApproximateWeakClosure( | 4207 gc_idle_time_handler_->ShouldDoOverApproximateWeakClosure( |
| 4200 idle_time_in_ms))) { | 4208 idle_time_in_ms))) { |
| 4201 FinalizeIncrementalMarking( | 4209 FinalizeIncrementalMarking( |
| 4202 "Idle notification: finalize incremental marking"); | 4210 "Idle notification: finalize incremental marking"); |
| 4203 return true; | 4211 return true; |
| 4204 } else if (incremental_marking()->IsComplete() || | 4212 } else if (incremental_marking()->IsComplete() || |
| 4205 (mark_compact_collector()->marking_deque()->IsEmpty() && | 4213 (MarkingDequesAreEmpty() && |
| 4206 gc_idle_time_handler_->ShouldDoFinalIncrementalMarkCompact( | 4214 gc_idle_time_handler_->ShouldDoFinalIncrementalMarkCompact( |
| 4207 idle_time_in_ms, size_of_objects, | 4215 idle_time_in_ms, size_of_objects, |
| 4208 final_incremental_mark_compact_speed_in_bytes_per_ms))) { | 4216 final_incremental_mark_compact_speed_in_bytes_per_ms))) { |
| 4209 CollectAllGarbage(current_gc_flags_, | 4217 CollectAllGarbage(current_gc_flags_, |
| 4210 "idle notification: finalize incremental marking"); | 4218 "idle notification: finalize incremental marking"); |
| 4211 return true; | 4219 return true; |
| 4212 } | 4220 } |
| 4213 return false; | 4221 return false; |
| 4214 } | 4222 } |
| 4215 | 4223 |
| (...skipping 2284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6500 } | 6508 } |
| 6501 | 6509 |
| 6502 | 6510 |
| 6503 // static | 6511 // static |
| 6504 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6512 int Heap::GetStaticVisitorIdForMap(Map* map) { |
| 6505 return StaticVisitorBase::GetVisitorId(map); | 6513 return StaticVisitorBase::GetVisitorId(map); |
| 6506 } | 6514 } |
| 6507 | 6515 |
| 6508 } // namespace internal | 6516 } // namespace internal |
| 6509 } // namespace v8 | 6517 } // namespace v8 |
| OLD | NEW |