Chromium Code Reviews| Index: runtime/vm/service.cc |
| diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc |
| index f60cd9655fd3dfc6ce6ee7736c0810900f7a05aa..2b6d25f5e6bde5f5124811988e4fb8ef7874a51e 100644 |
| --- a/runtime/vm/service.cc |
| +++ b/runtime/vm/service.cc |
| @@ -1488,6 +1488,42 @@ static bool HandleIsolateEval(Isolate* isolate, JSONStream* js) { |
| } |
| +static const MethodParameter* get_call_site_data_params[] = { |
| + ISOLATE_PARAMETER, |
| + NULL, |
|
Cutch
2015/02/12 20:38:02
Should be:
ISOLATE_PARAMETER,
new IdParameter("ta
rmacnak
2015/02/12 20:55:12
Done.
|
| +}; |
| + |
| + |
| +static bool HandleIsolateGetCallSiteData(Isolate* isolate, JSONStream* js) { |
| + const char* target_id = js->LookupParam("targetId"); |
| + Object& obj = Object::Handle(LookupHeapObject(isolate, target_id, NULL)); |
| + if (obj.raw() == Object::sentinel().raw()) { |
| + PrintInvalidParamError(js, "targetId"); |
| + return true; |
| + } |
| + if (obj.IsFunction()) { |
| + const Function& func = Function::Cast(obj); |
| + const GrowableObjectArray& ics = |
| + GrowableObjectArray::Handle(func.CollectICsWithSourcePositions()); |
| + JSONObject jsobj(js); |
| + jsobj.AddProperty("type", "CallSiteData"); |
|
Cutch
2015/02/12 20:38:02
If this isn't guaranteed to be stable across VM ve
rmacnak
2015/02/12 20:55:12
Good idea for a first cut.
|
| + jsobj.AddProperty("function", func); |
| + JSONArray elements(&jsobj, "callSites"); |
| + Smi& line = Smi::Handle(); |
| + Smi& column = Smi::Handle(); |
| + ICData& ic_data = ICData::Handle(); |
| + for (intptr_t i = 0; i < ics.Length();) { |
| + ic_data ^= ics.At(i++); |
| + line ^= ics.At(i++); |
| + column ^= ics.At(i++); |
| + ic_data.PrintToJSONArray(&elements, line.Value(), column.Value()); |
| + } |
| + return true; |
| + } |
| + return false; |
| +} |
| + |
| + |
| class GetInstancesVisitor : public ObjectGraph::Visitor { |
| public: |
| GetInstancesVisitor(const Class& cls, const Array& storage) |
| @@ -2419,6 +2455,8 @@ static ServiceMethodDescriptor service_methods_[] = { |
| get_allocation_profile_params }, |
| { "getBreakpoints", HandleIsolateGetBreakpoints, |
| get_breakpoints_params }, |
| + { "getCallSiteData", HandleIsolateGetCallSiteData, |
|
Cutch
2015/02/12 20:38:02
Please add this to service.idl
rmacnak
2015/02/12 20:55:12
Done.
|
| + get_call_site_data_params }, |
| { "getClassList", HandleIsolateGetClassList, |
| get_class_list_params }, |
| { "getCoverage", HandleIsolateGetCoverage, |