Chromium Code Reviews| 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 2234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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. |
|
koda
2015/05/19 20:12:36
Add named constant for chunk size.
rmacnak
2015/05/19 22:16:08
Done.
| |
| 2259 intptr_t num_chunks = (stream.bytes_written() + (MB - 1)) / MB; | |
| 2260 for (intptr_t i = 0; i < num_chunks; i++) { | |
| 2261 JSONStream js; | |
| 2259 { | 2262 { |
| 2260 JSONObject event(&jsobj, "event"); | 2263 JSONObject jsobj(&js); |
| 2261 event.AddProperty("type", "ServiceEvent"); | 2264 { |
| 2262 event.AddProperty("eventType", "_Graph"); | 2265 JSONObject event(&jsobj, "event"); |
| 2263 event.AddProperty("isolate", isolate); | 2266 event.AddProperty("type", "ServiceEvent"); |
| 2267 event.AddProperty("eventType", "_Graph"); | |
| 2268 event.AddProperty("isolate", isolate); | |
| 2269 | |
| 2270 event.AddProperty("i", i); | |
| 2271 event.AddProperty("n", num_chunks); | |
| 2272 event.AddProperty("nodeCount", node_count); | |
| 2273 } | |
| 2264 } | 2274 } |
| 2275 const String& message = String::Handle(String::New(js.ToCString())); | |
| 2276 | |
| 2277 uint8_t* chunk_start = buffer + (i * MB); | |
| 2278 intptr_t chunk_size = (i + 1 == num_chunks) | |
|
koda
2015/05/19 20:12:35
Does this do the right thing when the last chunk i
rmacnak
2015/05/19 22:16:08
No, fixed.
| |
| 2279 ? stream.bytes_written() % MB | |
| 2280 : MB; | |
| 2281 | |
| 2282 SendEvent(message, chunk_start, chunk_size); | |
| 2265 } | 2283 } |
| 2266 const String& message = String::Handle(String::New(js.ToCString())); | |
| 2267 SendEvent(message, buffer, stream.bytes_written()); | |
| 2268 } | 2284 } |
| 2269 | 2285 |
| 2270 | 2286 |
| 2271 void Service::SendInspectEvent(Isolate* isolate, const Object& inspectee) { | 2287 void Service::SendInspectEvent(Isolate* isolate, const Object& inspectee) { |
| 2272 ServiceEvent event(isolate, ServiceEvent::kInspect); | 2288 ServiceEvent event(isolate, ServiceEvent::kInspect); |
| 2273 event.set_inspectee(&inspectee); | 2289 event.set_inspectee(&inspectee); |
| 2274 Service::HandleEvent(&event); | 2290 Service::HandleEvent(&event); |
| 2275 } | 2291 } |
| 2276 | 2292 |
| 2277 | 2293 |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2646 ServiceMethodDescriptor& method = service_methods_[i]; | 2662 ServiceMethodDescriptor& method = service_methods_[i]; |
| 2647 if (strcmp(method_name, method.name) == 0) { | 2663 if (strcmp(method_name, method.name) == 0) { |
| 2648 return &method; | 2664 return &method; |
| 2649 } | 2665 } |
| 2650 } | 2666 } |
| 2651 return NULL; | 2667 return NULL; |
| 2652 } | 2668 } |
| 2653 | 2669 |
| 2654 | 2670 |
| 2655 } // namespace dart | 2671 } // namespace dart |
| OLD | NEW |