Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Side by Side Diff: runtime/vm/service.cc

Issue 1414493003: Remove some Isolate::current_zone() calls, as it gets the zone from mutator thread not the current … (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: cleanup Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 return true; 1094 return true;
1095 } 1095 }
1096 } 1096 }
1097 return false; 1097 return false;
1098 } else { 1098 } else {
1099 return !(obj.IsInstance() || obj.IsNull()); 1099 return !(obj.IsInstance() || obj.IsNull());
1100 } 1100 }
1101 } 1101 }
1102 1102
1103 1103
1104 static RawObject* LookupObjectId(Isolate* isolate, 1104 static RawObject* LookupObjectId(Thread* thread,
1105 const char* arg, 1105 const char* arg,
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 = Integer::Handle(isolate->current_zone(), 1116 const Integer& obj = Integer::Handle(thread->zone(),
1117 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 = thread->isolate()->object_id_ring();
1128 ASSERT(ring != NULL); 1128 ASSERT(ring != NULL);
1129 intptr_t id = -1; 1129 intptr_t id = -1;
1130 if (!GetIntegerId(arg, &id)) { 1130 if (!GetIntegerId(arg, &id)) {
1131 *kind = ObjectIdRing::kInvalid; 1131 *kind = ObjectIdRing::kInvalid;
1132 return Object::null(); 1132 return Object::null();
1133 } 1133 }
1134 return ring->GetObjectForId(id, kind); 1134 return ring->GetObjectForId(id, kind);
1135 } 1135 }
1136 1136
1137 1137
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
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->current_zone(), 1241 String& id = String::Handle(String::New(encoded_id));
1242 String::New(encoded_id));
1243 id = String::DecodeIRI(id); 1242 id = String::DecodeIRI(id);
1244 if (id.IsNull()) { 1243 if (id.IsNull()) {
1245 return Object::sentinel().raw(); 1244 return Object::sentinel().raw();
1246 } 1245 }
1247 Function& func = Function::Handle(cls.LookupFunction(id)); 1246 Function& func = Function::Handle(cls.LookupFunction(id));
1248 if (func.IsNull()) { 1247 if (func.IsNull()) {
1249 return Object::sentinel().raw(); 1248 return Object::sentinel().raw();
1250 } 1249 }
1251 return func.raw(); 1250 return func.raw();
1252 1251
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
1392 MessageSnapshotReader reader(message->data(), 1391 MessageSnapshotReader reader(message->data(),
1393 message->len(), 1392 message->len(),
1394 Thread::Current()); 1393 Thread::Current());
1395 return reader.ReadObject(); 1394 return reader.ReadObject();
1396 } 1395 }
1397 1396
1398 1397
1399 static RawObject* LookupHeapObject(Isolate* isolate, 1398 static RawObject* LookupHeapObject(Isolate* isolate,
1400 const char* id_original, 1399 const char* id_original,
1401 ObjectIdRing::LookupResult* result) { 1400 ObjectIdRing::LookupResult* result) {
1402 char* id = Thread::Current()->zone()->MakeCopyOfString(id_original); 1401 Thread* thread = Thread::Current();
1402 char* id = thread->zone()->MakeCopyOfString(id_original);
1403 1403
1404 // Parse the id by splitting at each '/'. 1404 // Parse the id by splitting at each '/'.
1405 const int MAX_PARTS = 8; 1405 const int MAX_PARTS = 8;
1406 char* parts[MAX_PARTS]; 1406 char* parts[MAX_PARTS];
1407 int num_parts = 0; 1407 int num_parts = 0;
1408 int i = 0; 1408 int i = 0;
1409 int start_pos = 0; 1409 int start_pos = 0;
1410 while (id[i] != '\0') { 1410 while (id[i] != '\0') {
1411 if (id[i] == '/') { 1411 if (id[i] == '/') {
1412 id[i++] = '\0'; 1412 id[i++] = '\0';
1413 parts[num_parts++] = &id[start_pos]; 1413 parts[num_parts++] = &id[start_pos];
1414 if (num_parts == MAX_PARTS) { 1414 if (num_parts == MAX_PARTS) {
1415 break; 1415 break;
1416 } 1416 }
1417 start_pos = i; 1417 start_pos = i;
1418 } else { 1418 } else {
1419 i++; 1419 i++;
1420 } 1420 }
1421 } 1421 }
1422 if (num_parts < MAX_PARTS) { 1422 if (num_parts < MAX_PARTS) {
1423 parts[num_parts++] = &id[start_pos]; 1423 parts[num_parts++] = &id[start_pos];
1424 } 1424 }
1425 1425
1426 if (result != NULL) { 1426 if (result != NULL) {
1427 *result = ObjectIdRing::kValid; 1427 *result = ObjectIdRing::kValid;
1428 } 1428 }
1429 1429
1430 if (strcmp(parts[0], "objects") == 0) { 1430 if (strcmp(parts[0], "objects") == 0) {
1431 // Object ids look like "objects/1123" 1431 // Object ids look like "objects/1123"
1432 Object& obj = Object::Handle(isolate->current_zone()); 1432 Object& obj = Object::Handle(thread->zone());
1433 ObjectIdRing::LookupResult lookup_result; 1433 ObjectIdRing::LookupResult lookup_result;
1434 obj = LookupObjectId(isolate, parts[1], &lookup_result); 1434 obj = LookupObjectId(thread, parts[1], &lookup_result);
1435 if (lookup_result != ObjectIdRing::kValid) { 1435 if (lookup_result != ObjectIdRing::kValid) {
1436 if (result != NULL) { 1436 if (result != NULL) {
1437 *result = lookup_result; 1437 *result = lookup_result;
1438 } 1438 }
1439 return Object::sentinel().raw(); 1439 return Object::sentinel().raw();
1440 } 1440 }
1441 return obj.raw(); 1441 return obj.raw();
1442 1442
1443 } else if (strcmp(parts[0], "libraries") == 0) { 1443 } else if (strcmp(parts[0], "libraries") == 0) {
1444 return LookupHeapObjectLibraries(isolate, parts, num_parts); 1444 return LookupHeapObjectLibraries(isolate, parts, num_parts);
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
1772 const char* target_id = js->LookupParam("targetId"); 1772 const char* target_id = js->LookupParam("targetId");
1773 if (target_id == NULL) { 1773 if (target_id == NULL) {
1774 PrintMissingParamError(js, "targetId"); 1774 PrintMissingParamError(js, "targetId");
1775 return true; 1775 return true;
1776 } 1776 }
1777 const char* expr = js->LookupParam("expression"); 1777 const char* expr = js->LookupParam("expression");
1778 if (expr == NULL) { 1778 if (expr == NULL) {
1779 PrintMissingParamError(js, "expression"); 1779 PrintMissingParamError(js, "expression");
1780 return true; 1780 return true;
1781 } 1781 }
1782 const String& expr_str = 1782 const String& expr_str = String::Handle(String::New(expr));
1783 String::Handle(isolate->current_zone(), String::New(expr));
1784 ObjectIdRing::LookupResult lookup_result; 1783 ObjectIdRing::LookupResult lookup_result;
1785 Object& obj = Object::Handle(LookupHeapObject(isolate, target_id, 1784 Object& obj = Object::Handle(LookupHeapObject(isolate, target_id,
1786 &lookup_result)); 1785 &lookup_result));
1787 if (obj.raw() == Object::sentinel().raw()) { 1786 if (obj.raw() == Object::sentinel().raw()) {
1788 if (lookup_result == ObjectIdRing::kCollected) { 1787 if (lookup_result == ObjectIdRing::kCollected) {
1789 PrintSentinel(js, kCollectedSentinel); 1788 PrintSentinel(js, kCollectedSentinel);
1790 } else if (lookup_result == ObjectIdRing::kExpired) { 1789 } else if (lookup_result == ObjectIdRing::kExpired) {
1791 PrintSentinel(js, kExpiredSentinel); 1790 PrintSentinel(js, kExpiredSentinel);
1792 } else { 1791 } else {
1793 PrintInvalidParamError(js, "targetId"); 1792 PrintInvalidParamError(js, "targetId");
(...skipping 12 matching lines...) Expand all
1806 const Class& cls = Class::Cast(obj); 1805 const Class& cls = Class::Cast(obj);
1807 const Object& result = Object::Handle(cls.Evaluate(expr_str, 1806 const Object& result = Object::Handle(cls.Evaluate(expr_str,
1808 Array::empty_array(), 1807 Array::empty_array(),
1809 Array::empty_array())); 1808 Array::empty_array()));
1810 result.PrintJSON(js, true); 1809 result.PrintJSON(js, true);
1811 return true; 1810 return true;
1812 } 1811 }
1813 if ((obj.IsInstance() || obj.IsNull()) && 1812 if ((obj.IsInstance() || obj.IsNull()) &&
1814 !ContainsNonInstance(obj)) { 1813 !ContainsNonInstance(obj)) {
1815 // We don't use Instance::Cast here because it doesn't allow null. 1814 // We don't use Instance::Cast here because it doesn't allow null.
1816 Instance& instance = Instance::Handle(isolate->current_zone()); 1815 Instance& instance = Instance::Handle();
1817 instance ^= obj.raw(); 1816 instance ^= obj.raw();
1818 const Object& result = 1817 const Object& result =
1819 Object::Handle(instance.Evaluate(expr_str, 1818 Object::Handle(instance.Evaluate(expr_str,
1820 Array::empty_array(), 1819 Array::empty_array(),
1821 Array::empty_array())); 1820 Array::empty_array()));
1822 result.PrintJSON(js, true); 1821 result.PrintJSON(js, true);
1823 return true; 1822 return true;
1824 } 1823 }
1825 js->PrintError(kInvalidParams, 1824 js->PrintError(kInvalidParams,
1826 "%s: invalid 'targetId' parameter: " 1825 "%s: invalid 'targetId' parameter: "
(...skipping 19 matching lines...) Expand all
1846 } 1845 }
1847 DebuggerStackTrace* stack = isolate->debugger()->StackTrace(); 1846 DebuggerStackTrace* stack = isolate->debugger()->StackTrace();
1848 intptr_t framePos = UIntParameter::Parse(js->LookupParam("frameIndex")); 1847 intptr_t framePos = UIntParameter::Parse(js->LookupParam("frameIndex"));
1849 if (framePos > stack->Length()) { 1848 if (framePos > stack->Length()) {
1850 PrintInvalidParamError(js, "frameIndex"); 1849 PrintInvalidParamError(js, "frameIndex");
1851 return true; 1850 return true;
1852 } 1851 }
1853 ActivationFrame* frame = stack->FrameAt(framePos); 1852 ActivationFrame* frame = stack->FrameAt(framePos);
1854 1853
1855 const char* expr = js->LookupParam("expression"); 1854 const char* expr = js->LookupParam("expression");
1856 const String& expr_str = String::Handle(isolate->current_zone(), 1855 const String& expr_str = String::Handle(String::New(expr));
1857 String::New(expr));
1858 1856
1859 const Object& result = Object::Handle(frame->Evaluate(expr_str)); 1857 const Object& result = Object::Handle(frame->Evaluate(expr_str));
1860 result.PrintJSON(js, true); 1858 result.PrintJSON(js, true);
1861 return true; 1859 return true;
1862 } 1860 }
1863 1861
1864 1862
1865 class GetInstancesVisitor : public ObjectGraph::Visitor { 1863 class GetInstancesVisitor : public ObjectGraph::Visitor {
1866 public: 1864 public:
1867 GetInstancesVisitor(const Class& cls, const Array& storage) 1865 GetInstancesVisitor(const Class& cls, const Array& storage)
(...skipping 1456 matching lines...) Expand 10 before | Expand all | Expand 10 after
3324 ServiceMethodDescriptor& method = service_methods_[i]; 3322 ServiceMethodDescriptor& method = service_methods_[i];
3325 if (strcmp(method_name, method.name) == 0) { 3323 if (strcmp(method_name, method.name) == 0) {
3326 return &method; 3324 return &method;
3327 } 3325 }
3328 } 3326 }
3329 return NULL; 3327 return NULL;
3330 } 3328 }
3331 3329
3332 3330
3333 } // namespace dart 3331 } // namespace dart
OLDNEW
« runtime/vm/object.cc ('K') | « runtime/vm/object.cc ('k') | runtime/vm/snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698