| 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 1470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1481 result.PrintJSON(js, true); | 1481 result.PrintJSON(js, true); |
| 1482 return true; | 1482 return true; |
| 1483 } | 1483 } |
| 1484 PrintError(js, "%s: Invalid 'targetId' parameter value: " | 1484 PrintError(js, "%s: Invalid 'targetId' parameter value: " |
| 1485 "id '%s' does not correspond to a " | 1485 "id '%s' does not correspond to a " |
| 1486 "library, class, or instance", js->method(), target_id); | 1486 "library, class, or instance", js->method(), target_id); |
| 1487 return true; | 1487 return true; |
| 1488 } | 1488 } |
| 1489 | 1489 |
| 1490 | 1490 |
| 1491 static const MethodParameter* get_call_site_data_params[] = { |
| 1492 ISOLATE_PARAMETER, |
| 1493 new IdParameter("targetId", true), |
| 1494 NULL, |
| 1495 }; |
| 1496 |
| 1497 |
| 1498 static bool HandleIsolateGetCallSiteData(Isolate* isolate, JSONStream* js) { |
| 1499 const char* target_id = js->LookupParam("targetId"); |
| 1500 Object& obj = Object::Handle(LookupHeapObject(isolate, target_id, NULL)); |
| 1501 if (obj.raw() == Object::sentinel().raw()) { |
| 1502 PrintInvalidParamError(js, "targetId"); |
| 1503 return true; |
| 1504 } |
| 1505 if (obj.IsFunction()) { |
| 1506 const Function& func = Function::Cast(obj); |
| 1507 const GrowableObjectArray& ics = |
| 1508 GrowableObjectArray::Handle(func.CollectICsWithSourcePositions()); |
| 1509 JSONObject jsobj(js); |
| 1510 jsobj.AddProperty("type", "_CallSiteData"); |
| 1511 jsobj.AddProperty("function", func); |
| 1512 JSONArray elements(&jsobj, "callSites"); |
| 1513 Smi& line = Smi::Handle(); |
| 1514 Smi& column = Smi::Handle(); |
| 1515 ICData& ic_data = ICData::Handle(); |
| 1516 for (intptr_t i = 0; i < ics.Length();) { |
| 1517 ic_data ^= ics.At(i++); |
| 1518 line ^= ics.At(i++); |
| 1519 column ^= ics.At(i++); |
| 1520 ic_data.PrintToJSONArray(&elements, line.Value(), column.Value()); |
| 1521 } |
| 1522 return true; |
| 1523 } |
| 1524 return false; |
| 1525 } |
| 1526 |
| 1527 |
| 1491 class GetInstancesVisitor : public ObjectGraph::Visitor { | 1528 class GetInstancesVisitor : public ObjectGraph::Visitor { |
| 1492 public: | 1529 public: |
| 1493 GetInstancesVisitor(const Class& cls, const Array& storage) | 1530 GetInstancesVisitor(const Class& cls, const Array& storage) |
| 1494 : cls_(cls), storage_(storage), count_(0) {} | 1531 : cls_(cls), storage_(storage), count_(0) {} |
| 1495 | 1532 |
| 1496 virtual Direction VisitObject(ObjectGraph::StackIterator* it) { | 1533 virtual Direction VisitObject(ObjectGraph::StackIterator* it) { |
| 1497 RawObject* raw_obj = it->Get(); | 1534 RawObject* raw_obj = it->Get(); |
| 1498 if (raw_obj->IsFreeListElement()) { | 1535 if (raw_obj->IsFreeListElement()) { |
| 1499 return kProceed; | 1536 return kProceed; |
| 1500 } | 1537 } |
| (...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2412 { "_triggerEchoEvent", HandleIsolateTriggerEchoEvent, | 2449 { "_triggerEchoEvent", HandleIsolateTriggerEchoEvent, |
| 2413 NULL }, | 2450 NULL }, |
| 2414 { "addBreakpoint", HandleIsolateAddBreakpoint, | 2451 { "addBreakpoint", HandleIsolateAddBreakpoint, |
| 2415 add_breakpoint_params }, | 2452 add_breakpoint_params }, |
| 2416 { "eval", HandleIsolateEval, | 2453 { "eval", HandleIsolateEval, |
| 2417 eval_params }, | 2454 eval_params }, |
| 2418 { "getAllocationProfile", HandleIsolateGetAllocationProfile, | 2455 { "getAllocationProfile", HandleIsolateGetAllocationProfile, |
| 2419 get_allocation_profile_params }, | 2456 get_allocation_profile_params }, |
| 2420 { "getBreakpoints", HandleIsolateGetBreakpoints, | 2457 { "getBreakpoints", HandleIsolateGetBreakpoints, |
| 2421 get_breakpoints_params }, | 2458 get_breakpoints_params }, |
| 2459 { "getCallSiteData", HandleIsolateGetCallSiteData, |
| 2460 get_call_site_data_params }, |
| 2422 { "getClassList", HandleIsolateGetClassList, | 2461 { "getClassList", HandleIsolateGetClassList, |
| 2423 get_class_list_params }, | 2462 get_class_list_params }, |
| 2424 { "getCoverage", HandleIsolateGetCoverage, | 2463 { "getCoverage", HandleIsolateGetCoverage, |
| 2425 get_coverage_params }, | 2464 get_coverage_params }, |
| 2426 { "getCpuProfile", HandleIsolateGetCpuProfile, | 2465 { "getCpuProfile", HandleIsolateGetCpuProfile, |
| 2427 get_cpu_profile_params }, | 2466 get_cpu_profile_params }, |
| 2428 { "getFlagList", HandleVMFlagList , | 2467 { "getFlagList", HandleVMFlagList , |
| 2429 get_flag_list_params }, | 2468 get_flag_list_params }, |
| 2430 { "getHeapMap", HandleIsolateGetHeapMap, | 2469 { "getHeapMap", HandleIsolateGetHeapMap, |
| 2431 get_heap_map_params }, | 2470 get_heap_map_params }, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2479 ServiceMethodDescriptor& method = service_methods_[i]; | 2518 ServiceMethodDescriptor& method = service_methods_[i]; |
| 2480 if (strcmp(method_name, method.name) == 0) { | 2519 if (strcmp(method_name, method.name) == 0) { |
| 2481 return &method; | 2520 return &method; |
| 2482 } | 2521 } |
| 2483 } | 2522 } |
| 2484 return NULL; | 2523 return NULL; |
| 2485 } | 2524 } |
| 2486 | 2525 |
| 2487 | 2526 |
| 2488 } // namespace dart | 2527 } // namespace dart |
| OLD | NEW |