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/scopeinfo.h" | 9 #include "src/ast/scopeinfo.h" |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "src/heap/scavenge-job.h" | 31 #include "src/heap/scavenge-job.h" |
32 #include "src/heap/scavenger-inl.h" | 32 #include "src/heap/scavenger-inl.h" |
33 #include "src/heap/store-buffer.h" | 33 #include "src/heap/store-buffer.h" |
34 #include "src/interpreter/interpreter.h" | 34 #include "src/interpreter/interpreter.h" |
35 #include "src/profiler/cpu-profiler.h" | 35 #include "src/profiler/cpu-profiler.h" |
36 #include "src/regexp/jsregexp.h" | 36 #include "src/regexp/jsregexp.h" |
37 #include "src/runtime-profiler.h" | 37 #include "src/runtime-profiler.h" |
38 #include "src/snapshot/natives.h" | 38 #include "src/snapshot/natives.h" |
39 #include "src/snapshot/serialize.h" | 39 #include "src/snapshot/serialize.h" |
40 #include "src/snapshot/snapshot.h" | 40 #include "src/snapshot/snapshot.h" |
| 41 #include "src/tracing/trace-event.h" |
41 #include "src/type-feedback-vector.h" | 42 #include "src/type-feedback-vector.h" |
42 #include "src/utils.h" | 43 #include "src/utils.h" |
43 #include "src/v8.h" | 44 #include "src/v8.h" |
44 #include "src/v8threads.h" | 45 #include "src/v8threads.h" |
45 #include "src/vm-state-inl.h" | 46 #include "src/vm-state-inl.h" |
46 | 47 |
47 namespace v8 { | 48 namespace v8 { |
48 namespace internal { | 49 namespace internal { |
49 | 50 |
50 | 51 |
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
810 | 811 |
811 | 812 |
812 void Heap::FinalizeIncrementalMarking(const char* gc_reason) { | 813 void Heap::FinalizeIncrementalMarking(const char* gc_reason) { |
813 if (FLAG_trace_incremental_marking) { | 814 if (FLAG_trace_incremental_marking) { |
814 PrintF("[IncrementalMarking] (%s).\n", gc_reason); | 815 PrintF("[IncrementalMarking] (%s).\n", gc_reason); |
815 } | 816 } |
816 | 817 |
817 GCTracer::Scope gc_scope(tracer(), GCTracer::Scope::MC_INCREMENTAL_FINALIZE); | 818 GCTracer::Scope gc_scope(tracer(), GCTracer::Scope::MC_INCREMENTAL_FINALIZE); |
818 HistogramTimerScope incremental_marking_scope( | 819 HistogramTimerScope incremental_marking_scope( |
819 isolate()->counters()->gc_incremental_marking_finalize()); | 820 isolate()->counters()->gc_incremental_marking_finalize()); |
| 821 TRACE_EVENT0("v8", "V8.GCIncrementalMarkingFinalize"); |
820 | 822 |
821 { | 823 { |
822 GCCallbacksScope scope(this); | 824 GCCallbacksScope scope(this); |
823 if (scope.CheckReenter()) { | 825 if (scope.CheckReenter()) { |
824 AllowHeapAllocation allow_allocation; | 826 AllowHeapAllocation allow_allocation; |
825 GCTracer::Scope scope(tracer(), GCTracer::Scope::EXTERNAL); | 827 GCTracer::Scope scope(tracer(), GCTracer::Scope::EXTERNAL); |
826 VMState<EXTERNAL> state(isolate_); | 828 VMState<EXTERNAL> state(isolate_); |
827 HandleScope handle_scope(isolate_); | 829 HandleScope handle_scope(isolate_); |
828 CallGCPrologueCallbacks(kGCTypeIncrementalMarking, kNoGCCallbackFlags); | 830 CallGCPrologueCallbacks(kGCTypeIncrementalMarking, kNoGCCallbackFlags); |
829 } | 831 } |
(...skipping 21 matching lines...) Expand all Loading... |
851 return isolate_->counters()->gc_finalize_reduce_memory(); | 853 return isolate_->counters()->gc_finalize_reduce_memory(); |
852 } else { | 854 } else { |
853 return isolate_->counters()->gc_finalize(); | 855 return isolate_->counters()->gc_finalize(); |
854 } | 856 } |
855 } else { | 857 } else { |
856 return isolate_->counters()->gc_compactor(); | 858 return isolate_->counters()->gc_compactor(); |
857 } | 859 } |
858 } | 860 } |
859 } | 861 } |
860 | 862 |
861 | |
862 void Heap::CollectAllGarbage(int flags, const char* gc_reason, | 863 void Heap::CollectAllGarbage(int flags, const char* gc_reason, |
863 const v8::GCCallbackFlags gc_callback_flags) { | 864 const v8::GCCallbackFlags gc_callback_flags) { |
864 // Since we are ignoring the return value, the exact choice of space does | 865 // Since we are ignoring the return value, the exact choice of space does |
865 // not matter, so long as we do not specify NEW_SPACE, which would not | 866 // not matter, so long as we do not specify NEW_SPACE, which would not |
866 // cause a full GC. | 867 // cause a full GC. |
867 set_current_gc_flags(flags); | 868 set_current_gc_flags(flags); |
868 CollectGarbage(OLD_SPACE, gc_reason, gc_callback_flags); | 869 CollectGarbage(OLD_SPACE, gc_reason, gc_callback_flags); |
869 set_current_gc_flags(kNoGCFlags); | 870 set_current_gc_flags(kNoGCFlags); |
870 } | 871 } |
871 | 872 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
999 committed_memory_before = CommittedOldGenerationMemory(); | 1000 committed_memory_before = CommittedOldGenerationMemory(); |
1000 } | 1001 } |
1001 | 1002 |
1002 { | 1003 { |
1003 tracer()->Start(collector, gc_reason, collector_reason); | 1004 tracer()->Start(collector, gc_reason, collector_reason); |
1004 DCHECK(AllowHeapAllocation::IsAllowed()); | 1005 DCHECK(AllowHeapAllocation::IsAllowed()); |
1005 DisallowHeapAllocation no_allocation_during_gc; | 1006 DisallowHeapAllocation no_allocation_during_gc; |
1006 GarbageCollectionPrologue(); | 1007 GarbageCollectionPrologue(); |
1007 | 1008 |
1008 { | 1009 { |
1009 HistogramTimerScope histogram_timer_scope(GCTypeTimer(collector)); | 1010 HistogramTimer* gc_type_timer = GCTypeTimer(collector); |
| 1011 HistogramTimerScope histogram_timer_scope(gc_type_timer); |
| 1012 TRACE_EVENT0("v8", gc_type_timer->name()); |
1010 | 1013 |
1011 next_gc_likely_to_collect_more = | 1014 next_gc_likely_to_collect_more = |
1012 PerformGarbageCollection(collector, gc_callback_flags); | 1015 PerformGarbageCollection(collector, gc_callback_flags); |
1013 } | 1016 } |
1014 | 1017 |
1015 GarbageCollectionEpilogue(); | 1018 GarbageCollectionEpilogue(); |
1016 if (collector == MARK_COMPACTOR && FLAG_track_detached_contexts) { | 1019 if (collector == MARK_COMPACTOR && FLAG_track_detached_contexts) { |
1017 isolate()->CheckDetachedContextsAfterGC(); | 1020 isolate()->CheckDetachedContextsAfterGC(); |
1018 } | 1021 } |
1019 | 1022 |
(...skipping 3169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4189 ->incremental_marking_job() | 4192 ->incremental_marking_job() |
4190 ->NotifyIdleTaskProgress(); | 4193 ->NotifyIdleTaskProgress(); |
4191 result = IncrementalMarkingJob::IdleTask::Step(this, deadline_in_ms) == | 4194 result = IncrementalMarkingJob::IdleTask::Step(this, deadline_in_ms) == |
4192 IncrementalMarkingJob::IdleTask::kDone; | 4195 IncrementalMarkingJob::IdleTask::kDone; |
4193 } | 4196 } |
4194 break; | 4197 break; |
4195 } | 4198 } |
4196 case DO_FULL_GC: { | 4199 case DO_FULL_GC: { |
4197 DCHECK(contexts_disposed_ > 0); | 4200 DCHECK(contexts_disposed_ > 0); |
4198 HistogramTimerScope scope(isolate_->counters()->gc_context()); | 4201 HistogramTimerScope scope(isolate_->counters()->gc_context()); |
| 4202 TRACE_EVENT0("v8", "V8.GCContext"); |
4199 CollectAllGarbage(kNoGCFlags, "idle notification: contexts disposed"); | 4203 CollectAllGarbage(kNoGCFlags, "idle notification: contexts disposed"); |
4200 break; | 4204 break; |
4201 } | 4205 } |
4202 case DO_NOTHING: | 4206 case DO_NOTHING: |
4203 break; | 4207 break; |
4204 } | 4208 } |
4205 | 4209 |
4206 return result; | 4210 return result; |
4207 } | 4211 } |
4208 | 4212 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4274 } | 4278 } |
4275 | 4279 |
4276 | 4280 |
4277 bool Heap::IdleNotification(double deadline_in_seconds) { | 4281 bool Heap::IdleNotification(double deadline_in_seconds) { |
4278 CHECK(HasBeenSetUp()); | 4282 CHECK(HasBeenSetUp()); |
4279 double deadline_in_ms = | 4283 double deadline_in_ms = |
4280 deadline_in_seconds * | 4284 deadline_in_seconds * |
4281 static_cast<double>(base::Time::kMillisecondsPerSecond); | 4285 static_cast<double>(base::Time::kMillisecondsPerSecond); |
4282 HistogramTimerScope idle_notification_scope( | 4286 HistogramTimerScope idle_notification_scope( |
4283 isolate_->counters()->gc_idle_notification()); | 4287 isolate_->counters()->gc_idle_notification()); |
| 4288 TRACE_EVENT0("v8", "V8.GCIdleNotification"); |
4284 double start_ms = MonotonicallyIncreasingTimeInMs(); | 4289 double start_ms = MonotonicallyIncreasingTimeInMs(); |
4285 double idle_time_in_ms = deadline_in_ms - start_ms; | 4290 double idle_time_in_ms = deadline_in_ms - start_ms; |
4286 | 4291 |
4287 tracer()->SampleAllocation(start_ms, NewSpaceAllocationCounter(), | 4292 tracer()->SampleAllocation(start_ms, NewSpaceAllocationCounter(), |
4288 OldGenerationAllocationCounter()); | 4293 OldGenerationAllocationCounter()); |
4289 | 4294 |
4290 GCIdleTimeHeapState heap_state = ComputeHeapState(); | 4295 GCIdleTimeHeapState heap_state = ComputeHeapState(); |
4291 | 4296 |
4292 GCIdleTimeAction action = | 4297 GCIdleTimeAction action = |
4293 gc_idle_time_handler_->Compute(idle_time_in_ms, heap_state); | 4298 gc_idle_time_handler_->Compute(idle_time_in_ms, heap_state); |
(...skipping 1971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6265 } | 6270 } |
6266 | 6271 |
6267 | 6272 |
6268 // static | 6273 // static |
6269 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6274 int Heap::GetStaticVisitorIdForMap(Map* map) { |
6270 return StaticVisitorBase::GetVisitorId(map); | 6275 return StaticVisitorBase::GetVisitorId(map); |
6271 } | 6276 } |
6272 | 6277 |
6273 } // namespace internal | 6278 } // namespace internal |
6274 } // namespace v8 | 6279 } // namespace v8 |
OLD | NEW |