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

Unified Diff: runtime/lib/isolate.cc

Issue 545483002: Per isolate package root. (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/lib/isolate.cc
diff --git a/runtime/lib/isolate.cc b/runtime/lib/isolate.cc
index f85726d1e02dc35b5a5fa8ee767d2f3ecb48bc7a..483da4177397a0de41dff6e1fa1b3aa5f4f76543 100644
--- a/runtime/lib/isolate.cc
+++ b/runtime/lib/isolate.cc
@@ -18,6 +18,7 @@
#include "vm/resolver.h"
#include "vm/snapshot.h"
#include "vm/symbols.h"
+#include "vm/unicode.h"
namespace dart {
@@ -141,6 +142,7 @@ static bool CanonicalizeUri(Isolate* isolate,
static bool CreateIsolate(Isolate* parent_isolate,
IsolateSpawnState* state,
+ const char* package_root,
char** error) {
Dart_IsolateCreateCallback callback = Isolate::CreateCallback();
if (callback == NULL) {
@@ -153,6 +155,7 @@ static bool CreateIsolate(Isolate* parent_isolate,
Isolate* child_isolate = reinterpret_cast<Isolate*>(
(callback)(state->script_url(),
state->function_name(),
+ package_root,
init_data,
error));
if (child_isolate == NULL) {
@@ -167,10 +170,11 @@ static bool CreateIsolate(Isolate* parent_isolate,
static RawObject* Spawn(Isolate* parent_isolate,
- IsolateSpawnState* state) {
+ IsolateSpawnState* state,
+ const char* package_root) {
// Create a new isolate.
char* error = NULL;
- if (!CreateIsolate(parent_isolate, state, &error)) {
+ if (!CreateIsolate(parent_isolate, state, package_root, &error)) {
delete state;
const String& msg = String::Handle(String::New(error));
free(error);
@@ -206,7 +210,9 @@ DEFINE_NATIVE_ENTRY(Isolate_spawnFunction, 3) {
ctx = Closure::context(closure);
ASSERT(ctx.num_variables() == 0);
#endif
- return Spawn(isolate, new IsolateSpawnState(port.Id(), func, message));
+ return Spawn(isolate,
+ new IsolateSpawnState(port.Id(), func, message),
+ NULL);
turnidge 2014/09/08 16:40:48 Please add the package_root to IsolateSpawnState a
Anders Johnsen 2014/09/09 06:45:44 Done.
}
}
const String& msg = String::Handle(String::New(
@@ -216,11 +222,12 @@ DEFINE_NATIVE_ENTRY(Isolate_spawnFunction, 3) {
}
-DEFINE_NATIVE_ENTRY(Isolate_spawnUri, 4) {
+DEFINE_NATIVE_ENTRY(Isolate_spawnUri, 5) {
GET_NON_NULL_NATIVE_ARGUMENT(SendPort, port, arguments->NativeArgAt(0));
GET_NON_NULL_NATIVE_ARGUMENT(String, uri, arguments->NativeArgAt(1));
GET_NON_NULL_NATIVE_ARGUMENT(Instance, args, arguments->NativeArgAt(2));
GET_NON_NULL_NATIVE_ARGUMENT(Instance, message, arguments->NativeArgAt(3));
+ GET_NATIVE_ARGUMENT(String, package_root, arguments->NativeArgAt(4));
// Canonicalize the uri with respect to the current isolate.
char* error = NULL;
@@ -233,8 +240,18 @@ DEFINE_NATIVE_ENTRY(Isolate_spawnUri, 4) {
ThrowIsolateSpawnException(msg);
}
- return Spawn(isolate, new IsolateSpawnState(port.Id(), canonical_uri,
- args, message));
+ char* utf8_package_root = NULL;
+ if (!package_root.IsNull()) {
+ const intptr_t len = Utf8::Length(package_root);
+ Zone* zone = isolate->current_zone();
+ utf8_package_root = zone->Alloc<char>(len + 1);
+ package_root.ToUTF8(reinterpret_cast<uint8_t*>(utf8_package_root), len);
+ utf8_package_root[len] = '\0';
+ }
+
+ return Spawn(isolate,
+ new IsolateSpawnState(port.Id(), canonical_uri, args, message),
+ utf8_package_root);
turnidge 2014/09/08 16:40:48 Ditto above, please pass the package root via Isol
Anders Johnsen 2014/09/09 06:45:43 Done.
}

Powered by Google App Engine
This is Rietveld 408576698