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

Unified Diff: runtime/vm/service.cc

Issue 177473004: Handle collected objects and expired handles more gracefully. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: gen js Created 6 years, 9 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/object_id_ring.cc ('k') | tests/standalone/vmservice/isolate_bad_object_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/service.cc
diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc
index a9e195704e66462b56188890906b007a7c23498c..1019498aeaa3f4c250d3404d0ea3d72b9fca60f6 100644
--- a/runtime/vm/service.cc
+++ b/runtime/vm/service.cc
@@ -857,6 +857,16 @@ static bool HandleLibraries(Isolate* isolate, JSONStream* js) {
}
+static void PrintPseudoNull(JSONStream* js,
+ const char* id,
+ const char* preview) {
+ JSONObject jsobj(js);
+ jsobj.AddProperty("type", "Null");
+ jsobj.AddProperty("id", id);
+ jsobj.AddProperty("preview", preview);
+}
+
+
static bool HandleObjects(Isolate* isolate, JSONStream* js) {
REQUIRE_COLLECTION_ID("objects");
ASSERT(js->num_arguments() >= 2);
@@ -864,13 +874,30 @@ static bool HandleObjects(Isolate* isolate, JSONStream* js) {
// TODO(turnidge): Handle <optimized out> the same way as other
// special nulls.
- if (strcmp(arg, "null") == 0 ||
- strcmp(arg, "not-initialized") == 0 ||
- strcmp(arg, "being-initialized") == 0 ||
- strcmp(arg, "optimized-out") == 0) {
+ if (strcmp(arg, "null") == 0) {
Object::null_object().PrintToJSONStream(js, false);
return true;
+ } else if (strcmp(arg, "not-initialized") == 0) {
+ Object::sentinel().PrintToJSONStream(js, false);
+ return true;
+
+ } else if (strcmp(arg, "being-initialized") == 0) {
+ Object::transition_sentinel().PrintToJSONStream(js, false);
+ return true;
+
+ } else if (strcmp(arg, "optimized-out") == 0) {
+ Symbols::OptimizedOut().PrintToJSONStream(js, false);
+ return true;
+
+ } else if (strcmp(arg, "collected") == 0) {
+ PrintPseudoNull(js, "objects/collected", "<collected>");
+ return true;
+
+ } else if (strcmp(arg, "expired") == 0) {
+ PrintPseudoNull(js, "objects/expired", "<expired>");
+ return true;
+
} else if (strcmp(arg, "int") == 0) {
if (js->num_arguments() < 3) {
PrintError(js, "expected 3 arguments but found %" Pd "\n",
@@ -917,6 +944,15 @@ static bool HandleObjects(Isolate* isolate, JSONStream* js) {
return true;
}
Object& obj = Object::Handle(ring->GetObjectForId(id));
+ if (obj.IsNull()) {
+ // The object has been collected by the gc.
+ PrintPseudoNull(js, "objects/collected", "<collected>");
+ return true;
+ } else if (obj.raw() == Object::sentinel().raw()) {
+ // The object id has expired.
+ PrintPseudoNull(js, "objects/expired", "<expired>");
+ return true;
+ }
obj.PrintToJSONStream(js, false);
return true;
}
« no previous file with comments | « runtime/vm/object_id_ring.cc ('k') | tests/standalone/vmservice/isolate_bad_object_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698