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

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

Issue 2857213003: [heap] Fix RuntimeCallTimerScope usages (Closed)
Patch Set: Just fix timer scopes Created 3 years, 7 months 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 | « no previous file | src/heap/spaces.cc » ('j') | 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/assembler-inl.h" 9 #include "src/assembler-inl.h"
10 #include "src/ast/context-slot-cache.h" 10 #include "src/ast/context-slot-cache.h"
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 // handles, but won't collect weakly reachable objects until next 889 // handles, but won't collect weakly reachable objects until next
890 // major GC. Therefore if we collect aggressively and weak handle callback 890 // major GC. Therefore if we collect aggressively and weak handle callback
891 // has been invoked, we rerun major GC to release objects which become 891 // has been invoked, we rerun major GC to release objects which become
892 // garbage. 892 // garbage.
893 // Note: as weak callbacks can execute arbitrary code, we cannot 893 // Note: as weak callbacks can execute arbitrary code, we cannot
894 // hope that eventually there will be no weak callbacks invocations. 894 // hope that eventually there will be no weak callbacks invocations.
895 // Therefore stop recollecting after several attempts. 895 // Therefore stop recollecting after several attempts.
896 if (gc_reason == GarbageCollectionReason::kLastResort) { 896 if (gc_reason == GarbageCollectionReason::kLastResort) {
897 InvokeOutOfMemoryCallback(); 897 InvokeOutOfMemoryCallback();
898 } 898 }
899 RuntimeCallTimerScope(isolate(), &RuntimeCallStats::GC_AllAvailableGarbage); 899 RuntimeCallTimerScope runtime_timer(
900 isolate(), &RuntimeCallStats::GC_AllAvailableGarbage);
900 if (isolate()->concurrent_recompilation_enabled()) { 901 if (isolate()->concurrent_recompilation_enabled()) {
901 // The optimizing compiler may be unnecessarily holding on to memory. 902 // The optimizing compiler may be unnecessarily holding on to memory.
902 DisallowHeapAllocation no_recursive_gc; 903 DisallowHeapAllocation no_recursive_gc;
903 isolate()->optimizing_compile_dispatcher()->Flush( 904 isolate()->optimizing_compile_dispatcher()->Flush(
904 OptimizingCompileDispatcher::BlockingBehavior::kDontBlock); 905 OptimizingCompileDispatcher::BlockingBehavior::kDontBlock);
905 } 906 }
906 isolate()->ClearSerializerData(); 907 isolate()->ClearSerializerData();
907 set_current_gc_flags(kMakeHeapIterableMask | kReduceMemoryFootprintMask); 908 set_current_gc_flags(kMakeHeapIterableMask | kReduceMemoryFootprintMask);
908 isolate_->compilation_cache()->Clear(); 909 isolate_->compilation_cache()->Clear();
909 const int kMaxNumberOfAttempts = 7; 910 const int kMaxNumberOfAttempts = 7;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 CreateFillerObjectAt(to_top, remaining_in_page, ClearRecordedSlots::kNo); 973 CreateFillerObjectAt(to_top, remaining_in_page, ClearRecordedSlots::kNo);
973 } 974 }
974 } 975 }
975 976
976 bool Heap::CollectGarbage(GarbageCollector collector, 977 bool Heap::CollectGarbage(GarbageCollector collector,
977 GarbageCollectionReason gc_reason, 978 GarbageCollectionReason gc_reason,
978 const char* collector_reason, 979 const char* collector_reason,
979 const v8::GCCallbackFlags gc_callback_flags) { 980 const v8::GCCallbackFlags gc_callback_flags) {
980 // The VM is in the GC state until exiting this function. 981 // The VM is in the GC state until exiting this function.
981 VMState<GC> state(isolate()); 982 VMState<GC> state(isolate());
982 RuntimeCallTimerScope(isolate(), &RuntimeCallStats::GC); 983 RuntimeCallTimerScope runtime_timer(isolate(), &RuntimeCallStats::GC);
983 984
984 #ifdef DEBUG 985 #ifdef DEBUG
985 // Reset the allocation timeout to the GC interval, but make sure to 986 // Reset the allocation timeout to the GC interval, but make sure to
986 // allow at least a few allocations after a collection. The reason 987 // allow at least a few allocations after a collection. The reason
987 // for this is that we have a lot of allocation sequences and we 988 // for this is that we have a lot of allocation sequences and we
988 // assume that a garbage collection will allow the subsequent 989 // assume that a garbage collection will allow the subsequent
989 // allocation attempts to go through. 990 // allocation attempts to go through.
990 allocation_timeout_ = Max(6, FLAG_gc_interval); 991 allocation_timeout_ = Max(6, FLAG_gc_interval);
991 #endif 992 #endif
992 993
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 if (FLAG_verify_heap) { 1424 if (FLAG_verify_heap) {
1424 VerifyStringTable(this); 1425 VerifyStringTable(this);
1425 } 1426 }
1426 #endif 1427 #endif
1427 1428
1428 return freed_global_handles > 0; 1429 return freed_global_handles > 0;
1429 } 1430 }
1430 1431
1431 1432
1432 void Heap::CallGCPrologueCallbacks(GCType gc_type, GCCallbackFlags flags) { 1433 void Heap::CallGCPrologueCallbacks(GCType gc_type, GCCallbackFlags flags) {
1433 RuntimeCallTimerScope(isolate(), &RuntimeCallStats::GCPrologueCallback); 1434 RuntimeCallTimerScope runtime_timer(isolate(),
1435 &RuntimeCallStats::GCPrologueCallback);
1434 for (int i = 0; i < gc_prologue_callbacks_.length(); ++i) { 1436 for (int i = 0; i < gc_prologue_callbacks_.length(); ++i) {
1435 if (gc_type & gc_prologue_callbacks_[i].gc_type) { 1437 if (gc_type & gc_prologue_callbacks_[i].gc_type) {
1436 if (!gc_prologue_callbacks_[i].pass_isolate) { 1438 if (!gc_prologue_callbacks_[i].pass_isolate) {
1437 v8::GCCallback callback = reinterpret_cast<v8::GCCallback>( 1439 v8::GCCallback callback = reinterpret_cast<v8::GCCallback>(
1438 gc_prologue_callbacks_[i].callback); 1440 gc_prologue_callbacks_[i].callback);
1439 callback(gc_type, flags); 1441 callback(gc_type, flags);
1440 } else { 1442 } else {
1441 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(this->isolate()); 1443 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(this->isolate());
1442 gc_prologue_callbacks_[i].callback(isolate, gc_type, flags); 1444 gc_prologue_callbacks_[i].callback(isolate, gc_type, flags);
1443 } 1445 }
1444 } 1446 }
1445 } 1447 }
1446 } 1448 }
1447 1449
1448 1450
1449 void Heap::CallGCEpilogueCallbacks(GCType gc_type, 1451 void Heap::CallGCEpilogueCallbacks(GCType gc_type,
1450 GCCallbackFlags gc_callback_flags) { 1452 GCCallbackFlags gc_callback_flags) {
1451 RuntimeCallTimerScope(isolate(), &RuntimeCallStats::GCEpilogueCallback); 1453 RuntimeCallTimerScope runtime_timer(isolate(),
1454 &RuntimeCallStats::GCEpilogueCallback);
1452 for (int i = 0; i < gc_epilogue_callbacks_.length(); ++i) { 1455 for (int i = 0; i < gc_epilogue_callbacks_.length(); ++i) {
1453 if (gc_type & gc_epilogue_callbacks_[i].gc_type) { 1456 if (gc_type & gc_epilogue_callbacks_[i].gc_type) {
1454 if (!gc_epilogue_callbacks_[i].pass_isolate) { 1457 if (!gc_epilogue_callbacks_[i].pass_isolate) {
1455 v8::GCCallback callback = reinterpret_cast<v8::GCCallback>( 1458 v8::GCCallback callback = reinterpret_cast<v8::GCCallback>(
1456 gc_epilogue_callbacks_[i].callback); 1459 gc_epilogue_callbacks_[i].callback);
1457 callback(gc_type, gc_callback_flags); 1460 callback(gc_type, gc_callback_flags);
1458 } else { 1461 } else {
1459 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(this->isolate()); 1462 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(this->isolate());
1460 gc_epilogue_callbacks_[i].callback(isolate, gc_type, gc_callback_flags); 1463 gc_epilogue_callbacks_[i].callback(isolate, gc_type, gc_callback_flags);
1461 } 1464 }
(...skipping 4921 matching lines...) Expand 10 before | Expand all | Expand 10 after
6383 case LO_SPACE: 6386 case LO_SPACE:
6384 return "LO_SPACE"; 6387 return "LO_SPACE";
6385 default: 6388 default:
6386 UNREACHABLE(); 6389 UNREACHABLE();
6387 } 6390 }
6388 return NULL; 6391 return NULL;
6389 } 6392 }
6390 6393
6391 } // namespace internal 6394 } // namespace internal
6392 } // namespace v8 6395 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/heap/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698