Skip to content

Commit 203b303

Browse files
rmacnak-googleCommit Queue
authored andcommitted
[vm, isolates] Allocate the main port before entering the isolate.
Once we enter the isolate, other threads may read the main port as part of attempting to bring all the group members to a reload safepoint. TEST=tsan Change-Id: Ie7ccfd8672c9b923c7e071023a418ddbc58660ae Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/398780 Reviewed-by: Alexander Aprelev <[email protected]> Commit-Queue: Ryan Macnak <[email protected]>
1 parent a888aaa commit 203b303

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

runtime/vm/isolate.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,14 +1860,6 @@ Isolate* Isolate::InitIsolate(const char* name_prefix,
18601860
#undef ISOLATE_METRIC_INIT
18611861
#endif // !defined(PRODUCT)
18621862

1863-
// First we ensure we enter the isolate. This will ensure we're participating
1864-
// in any safepointing requests from this point on. Other threads requesting a
1865-
// safepoint operation will therefore wait until we've stopped.
1866-
//
1867-
// Though the [result] isolate is still in a state where no memory has been
1868-
// allocated, which means it's safe to GC the isolate group until here.
1869-
Thread::EnterIsolate(result);
1870-
18711863
// Setup the isolate message handler.
18721864
result->message_handler_ = new IsolateMessageHandler(result);
18731865

@@ -1879,6 +1871,14 @@ Isolate* Isolate::InitIsolate(const char* name_prefix,
18791871
#endif
18801872
result->set_origin_id(result->main_port());
18811873

1874+
// First we ensure we enter the isolate. This will ensure we're participating
1875+
// in any safepointing requests from this point on. Other threads requesting a
1876+
// safepoint operation will therefore wait until we've stopped.
1877+
//
1878+
// Though the [result] isolate is still in a state where no memory has been
1879+
// allocated, which means it's safe to GC the isolate group until here.
1880+
Thread::EnterIsolate(result);
1881+
18821882
// Keep capability IDs less than 2^53 so web clients of the service
18831883
// protocol can process it properly.
18841884
//

runtime/vm/port.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ Dart_Port PortMap::CreatePort(PortHandler* handler) {
5959
return ILLEGAL_PORT;
6060
}
6161

62-
#if defined(DEBUG)
63-
handler->CheckAccess();
64-
#endif
65-
6662
const Dart_Port port = AllocatePort();
6763
if (auto ports = handler->ports(ml)) {
6864
ports->Insert(PortHandler::PortSetEntry{port});

0 commit comments

Comments
 (0)