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 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } |
819 } | 819 } |
820 | 820 |
821 | 821 |
| 822 HistogramTimer* Heap::GCTypeTimer(GarbageCollector collector) { |
| 823 if (collector == SCAVENGER) { |
| 824 return isolate_->counters()->gc_scavenger(); |
| 825 } else { |
| 826 if (!incremental_marking()->IsStopped()) { |
| 827 if (ShouldReduceMemory()) { |
| 828 return isolate_->counters()->gc_finalize_reduce_memory(); |
| 829 } else { |
| 830 return isolate_->counters()->gc_finalize(); |
| 831 } |
| 832 } else { |
| 833 return isolate_->counters()->gc_compactor(); |
| 834 } |
| 835 } |
| 836 } |
| 837 |
| 838 |
822 void Heap::CollectAllGarbage(int flags, const char* gc_reason, | 839 void Heap::CollectAllGarbage(int flags, const char* gc_reason, |
823 const v8::GCCallbackFlags gc_callback_flags) { | 840 const v8::GCCallbackFlags gc_callback_flags) { |
824 // Since we are ignoring the return value, the exact choice of space does | 841 // Since we are ignoring the return value, the exact choice of space does |
825 // not matter, so long as we do not specify NEW_SPACE, which would not | 842 // not matter, so long as we do not specify NEW_SPACE, which would not |
826 // cause a full GC. | 843 // cause a full GC. |
827 set_current_gc_flags(flags); | 844 set_current_gc_flags(flags); |
828 CollectGarbage(OLD_SPACE, gc_reason, gc_callback_flags); | 845 CollectGarbage(OLD_SPACE, gc_reason, gc_callback_flags); |
829 set_current_gc_flags(kNoGCFlags); | 846 set_current_gc_flags(kNoGCFlags); |
830 } | 847 } |
831 | 848 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
957 committed_memory_before = CommittedOldGenerationMemory(); | 974 committed_memory_before = CommittedOldGenerationMemory(); |
958 } | 975 } |
959 | 976 |
960 { | 977 { |
961 tracer()->Start(collector, gc_reason, collector_reason); | 978 tracer()->Start(collector, gc_reason, collector_reason); |
962 DCHECK(AllowHeapAllocation::IsAllowed()); | 979 DCHECK(AllowHeapAllocation::IsAllowed()); |
963 DisallowHeapAllocation no_allocation_during_gc; | 980 DisallowHeapAllocation no_allocation_during_gc; |
964 GarbageCollectionPrologue(); | 981 GarbageCollectionPrologue(); |
965 | 982 |
966 { | 983 { |
967 HistogramTimerScope histogram_timer_scope( | 984 HistogramTimerScope histogram_timer_scope(GCTypeTimer(collector)); |
968 (collector == SCAVENGER) ? isolate_->counters()->gc_scavenger() | 985 |
969 : isolate_->counters()->gc_compactor()); | |
970 next_gc_likely_to_collect_more = | 986 next_gc_likely_to_collect_more = |
971 PerformGarbageCollection(collector, gc_callback_flags); | 987 PerformGarbageCollection(collector, gc_callback_flags); |
972 } | 988 } |
973 | 989 |
974 GarbageCollectionEpilogue(); | 990 GarbageCollectionEpilogue(); |
975 if (collector == MARK_COMPACTOR && FLAG_track_detached_contexts) { | 991 if (collector == MARK_COMPACTOR && FLAG_track_detached_contexts) { |
976 isolate()->CheckDetachedContextsAfterGC(); | 992 isolate()->CheckDetachedContextsAfterGC(); |
977 } | 993 } |
978 | 994 |
979 if (collector == MARK_COMPACTOR) { | 995 if (collector == MARK_COMPACTOR) { |
(...skipping 5109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6089 } | 6105 } |
6090 | 6106 |
6091 | 6107 |
6092 // static | 6108 // static |
6093 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6109 int Heap::GetStaticVisitorIdForMap(Map* map) { |
6094 return StaticVisitorBase::GetVisitorId(map); | 6110 return StaticVisitorBase::GetVisitorId(map); |
6095 } | 6111 } |
6096 | 6112 |
6097 } // namespace internal | 6113 } // namespace internal |
6098 } // namespace v8 | 6114 } // namespace v8 |
OLD | NEW |