Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: src/heap/heap.cc

Issue 2524733007: [gc] Add runtime timer for gc prologue and epilogue callbacks (Closed)
Patch Set: adding more gc counters Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/counters.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 // not matter, so long as we do not specify NEW_SPACE, which would not 848 // not matter, so long as we do not specify NEW_SPACE, which would not
849 // cause a full GC. 849 // cause a full GC.
850 // Major GC would invoke weak handle callbacks on weakly reachable 850 // Major GC would invoke weak handle callbacks on weakly reachable
851 // handles, but won't collect weakly reachable objects until next 851 // handles, but won't collect weakly reachable objects until next
852 // major GC. Therefore if we collect aggressively and weak handle callback 852 // major GC. Therefore if we collect aggressively and weak handle callback
853 // has been invoked, we rerun major GC to release objects which become 853 // has been invoked, we rerun major GC to release objects which become
854 // garbage. 854 // garbage.
855 // Note: as weak callbacks can execute arbitrary code, we cannot 855 // Note: as weak callbacks can execute arbitrary code, we cannot
856 // hope that eventually there will be no weak callbacks invocations. 856 // hope that eventually there will be no weak callbacks invocations.
857 // Therefore stop recollecting after several attempts. 857 // Therefore stop recollecting after several attempts.
858 RuntimeCallTimerScope(isolate(), &RuntimeCallStats::GC_AllAvailableGarbage);
Hannes Payer (out of office) 2016/11/23 16:53:05 Not sure what your naming scheme is but shouldn't
858 if (isolate()->concurrent_recompilation_enabled()) { 859 if (isolate()->concurrent_recompilation_enabled()) {
859 // The optimizing compiler may be unnecessarily holding on to memory. 860 // The optimizing compiler may be unnecessarily holding on to memory.
860 DisallowHeapAllocation no_recursive_gc; 861 DisallowHeapAllocation no_recursive_gc;
861 isolate()->optimizing_compile_dispatcher()->Flush(); 862 isolate()->optimizing_compile_dispatcher()->Flush();
862 } 863 }
863 isolate()->ClearSerializerData(); 864 isolate()->ClearSerializerData();
864 set_current_gc_flags(kMakeHeapIterableMask | kReduceMemoryFootprintMask); 865 set_current_gc_flags(kMakeHeapIterableMask | kReduceMemoryFootprintMask);
865 isolate_->compilation_cache()->Clear(); 866 isolate_->compilation_cache()->Clear();
866 const int kMaxNumberOfAttempts = 7; 867 const int kMaxNumberOfAttempts = 7;
867 const int kMinNumberOfAttempts = 2; 868 const int kMinNumberOfAttempts = 2;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 CreateFillerObjectAt(to_top, remaining_in_page, ClearRecordedSlots::kNo); 930 CreateFillerObjectAt(to_top, remaining_in_page, ClearRecordedSlots::kNo);
930 } 931 }
931 } 932 }
932 933
933 bool Heap::CollectGarbage(GarbageCollector collector, 934 bool Heap::CollectGarbage(GarbageCollector collector,
934 GarbageCollectionReason gc_reason, 935 GarbageCollectionReason gc_reason,
935 const char* collector_reason, 936 const char* collector_reason,
936 const v8::GCCallbackFlags gc_callback_flags) { 937 const v8::GCCallbackFlags gc_callback_flags) {
937 // The VM is in the GC state until exiting this function. 938 // The VM is in the GC state until exiting this function.
938 VMState<GC> state(isolate_); 939 VMState<GC> state(isolate_);
940 RuntimeCallTimerScope(isolate(), &RuntimeCallStats::GC);
939 941
940 #ifdef DEBUG 942 #ifdef DEBUG
941 // Reset the allocation timeout to the GC interval, but make sure to 943 // Reset the allocation timeout to the GC interval, but make sure to
942 // allow at least a few allocations after a collection. The reason 944 // allow at least a few allocations after a collection. The reason
943 // for this is that we have a lot of allocation sequences and we 945 // for this is that we have a lot of allocation sequences and we
944 // assume that a garbage collection will allow the subsequent 946 // assume that a garbage collection will allow the subsequent
945 // allocation attempts to go through. 947 // allocation attempts to go through.
946 allocation_timeout_ = Max(6, FLAG_gc_interval); 948 allocation_timeout_ = Max(6, FLAG_gc_interval);
947 #endif 949 #endif
948 950
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
1379 if (FLAG_verify_heap) { 1381 if (FLAG_verify_heap) {
1380 VerifyStringTable(this); 1382 VerifyStringTable(this);
1381 } 1383 }
1382 #endif 1384 #endif
1383 1385
1384 return freed_global_handles > 0; 1386 return freed_global_handles > 0;
1385 } 1387 }
1386 1388
1387 1389
1388 void Heap::CallGCPrologueCallbacks(GCType gc_type, GCCallbackFlags flags) { 1390 void Heap::CallGCPrologueCallbacks(GCType gc_type, GCCallbackFlags flags) {
1391 RuntimeCallTimerScope(isolate(), &RuntimeCallStats::GCPrologueCallback);
1389 for (int i = 0; i < gc_prologue_callbacks_.length(); ++i) { 1392 for (int i = 0; i < gc_prologue_callbacks_.length(); ++i) {
1390 if (gc_type & gc_prologue_callbacks_[i].gc_type) { 1393 if (gc_type & gc_prologue_callbacks_[i].gc_type) {
1391 if (!gc_prologue_callbacks_[i].pass_isolate) { 1394 if (!gc_prologue_callbacks_[i].pass_isolate) {
1392 v8::GCCallback callback = reinterpret_cast<v8::GCCallback>( 1395 v8::GCCallback callback = reinterpret_cast<v8::GCCallback>(
1393 gc_prologue_callbacks_[i].callback); 1396 gc_prologue_callbacks_[i].callback);
1394 callback(gc_type, flags); 1397 callback(gc_type, flags);
1395 } else { 1398 } else {
1396 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(this->isolate()); 1399 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(this->isolate());
1397 gc_prologue_callbacks_[i].callback(isolate, gc_type, flags); 1400 gc_prologue_callbacks_[i].callback(isolate, gc_type, flags);
1398 } 1401 }
1399 } 1402 }
1400 } 1403 }
1401 if (FLAG_trace_object_groups && (gc_type == kGCTypeIncrementalMarking || 1404 if (FLAG_trace_object_groups && (gc_type == kGCTypeIncrementalMarking ||
1402 gc_type == kGCTypeMarkSweepCompact)) { 1405 gc_type == kGCTypeMarkSweepCompact)) {
1403 isolate_->global_handles()->PrintObjectGroups(); 1406 isolate_->global_handles()->PrintObjectGroups();
1404 } 1407 }
1405 } 1408 }
1406 1409
1407 1410
1408 void Heap::CallGCEpilogueCallbacks(GCType gc_type, 1411 void Heap::CallGCEpilogueCallbacks(GCType gc_type,
1409 GCCallbackFlags gc_callback_flags) { 1412 GCCallbackFlags gc_callback_flags) {
1413 RuntimeCallTimerScope(isolate(), &RuntimeCallStats::GCEpilogueCallback);
1410 for (int i = 0; i < gc_epilogue_callbacks_.length(); ++i) { 1414 for (int i = 0; i < gc_epilogue_callbacks_.length(); ++i) {
1411 if (gc_type & gc_epilogue_callbacks_[i].gc_type) { 1415 if (gc_type & gc_epilogue_callbacks_[i].gc_type) {
1412 if (!gc_epilogue_callbacks_[i].pass_isolate) { 1416 if (!gc_epilogue_callbacks_[i].pass_isolate) {
1413 v8::GCCallback callback = reinterpret_cast<v8::GCCallback>( 1417 v8::GCCallback callback = reinterpret_cast<v8::GCCallback>(
1414 gc_epilogue_callbacks_[i].callback); 1418 gc_epilogue_callbacks_[i].callback);
1415 callback(gc_type, gc_callback_flags); 1419 callback(gc_type, gc_callback_flags);
1416 } else { 1420 } else {
1417 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(this->isolate()); 1421 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(this->isolate());
1418 gc_epilogue_callbacks_[i].callback(isolate, gc_type, gc_callback_flags); 1422 gc_epilogue_callbacks_[i].callback(isolate, gc_type, gc_callback_flags);
1419 } 1423 }
(...skipping 5043 matching lines...) Expand 10 before | Expand all | Expand 10 after
6463 } 6467 }
6464 6468
6465 6469
6466 // static 6470 // static
6467 int Heap::GetStaticVisitorIdForMap(Map* map) { 6471 int Heap::GetStaticVisitorIdForMap(Map* map) {
6468 return StaticVisitorBase::GetVisitorId(map); 6472 return StaticVisitorBase::GetVisitorId(map);
6469 } 6473 }
6470 6474
6471 } // namespace internal 6475 } // namespace internal
6472 } // namespace v8 6476 } // namespace v8
OLDNEW
« no previous file with comments | « src/counters.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698