Index: runtime/lib/isolate.cc |
diff --git a/runtime/lib/isolate.cc b/runtime/lib/isolate.cc |
index affd85d1f278d282196e484747e54871f67e527d..dd93fbe588be9dfd29178e9d9cc9ca437284d538 100644 |
--- a/runtime/lib/isolate.cc |
+++ b/runtime/lib/isolate.cc |
@@ -158,7 +158,7 @@ class SpawnIsolateTask : public ThreadPool::Task { |
(callback)(state_->script_url(), |
state_->function_name(), |
state_->package_root(), |
- state_->package_map(), |
+ state_->package_config(), |
&api_flags, |
state_->init_data(), |
&error)); |
@@ -202,7 +202,17 @@ class SpawnIsolateTask : public ThreadPool::Task { |
}; |
-DEFINE_NATIVE_ENTRY(Isolate_spawnFunction, 7) { |
+static const char* String2UTF8(const String& str) { |
+ intptr_t len = Utf8::Length(str); |
+ char* result = new char[len + 1]; |
+ str.ToUTF8(reinterpret_cast<uint8_t*>(result), len); |
+ result[len] = 0; |
+ |
+ return result; |
+} |
+ |
+ |
+DEFINE_NATIVE_ENTRY(Isolate_spawnFunction, 9) { |
GET_NON_NULL_NATIVE_ARGUMENT(SendPort, port, arguments->NativeArgAt(0)); |
GET_NON_NULL_NATIVE_ARGUMENT(Instance, closure, arguments->NativeArgAt(1)); |
GET_NON_NULL_NATIVE_ARGUMENT(Instance, message, arguments->NativeArgAt(2)); |
@@ -210,6 +220,8 @@ DEFINE_NATIVE_ENTRY(Isolate_spawnFunction, 7) { |
GET_NATIVE_ARGUMENT(Bool, fatalErrors, arguments->NativeArgAt(4)); |
GET_NATIVE_ARGUMENT(SendPort, onExit, arguments->NativeArgAt(5)); |
GET_NATIVE_ARGUMENT(SendPort, onError, arguments->NativeArgAt(6)); |
+ GET_NATIVE_ARGUMENT(String, packageRoot, arguments->NativeArgAt(7)); |
+ GET_NATIVE_ARGUMENT(String, packageConfig, arguments->NativeArgAt(8)); |
if (closure.IsClosure()) { |
Function& func = Function::Handle(); |
@@ -223,6 +235,16 @@ DEFINE_NATIVE_ENTRY(Isolate_spawnFunction, 7) { |
// Get the parent function so that we get the right function name. |
func = func.parent_function(); |
+ // Get the script URI so that we know what script to load. |
+ const Library& root_lib = Library::Handle(zone, |
+ isolate->object_store()->root_library()); |
+ const String& script_uri = String::Handle(zone, root_lib.url()); |
+ |
+ const char* utf8_package_root = |
+ packageRoot.IsNull() ? NULL : String2UTF8(packageRoot); |
+ const char* utf8_package_config = |
+ packageConfig.IsNull() ? NULL : String2UTF8(packageConfig); |
+ |
bool fatal_errors = fatalErrors.IsNull() ? true : fatalErrors.value(); |
Dart_Port on_exit_port = onExit.IsNull() ? ILLEGAL_PORT : onExit.Id(); |
Dart_Port on_error_port = onError.IsNull() ? ILLEGAL_PORT : onError.Id(); |
@@ -231,10 +253,13 @@ DEFINE_NATIVE_ENTRY(Isolate_spawnFunction, 7) { |
new IsolateSpawnState(port.Id(), |
isolate->origin_id(), |
isolate->init_callback_data(), |
+ String2UTF8(script_uri), |
func, |
message, |
isolate->spawn_count_monitor(), |
isolate->spawn_count(), |
+ utf8_package_root, |
+ utf8_package_config, |
paused.value(), |
fatal_errors, |
on_exit_port, |
@@ -268,16 +293,6 @@ DEFINE_NATIVE_ENTRY(Isolate_spawnFunction, 7) { |
} |
-static const char* String2UTF8(const String& str) { |
- intptr_t len = Utf8::Length(str); |
- char* result = new char[len + 1]; |
- str.ToUTF8(reinterpret_cast<uint8_t*>(result), len); |
- result[len] = 0; |
- |
- return result; |
-} |
- |
- |
static const char* CanonicalizeUri(Thread* thread, |
const Library& library, |
const String& uri, |
@@ -330,8 +345,8 @@ DEFINE_NATIVE_ENTRY(Isolate_spawnUri, 12) { |
GET_NATIVE_ARGUMENT(Array, environment, arguments->NativeArgAt(9)); |
- GET_NATIVE_ARGUMENT(String, package_root, arguments->NativeArgAt(10)); |
- GET_NATIVE_ARGUMENT(Array, packages, arguments->NativeArgAt(11)); |
+ GET_NATIVE_ARGUMENT(String, packageRoot, arguments->NativeArgAt(10)); |
+ GET_NATIVE_ARGUMENT(String, packageConfig, arguments->NativeArgAt(11)); |
if (Dart::IsRunningPrecompiledCode()) { |
const Array& args = Array::Handle(Array::New(1)); |
@@ -352,26 +367,9 @@ DEFINE_NATIVE_ENTRY(Isolate_spawnUri, 12) { |
} |
const char* utf8_package_root = |
- package_root.IsNull() ? NULL : String2UTF8(package_root); |
- |
- const char** utf8_package_map = NULL; |
- if (!packages.IsNull()) { |
- intptr_t len = packages.Length(); |
- utf8_package_map = new const char*[len + 1]; |
- |
- Object& entry = Object::Handle(); |
- for (intptr_t i = 0; i < len; i++) { |
- entry = packages.At(i); |
- if (!entry.IsString()) { |
- const String& msg = String::Handle(String::NewFormatted( |
- "Bad value in package map: %s", entry.ToCString())); |
- ThrowIsolateSpawnException(msg); |
- } |
- utf8_package_map[i] = String2UTF8(String::Cast(entry)); |
- } |
- // NULL terminated array. |
- utf8_package_map[len] = NULL; |
- } |
+ packageRoot.IsNull() ? NULL : String2UTF8(packageRoot); |
+ const char* utf8_package_config = |
+ packageConfig.IsNull() ? NULL : String2UTF8(packageConfig); |
bool fatal_errors = fatalErrors.IsNull() ? true : fatalErrors.value(); |
Dart_Port on_exit_port = onExit.IsNull() ? ILLEGAL_PORT : onExit.Id(); |
@@ -383,7 +381,7 @@ DEFINE_NATIVE_ENTRY(Isolate_spawnUri, 12) { |
isolate->init_callback_data(), |
canonical_uri, |
utf8_package_root, |
- utf8_package_map, |
+ utf8_package_config, |
args, |
message, |
isolate->spawn_count_monitor(), |
@@ -433,6 +431,13 @@ DEFINE_NATIVE_ENTRY(Isolate_getPortAndCapabilitiesOfCurrentIsolate, 0) { |
} |
+DEFINE_NATIVE_ENTRY(Isolate_getCurrentRootUriStr, 0) { |
+ const Library& root_lib = Library::Handle(zone, |
+ isolate->object_store()->root_library()); |
+ return root_lib.url(); |
+} |
+ |
+ |
DEFINE_NATIVE_ENTRY(Isolate_sendOOB, 2) { |
GET_NON_NULL_NATIVE_ARGUMENT(SendPort, port, arguments->NativeArgAt(0)); |
GET_NON_NULL_NATIVE_ARGUMENT(Array, msg, arguments->NativeArgAt(1)); |