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

Unified Diff: runtime/bin/main.cc

Issue 584023004: Service isolate rework (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: runtime/bin/main.cc
diff --git a/runtime/bin/main.cc b/runtime/bin/main.cc
index b96d513fe01dfeae2cd3c684100e46842438f248..4162413a244bcc4362600f4c3bffacc4b4f8db5f 100644
--- a/runtime/bin/main.cc
+++ b/runtime/bin/main.cc
@@ -586,7 +586,12 @@ static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri,
// closures and setting up 'package root' for URI resolution.
result = DartUtils::PrepareForScriptLoading(package_root, builtin_lib);
CHECK_RESULT(result);
-
+ if (strcmp(script_uri, "vm-service") == 0) {
+ VmService::SetupIsolate(vm_service_server_ip, vm_service_server_port);
+ Dart_ExitScope();
+ Dart_ExitIsolate();
+ return isolate;
+ }
IsolateData* isolate_data = reinterpret_cast<IsolateData*>(data);
ASSERT(isolate_data != NULL);
ASSERT(isolate_data->script_url != NULL);
@@ -654,50 +659,6 @@ static Dart_Isolate CreateIsolateAndSetup(const char* script_uri,
}
-#define CHECK_RESULT(result) \
- if (Dart_IsError(result)) { \
- *error = strdup(Dart_GetError(result)); \
- Dart_ExitScope(); \
- Dart_ShutdownIsolate(); \
- return NULL; \
- } \
-
-static Dart_Isolate CreateServiceIsolate(void* data, char** error) {
- const char* script_uri = DartUtils::kVMServiceLibURL;
- IsolateData* isolate_data = new IsolateData(script_uri);
- Dart_Isolate isolate =
- Dart_CreateIsolate(script_uri, "main", snapshot_buffer, isolate_data,
- error);
- if (isolate == NULL) {
- return NULL;
- }
- Dart_EnterScope();
- if (snapshot_buffer != NULL) {
- // Setup the native resolver as the snapshot does not carry it.
- Builtin::SetNativeResolver(Builtin::kBuiltinLibrary);
- Builtin::SetNativeResolver(Builtin::kIOLibrary);
- }
- // Set up the library tag handler for this isolate.
- Dart_Handle result = Dart_SetLibraryTagHandler(DartUtils::LibraryTagHandler);
- CHECK_RESULT(result);
- result = Dart_SetEnvironmentCallback(EnvironmentCallback);
- CHECK_RESULT(result);
- // Prepare builtin and its dependent libraries for use to resolve URIs.
- Dart_Handle builtin_lib =
- Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary);
- CHECK_RESULT(builtin_lib);
- // Prepare for script loading by setting up the 'print' and 'timer'
- // closures and setting up 'package root' for URI resolution.
- result = DartUtils::PrepareForScriptLoading(package_root, builtin_lib);
- CHECK_RESULT(result);
-
- Dart_ExitScope();
- Dart_ExitIsolate();
- return isolate;
-}
-
-#undef CHECK_RESULT
-
static void PrintVersion() {
Log::PrintErr("Dart VM version: %s\n", Dart_VersionString());
}
@@ -978,21 +939,22 @@ void main(int argc, char** argv) {
Dart_SetVMFlags(vm_options.count(), vm_options.arguments());
+ // Start event handler.
+ EventHandler::Start();
+
// Initialize the Dart VM.
if (!Dart_Initialize(CreateIsolateAndSetup, NULL, NULL, ShutdownIsolate,
DartUtils::OpenFile,
DartUtils::ReadFile,
DartUtils::WriteFile,
DartUtils::CloseFile,
- DartUtils::EntropySource,
- CreateServiceIsolate)) {
+ DartUtils::EntropySource)) {
fprintf(stderr, "%s", "VM initialization failed\n");
fflush(stderr);
exit(kErrorExitCode);
}
- // Start event handler.
- EventHandler::Start();
+
// Start the debugger wire protocol handler if necessary.
if (start_debugger) {
@@ -1004,21 +966,9 @@ void main(int argc, char** argv) {
}
}
- ASSERT(Dart_CurrentIsolate() == NULL);
- // Start the VM service isolate, if necessary.
- if (start_vm_service) {
- if (!start_debugger) {
- DebuggerConnectionHandler::InitForVmService();
- }
- bool r = VmService::Start(vm_service_server_ip, vm_service_server_port);
- if (!r) {
- Log::PrintErr("Could not start VM Service isolate %s\n",
- VmService::GetErrorMessage());
- }
- Dart_RegisterIsolateServiceRequestCallback(
+ DebuggerConnectionHandler::InitForVmService();
+ Dart_RegisterIsolateServiceRequestCallback(
"io", &ServiceRequestHandler, NULL);
- }
- ASSERT(Dart_CurrentIsolate() == NULL);
// Call CreateIsolateAndSetup which creates an isolate and loads up
// the specified application script.

Powered by Google App Engine
This is Rietveld 408576698