| 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/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/base/once.h" | 10 #include "src/base/once.h" |
| (...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 }; | 767 }; |
| 768 | 768 |
| 769 | 769 |
| 770 void Heap::HandleGCRequest() { | 770 void Heap::HandleGCRequest() { |
| 771 if (incremental_marking()->request_type() == | 771 if (incremental_marking()->request_type() == |
| 772 IncrementalMarking::COMPLETE_MARKING) { | 772 IncrementalMarking::COMPLETE_MARKING) { |
| 773 CollectAllGarbage(current_gc_flags_, "GC interrupt", | 773 CollectAllGarbage(current_gc_flags_, "GC interrupt", |
| 774 current_gc_callback_flags_); | 774 current_gc_callback_flags_); |
| 775 return; | 775 return; |
| 776 } | 776 } |
| 777 DCHECK(FLAG_overapproximate_weak_closure); | 777 DCHECK(FLAG_finalize_marking_incrementally); |
| 778 if (!incremental_marking()->weak_closure_was_overapproximated()) { | 778 if (!incremental_marking()->finalize_marking_completed()) { |
| 779 OverApproximateWeakClosure("GC interrupt"); | 779 FinalizeIncrementalMarking("GC interrupt"); |
| 780 } | 780 } |
| 781 } | 781 } |
| 782 | 782 |
| 783 | 783 |
| 784 void Heap::ScheduleIdleScavengeIfNeeded(int bytes_allocated) { | 784 void Heap::ScheduleIdleScavengeIfNeeded(int bytes_allocated) { |
| 785 scavenge_job_->ScheduleIdleTaskIfNeeded(this, bytes_allocated); | 785 scavenge_job_->ScheduleIdleTaskIfNeeded(this, bytes_allocated); |
| 786 } | 786 } |
| 787 | 787 |
| 788 | 788 |
| 789 void Heap::OverApproximateWeakClosure(const char* gc_reason) { | 789 void Heap::FinalizeIncrementalMarking(const char* gc_reason) { |
| 790 if (FLAG_trace_incremental_marking) { | 790 if (FLAG_trace_incremental_marking) { |
| 791 PrintF("[IncrementalMarking] Overapproximate weak closure (%s).\n", | 791 PrintF("[IncrementalMarking] Overapproximate weak closure (%s).\n", |
| 792 gc_reason); | 792 gc_reason); |
| 793 } | 793 } |
| 794 | 794 |
| 795 GCTracer::Scope gc_scope(tracer(), | 795 GCTracer::Scope gc_scope(tracer(), GCTracer::Scope::MC_INCREMENTAL_FINALIZE); |
| 796 GCTracer::Scope::MC_INCREMENTAL_WEAKCLOSURE); | |
| 797 | 796 |
| 798 { | 797 { |
| 799 GCCallbacksScope scope(this); | 798 GCCallbacksScope scope(this); |
| 800 if (scope.CheckReenter()) { | 799 if (scope.CheckReenter()) { |
| 801 AllowHeapAllocation allow_allocation; | 800 AllowHeapAllocation allow_allocation; |
| 802 GCTracer::Scope scope(tracer(), GCTracer::Scope::EXTERNAL); | 801 GCTracer::Scope scope(tracer(), GCTracer::Scope::EXTERNAL); |
| 803 VMState<EXTERNAL> state(isolate_); | 802 VMState<EXTERNAL> state(isolate_); |
| 804 HandleScope handle_scope(isolate_); | 803 HandleScope handle_scope(isolate_); |
| 805 CallGCPrologueCallbacks(kGCTypeIncrementalMarking, kNoGCCallbackFlags); | 804 CallGCPrologueCallbacks(kGCTypeIncrementalMarking, kNoGCCallbackFlags); |
| 806 } | 805 } |
| 807 } | 806 } |
| 808 incremental_marking()->MarkObjectGroups(); | 807 incremental_marking()->FinalizeIncrementally(); |
| 809 { | 808 { |
| 810 GCCallbacksScope scope(this); | 809 GCCallbacksScope scope(this); |
| 811 if (scope.CheckReenter()) { | 810 if (scope.CheckReenter()) { |
| 812 AllowHeapAllocation allow_allocation; | 811 AllowHeapAllocation allow_allocation; |
| 813 GCTracer::Scope scope(tracer(), GCTracer::Scope::EXTERNAL); | 812 GCTracer::Scope scope(tracer(), GCTracer::Scope::EXTERNAL); |
| 814 VMState<EXTERNAL> state(isolate_); | 813 VMState<EXTERNAL> state(isolate_); |
| 815 HandleScope handle_scope(isolate_); | 814 HandleScope handle_scope(isolate_); |
| 816 CallGCEpilogueCallbacks(kGCTypeIncrementalMarking, kNoGCCallbackFlags); | 815 CallGCEpilogueCallbacks(kGCTypeIncrementalMarking, kNoGCCallbackFlags); |
| 817 } | 816 } |
| 818 } | 817 } |
| (...skipping 3245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4064 if (ShouldReduceMemory() || | 4063 if (ShouldReduceMemory() || |
| 4065 ((allocation_throughput != 0) && | 4064 ((allocation_throughput != 0) && |
| 4066 (allocation_throughput < kLowAllocationThroughput))) { | 4065 (allocation_throughput < kLowAllocationThroughput))) { |
| 4067 new_space_.Shrink(); | 4066 new_space_.Shrink(); |
| 4068 UncommitFromSpace(); | 4067 UncommitFromSpace(); |
| 4069 } | 4068 } |
| 4070 } | 4069 } |
| 4071 | 4070 |
| 4072 | 4071 |
| 4073 void Heap::FinalizeIncrementalMarkingIfComplete(const char* comment) { | 4072 void Heap::FinalizeIncrementalMarkingIfComplete(const char* comment) { |
| 4074 if (FLAG_overapproximate_weak_closure && incremental_marking()->IsMarking() && | 4073 if (FLAG_finalize_marking_incrementally && |
| 4074 incremental_marking()->IsMarking() && |
| 4075 (incremental_marking()->IsReadyToOverApproximateWeakClosure() || | 4075 (incremental_marking()->IsReadyToOverApproximateWeakClosure() || |
| 4076 (!incremental_marking()->weak_closure_was_overapproximated() && | 4076 (!incremental_marking()->finalize_marking_completed() && |
| 4077 mark_compact_collector()->marking_deque()->IsEmpty()))) { | 4077 mark_compact_collector()->marking_deque()->IsEmpty()))) { |
| 4078 OverApproximateWeakClosure(comment); | 4078 FinalizeIncrementalMarking(comment); |
| 4079 } else if (incremental_marking()->IsComplete() || | 4079 } else if (incremental_marking()->IsComplete() || |
| 4080 (mark_compact_collector()->marking_deque()->IsEmpty())) { | 4080 (mark_compact_collector()->marking_deque()->IsEmpty())) { |
| 4081 CollectAllGarbage(current_gc_flags_, comment); | 4081 CollectAllGarbage(current_gc_flags_, comment); |
| 4082 } | 4082 } |
| 4083 } | 4083 } |
| 4084 | 4084 |
| 4085 | 4085 |
| 4086 bool Heap::TryFinalizeIdleIncrementalMarking(double idle_time_in_ms) { | 4086 bool Heap::TryFinalizeIdleIncrementalMarking(double idle_time_in_ms) { |
| 4087 size_t size_of_objects = static_cast<size_t>(SizeOfObjects()); | 4087 size_t size_of_objects = static_cast<size_t>(SizeOfObjects()); |
| 4088 size_t final_incremental_mark_compact_speed_in_bytes_per_ms = | 4088 size_t final_incremental_mark_compact_speed_in_bytes_per_ms = |
| 4089 static_cast<size_t>( | 4089 static_cast<size_t>( |
| 4090 tracer()->FinalIncrementalMarkCompactSpeedInBytesPerMillisecond()); | 4090 tracer()->FinalIncrementalMarkCompactSpeedInBytesPerMillisecond()); |
| 4091 if (FLAG_overapproximate_weak_closure && | 4091 if (FLAG_finalize_marking_incrementally && |
| 4092 (incremental_marking()->IsReadyToOverApproximateWeakClosure() || | 4092 (incremental_marking()->IsReadyToOverApproximateWeakClosure() || |
| 4093 (!incremental_marking()->weak_closure_was_overapproximated() && | 4093 (!incremental_marking()->finalize_marking_completed() && |
| 4094 mark_compact_collector()->marking_deque()->IsEmpty() && | 4094 mark_compact_collector()->marking_deque()->IsEmpty() && |
| 4095 gc_idle_time_handler_->ShouldDoOverApproximateWeakClosure( | 4095 gc_idle_time_handler_->ShouldDoOverApproximateWeakClosure( |
| 4096 static_cast<size_t>(idle_time_in_ms))))) { | 4096 static_cast<size_t>(idle_time_in_ms))))) { |
| 4097 OverApproximateWeakClosure( | 4097 FinalizeIncrementalMarking( |
| 4098 "Idle notification: overapproximate weak closure"); | 4098 "Idle notification: overapproximate weak closure"); |
| 4099 return true; | 4099 return true; |
| 4100 } else if (incremental_marking()->IsComplete() || | 4100 } else if (incremental_marking()->IsComplete() || |
| 4101 (mark_compact_collector()->marking_deque()->IsEmpty() && | 4101 (mark_compact_collector()->marking_deque()->IsEmpty() && |
| 4102 gc_idle_time_handler_->ShouldDoFinalIncrementalMarkCompact( | 4102 gc_idle_time_handler_->ShouldDoFinalIncrementalMarkCompact( |
| 4103 static_cast<size_t>(idle_time_in_ms), size_of_objects, | 4103 static_cast<size_t>(idle_time_in_ms), size_of_objects, |
| 4104 final_incremental_mark_compact_speed_in_bytes_per_ms))) { | 4104 final_incremental_mark_compact_speed_in_bytes_per_ms))) { |
| 4105 CollectAllGarbage(current_gc_flags_, | 4105 CollectAllGarbage(current_gc_flags_, |
| 4106 "idle notification: finalize incremental"); | 4106 "idle notification: finalize incremental"); |
| 4107 return true; | 4107 return true; |
| (...skipping 2076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6184 } | 6184 } |
| 6185 | 6185 |
| 6186 | 6186 |
| 6187 // static | 6187 // static |
| 6188 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6188 int Heap::GetStaticVisitorIdForMap(Map* map) { |
| 6189 return StaticVisitorBase::GetVisitorId(map); | 6189 return StaticVisitorBase::GetVisitorId(map); |
| 6190 } | 6190 } |
| 6191 | 6191 |
| 6192 } // namespace internal | 6192 } // namespace internal |
| 6193 } // namespace v8 | 6193 } // namespace v8 |
| OLD | NEW |