Skip to content

Commit feabbd9

Browse files
aamCommit Queue
authored andcommitted
[vm/shared] Ensure Resume stub works in absence of isolate.
The stub can be invoked from isolategroup-bound code. Also require set experimental-shared-data flag when using IsolateGroup.runSync. TEST=vm/dart/shared_syncstar_test BUG=#61137 Change-Id: I2af27f3f9eeb0dd0dbdfe2e4ec5b162a8e0bd816 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441260 Reviewed-by: Ryan Macnak <[email protected]> Commit-Queue: Alexander Aprelev <[email protected]>
1 parent 4faed73 commit feabbd9

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

runtime/lib/concurrent.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ DEFINE_FFI_NATIVE_ENTRY(ConditionVariable_NotifyAll,
115115
DEFINE_FFI_NATIVE_ENTRY(IsolateGroup_runSync,
116116
Dart_Handle,
117117
(Dart_Handle closure)) {
118+
if (!FLAG_experimental_shared_data) {
119+
FATAL(
120+
"Encountered shared data api when functionality is disabled. "
121+
"Pass --experimental-shared-data");
122+
}
123+
118124
Thread* current_thread = Thread::Current();
119125
ASSERT(current_thread->execution_state() == Thread::kThreadInNative);
120126
Isolate* saved_isolate = current_thread->isolate();
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
//
5+
// VMOptions=--experimental-shared-data
6+
//
7+
import 'dart:_internal' show VMInternalsForTesting;
8+
import 'package:dart_internal/isolate_group.dart' show IsolateGroup;
9+
10+
Iterable<int> syncStar() sync* {
11+
yield 0;
12+
}
13+
14+
main() {
15+
IsolateGroup.runSync(() {
16+
syncStar().iterator.moveNext();
17+
});
18+
}

runtime/vm/compiler/stub_code_compiler.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2422,11 +2422,15 @@ void StubCodeCompiler::GenerateResumeStub() {
24222422
#if !defined(PRODUCT)
24232423
// Check if there is a breakpoint at resumption.
24242424
__ LoadIsolate(kTemp);
2425+
Label skip_breakpoints_check;
2426+
// Skip check if no isolate is available(running isolategroup-bound code)
2427+
__ BranchIfZero(kTemp, &skip_breakpoints_check);
24252428
__ LoadFromOffset(kTemp, kTemp,
24262429
target::Isolate::has_resumption_breakpoints_offset(),
24272430
kUnsignedByte);
24282431
__ CompareImmediate(kTemp, 0);
24292432
__ BranchIf(NOT_EQUAL, &call_runtime);
2433+
__ Bind(&skip_breakpoints_check);
24302434
#endif
24312435
}
24322436

0 commit comments

Comments
 (0)