Files
sdk/runtime/tests/vm/dart/isolates/internal.dart
T
Alexander Markov f9eb40cc79 [vm/nnbd] Migate runtime/tests/vm/dart/* tests to NNBD
This change actually migrates vm/dart/* tests to NNBD by fixing
compile-time errors and adjusting tests where needed.

vm/dart/null_float32x4_simd_ops_test and vm/dart/null_float64x2_simd_ops_test
are deleted as they are superseded by static type checks.

vm/dart/regress_40462_test.dart is a huge source code auto-generated
by fuzzer and migrating and maintaining this source doesn't have much
value, so it is deleted.

There are still failures in strong mode due to dependencies on
the packages which are not migrated yet (https://github.com/dart-lang/sdk/issues/42146).

Migrated vm/dart/null_checks_with_dwarf_stack_traces_test fails both in
weak and strong mode due to https://github.com/dart-lang/sdk/issues/42149.

Issue: https://github.com/dart-lang/sdk/issues/41314
Change-Id: I5561f1c8705ec16def0c4e0efa495d15f4ea7259
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149493
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-06-02 22:49:09 +00:00

87 lines
2.8 KiB
Dart

// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:io';
import 'dart:isolate';
import 'dart:async';
import 'dart:_internal' as dart_internal;
/// Similar to `Isolate.spawn<T>()` but supports `newIsolateGroup`.
Future<Isolate> internalSpawn<T>(void entryPoint(T message), T message,
{SendPort? onExit,
SendPort? onError,
bool newIsolateGroup = false,
String? debugName}) async {
final packageConfig = null;
final paused = false;
final bool errorsAreFatal = true;
final readyPort = new RawReceivePort();
try {
dart_internal.spawnFunction(
readyPort.sendPort,
Platform.script.toString(),
entryPoint,
message,
paused,
errorsAreFatal,
onExit,
onError,
packageConfig,
newIsolateGroup,
debugName);
return await _spawnCommon(readyPort);
} catch (e, st) {
readyPort.close();
return await new Future<Isolate>.error(e, st);
}
}
/// A copy of `dart:isolate`s internal `Isolate._spawnCommon()`.
Future<Isolate> _spawnCommon(RawReceivePort readyPort) {
final completer = new Completer<Isolate>.sync();
readyPort.handler = (readyMessage) {
readyPort.close();
if (readyMessage is List && readyMessage.length == 2) {
SendPort controlPort = readyMessage[0];
List capabilities = readyMessage[1];
completer.complete(new Isolate(controlPort,
pauseCapability: capabilities[0],
terminateCapability: capabilities[1]));
} else if (readyMessage is String) {
// We encountered an error while starting the new isolate.
completer.completeError(new IsolateSpawnException(
'Unable to spawn isolate: ${readyMessage}'));
} else {
// This shouldn't happen.
completer.completeError(new IsolateSpawnException(
"Internal error: unexpected format for ready message: "
"'${readyMessage}'"));
}
};
return completer.future;
}
/// Spawns the [staticClosure] in a detached isolate group.
Future<Isolate> spawnInDetachedGroup<T>(
void staticClosure(T message), T message,
{SendPort? onExit, SendPort? onError}) {
return _IG0([staticClosure, message]);
}
// This is the isolate group of "main". We spawn another one.
_IG0(args) => internalSpawn(_IG1, args, newIsolateGroup: true);
// This is an intermediate isolate group. The actual code we run in a new IG and
// this one will die.
_IG1(args) => internalSpawn(_IG2, args, newIsolateGroup: true);
// Run the actual code
_IG2(args) => args[0](args[1]);
extension SendPortSendAndExit on SendPort {
void sendAndExit(var message) {
dart_internal.sendAndExit(this, message);
}
}