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

Unified Diff: lib/isolate.cc

Issue 8673002: - Refactor the isolate callback mechanism to also include creation of the (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: '' Created 9 years, 1 month 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
« no previous file with comments | « include/dart_api.h ('k') | vm/bootstrap.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/isolate.cc
===================================================================
--- lib/isolate.cc (revision 1955)
+++ lib/isolate.cc (working copy)
@@ -261,21 +261,17 @@
ASSERT(!library.IsNull());
const char* library_url = String::Handle(library.url()).ToCString();
intptr_t port_id = 0;
- const char* error_msg = NULL;
LongJump jump;
bool init_successful = true;
-
- Isolate* spawned_isolate = Dart::CreateIsolate();
- if (spawned_isolate != NULL) {
- // First initialize the spawned isolate.
- LongJump* base = spawned_isolate->long_jump_base();
- spawned_isolate->set_long_jump_base(&jump);
- if (setjmp(*jump.Set()) == 0) {
- Dart::InitializeIsolate(NULL, preserved_isolate->init_callback_data());
- } else {
- init_successful = false;
- }
- spawned_isolate->set_long_jump_base(base);
+ Isolate* spawned_isolate = NULL;
+ void* callback_data = preserved_isolate->init_callback_data();
+ char* error = NULL;
+ Dart_IsolateCreateCallback callback = Isolate::CreateCallback();
+ if (callback == NULL) {
+ error = strdup("Null callback specified for isolate creation\n");
+ } else if (callback(callback_data, &error)) {
+ spawned_isolate = Isolate::Current();
+ ASSERT(spawned_isolate != NULL);
// Check arguments to see if the specified library and classes are
// loaded, this check will throw an exception if they are not loaded.
if (init_successful && CheckArguments(library_url, class_name)) {
@@ -295,29 +291,21 @@
{
Zone zone(spawned_isolate);
HandleScope scope(spawned_isolate);
- const String& error = String::Handle(
+ const String& errmsg = String::Handle(
spawned_isolate->object_store()->sticky_error());
- const char* temp_error_msg = error.ToCString();
- intptr_t err_len = strlen(temp_error_msg) + 1;
- Zone* preserved_zone = preserved_isolate->current_zone();
- error_msg = reinterpret_cast<char*>(preserved_zone->Allocate(err_len));
- OS::SNPrint(
- const_cast<char*>(error_msg), err_len, "%s", temp_error_msg);
+ error = strdup(errmsg.ToCString());
}
Dart::ShutdownIsolate();
spawned_isolate = NULL;
}
- } else {
- error_msg = "Creation of Isolate failed : ";
}
// Switch back to the original isolate and return.
Isolate::SetCurrent(preserved_isolate);
if (spawned_isolate == NULL) {
// Unable to spawn isolate correctly, throw exception.
- ASSERT(error_msg != NULL);
ThrowErrorException(Exceptions::kIllegalArgument,
- error_msg,
+ error,
library_url,
class_name);
}
« no previous file with comments | « include/dart_api.h ('k') | vm/bootstrap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698