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

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

Issue 120723003: Refactors CPU feature detection. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
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 8
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/coverage.h" 10 #include "vm/coverage.h"
(...skipping 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 PrintError(js, "Command too long"); 1050 PrintError(js, "Command too long");
1051 return true; 1051 return true;
1052 } 1052 }
1053 } else { 1053 } else {
1054 PrintError(js, "Unrecognized subcommand '%s'", js->GetArgument(1)); 1054 PrintError(js, "Unrecognized subcommand '%s'", js->GetArgument(1));
1055 return true; 1055 return true;
1056 } 1056 }
1057 } 1057 }
1058 1058
1059 1059
1060 static bool HandleCpu(Isolate* isolate, JSONStream* js) {
1061 JSONObject jsobj(js);
1062 jsobj.AddProperty("type", "CPU");
1063 jsobj.AddProperty("targetCPU", CPU::Id());
1064 jsobj.AddProperty("hostCPU", HostCPUFeatures::hardware());
1065 return true;
1066 }
1067
1068
1060 static bool HandleCode(Isolate* isolate, JSONStream* js) { 1069 static bool HandleCode(Isolate* isolate, JSONStream* js) {
1061 REQUIRE_COLLECTION_ID("code"); 1070 REQUIRE_COLLECTION_ID("code");
1062 uintptr_t pc; 1071 uintptr_t pc;
1063 if (!GetUnsignedIntegerId(js->GetArgument(1), &pc, 16)) { 1072 if (!GetUnsignedIntegerId(js->GetArgument(1), &pc, 16)) {
1064 PrintError(js, "Must specify code address: code/c0deadd0."); 1073 PrintError(js, "Must specify code address: code/c0deadd0.");
1065 return true; 1074 return true;
1066 } 1075 }
1067 Code& code = Code::Handle(Code::LookupCode(pc)); 1076 Code& code = Code::Handle(Code::LookupCode(pc));
1068 if (code.IsNull()) { 1077 if (code.IsNull()) {
1069 PrintError(js, "Could not find code at %" Px "", pc); 1078 PrintError(js, "Could not find code at %" Px "", pc);
(...skipping 21 matching lines...) Expand all
1091 } 1100 }
1092 1101
1093 1102
1094 static IsolateMessageHandlerEntry isolate_handlers[] = { 1103 static IsolateMessageHandlerEntry isolate_handlers[] = {
1095 { "_echo", HandleIsolateEcho }, 1104 { "_echo", HandleIsolateEcho },
1096 { "", HandleIsolate }, 1105 { "", HandleIsolate },
1097 { "allocationprofile", HandleAllocationProfile }, 1106 { "allocationprofile", HandleAllocationProfile },
1098 { "classes", HandleClasses }, 1107 { "classes", HandleClasses },
1099 { "code", HandleCode }, 1108 { "code", HandleCode },
1100 { "coverage", HandleCoverage }, 1109 { "coverage", HandleCoverage },
1110 { "cpu", HandleCpu },
1101 { "debug", HandleDebug }, 1111 { "debug", HandleDebug },
1102 { "libraries", HandleLibraries }, 1112 { "libraries", HandleLibraries },
1103 { "objecthistogram", HandleObjectHistogram}, 1113 { "objecthistogram", HandleObjectHistogram},
1104 { "objects", HandleObjects }, 1114 { "objects", HandleObjects },
1105 { "profile", HandleProfile }, 1115 { "profile", HandleProfile },
1106 { "scripts", HandleScripts }, 1116 { "scripts", HandleScripts },
1107 { "stacktrace", HandleStackTrace }, 1117 { "stacktrace", HandleStackTrace },
1108 }; 1118 };
1109 1119
1110 1120
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 for (intptr_t i = 0; i < num_message_handlers; i++) { 1213 for (intptr_t i = 0; i < num_message_handlers; i++) {
1204 const RootMessageHandlerEntry& entry = root_handlers[i]; 1214 const RootMessageHandlerEntry& entry = root_handlers[i];
1205 if (!strcmp(command, entry.command)) { 1215 if (!strcmp(command, entry.command)) {
1206 return entry.handler; 1216 return entry.handler;
1207 } 1217 }
1208 } 1218 }
1209 return NULL; 1219 return NULL;
1210 } 1220 }
1211 1221
1212 } // namespace dart 1222 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698