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

Unified Diff: runtime/lib/isolate.cc

Issue 834233003: Fix for issue 21398 (only send "literal like" objects across isolates spawned using spawnURI (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 11 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
« no previous file with comments | « runtime/include/dart_native_api.h ('k') | runtime/lib/isolate_patch.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/isolate.cc
===================================================================
--- runtime/lib/isolate.cc (revision 42788)
+++ runtime/lib/isolate.cc (working copy)
@@ -102,7 +102,8 @@
GET_NON_NULL_NATIVE_ARGUMENT(Instance, obj, arguments->NativeArgAt(1));
uint8_t* data = NULL;
- MessageWriter writer(&data, &allocator);
+ bool can_send_any_object = (isolate->origin_id() == port.origin_id());
+ MessageWriter writer(&data, &allocator, can_send_any_object);
writer.WriteMessage(obj);
// TODO(turnidge): Throw an exception when the return value is false?
@@ -178,6 +179,11 @@
Isolate::SetCurrent(parent_isolate);
return false;
}
+ if (!state->is_spawn_uri()) {
+ // For isolates spawned using the spawnFunction semantics we set
+ // the origin_id to the origin_id of the parent isolate.
+ child_isolate->set_origin_id(parent_isolate->origin_id());
+ }
state->set_isolate(reinterpret_cast<Isolate*>(child_isolate));
Isolate::SetCurrent(parent_isolate);
@@ -185,8 +191,7 @@
}
-static RawObject* Spawn(Isolate* parent_isolate,
- IsolateSpawnState* state) {
+static void Spawn(Isolate* parent_isolate, IsolateSpawnState* state) {
// Create a new isolate.
char* error = NULL;
if (!CreateIsolate(parent_isolate, state, &error)) {
@@ -196,19 +201,13 @@
ThrowIsolateSpawnException(msg);
}
- // Create a SendPort for the new isolate.
+ // Start the new isolate if it is already marked as runnable.
Isolate* spawned_isolate = state->isolate();
- const SendPort& port = SendPort::Handle(
- SendPort::New(spawned_isolate->main_port()));
-
- // Start the new isolate if it is already marked as runnable.
MutexLocker ml(spawned_isolate->mutex());
spawned_isolate->set_spawn_state(state);
if (spawned_isolate->is_runnable()) {
spawned_isolate->Run();
}
-
- return port.raw();
}
@@ -226,8 +225,11 @@
ctx = Closure::context(closure);
ASSERT(ctx.num_variables() == 0);
#endif
- return Spawn(isolate, new IsolateSpawnState(
- port.Id(), func, message, paused.value()));
+ Spawn(isolate, new IsolateSpawnState(port.Id(),
+ func,
+ message,
+ paused.value()));
+ return Object::null();
}
}
const String& msg = String::Handle(String::New(
@@ -265,12 +267,13 @@
utf8_package_root[len] = '\0';
}
- return Spawn(isolate, new IsolateSpawnState(port.Id(),
- canonical_uri,
- utf8_package_root,
- args,
- message,
- paused.value()));
+ Spawn(isolate, new IsolateSpawnState(port.Id(),
+ canonical_uri,
+ utf8_package_root,
+ args,
+ message,
+ paused.value()));
+ return Object::null();
}
@@ -293,7 +296,7 @@
msg.SetAt(0, Smi::Handle(Smi::New(Message::kIsolateLibOOBMsg)));
uint8_t* data = NULL;
- MessageWriter writer(&data, &allocator);
+ MessageWriter writer(&data, &allocator, false);
writer.WriteMessage(msg);
PortMap::PostMessage(new Message(port.Id(),
« no previous file with comments | « runtime/include/dart_native_api.h ('k') | runtime/lib/isolate_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698