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

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

Issue 1124153006: Heap snapshot visualizations (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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 | Annotate | Revision Log
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 "platform/globals.h" 8 #include "platform/globals.h"
9 9
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 2234 matching lines...) Expand 10 before | Expand all | Expand 10 after
2245 jsobj.AddProperty("type", "OK"); 2245 jsobj.AddProperty("type", "OK");
2246 jsobj.AddProperty("id", "ok"); 2246 jsobj.AddProperty("id", "ok");
2247 return true; 2247 return true;
2248 } 2248 }
2249 2249
2250 2250
2251 void Service::SendGraphEvent(Isolate* isolate) { 2251 void Service::SendGraphEvent(Isolate* isolate) {
2252 uint8_t* buffer = NULL; 2252 uint8_t* buffer = NULL;
2253 WriteStream stream(&buffer, &allocator, 1 * MB); 2253 WriteStream stream(&buffer, &allocator, 1 * MB);
2254 ObjectGraph graph(isolate); 2254 ObjectGraph graph(isolate);
2255 graph.Serialize(&stream); 2255 intptr_t node_count = graph.Serialize(&stream);
2256 JSONStream js; 2256
2257 { 2257 // Chrome crashes receiving a single tens-of-megabytes blob, so send the
2258 JSONObject jsobj(&js); 2258 // snapshot in megabyte-sized chunks instead.
2259 const intptr_t kChunkSize = 1 * MB;
2260 intptr_t num_chunks =
2261 (stream.bytes_written() + (kChunkSize - 1)) / kChunkSize;
2262 for (intptr_t i = 0; i < num_chunks; i++) {
2263 JSONStream js;
2259 { 2264 {
2260 JSONObject event(&jsobj, "event"); 2265 JSONObject jsobj(&js);
2261 event.AddProperty("type", "ServiceEvent"); 2266 {
2262 event.AddProperty("eventType", "_Graph"); 2267 JSONObject event(&jsobj, "event");
2263 event.AddProperty("isolate", isolate); 2268 event.AddProperty("type", "ServiceEvent");
2269 event.AddProperty("eventType", "_Graph");
2270 event.AddProperty("isolate", isolate);
2271
2272 event.AddProperty("chunkIndex", i);
2273 event.AddProperty("chunkCount", num_chunks);
2274 event.AddProperty("nodeCount", node_count);
2275 }
2264 } 2276 }
2277 const String& message = String::Handle(String::New(js.ToCString()));
2278
2279 uint8_t* chunk_start = buffer + (i * kChunkSize);
2280 intptr_t chunk_size = (i + 1 == num_chunks)
2281 ? stream.bytes_written() - (i * kChunkSize)
2282 : kChunkSize;
2283
2284 SendEvent(message, chunk_start, chunk_size);
2265 } 2285 }
2266 const String& message = String::Handle(String::New(js.ToCString()));
2267 SendEvent(message, buffer, stream.bytes_written());
2268 } 2286 }
2269 2287
2270 2288
2271 void Service::SendInspectEvent(Isolate* isolate, const Object& inspectee) { 2289 void Service::SendInspectEvent(Isolate* isolate, const Object& inspectee) {
2272 ServiceEvent event(isolate, ServiceEvent::kInspect); 2290 ServiceEvent event(isolate, ServiceEvent::kInspect);
2273 event.set_inspectee(&inspectee); 2291 event.set_inspectee(&inspectee);
2274 Service::HandleEvent(&event); 2292 Service::HandleEvent(&event);
2275 } 2293 }
2276 2294
2277 2295
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
2646 ServiceMethodDescriptor& method = service_methods_[i]; 2664 ServiceMethodDescriptor& method = service_methods_[i];
2647 if (strcmp(method_name, method.name) == 0) { 2665 if (strcmp(method_name, method.name) == 0) {
2648 return &method; 2666 return &method;
2649 } 2667 }
2650 } 2668 }
2651 return NULL; 2669 return NULL;
2652 } 2670 }
2653 2671
2654 2672
2655 } // namespace dart 2673 } // namespace dart
OLDNEW
« runtime/observatory/lib/object_graph.dart ('K') | « runtime/vm/object_graph.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698