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()->weak_closure_was_overapproximated()) { |
779 OverApproximateWeakClosure("GC interrupt"); | 779 OverApproximateWeakClosure("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 |
(...skipping 10 matching lines...) Expand all Loading... |
798 { | 798 { |
799 GCCallbacksScope scope(this); | 799 GCCallbacksScope scope(this); |
800 if (scope.CheckReenter()) { | 800 if (scope.CheckReenter()) { |
801 AllowHeapAllocation allow_allocation; | 801 AllowHeapAllocation allow_allocation; |
802 GCTracer::Scope scope(tracer(), GCTracer::Scope::EXTERNAL); | 802 GCTracer::Scope scope(tracer(), GCTracer::Scope::EXTERNAL); |
803 VMState<EXTERNAL> state(isolate_); | 803 VMState<EXTERNAL> state(isolate_); |
804 HandleScope handle_scope(isolate_); | 804 HandleScope handle_scope(isolate_); |
805 CallGCPrologueCallbacks(kGCTypeIncrementalMarking, kNoGCCallbackFlags); | 805 CallGCPrologueCallbacks(kGCTypeIncrementalMarking, kNoGCCallbackFlags); |
806 } | 806 } |
807 } | 807 } |
808 incremental_marking()->MarkObjectGroups(); | 808 incremental_marking()->FinalizeIncrementally(); |
809 { | 809 { |
810 GCCallbacksScope scope(this); | 810 GCCallbacksScope scope(this); |
811 if (scope.CheckReenter()) { | 811 if (scope.CheckReenter()) { |
812 AllowHeapAllocation allow_allocation; | 812 AllowHeapAllocation allow_allocation; |
813 GCTracer::Scope scope(tracer(), GCTracer::Scope::EXTERNAL); | 813 GCTracer::Scope scope(tracer(), GCTracer::Scope::EXTERNAL); |
814 VMState<EXTERNAL> state(isolate_); | 814 VMState<EXTERNAL> state(isolate_); |
815 HandleScope handle_scope(isolate_); | 815 HandleScope handle_scope(isolate_); |
816 CallGCEpilogueCallbacks(kGCTypeIncrementalMarking, kNoGCCallbackFlags); | 816 CallGCEpilogueCallbacks(kGCTypeIncrementalMarking, kNoGCCallbackFlags); |
817 } | 817 } |
818 } | 818 } |
(...skipping 3245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4064 if (ShouldReduceMemory() || | 4064 if (ShouldReduceMemory() || |
4065 ((allocation_throughput != 0) && | 4065 ((allocation_throughput != 0) && |
4066 (allocation_throughput < kLowAllocationThroughput))) { | 4066 (allocation_throughput < kLowAllocationThroughput))) { |
4067 new_space_.Shrink(); | 4067 new_space_.Shrink(); |
4068 UncommitFromSpace(); | 4068 UncommitFromSpace(); |
4069 } | 4069 } |
4070 } | 4070 } |
4071 | 4071 |
4072 | 4072 |
4073 void Heap::FinalizeIncrementalMarkingIfComplete(const char* comment) { | 4073 void Heap::FinalizeIncrementalMarkingIfComplete(const char* comment) { |
4074 if (FLAG_overapproximate_weak_closure && incremental_marking()->IsMarking() && | 4074 if (FLAG_finalize_marking_incrementally && |
| 4075 incremental_marking()->IsMarking() && |
4075 (incremental_marking()->IsReadyToOverApproximateWeakClosure() || | 4076 (incremental_marking()->IsReadyToOverApproximateWeakClosure() || |
4076 (!incremental_marking()->weak_closure_was_overapproximated() && | 4077 (!incremental_marking()->weak_closure_was_overapproximated() && |
4077 mark_compact_collector()->marking_deque()->IsEmpty()))) { | 4078 mark_compact_collector()->marking_deque()->IsEmpty()))) { |
4078 OverApproximateWeakClosure(comment); | 4079 OverApproximateWeakClosure(comment); |
4079 } else if (incremental_marking()->IsComplete() || | 4080 } else if (incremental_marking()->IsComplete() || |
4080 (mark_compact_collector()->marking_deque()->IsEmpty())) { | 4081 (mark_compact_collector()->marking_deque()->IsEmpty())) { |
4081 CollectAllGarbage(current_gc_flags_, comment); | 4082 CollectAllGarbage(current_gc_flags_, comment); |
4082 } | 4083 } |
4083 } | 4084 } |
4084 | 4085 |
4085 | 4086 |
4086 bool Heap::TryFinalizeIdleIncrementalMarking(double idle_time_in_ms) { | 4087 bool Heap::TryFinalizeIdleIncrementalMarking(double idle_time_in_ms) { |
4087 size_t size_of_objects = static_cast<size_t>(SizeOfObjects()); | 4088 size_t size_of_objects = static_cast<size_t>(SizeOfObjects()); |
4088 size_t final_incremental_mark_compact_speed_in_bytes_per_ms = | 4089 size_t final_incremental_mark_compact_speed_in_bytes_per_ms = |
4089 static_cast<size_t>( | 4090 static_cast<size_t>( |
4090 tracer()->FinalIncrementalMarkCompactSpeedInBytesPerMillisecond()); | 4091 tracer()->FinalIncrementalMarkCompactSpeedInBytesPerMillisecond()); |
4091 if (FLAG_overapproximate_weak_closure && | 4092 if (FLAG_finalize_marking_incrementally && |
4092 (incremental_marking()->IsReadyToOverApproximateWeakClosure() || | 4093 (incremental_marking()->IsReadyToOverApproximateWeakClosure() || |
4093 (!incremental_marking()->weak_closure_was_overapproximated() && | 4094 (!incremental_marking()->weak_closure_was_overapproximated() && |
4094 mark_compact_collector()->marking_deque()->IsEmpty() && | 4095 mark_compact_collector()->marking_deque()->IsEmpty() && |
4095 gc_idle_time_handler_->ShouldDoOverApproximateWeakClosure( | 4096 gc_idle_time_handler_->ShouldDoOverApproximateWeakClosure( |
4096 static_cast<size_t>(idle_time_in_ms))))) { | 4097 static_cast<size_t>(idle_time_in_ms))))) { |
4097 OverApproximateWeakClosure( | 4098 OverApproximateWeakClosure( |
4098 "Idle notification: overapproximate weak closure"); | 4099 "Idle notification: overapproximate weak closure"); |
4099 return true; | 4100 return true; |
4100 } else if (incremental_marking()->IsComplete() || | 4101 } else if (incremental_marking()->IsComplete() || |
4101 (mark_compact_collector()->marking_deque()->IsEmpty() && | 4102 (mark_compact_collector()->marking_deque()->IsEmpty() && |
(...skipping 2082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6184 } | 6185 } |
6185 | 6186 |
6186 | 6187 |
6187 // static | 6188 // static |
6188 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6189 int Heap::GetStaticVisitorIdForMap(Map* map) { |
6189 return StaticVisitorBase::GetVisitorId(map); | 6190 return StaticVisitorBase::GetVisitorId(map); |
6190 } | 6191 } |
6191 | 6192 |
6192 } // namespace internal | 6193 } // namespace internal |
6193 } // namespace v8 | 6194 } // namespace v8 |
OLD | NEW |