| 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 "include/dart_native_api.h" | 8 #include "include/dart_native_api.h" | 
| 9 #include "platform/globals.h" | 9 #include "platform/globals.h" | 
| 10 | 10 | 
| (...skipping 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1106                                  ObjectIdRing::LookupResult* kind) { | 1106                                  ObjectIdRing::LookupResult* kind) { | 
| 1107   *kind = ObjectIdRing::kValid; | 1107   *kind = ObjectIdRing::kValid; | 
| 1108   if (strncmp(arg, "int-", 4) == 0) { | 1108   if (strncmp(arg, "int-", 4) == 0) { | 
| 1109     arg += 4; | 1109     arg += 4; | 
| 1110     int64_t value = 0; | 1110     int64_t value = 0; | 
| 1111     if (!OS::StringToInt64(arg, &value) || | 1111     if (!OS::StringToInt64(arg, &value) || | 
| 1112         !Smi::IsValid(value)) { | 1112         !Smi::IsValid(value)) { | 
| 1113       *kind = ObjectIdRing::kInvalid; | 1113       *kind = ObjectIdRing::kInvalid; | 
| 1114       return Object::null(); | 1114       return Object::null(); | 
| 1115     } | 1115     } | 
| 1116     const Integer& obj = | 1116     const Integer& obj = Integer::Handle(isolate->current_zone(), | 
| 1117         Integer::Handle(isolate, Smi::New(static_cast<intptr_t>(value))); | 1117         Smi::New(static_cast<intptr_t>(value))); | 
| 1118     return obj.raw(); | 1118     return obj.raw(); | 
| 1119   } else if (strcmp(arg, "bool-true") == 0) { | 1119   } else if (strcmp(arg, "bool-true") == 0) { | 
| 1120     return Bool::True().raw(); | 1120     return Bool::True().raw(); | 
| 1121   } else if (strcmp(arg, "bool-false") == 0) { | 1121   } else if (strcmp(arg, "bool-false") == 0) { | 
| 1122     return Bool::False().raw(); | 1122     return Bool::False().raw(); | 
| 1123   } else if (strcmp(arg, "null") == 0) { | 1123   } else if (strcmp(arg, "null") == 0) { | 
| 1124     return Object::null(); | 1124     return Object::null(); | 
| 1125   } | 1125   } | 
| 1126 | 1126 | 
| 1127   ObjectIdRing* ring = isolate->object_id_ring(); | 1127   ObjectIdRing* ring = isolate->object_id_ring(); | 
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1231       return Object::sentinel().raw(); | 1231       return Object::sentinel().raw(); | 
| 1232     } | 1232     } | 
| 1233     return field.raw(); | 1233     return field.raw(); | 
| 1234 | 1234 | 
| 1235   } else if (strcmp(parts[2], "functions") == 0) { | 1235   } else if (strcmp(parts[2], "functions") == 0) { | 
| 1236     // Function ids look like: "classes/17/functions/11" | 1236     // Function ids look like: "classes/17/functions/11" | 
| 1237     if (num_parts != 4) { | 1237     if (num_parts != 4) { | 
| 1238       return Object::sentinel().raw(); | 1238       return Object::sentinel().raw(); | 
| 1239     } | 1239     } | 
| 1240     const char* encoded_id = parts[3]; | 1240     const char* encoded_id = parts[3]; | 
| 1241     String& id = String::Handle(isolate, String::New(encoded_id)); | 1241     String& id = String::Handle(isolate->current_zone(), | 
|  | 1242         String::New(encoded_id)); | 
| 1242     id = String::DecodeIRI(id); | 1243     id = String::DecodeIRI(id); | 
| 1243     if (id.IsNull()) { | 1244     if (id.IsNull()) { | 
| 1244       return Object::sentinel().raw(); | 1245       return Object::sentinel().raw(); | 
| 1245     } | 1246     } | 
| 1246     Function& func = Function::Handle(cls.LookupFunction(id)); | 1247     Function& func = Function::Handle(cls.LookupFunction(id)); | 
| 1247     if (func.IsNull()) { | 1248     if (func.IsNull()) { | 
| 1248       return Object::sentinel().raw(); | 1249       return Object::sentinel().raw(); | 
| 1249     } | 1250     } | 
| 1250     return func.raw(); | 1251     return func.raw(); | 
| 1251 | 1252 | 
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1421   if (num_parts < MAX_PARTS) { | 1422   if (num_parts < MAX_PARTS) { | 
| 1422     parts[num_parts++] = &id[start_pos]; | 1423     parts[num_parts++] = &id[start_pos]; | 
| 1423   } | 1424   } | 
| 1424 | 1425 | 
| 1425   if (result != NULL) { | 1426   if (result != NULL) { | 
| 1426     *result = ObjectIdRing::kValid; | 1427     *result = ObjectIdRing::kValid; | 
| 1427   } | 1428   } | 
| 1428 | 1429 | 
| 1429   if (strcmp(parts[0], "objects") == 0) { | 1430   if (strcmp(parts[0], "objects") == 0) { | 
| 1430     // Object ids look like "objects/1123" | 1431     // Object ids look like "objects/1123" | 
| 1431     Object& obj = Object::Handle(isolate); | 1432     Object& obj = Object::Handle(isolate->current_zone()); | 
| 1432     ObjectIdRing::LookupResult lookup_result; | 1433     ObjectIdRing::LookupResult lookup_result; | 
| 1433     obj = LookupObjectId(isolate, parts[1], &lookup_result); | 1434     obj = LookupObjectId(isolate, parts[1], &lookup_result); | 
| 1434     if (lookup_result != ObjectIdRing::kValid) { | 1435     if (lookup_result != ObjectIdRing::kValid) { | 
| 1435       if (result != NULL) { | 1436       if (result != NULL) { | 
| 1436         *result = lookup_result; | 1437         *result = lookup_result; | 
| 1437       } | 1438       } | 
| 1438       return Object::sentinel().raw(); | 1439       return Object::sentinel().raw(); | 
| 1439     } | 1440     } | 
| 1440     return obj.raw(); | 1441     return obj.raw(); | 
| 1441 | 1442 | 
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1583   if (limit_cstr == NULL) { | 1584   if (limit_cstr == NULL) { | 
| 1584     PrintMissingParamError(js, "limit"); | 1585     PrintMissingParamError(js, "limit"); | 
| 1585     return true; | 1586     return true; | 
| 1586   } | 1587   } | 
| 1587   intptr_t limit; | 1588   intptr_t limit; | 
| 1588   if (!GetIntegerId(limit_cstr, &limit)) { | 1589   if (!GetIntegerId(limit_cstr, &limit)) { | 
| 1589     PrintInvalidParamError(js, "limit"); | 1590     PrintInvalidParamError(js, "limit"); | 
| 1590     return true; | 1591     return true; | 
| 1591   } | 1592   } | 
| 1592 | 1593 | 
| 1593   Object& obj = Object::Handle(isolate); | 1594   Object& obj = Object::Handle(thread->zone()); | 
| 1594   ObjectIdRing::LookupResult lookup_result; | 1595   ObjectIdRing::LookupResult lookup_result; | 
| 1595   { | 1596   { | 
| 1596     HANDLESCOPE(thread); | 1597     HANDLESCOPE(thread); | 
| 1597     obj = LookupHeapObject(isolate, target_id, &lookup_result); | 1598     obj = LookupHeapObject(isolate, target_id, &lookup_result); | 
| 1598   } | 1599   } | 
| 1599   if (obj.raw() == Object::sentinel().raw()) { | 1600   if (obj.raw() == Object::sentinel().raw()) { | 
| 1600     if (lookup_result == ObjectIdRing::kCollected) { | 1601     if (lookup_result == ObjectIdRing::kCollected) { | 
| 1601       PrintSentinel(js, kCollectedSentinel); | 1602       PrintSentinel(js, kCollectedSentinel); | 
| 1602     } else if (lookup_result == ObjectIdRing::kExpired) { | 1603     } else if (lookup_result == ObjectIdRing::kExpired) { | 
| 1603       PrintSentinel(js, kExpiredSentinel); | 1604       PrintSentinel(js, kExpiredSentinel); | 
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1685   if (limit_cstr == NULL) { | 1686   if (limit_cstr == NULL) { | 
| 1686     PrintMissingParamError(js, "limit"); | 1687     PrintMissingParamError(js, "limit"); | 
| 1687     return true; | 1688     return true; | 
| 1688   } | 1689   } | 
| 1689   intptr_t limit; | 1690   intptr_t limit; | 
| 1690   if (!GetIntegerId(limit_cstr, &limit)) { | 1691   if (!GetIntegerId(limit_cstr, &limit)) { | 
| 1691     PrintInvalidParamError(js, "limit"); | 1692     PrintInvalidParamError(js, "limit"); | 
| 1692     return true; | 1693     return true; | 
| 1693   } | 1694   } | 
| 1694 | 1695 | 
| 1695   Object& obj = Object::Handle(isolate); | 1696   Object& obj = Object::Handle(thread->zone()); | 
| 1696   ObjectIdRing::LookupResult lookup_result; | 1697   ObjectIdRing::LookupResult lookup_result; | 
| 1697   { | 1698   { | 
| 1698     HANDLESCOPE(thread); | 1699     HANDLESCOPE(thread); | 
| 1699     obj = LookupHeapObject(isolate, target_id, &lookup_result); | 1700     obj = LookupHeapObject(isolate, target_id, &lookup_result); | 
| 1700   } | 1701   } | 
| 1701   if (obj.raw() == Object::sentinel().raw()) { | 1702   if (obj.raw() == Object::sentinel().raw()) { | 
| 1702     if (lookup_result == ObjectIdRing::kCollected) { | 1703     if (lookup_result == ObjectIdRing::kCollected) { | 
| 1703       PrintSentinel(js, kCollectedSentinel); | 1704       PrintSentinel(js, kCollectedSentinel); | 
| 1704     } else if (lookup_result == ObjectIdRing::kExpired) { | 1705     } else if (lookup_result == ObjectIdRing::kExpired) { | 
| 1705       PrintSentinel(js, kExpiredSentinel); | 1706       PrintSentinel(js, kExpiredSentinel); | 
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1766   const char* target_id = js->LookupParam("targetId"); | 1767   const char* target_id = js->LookupParam("targetId"); | 
| 1767   if (target_id == NULL) { | 1768   if (target_id == NULL) { | 
| 1768     PrintMissingParamError(js, "targetId"); | 1769     PrintMissingParamError(js, "targetId"); | 
| 1769     return true; | 1770     return true; | 
| 1770   } | 1771   } | 
| 1771   const char* expr = js->LookupParam("expression"); | 1772   const char* expr = js->LookupParam("expression"); | 
| 1772   if (expr == NULL) { | 1773   if (expr == NULL) { | 
| 1773     PrintMissingParamError(js, "expression"); | 1774     PrintMissingParamError(js, "expression"); | 
| 1774     return true; | 1775     return true; | 
| 1775   } | 1776   } | 
| 1776   const String& expr_str = String::Handle(isolate, String::New(expr)); | 1777   const String& expr_str = | 
|  | 1778       String::Handle(isolate->current_zone(), String::New(expr)); | 
| 1777   ObjectIdRing::LookupResult lookup_result; | 1779   ObjectIdRing::LookupResult lookup_result; | 
| 1778   Object& obj = Object::Handle(LookupHeapObject(isolate, target_id, | 1780   Object& obj = Object::Handle(LookupHeapObject(isolate, target_id, | 
| 1779                                                 &lookup_result)); | 1781                                                 &lookup_result)); | 
| 1780   if (obj.raw() == Object::sentinel().raw()) { | 1782   if (obj.raw() == Object::sentinel().raw()) { | 
| 1781     if (lookup_result == ObjectIdRing::kCollected) { | 1783     if (lookup_result == ObjectIdRing::kCollected) { | 
| 1782       PrintSentinel(js, kCollectedSentinel); | 1784       PrintSentinel(js, kCollectedSentinel); | 
| 1783     } else if (lookup_result == ObjectIdRing::kExpired) { | 1785     } else if (lookup_result == ObjectIdRing::kExpired) { | 
| 1784       PrintSentinel(js, kExpiredSentinel); | 1786       PrintSentinel(js, kExpiredSentinel); | 
| 1785     } else { | 1787     } else { | 
| 1786       PrintInvalidParamError(js, "targetId"); | 1788       PrintInvalidParamError(js, "targetId"); | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
| 1799     const Class& cls = Class::Cast(obj); | 1801     const Class& cls = Class::Cast(obj); | 
| 1800     const Object& result = Object::Handle(cls.Evaluate(expr_str, | 1802     const Object& result = Object::Handle(cls.Evaluate(expr_str, | 
| 1801                                                        Array::empty_array(), | 1803                                                        Array::empty_array(), | 
| 1802                                                        Array::empty_array())); | 1804                                                        Array::empty_array())); | 
| 1803     result.PrintJSON(js, true); | 1805     result.PrintJSON(js, true); | 
| 1804     return true; | 1806     return true; | 
| 1805   } | 1807   } | 
| 1806   if ((obj.IsInstance() || obj.IsNull()) && | 1808   if ((obj.IsInstance() || obj.IsNull()) && | 
| 1807       !ContainsNonInstance(obj)) { | 1809       !ContainsNonInstance(obj)) { | 
| 1808     // We don't use Instance::Cast here because it doesn't allow null. | 1810     // We don't use Instance::Cast here because it doesn't allow null. | 
| 1809     Instance& instance = Instance::Handle(isolate); | 1811     Instance& instance = Instance::Handle(isolate->current_zone()); | 
| 1810     instance ^= obj.raw(); | 1812     instance ^= obj.raw(); | 
| 1811     const Object& result = | 1813     const Object& result = | 
| 1812         Object::Handle(instance.Evaluate(expr_str, | 1814         Object::Handle(instance.Evaluate(expr_str, | 
| 1813                                          Array::empty_array(), | 1815                                          Array::empty_array(), | 
| 1814                                          Array::empty_array())); | 1816                                          Array::empty_array())); | 
| 1815     result.PrintJSON(js, true); | 1817     result.PrintJSON(js, true); | 
| 1816     return true; | 1818     return true; | 
| 1817   } | 1819   } | 
| 1818   js->PrintError(kInvalidParams, | 1820   js->PrintError(kInvalidParams, | 
| 1819                  "%s: invalid 'targetId' parameter: " | 1821                  "%s: invalid 'targetId' parameter: " | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
| 1834 static bool EvaluateInFrame(Isolate* isolate, JSONStream* js) { | 1836 static bool EvaluateInFrame(Isolate* isolate, JSONStream* js) { | 
| 1835   DebuggerStackTrace* stack = isolate->debugger()->StackTrace(); | 1837   DebuggerStackTrace* stack = isolate->debugger()->StackTrace(); | 
| 1836   intptr_t framePos = UIntParameter::Parse(js->LookupParam("frameIndex")); | 1838   intptr_t framePos = UIntParameter::Parse(js->LookupParam("frameIndex")); | 
| 1837   if (framePos > stack->Length()) { | 1839   if (framePos > stack->Length()) { | 
| 1838     PrintInvalidParamError(js, "frameIndex"); | 1840     PrintInvalidParamError(js, "frameIndex"); | 
| 1839     return true; | 1841     return true; | 
| 1840   } | 1842   } | 
| 1841   ActivationFrame* frame = stack->FrameAt(framePos); | 1843   ActivationFrame* frame = stack->FrameAt(framePos); | 
| 1842 | 1844 | 
| 1843   const char* expr = js->LookupParam("expression"); | 1845   const char* expr = js->LookupParam("expression"); | 
| 1844   const String& expr_str = String::Handle(isolate, String::New(expr)); | 1846   const String& expr_str = String::Handle(isolate->current_zone(), | 
|  | 1847       String::New(expr)); | 
| 1845 | 1848 | 
| 1846   const Object& result = Object::Handle(frame->Evaluate(expr_str)); | 1849   const Object& result = Object::Handle(frame->Evaluate(expr_str)); | 
| 1847   result.PrintJSON(js, true); | 1850   result.PrintJSON(js, true); | 
| 1848   return true; | 1851   return true; | 
| 1849 } | 1852 } | 
| 1850 | 1853 | 
| 1851 | 1854 | 
| 1852 class GetInstancesVisitor : public ObjectGraph::Visitor { | 1855 class GetInstancesVisitor : public ObjectGraph::Visitor { | 
| 1853  public: | 1856  public: | 
| 1854   GetInstancesVisitor(const Class& cls, const Array& storage) | 1857   GetInstancesVisitor(const Class& cls, const Array& storage) | 
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1988                                const Class& cls, | 1991                                const Class& cls, | 
| 1989                                const Function& func) const { | 1992                                const Function& func) const { | 
| 1990     return func.raw() == func_.raw(); | 1993     return func.raw() == func_.raw(); | 
| 1991   } | 1994   } | 
| 1992  private: | 1995  private: | 
| 1993   const Function& func_; | 1996   const Function& func_; | 
| 1994 }; | 1997 }; | 
| 1995 | 1998 | 
| 1996 | 1999 | 
| 1997 static bool GetHitsOrSites(Isolate* isolate, JSONStream* js, bool as_sites) { | 2000 static bool GetHitsOrSites(Isolate* isolate, JSONStream* js, bool as_sites) { | 
|  | 2001   Thread* thread = Thread::Current(); | 
| 1998   if (!js->HasParam("targetId")) { | 2002   if (!js->HasParam("targetId")) { | 
| 1999     CodeCoverage::PrintJSON(isolate, js, NULL, as_sites); | 2003     CodeCoverage::PrintJSON(thread, js, NULL, as_sites); | 
| 2000     return true; | 2004     return true; | 
| 2001   } | 2005   } | 
| 2002   const char* target_id = js->LookupParam("targetId"); | 2006   const char* target_id = js->LookupParam("targetId"); | 
| 2003   Object& obj = Object::Handle(LookupHeapObject(isolate, target_id, NULL)); | 2007   Object& obj = Object::Handle(LookupHeapObject(isolate, target_id, NULL)); | 
| 2004   if (obj.raw() == Object::sentinel().raw()) { | 2008   if (obj.raw() == Object::sentinel().raw()) { | 
| 2005     PrintInvalidParamError(js, "targetId"); | 2009     PrintInvalidParamError(js, "targetId"); | 
| 2006     return true; | 2010     return true; | 
| 2007   } | 2011   } | 
| 2008   if (obj.IsScript()) { | 2012   if (obj.IsScript()) { | 
| 2009     ScriptCoverageFilter sf(Script::Cast(obj)); | 2013     ScriptCoverageFilter sf(Script::Cast(obj)); | 
| 2010     CodeCoverage::PrintJSON(isolate, js, &sf, as_sites); | 2014     CodeCoverage::PrintJSON(thread, js, &sf, as_sites); | 
| 2011     return true; | 2015     return true; | 
| 2012   } | 2016   } | 
| 2013   if (obj.IsLibrary()) { | 2017   if (obj.IsLibrary()) { | 
| 2014     LibraryCoverageFilter lf(Library::Cast(obj)); | 2018     LibraryCoverageFilter lf(Library::Cast(obj)); | 
| 2015     CodeCoverage::PrintJSON(isolate, js, &lf, as_sites); | 2019     CodeCoverage::PrintJSON(thread, js, &lf, as_sites); | 
| 2016     return true; | 2020     return true; | 
| 2017   } | 2021   } | 
| 2018   if (obj.IsClass()) { | 2022   if (obj.IsClass()) { | 
| 2019     ClassCoverageFilter cf(Class::Cast(obj)); | 2023     ClassCoverageFilter cf(Class::Cast(obj)); | 
| 2020     CodeCoverage::PrintJSON(isolate, js, &cf, as_sites); | 2024     CodeCoverage::PrintJSON(thread, js, &cf, as_sites); | 
| 2021     return true; | 2025     return true; | 
| 2022   } | 2026   } | 
| 2023   if (obj.IsFunction()) { | 2027   if (obj.IsFunction()) { | 
| 2024     FunctionCoverageFilter ff(Function::Cast(obj)); | 2028     FunctionCoverageFilter ff(Function::Cast(obj)); | 
| 2025     CodeCoverage::PrintJSON(isolate, js, &ff, as_sites); | 2029     CodeCoverage::PrintJSON(thread, js, &ff, as_sites); | 
| 2026     return true; | 2030     return true; | 
| 2027   } | 2031   } | 
| 2028   js->PrintError(kInvalidParams, | 2032   js->PrintError(kInvalidParams, | 
| 2029                  "%s: invalid 'targetId' parameter: " | 2033                  "%s: invalid 'targetId' parameter: " | 
| 2030                  "id '%s' does not correspond to a " | 2034                  "id '%s' does not correspond to a " | 
| 2031                  "script, library, class, or function", | 2035                  "script, library, class, or function", | 
| 2032                  js->method(), target_id); | 2036                  js->method(), target_id); | 
| 2033   return true; | 2037   return true; | 
| 2034 } | 2038 } | 
| 2035 | 2039 | 
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2204     PrintInvalidParamError(js, "breakpointId"); | 2208     PrintInvalidParamError(js, "breakpointId"); | 
| 2205     return true; | 2209     return true; | 
| 2206   } | 2210   } | 
| 2207   isolate->debugger()->RemoveBreakpoint(bpt->id()); | 2211   isolate->debugger()->RemoveBreakpoint(bpt->id()); | 
| 2208   PrintSuccess(js); | 2212   PrintSuccess(js); | 
| 2209   return true; | 2213   return true; | 
| 2210 } | 2214 } | 
| 2211 | 2215 | 
| 2212 | 2216 | 
| 2213 static RawClass* GetMetricsClass(Isolate* isolate) { | 2217 static RawClass* GetMetricsClass(Isolate* isolate) { | 
|  | 2218   Zone* zone = isolate->current_zone(); | 
| 2214   const Library& prof_lib = | 2219   const Library& prof_lib = | 
| 2215       Library::Handle(isolate, Library::DeveloperLibrary()); | 2220       Library::Handle(zone, Library::DeveloperLibrary()); | 
| 2216   ASSERT(!prof_lib.IsNull()); | 2221   ASSERT(!prof_lib.IsNull()); | 
| 2217   const String& metrics_cls_name = | 2222   const String& metrics_cls_name = | 
| 2218       String::Handle(isolate, String::New("Metrics")); | 2223       String::Handle(zone, String::New("Metrics")); | 
| 2219   ASSERT(!metrics_cls_name.IsNull()); | 2224   ASSERT(!metrics_cls_name.IsNull()); | 
| 2220   const Class& metrics_cls = | 2225   const Class& metrics_cls = | 
| 2221       Class::Handle(isolate, prof_lib.LookupClass(metrics_cls_name)); | 2226       Class::Handle(zone, prof_lib.LookupClass(metrics_cls_name)); | 
| 2222   ASSERT(!metrics_cls.IsNull()); | 2227   ASSERT(!metrics_cls.IsNull()); | 
| 2223   return metrics_cls.raw(); | 2228   return metrics_cls.raw(); | 
| 2224 } | 2229 } | 
| 2225 | 2230 | 
| 2226 | 2231 | 
| 2227 | 2232 | 
| 2228 static bool HandleNativeMetricsList(Isolate* isolate, JSONStream* js) { | 2233 static bool HandleNativeMetricsList(Isolate* isolate, JSONStream* js) { | 
| 2229   JSONObject obj(js); | 2234   JSONObject obj(js); | 
| 2230   obj.AddProperty("type", "MetricList"); | 2235   obj.AddProperty("type", "MetricList"); | 
| 2231   { | 2236   { | 
| (...skipping 20 matching lines...) Expand all  Loading... | 
| 2252       return true; | 2257       return true; | 
| 2253     } | 2258     } | 
| 2254     current = current->next(); | 2259     current = current->next(); | 
| 2255   } | 2260   } | 
| 2256   PrintInvalidParamError(js, "metricId"); | 2261   PrintInvalidParamError(js, "metricId"); | 
| 2257   return true; | 2262   return true; | 
| 2258 } | 2263 } | 
| 2259 | 2264 | 
| 2260 | 2265 | 
| 2261 static bool HandleDartMetricsList(Isolate* isolate, JSONStream* js) { | 2266 static bool HandleDartMetricsList(Isolate* isolate, JSONStream* js) { | 
| 2262   const Class& metrics_cls = Class::Handle(isolate, GetMetricsClass(isolate)); | 2267   Zone* zone = isolate->current_zone(); | 
|  | 2268   const Class& metrics_cls = Class::Handle(zone, GetMetricsClass(isolate)); | 
| 2263   const String& print_metrics_name = | 2269   const String& print_metrics_name = | 
| 2264       String::Handle(String::New("_printMetrics")); | 2270       String::Handle(String::New("_printMetrics")); | 
| 2265   ASSERT(!print_metrics_name.IsNull()); | 2271   ASSERT(!print_metrics_name.IsNull()); | 
| 2266   const Function& print_metrics = Function::Handle( | 2272   const Function& print_metrics = Function::Handle( | 
| 2267       isolate, | 2273       zone, | 
| 2268       metrics_cls.LookupStaticFunctionAllowPrivate(print_metrics_name)); | 2274       metrics_cls.LookupStaticFunctionAllowPrivate(print_metrics_name)); | 
| 2269   ASSERT(!print_metrics.IsNull()); | 2275   ASSERT(!print_metrics.IsNull()); | 
| 2270   const Array& args = Object::empty_array(); | 2276   const Array& args = Object::empty_array(); | 
| 2271   const Object& result = | 2277   const Object& result = | 
| 2272       Object::Handle(isolate, DartEntry::InvokeFunction(print_metrics, args)); | 2278       Object::Handle(zone, DartEntry::InvokeFunction(print_metrics, args)); | 
| 2273   ASSERT(!result.IsNull()); | 2279   ASSERT(!result.IsNull()); | 
| 2274   ASSERT(result.IsString()); | 2280   ASSERT(result.IsString()); | 
| 2275   TextBuffer* buffer = js->buffer(); | 2281   TextBuffer* buffer = js->buffer(); | 
| 2276   buffer->AddString(String::Cast(result).ToCString()); | 2282   buffer->AddString(String::Cast(result).ToCString()); | 
| 2277   return true; | 2283   return true; | 
| 2278 } | 2284 } | 
| 2279 | 2285 | 
| 2280 | 2286 | 
| 2281 static bool HandleDartMetric(Isolate* isolate, JSONStream* js, const char* id) { | 2287 static bool HandleDartMetric(Isolate* isolate, JSONStream* js, const char* id) { | 
| 2282   const Class& metrics_cls = Class::Handle(isolate, GetMetricsClass(isolate)); | 2288   Zone* zone = isolate->current_zone(); | 
|  | 2289   const Class& metrics_cls = Class::Handle(zone, GetMetricsClass(isolate)); | 
| 2283   const String& print_metric_name = | 2290   const String& print_metric_name = | 
| 2284       String::Handle(String::New("_printMetric")); | 2291       String::Handle(String::New("_printMetric")); | 
| 2285   ASSERT(!print_metric_name.IsNull()); | 2292   ASSERT(!print_metric_name.IsNull()); | 
| 2286   const Function& print_metric = Function::Handle( | 2293   const Function& print_metric = Function::Handle( | 
| 2287       isolate, | 2294       zone, | 
| 2288       metrics_cls.LookupStaticFunctionAllowPrivate(print_metric_name)); | 2295       metrics_cls.LookupStaticFunctionAllowPrivate(print_metric_name)); | 
| 2289   ASSERT(!print_metric.IsNull()); | 2296   ASSERT(!print_metric.IsNull()); | 
| 2290   const String& arg0 = String::Handle(String::New(id)); | 2297   const String& arg0 = String::Handle(String::New(id)); | 
| 2291   ASSERT(!arg0.IsNull()); | 2298   ASSERT(!arg0.IsNull()); | 
| 2292   const Array& args = Array::Handle(Array::New(1)); | 2299   const Array& args = Array::Handle(Array::New(1)); | 
| 2293   ASSERT(!args.IsNull()); | 2300   ASSERT(!args.IsNull()); | 
| 2294   args.SetAt(0, arg0); | 2301   args.SetAt(0, arg0); | 
| 2295   const Object& result = | 2302   const Object& result = | 
| 2296       Object::Handle(isolate, DartEntry::InvokeFunction(print_metric, args)); | 2303       Object::Handle(zone, DartEntry::InvokeFunction(print_metric, args)); | 
| 2297   if (!result.IsNull()) { | 2304   if (!result.IsNull()) { | 
| 2298     ASSERT(result.IsString()); | 2305     ASSERT(result.IsString()); | 
| 2299     TextBuffer* buffer = js->buffer(); | 2306     TextBuffer* buffer = js->buffer(); | 
| 2300     buffer->AddString(String::Cast(result).ToCString()); | 2307     buffer->AddString(String::Cast(result).ToCString()); | 
| 2301     return true; | 2308     return true; | 
| 2302   } | 2309   } | 
| 2303   PrintInvalidParamError(js, "metricId"); | 2310   PrintInvalidParamError(js, "metricId"); | 
| 2304   return true; | 2311   return true; | 
| 2305 } | 2312 } | 
| 2306 | 2313 | 
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2740 }; | 2747 }; | 
| 2741 | 2748 | 
| 2742 | 2749 | 
| 2743 static const MethodParameter* get_object_by_address_params[] = { | 2750 static const MethodParameter* get_object_by_address_params[] = { | 
| 2744   ISOLATE_PARAMETER, | 2751   ISOLATE_PARAMETER, | 
| 2745   NULL, | 2752   NULL, | 
| 2746 }; | 2753 }; | 
| 2747 | 2754 | 
| 2748 | 2755 | 
| 2749 static RawObject* GetObjectHelper(Isolate* isolate, uword addr) { | 2756 static RawObject* GetObjectHelper(Isolate* isolate, uword addr) { | 
| 2750   Object& object = Object::Handle(isolate); | 2757   Object& object = Object::Handle(isolate->current_zone()); | 
| 2751 | 2758 | 
| 2752   { | 2759   { | 
| 2753     NoSafepointScope no_safepoint; | 2760     NoSafepointScope no_safepoint; | 
| 2754     ContainsAddressVisitor visitor(isolate, addr); | 2761     ContainsAddressVisitor visitor(isolate, addr); | 
| 2755     object = isolate->heap()->FindObject(&visitor); | 2762     object = isolate->heap()->FindObject(&visitor); | 
| 2756   } | 2763   } | 
| 2757 | 2764 | 
| 2758   if (!object.IsNull()) { | 2765   if (!object.IsNull()) { | 
| 2759     return object.raw(); | 2766     return object.raw(); | 
| 2760   } | 2767   } | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
| 2776     return true; | 2783     return true; | 
| 2777   } | 2784   } | 
| 2778 | 2785 | 
| 2779   // Handle heap objects. | 2786   // Handle heap objects. | 
| 2780   uword addr = 0; | 2787   uword addr = 0; | 
| 2781   if (!GetUnsignedIntegerId(addr_str, &addr, 16)) { | 2788   if (!GetUnsignedIntegerId(addr_str, &addr, 16)) { | 
| 2782     PrintInvalidParamError(js, "address"); | 2789     PrintInvalidParamError(js, "address"); | 
| 2783     return true; | 2790     return true; | 
| 2784   } | 2791   } | 
| 2785   bool ref = js->HasParam("ref") && js->ParamIs("ref", "true"); | 2792   bool ref = js->HasParam("ref") && js->ParamIs("ref", "true"); | 
| 2786   const Object& obj = Object::Handle(isolate, GetObjectHelper(isolate, addr)); | 2793   const Object& obj = Object::Handle(isolate->current_zone(), | 
|  | 2794       GetObjectHelper(isolate, addr)); | 
| 2787   if (obj.IsNull()) { | 2795   if (obj.IsNull()) { | 
| 2788     PrintSentinel(js, kFreeSentinel); | 2796     PrintSentinel(js, kFreeSentinel); | 
| 2789   } else { | 2797   } else { | 
| 2790     obj.PrintJSON(js, ref); | 2798     obj.PrintJSON(js, ref); | 
| 2791   } | 2799   } | 
| 2792   return true; | 2800   return true; | 
| 2793 } | 2801 } | 
| 2794 | 2802 | 
| 2795 | 2803 | 
| 2796 static const MethodParameter* get_ports_params[] = { | 2804 static const MethodParameter* get_ports_params[] = { | 
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3288     ServiceMethodDescriptor& method = service_methods_[i]; | 3296     ServiceMethodDescriptor& method = service_methods_[i]; | 
| 3289     if (strcmp(method_name, method.name) == 0) { | 3297     if (strcmp(method_name, method.name) == 0) { | 
| 3290       return &method; | 3298       return &method; | 
| 3291     } | 3299     } | 
| 3292   } | 3300   } | 
| 3293   return NULL; | 3301   return NULL; | 
| 3294 } | 3302 } | 
| 3295 | 3303 | 
| 3296 | 3304 | 
| 3297 }  // namespace dart | 3305 }  // namespace dart | 
| OLD | NEW | 
|---|