@@ -102,20 +102,18 @@ DEFINE_NATIVE_ENTRY(SendPort_get_hashcode, 0, 1) {
102102 return Smi::New (hash);
103103}
104104
105- static bool InSameGroup (Isolate* sender, const SendPort& receiver) {
106- // Cannot determine whether sender is in same group (yet).
107- if (sender->origin_id () == ILLEGAL_PORT) return false ;
108-
105+ static bool InSameGroup (IsolateGroup* sender, const SendPort& receiver) {
109106 // Only allow arbitrary messages between isolates of the same IG.
110- return sender->origin_id () == receiver.origin_id ();
107+ return sender->id () == receiver.origin_id ();
111108}
112109
113110DEFINE_NATIVE_ENTRY (SendPort_sendInternal_, 0 , 2 ) {
114111 GET_NON_NULL_NATIVE_ARGUMENT (SendPort, port, arguments->NativeArgAt (0 ));
115112 GET_NON_NULL_NATIVE_ARGUMENT (Instance, obj, arguments->NativeArgAt (1 ));
116113
117114 const Dart_Port destination_port_id = port.Id ();
118- const bool same_group = InSameGroup (isolate, port);
115+ IsolateGroup* group = thread->isolate_group ();
116+ const bool same_group = InSameGroup (group, port);
119117#if defined(DEBUG)
120118 if (same_group) {
121119 ASSERT (PortMap::IsReceiverInThisIsolateGroupOrClosed (destination_port_id,
@@ -505,11 +503,11 @@ DEFINE_NATIVE_ENTRY(Isolate_exit_, 0, 2) {
505503 if (!port.IsNull ()) {
506504 GET_NATIVE_ARGUMENT (Instance, obj, arguments->NativeArgAt (1 ));
507505
508- const bool same_group = InSameGroup (isolate, port);
506+ IsolateGroup* group = thread->isolate_group ();
507+ const bool same_group = InSameGroup (group, port);
509508#if defined(DEBUG)
510509 if (same_group) {
511- ASSERT (PortMap::IsReceiverInThisIsolateGroupOrClosed (port.Id (),
512- isolate->group ()));
510+ ASSERT (PortMap::IsReceiverInThisIsolateGroupOrClosed (port.Id (), group));
513511 }
514512#endif
515513 if (!same_group) {
@@ -557,7 +555,6 @@ DEFINE_NATIVE_ENTRY(Isolate_exit_, 0, 2) {
557555class IsolateSpawnState {
558556 public:
559557 IsolateSpawnState (Dart_Port parent_port,
560- Dart_Port origin_id,
561558 const char * script_url,
562559 PersistentHandle* closure_tuple_handle,
563560 SerializedObjectBuffer* message_buffer,
@@ -582,7 +579,6 @@ class IsolateSpawnState {
582579 ~IsolateSpawnState ();
583580
584581 Dart_Port parent_port () const { return parent_port_; }
585- Dart_Port origin_id () const { return origin_id_; }
586582 Dart_Port on_exit_port () const { return on_exit_port_; }
587583 Dart_Port on_error_port () const { return on_error_port_; }
588584 const char * script_url () const { return script_url_; }
@@ -606,7 +602,6 @@ class IsolateSpawnState {
606602
607603 private:
608604 Dart_Port parent_port_;
609- Dart_Port origin_id_ = ILLEGAL_PORT;
610605 Dart_Port on_exit_port_;
611606 Dart_Port on_error_port_;
612607 const char * script_url_;
@@ -630,7 +625,6 @@ static const char* NewConstChar(const char* chars) {
630625}
631626
632627IsolateSpawnState::IsolateSpawnState (Dart_Port parent_port,
633- Dart_Port origin_id,
634628 const char * script_url,
635629 PersistentHandle* closure_tuple_handle,
636630 SerializedObjectBuffer* message_buffer,
@@ -642,7 +636,6 @@ IsolateSpawnState::IsolateSpawnState(Dart_Port parent_port,
642636 const char * debug_name,
643637 IsolateGroup* isolate_group)
644638 : parent_port_(parent_port),
645- origin_id_(origin_id),
646639 on_exit_port_(on_exit_port),
647640 on_error_port_(on_error_port),
648641 script_url_(script_url),
@@ -876,11 +869,6 @@ class SpawnIsolateTask : public ThreadPool::Task {
876869 return ;
877870 }
878871
879- if (state_->origin_id () != ILLEGAL_PORT) {
880- // origin_id is set to parent isolate main port id when spawning via
881- // spawnFunction.
882- child->set_origin_id (state_->origin_id ());
883- }
884872 bool errors_are_fatal = state_->errors_are_fatal ();
885873 Dart_Port on_error_port = state_->on_error_port ();
886874 Dart_Port on_exit_port = state_->on_exit_port ();
@@ -1119,10 +1107,9 @@ DEFINE_NATIVE_ENTRY(Isolate_spawnFunction, 0, 10) {
11191107 }
11201108
11211109 std::unique_ptr<IsolateSpawnState> state (new IsolateSpawnState (
1122- port.Id (), isolate->origin_id (), String2UTF8 (script_uri),
1123- closure_tuple_handle, &message_buffer, utf8_package_config,
1124- paused.value (), fatal_errors, on_exit_port, on_error_port,
1125- utf8_debug_name, isolate->group ()));
1110+ port.Id (), String2UTF8 (script_uri), closure_tuple_handle, &message_buffer,
1111+ utf8_package_config, paused.value (), fatal_errors, on_exit_port,
1112+ on_error_port, utf8_debug_name, isolate->group ()));
11261113
11271114 isolate->group ()->thread_pool ()->Run <SpawnIsolateTask>(isolate,
11281115 std::move (state));
0 commit comments