| OLD | NEW |
| 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 2291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2302 jsobj.AddProperty("type", "OK"); | 2302 jsobj.AddProperty("type", "OK"); |
| 2303 jsobj.AddProperty("id", "ok"); | 2303 jsobj.AddProperty("id", "ok"); |
| 2304 return true; | 2304 return true; |
| 2305 } | 2305 } |
| 2306 | 2306 |
| 2307 | 2307 |
| 2308 void Service::SendGraphEvent(Isolate* isolate) { | 2308 void Service::SendGraphEvent(Isolate* isolate) { |
| 2309 uint8_t* buffer = NULL; | 2309 uint8_t* buffer = NULL; |
| 2310 WriteStream stream(&buffer, &allocator, 1 * MB); | 2310 WriteStream stream(&buffer, &allocator, 1 * MB); |
| 2311 ObjectGraph graph(isolate); | 2311 ObjectGraph graph(isolate); |
| 2312 graph.Serialize(&stream); | 2312 intptr_t node_count = graph.Serialize(&stream); |
| 2313 JSONStream js; | 2313 |
| 2314 { | 2314 // Chrome crashes receiving a single tens-of-megabytes blob, so send the |
| 2315 JSONObject jsobj(&js); | 2315 // snapshot in megabyte-sized chunks instead. |
| 2316 const intptr_t kChunkSize = 1 * MB; |
| 2317 intptr_t num_chunks = |
| 2318 (stream.bytes_written() + (kChunkSize - 1)) / kChunkSize; |
| 2319 for (intptr_t i = 0; i < num_chunks; i++) { |
| 2320 JSONStream js; |
| 2316 { | 2321 { |
| 2317 JSONObject event(&jsobj, "event"); | 2322 JSONObject jsobj(&js); |
| 2318 event.AddProperty("type", "ServiceEvent"); | 2323 { |
| 2319 event.AddProperty("eventType", "_Graph"); | 2324 JSONObject event(&jsobj, "event"); |
| 2320 event.AddProperty("isolate", isolate); | 2325 event.AddProperty("type", "ServiceEvent"); |
| 2326 event.AddProperty("eventType", "_Graph"); |
| 2327 event.AddProperty("isolate", isolate); |
| 2328 |
| 2329 event.AddProperty("chunkIndex", i); |
| 2330 event.AddProperty("chunkCount", num_chunks); |
| 2331 event.AddProperty("nodeCount", node_count); |
| 2332 } |
| 2333 jsobj.AddProperty("streamId", "_Graph"); |
| 2321 } | 2334 } |
| 2322 jsobj.AddProperty("streamId", "_Graph"); | 2335 |
| 2336 const String& message = String::Handle(String::New(js.ToCString())); |
| 2337 |
| 2338 uint8_t* chunk_start = buffer + (i * kChunkSize); |
| 2339 intptr_t chunk_size = (i + 1 == num_chunks) |
| 2340 ? stream.bytes_written() - (i * kChunkSize) |
| 2341 : kChunkSize; |
| 2342 |
| 2343 SendEventWithData("_Graph", "_Graph", message, chunk_start, chunk_size); |
| 2323 } | 2344 } |
| 2324 const String& message = String::Handle(String::New(js.ToCString())); | |
| 2325 SendEventWithData("_Graph", "_Graph", message, | |
| 2326 buffer, stream.bytes_written()); | |
| 2327 } | 2345 } |
| 2328 | 2346 |
| 2329 | 2347 |
| 2330 void Service::SendInspectEvent(Isolate* isolate, const Object& inspectee) { | 2348 void Service::SendInspectEvent(Isolate* isolate, const Object& inspectee) { |
| 2331 if (!Service::NeedsDebugEvents()) { | 2349 if (!Service::NeedsDebugEvents()) { |
| 2332 return; | 2350 return; |
| 2333 } | 2351 } |
| 2334 ServiceEvent event(isolate, ServiceEvent::kInspect); | 2352 ServiceEvent event(isolate, ServiceEvent::kInspect); |
| 2335 event.set_inspectee(&inspectee); | 2353 event.set_inspectee(&inspectee); |
| 2336 Service::HandleEvent(&event); | 2354 Service::HandleEvent(&event); |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2708 ServiceMethodDescriptor& method = service_methods_[i]; | 2726 ServiceMethodDescriptor& method = service_methods_[i]; |
| 2709 if (strcmp(method_name, method.name) == 0) { | 2727 if (strcmp(method_name, method.name) == 0) { |
| 2710 return &method; | 2728 return &method; |
| 2711 } | 2729 } |
| 2712 } | 2730 } |
| 2713 return NULL; | 2731 return NULL; |
| 2714 } | 2732 } |
| 2715 | 2733 |
| 2716 | 2734 |
| 2717 } // namespace dart | 2735 } // namespace dart |
| OLD | NEW |