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

Unified Diff: runtime/vm/heap.cc

Issue 10872074: Report the reason for a garbage collection when verbose GC is enabled. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rename a parameter consistently Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/heap.h ('k') | runtime/vm/pages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/heap.cc
diff --git a/runtime/vm/heap.cc b/runtime/vm/heap.cc
index 6c9a7d1d858613cd89848ffcb6d9fb2edb4d0101..0168f73014ca2ef4edfad1cb41c2f60fd7171b55 100644
--- a/runtime/vm/heap.cc
+++ b/runtime/vm/heap.cc
@@ -177,18 +177,23 @@ RawInstructions* Heap::FindObjectInCodeSpace(FindObjectVisitor* visitor) {
void Heap::CollectGarbage(Space space, ApiCallbacks api_callbacks) {
bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks);
switch (space) {
- case kNew:
- new_space_->Scavenge(invoke_api_callbacks);
+ case kNew: {
+ new_space_->Scavenge(invoke_api_callbacks,
+ GCReasonToString(kNewSpace));
if (new_space_->HadPromotionFailure()) {
- old_space_->MarkSweep(true);
+ old_space_->MarkSweep(true,
+ GCReasonToString(kPromotionFailure));
}
break;
+ }
case kOld:
- old_space_->MarkSweep(invoke_api_callbacks);
+ old_space_->MarkSweep(invoke_api_callbacks,
+ GCReasonToString(kOldSpace));
break;
case kCode:
UNIMPLEMENTED();
- code_space_->MarkSweep(invoke_api_callbacks);
+ code_space_->MarkSweep(invoke_api_callbacks,
+ GCReasonToString(kCodeSpace));
break;
default:
UNREACHABLE();
@@ -211,10 +216,11 @@ void Heap::CollectGarbage(Space space) {
void Heap::CollectAllGarbage() {
- new_space_->Scavenge(kInvokeApiCallbacks);
- old_space_->MarkSweep(kInvokeApiCallbacks);
+ const char* gc_reason = GCReasonToString(kFull);
+ new_space_->Scavenge(kInvokeApiCallbacks, gc_reason);
+ old_space_->MarkSweep(kInvokeApiCallbacks, gc_reason);
// TODO(iposva): Merge old and code space.
- // code_space_->MarkSweep(kInvokeApiCallbacks);
+ // code_space_->MarkSweep(kInvokeApiCallbacks, gc_reason);
if (FLAG_verbose_gc) {
PrintSizes();
}
@@ -333,6 +339,29 @@ void Heap::Profile(Dart_HeapProfileWriteCallback callback, void* stream) const {
}
+const char* Heap::GCReasonToString(GCReason gc_reason) {
+ switch (gc_reason) {
+ case kNewSpace:
+ return "new space";
+ case kPromotionFailure:
+ return "promotion failure";
+ case kOldSpace:
+ return "old space";
+ case kCodeSpace:
+ return "code space";
+ case kFull:
+ return "full";
+ case kGCAtAlloc:
+ return "debugging";
+ case kGCTestCase:
+ return "test case";
+ default:
+ UNREACHABLE();
+ return "";
+ }
+}
+
+
#if defined(DEBUG)
NoGCScope::NoGCScope() : StackResource(Isolate::Current()) {
isolate()->IncrementNoGCScopeDepth();
« no previous file with comments | « runtime/vm/heap.h ('k') | runtime/vm/pages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698