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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 187 const String& script_url, | 187 const String& script_url, |
| 188 const Class& cls, | 188 const Class& cls, |
| 189 const Function& func) const { | 189 const Function& func) const { |
| 190 return cls.raw() == cls_.raw(); | 190 return cls.raw() == cls_.raw(); |
| 191 } | 191 } |
| 192 private: | 192 private: |
| 193 const Class& cls_; | 193 const Class& cls_; |
| 194 }; | 194 }; |
| 195 | 195 |
| 196 | 196 |
| 197 class FunctionCoverageFilter : public CoverageFilter { | |
| 198 public: | |
| 199 explicit FunctionCoverageFilter(const Function& func) : func_(func) {} | |
| 200 bool ShouldOutputCoverageFor(const Library& lib, | |
| 201 const String& script_url, | |
| 202 const Class& cls, | |
| 203 const Function& func) const { | |
| 204 return func.raw() == func_.raw(); | |
| 205 } | |
| 206 private: | |
| 207 const Function& func_; | |
| 208 }; | |
| 209 | |
| 210 | |
| 197 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) { | 211 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) { |
| 198 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); | 212 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); |
| 199 return reinterpret_cast<uint8_t*>(new_ptr); | 213 return reinterpret_cast<uint8_t*>(new_ptr); |
| 200 } | 214 } |
| 201 | 215 |
| 202 | 216 |
| 203 static void SendIsolateServiceMessage(Dart_NativeArguments args) { | 217 static void SendIsolateServiceMessage(Dart_NativeArguments args) { |
| 204 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); | 218 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); |
| 205 Isolate* isolate = arguments->isolate(); | 219 Isolate* isolate = arguments->isolate(); |
| 206 StackZone zone(isolate); | 220 StackZone zone(isolate); |
| (...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1104 func ^= cls.InvocationDispatcherFunctionFromIndex(id); | 1118 func ^= cls.InvocationDispatcherFunctionFromIndex(id); |
| 1105 if (func.IsNull()) { | 1119 if (func.IsNull()) { |
| 1106 PrintError(js, "Dispatcher %" Pd " not found", id); | 1120 PrintError(js, "Dispatcher %" Pd " not found", id); |
| 1107 return true; | 1121 return true; |
| 1108 } | 1122 } |
| 1109 func.PrintJSON(js, false); | 1123 func.PrintJSON(js, false); |
| 1110 return true; | 1124 return true; |
| 1111 } | 1125 } |
| 1112 | 1126 |
| 1113 | 1127 |
| 1128 static bool HandleClassesFunctionsCoverage( | |
| 1129 Isolate* isolate, const Function& func, JSONStream* js) { | |
| 1130 FunctionCoverageFilter filter(func); | |
| 1131 CodeCoverage::PrintJSON(isolate, js, &filter); | |
| 1132 return true; | |
| 1133 } | |
| 1134 | |
| 1135 | |
| 1114 static bool HandleClassesFunctions(Isolate* isolate, const Class& cls, | 1136 static bool HandleClassesFunctions(Isolate* isolate, const Class& cls, |
| 1115 JSONStream* js) { | 1137 JSONStream* js) { |
| 1116 intptr_t id; | 1138 intptr_t id; |
| 1117 if (js->num_arguments() > 4) { | |
| 1118 PrintError(js, "Command too long"); | |
| 1119 return true; | |
| 1120 } | |
| 1121 if (!GetIntegerId(js->GetArgument(3), &id)) { | 1139 if (!GetIntegerId(js->GetArgument(3), &id)) { |
|
Cutch
2014/07/10 20:21:06
Please re-insert the check for num_arguments > 5.
Michael Lippautz (Google)
2014/07/11 16:26:53
Done.
| |
| 1122 PrintError(js, "Must specify collection object id: functions/id"); | 1140 PrintError(js, "Must specify collection object id: functions/id"); |
| 1123 return true; | 1141 return true; |
| 1124 } | 1142 } |
| 1125 Function& func = Function::Handle(); | 1143 Function& func = Function::Handle(); |
| 1126 func ^= cls.FunctionFromIndex(id); | 1144 func ^= cls.FunctionFromIndex(id); |
| 1127 if (func.IsNull()) { | 1145 if (func.IsNull()) { |
| 1128 PrintError(js, "Function %" Pd " not found", id); | 1146 PrintError(js, "Function %" Pd " not found", id); |
| 1129 return true; | 1147 return true; |
| 1130 } | 1148 } |
| 1131 func.PrintJSON(js, false); | 1149 if (js->num_arguments() == 4) { |
| 1150 func.PrintJSON(js, false); | |
| 1151 return true; | |
| 1152 } else { | |
| 1153 const char* subcollection = js->GetArgument(4); | |
| 1154 if (strcmp(subcollection, "coverage") == 0) { | |
| 1155 return HandleClassesFunctionsCoverage(isolate, func, js); | |
| 1156 } else { | |
| 1157 PrintError(js, "Invalid sub collection %s", subcollection); | |
| 1158 return true; | |
| 1159 } | |
| 1160 } | |
| 1161 UNREACHABLE(); | |
|
Cutch
2014/07/10 20:21:06
I don't like the way this reads. This code can't e
Michael Lippautz (Google)
2014/07/11 16:26:53
As discussed, ignored :)
| |
| 1132 return true; | 1162 return true; |
| 1133 } | 1163 } |
| 1134 | 1164 |
| 1135 | 1165 |
| 1136 static bool HandleClassesImplicitClosures(Isolate* isolate, const Class& cls, | 1166 static bool HandleClassesImplicitClosures(Isolate* isolate, const Class& cls, |
| 1137 JSONStream* js) { | 1167 JSONStream* js) { |
| 1138 intptr_t id; | 1168 intptr_t id; |
| 1139 if (js->num_arguments() > 4) { | 1169 if (js->num_arguments() > 4) { |
| 1140 PrintError(js, "Command too long"); | 1170 PrintError(js, "Command too long"); |
| 1141 return true; | 1171 return true; |
| (...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2347 while (current != NULL) { | 2377 while (current != NULL) { |
| 2348 if (strcmp(name, current->name()) == 0) { | 2378 if (strcmp(name, current->name()) == 0) { |
| 2349 return current; | 2379 return current; |
| 2350 } | 2380 } |
| 2351 current = current->next(); | 2381 current = current->next(); |
| 2352 } | 2382 } |
| 2353 return NULL; | 2383 return NULL; |
| 2354 } | 2384 } |
| 2355 | 2385 |
| 2356 } // namespace dart | 2386 } // namespace dart |
| OLD | NEW |