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

Side by Side Diff: runtime/vm/service.cc

Issue 2502283003: Add a version of heap snapshots that use only fields and stack frames as roots and only include ins… (Closed)
Patch Set: . Created 4 years, 1 month 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
« runtime/vm/object_graph.cc ('K') | « runtime/vm/service.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 (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/service.h" 5 #include "vm/service.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "include/dart_native_api.h" 8 #include "include/dart_native_api.h"
9 #include "platform/globals.h" 9 #include "platform/globals.h"
10 10
(...skipping 3217 matching lines...) Expand 10 before | Expand all | Expand 10 after
3228 }; 3228 };
3229 3229
3230 3230
3231 static bool GetHeapMap(Thread* thread, JSONStream* js) { 3231 static bool GetHeapMap(Thread* thread, JSONStream* js) {
3232 Isolate* isolate = thread->isolate(); 3232 Isolate* isolate = thread->isolate();
3233 isolate->heap()->PrintHeapMapToJSONStream(isolate, js); 3233 isolate->heap()->PrintHeapMapToJSONStream(isolate, js);
3234 return true; 3234 return true;
3235 } 3235 }
3236 3236
3237 3237
3238 static const char* snapshot_roots_names[] = {
3239 "VM", "User", NULL,
3240 };
3241
3242
3243 static ObjectGraph::SnapshotRoots snapshot_roots_values[] = {
3244 ObjectGraph::kVM, ObjectGraph::kUser,
3245 };
3246
3247
3238 static const MethodParameter* request_heap_snapshot_params[] = { 3248 static const MethodParameter* request_heap_snapshot_params[] = {
3239 RUNNABLE_ISOLATE_PARAMETER, 3249 RUNNABLE_ISOLATE_PARAMETER,
3250 new EnumParameter("roots", false /* not required */, snapshot_roots_names),
3240 new BoolParameter("collectGarbage", false /* not required */), NULL, 3251 new BoolParameter("collectGarbage", false /* not required */), NULL,
3241 }; 3252 };
3242 3253
3243 3254
3244 static bool RequestHeapSnapshot(Thread* thread, JSONStream* js) { 3255 static bool RequestHeapSnapshot(Thread* thread, JSONStream* js) {
3256 ObjectGraph::SnapshotRoots roots = ObjectGraph::kVM;
3257 const char* roots_arg = js->LookupParam("roots");
3258 if (roots_arg != NULL) {
3259 roots = EnumMapper(roots_arg, snapshot_roots_names, snapshot_roots_values);
3260 }
3245 const bool collect_garbage = 3261 const bool collect_garbage =
3246 BoolParameter::Parse(js->LookupParam("collectGarbage"), true); 3262 BoolParameter::Parse(js->LookupParam("collectGarbage"), true);
3247 if (Service::graph_stream.enabled()) { 3263 if (Service::graph_stream.enabled()) {
3248 Service::SendGraphEvent(thread, collect_garbage); 3264 Service::SendGraphEvent(thread, roots, collect_garbage);
3249 } 3265 }
3250 // TODO(koda): Provide some id that ties this request to async response(s). 3266 // TODO(koda): Provide some id that ties this request to async response(s).
3251 JSONObject jsobj(js); 3267 JSONObject jsobj(js);
3252 jsobj.AddProperty("type", "OK"); 3268 jsobj.AddProperty("type", "OK");
3253 return true; 3269 return true;
3254 } 3270 }
3255 3271
3256 3272
3257 void Service::SendGraphEvent(Thread* thread, bool collect_garbage) { 3273 void Service::SendGraphEvent(Thread* thread,
3274 ObjectGraph::SnapshotRoots roots,
3275 bool collect_garbage) {
3258 uint8_t* buffer = NULL; 3276 uint8_t* buffer = NULL;
3259 WriteStream stream(&buffer, &allocator, 1 * MB); 3277 WriteStream stream(&buffer, &allocator, 1 * MB);
3260 ObjectGraph graph(thread); 3278 ObjectGraph graph(thread);
3261 intptr_t node_count = graph.Serialize(&stream, collect_garbage); 3279 intptr_t node_count = graph.Serialize(&stream, roots, collect_garbage);
3262 3280
3263 // Chrome crashes receiving a single tens-of-megabytes blob, so send the 3281 // Chrome crashes receiving a single tens-of-megabytes blob, so send the
3264 // snapshot in megabyte-sized chunks instead. 3282 // snapshot in megabyte-sized chunks instead.
3265 const intptr_t kChunkSize = 1 * MB; 3283 const intptr_t kChunkSize = 1 * MB;
3266 intptr_t num_chunks = 3284 intptr_t num_chunks =
3267 (stream.bytes_written() + (kChunkSize - 1)) / kChunkSize; 3285 (stream.bytes_written() + (kChunkSize - 1)) / kChunkSize;
3268 for (intptr_t i = 0; i < num_chunks; i++) { 3286 for (intptr_t i = 0; i < num_chunks; i++) {
3269 JSONStream js; 3287 JSONStream js;
3270 { 3288 {
3271 JSONObject jsobj(&js); 3289 JSONObject jsobj(&js);
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after
4072 if (strcmp(method_name, method.name) == 0) { 4090 if (strcmp(method_name, method.name) == 0) {
4073 return &method; 4091 return &method;
4074 } 4092 }
4075 } 4093 }
4076 return NULL; 4094 return NULL;
4077 } 4095 }
4078 4096
4079 #endif // !PRODUCT 4097 #endif // !PRODUCT
4080 4098
4081 } // namespace dart 4099 } // namespace dart
OLDNEW
« runtime/vm/object_graph.cc ('K') | « runtime/vm/service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698