Index: runtime/bin/main.cc |
=================================================================== |
--- runtime/bin/main.cc (revision 20976) |
+++ runtime/bin/main.cc (working copy) |
@@ -422,19 +422,19 @@ |
*error = strdup(Dart_GetError(result)); \ |
Dart_ExitScope(); \ |
Dart_ShutdownIsolate(); \ |
- return false; \ |
+ return NULL; \ |
} \ |
// Returns true on success, false on failure. |
-static bool CreateIsolateAndSetupHelper(const char* script_uri, |
- const char* main, |
- void* data, |
- char** error) { |
+static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri, |
+ const char* main, |
+ void* data, |
+ char** error) { |
Dart_Isolate isolate = |
Dart_CreateIsolate(script_uri, main, snapshot_buffer, data, error); |
if (isolate == NULL) { |
- return false; |
+ return NULL; |
} |
Dart_EnterScope(); |
@@ -476,17 +476,28 @@ |
*error = strdup(errbuf); |
Dart_ExitScope(); |
Dart_ShutdownIsolate(); |
- return false; |
+ return NULL; |
} |
+ |
+ // Make the isolate runnable so that it is ready to handle messages. |
Dart_ExitScope(); |
+ Dart_ExitIsolate(); |
+ bool retval = Dart_IsolateMakeRunnable(isolate); |
+ if (!retval) { |
+ *error = strdup("Invalid isolate state - Unable to make it runnable"); |
+ Dart_EnterIsolate(isolate); |
+ Dart_ShutdownIsolate(); |
+ return NULL; |
+ } |
+ |
VmStats::AddIsolate(reinterpret_cast<IsolateData*>(data), isolate); |
- return true; |
+ return isolate; |
} |
-static bool CreateIsolateAndSetup(const char* script_uri, |
- const char* main, |
- void* data, char** error) { |
+static Dart_Isolate CreateIsolateAndSetup(const char* script_uri, |
+ const char* main, |
+ void* data, char** error) { |
return CreateIsolateAndSetupHelper(script_uri, |
main, |
new IsolateData(), |
@@ -734,10 +745,11 @@ |
// the specified application script. |
char* error = NULL; |
char* isolate_name = BuildIsolateName(script_name, "main"); |
- if (!CreateIsolateAndSetupHelper(script_name, |
- "main", |
- new IsolateData(), |
- &error)) { |
+ Dart_Isolate isolate = CreateIsolateAndSetupHelper(script_name, |
+ "main", |
+ new IsolateData(), |
+ &error); |
+ if (isolate == NULL) { |
Log::PrintErr("%s\n", error); |
free(error); |
delete [] isolate_name; |
@@ -745,7 +757,8 @@ |
} |
delete [] isolate_name; |
- Dart_Isolate isolate = Dart_CurrentIsolate(); |
+ Dart_EnterIsolate(isolate); |
+ ASSERT(isolate == Dart_CurrentIsolate()); |
ASSERT(isolate != NULL); |
Dart_Handle result; |