Reformat runtime/ using the 3.8 formatter style.

Change-Id: I7b5e5dd768c87f28848ee02050582d23f3604cb1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426286
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
This commit is contained in:
Robert Nystrom
2025-05-03 12:54:15 -07:00
committed by Commit Queue
parent f01486a8e4
commit 11b81715ad
204 changed files with 79971 additions and 140330 deletions
@@ -10,11 +10,13 @@ import 'package:path/path.dart' as path;
final thisDirectory = path.join('runtime', 'tests', 'concurrency');
final stressTestListJson = path.join(thisDirectory, 'stress_test_list.json');
final generatedTest =
path.join(path.join(thisDirectory, 'generated_stress_test.dart'));
final generatedTest = path.join(
path.join(thisDirectory, 'generated_stress_test.dart'),
);
final List<String> testFiles =
List<String>.from(json.decode(File(stressTestListJson).readAsStringSync()));
final List<String> testFiles = List<String>.from(
json.decode(File(stressTestListJson).readAsStringSync()),
);
final dart = 'tools/sdks/dart-sdk/bin/dart';
main(List<String> args) async {
@@ -191,7 +193,7 @@ Future<String> format(String generatedSource) async {
result.stdin.close(),
result.stdout.transform(utf8.decoder).join(''),
result.stderr.transform(utf8.decoder).join(''),
result.exitCode
result.exitCode,
]);
final exitCode = results[3] as int;
@@ -202,8 +204,10 @@ Future<String> format(String generatedSource) async {
final stdout = results[1] as String;
final stderr = results[2] as String;
if (stderr.trim().length != 0) {
print('Note: Failed to format source code. Dart format had stderr: '
'$stderr');
print(
'Note: Failed to format source code. Dart format had stderr: '
'$stderr',
);
return generatedSource;
}
return stdout;
@@ -25,8 +25,9 @@ final dartDirectories = [
main(List<String> args) async {
final testFiles = await findValidTests(dartDirectories, true);
File(stressTestListJson)
.writeAsStringSync(const JsonEncoder.withIndent(' ').convert(testFiles));
File(
stressTestListJson,
).writeAsStringSync(const JsonEncoder.withIndent(' ').convert(testFiles));
}
Future<List<String>> findValidTests(List<String> directories, bool nnbd) async {
@@ -34,8 +35,11 @@ Future<List<String>> findValidTests(List<String> directories, bool nnbd) async {
final testFiles = <String>[];
final failedOrTimedOut = <String>[];
final filteredTests = <String>[];
await for (final testFile
in listTestFiles(sdkRoot, directories, filteredTests)) {
await for (final testFile in listTestFiles(
sdkRoot,
directories,
filteredTests,
)) {
print(testFile);
final duration = await run(sdkRoot, testFile, tempFile, nnbd);
if (duration != null && duration.inSeconds < 6) {
@@ -51,10 +55,14 @@ Future<List<String>> findValidTests(List<String> directories, bool nnbd) async {
filteredTests.sort();
dumpTestList(testFiles, 'The following tests will be included:');
dumpTestList(failedOrTimedOut,
'The following tests will be excluded due to timeout or test failure:');
dumpTestList(filteredTests,
'The following tests were filtered due to using blacklisted things:');
dumpTestList(
failedOrTimedOut,
'The following tests will be excluded due to timeout or test failure:',
);
dumpTestList(
filteredTests,
'The following tests were filtered due to using blacklisted things:',
);
for (int i = 0; i < testFiles.length; ++i) {
testFiles[i] = path.relative(testFiles[i], from: thisDirectory);
@@ -74,11 +82,15 @@ void dumpTestList(List<String> testFiles, String message) {
}
}
Stream<String> listTestFiles(String sdkRoot, List<String> directories,
List<String> filteredTests) async* {
Stream<String> listTestFiles(
String sdkRoot,
List<String> directories,
List<String> filteredTests,
) async* {
for (final dir in directories) {
await for (final file
in Directory(path.join(sdkRoot, dir)).list(recursive: true)) {
await for (final file in Directory(
path.join(sdkRoot, dir),
).list(recursive: true)) {
if (file is File && file.path.endsWith('_test.dart')) {
final contents = file.readAsStringSync();
if (contents.contains(RegExp('//# .* compile-time error')) ||
@@ -101,7 +113,11 @@ Stream<String> listTestFiles(String sdkRoot, List<String> directories,
}
Future<Duration?> run(
String sdkRoot, String testFile, String wrapFile, bool nnbd) async {
String sdkRoot,
String testFile,
String wrapFile,
bool nnbd,
) async {
final env = Map<String, String>.from(Platform.environment);
env['LD_LIBRARY_PATH'] = path.join(sdkRoot, 'out/ReleaseX64');
final sw = Stopwatch()..start();
@@ -131,9 +147,10 @@ main() async {
errors.close();
}
''');
final Process process = await Process.start(Platform.executable,
<String>[nnbd ? '--sound-null-safety' : '--no-sound-null-safety', f.path],
environment: env);
final Process process = await Process.start(Platform.executable, <String>[
nnbd ? '--sound-null-safety' : '--no-sound-null-safety',
f.path,
], environment: env);
final timer = Timer(const Duration(seconds: 3), () => process.kill());
bool good = false;
final stdoutF = process.stdout
@@ -17,10 +17,9 @@ int crashCounter = 0;
void forwardStream(Stream<List<int>> input, IOSink output) {
// Print the information line-by-line.
input
.transform(utf8.decoder)
.transform(const LineSplitter())
.listen((String line) {
input.transform(utf8.decoder).transform(const LineSplitter()).listen((
String line,
) {
output.writeln(line);
});
}
@@ -33,10 +32,16 @@ class PotentialCrash {
}
Future<bool> run(
String executable, List<String> args, List<PotentialCrash> crashes) async {
String executable,
List<String> args,
List<PotentialCrash> crashes,
) async {
print('Running "$executable ${args.join(' ')}"');
final Process process = await Process.start(executable, args,
environment: sanitizerEnvironmentVariables);
final Process process = await Process.start(
executable,
args,
environment: sanitizerEnvironmentVariables,
);
forwardStream(process.stdout, stdout);
forwardStream(process.stderr, stderr);
final int exitCode = await process.exitCode;
@@ -81,12 +86,15 @@ class AotTestRunner extends TestRunner {
await withTempDir((String dir) async {
final elfFile = path.join(dir, 'app.elf');
if (await run(
'$buildDir/gen_snapshot',
['--snapshot-kind=app-aot-elf', '--elf=$elfFile', ...arguments],
crashes)) {
await run(
'$buildDir/dartaotruntime', [...aotArguments, elfFile], crashes);
if (await run('$buildDir/gen_snapshot', [
'--snapshot-kind=app-aot-elf',
'--elf=$elfFile',
...arguments,
], crashes)) {
await run('$buildDir/dartaotruntime', [
...aotArguments,
elfFile,
], crashes);
}
});
}
@@ -141,13 +149,21 @@ main(List<String> arguments) async {
final parser = ArgParser()
..addOption('shards', help: 'number of shards used', defaultsTo: '1')
..addOption('shard', help: 'shard id', defaultsTo: '1')
..addOption('output-directory',
help: 'unused parameter to make sharding infra work', defaultsTo: '')
..addFlag('copy-coredumps',
help: 'whether to copy binaries for coredumps', defaultsTo: false)
..addOption('previous-results',
help: 'An earlier results.json for balancing tests across shards.')
..addOption('arch', help:'architecture to be tested', defaultsTo: 'X64');
..addOption(
'output-directory',
help: 'unused parameter to make sharding infra work',
defaultsTo: '',
)
..addFlag(
'copy-coredumps',
help: 'whether to copy binaries for coredumps',
defaultsTo: false,
)
..addOption(
'previous-results',
help: 'An earlier results.json for balancing tests across shards.',
)
..addOption('arch', help: 'architecture to be tested', defaultsTo: 'X64');
final options = parser.parse(arguments);
final shards = int.parse(options['shards']);
@@ -155,36 +171,32 @@ main(List<String> arguments) async {
final copyCoredumps = options['copy-coredumps'] as bool;
final arch = options['arch'].toUpperCase();
configurations = <TestRunner>[
JitTestRunner('out/Debug$arch', [
JitTestRunner('out/Debug$arch', [
'--disable-dart-dev',
'runtime/tests/concurrency/generated_stress_test.dart.jit.dill',
]),
JitTestRunner('out/Release$arch', [
'--disable-dart-dev',
'--no-inline-alloc',
'--use-slow-path',
'--deoptimize-on-runtime-call-every=3',
'runtime/tests/concurrency/generated_stress_test.dart.jit.dill',
]),
for (int i = 0; i < tsanShards; ++i)
JitTestRunner('out/ReleaseTSAN$arch', [
'--disable-dart-dev',
'-Drepeat=4',
'-Dshard=$i',
'-Dshards=$tsanShards',
'runtime/tests/concurrency/generated_stress_test.dart.jit.dill',
]),
JitTestRunner('out/Release$arch', [
'--disable-dart-dev',
'--no-inline-alloc',
'--use-slow-path',
'--deoptimize-on-runtime-call-every=3',
'runtime/tests/concurrency/generated_stress_test.dart.jit.dill',
]),
for (int i = 0; i < tsanShards; ++i)
JitTestRunner('out/ReleaseTSAN$arch', [
'--disable-dart-dev',
'-Drepeat=4',
'-Dshard=$i',
'-Dshards=$tsanShards',
'runtime/tests/concurrency/generated_stress_test.dart.jit.dill',
]),
AotTestRunner(
'out/Release$arch',
['runtime/tests/concurrency/generated_stress_test.dart.aot.dill'],
[],
),
AotTestRunner(
'out/Debug$arch',
['runtime/tests/concurrency/generated_stress_test.dart.aot.dill'],
[],
)];
AotTestRunner('out/Release$arch', [
'runtime/tests/concurrency/generated_stress_test.dart.aot.dill',
], []),
AotTestRunner('out/Debug$arch', [
'runtime/tests/concurrency/generated_stress_test.dart.aot.dill',
], []),
];
// Tasks will eventually be killed if they do not have any output for some
// time. So we'll explicitly print something every 4 minutes.
@@ -24,8 +24,12 @@ void matchIL$identity(FlowGraph graph) {
if (is32BitConfiguration) ...[
// The Dart int address is truncated before being returned.
'uint32' <<
match.IntConverter('address',
from: 'int64', to: 'uint32', is_truncating: true),
match.IntConverter(
'address',
from: 'int64',
to: 'uint32',
is_truncating: true,
),
'retval' << match.IntConverter('uint32', from: 'uint32', to: 'int64'),
],
match.DartReturn(retval),
+7 -4
View File
@@ -17,8 +17,10 @@ main(List<String> args) async {
}
if (Platform.isAndroid) {
print('Skipping test due to being on Android where needed tools are not '
'available.');
print(
'Skipping test due to being on Android where needed tools are not '
'available.',
);
return; // SDK tree and gen_snapshot not available on the test device.
}
@@ -36,8 +38,9 @@ main(List<String> args) async {
await withElfSnapshot((Elf elf) {
// NOTE: These tests validate properties we should strive to maintain.
// Please reach out to go/dart-ama before changing them.
final Symbol? symbol =
elf.dynamicSymbolFor('_kDartIsolateSnapshotInstructions');
final Symbol? symbol = elf.dynamicSymbolFor(
'_kDartIsolateSnapshotInstructions',
);
Expect.isTrue(symbol != null && symbol.value > 0);
});
}
@@ -15,12 +15,14 @@ import 'use_flag_test_helper.dart';
// Used to ensure we don't have multiple equivalent calls to test.
final _seenDescriptions = <String>{};
Future<void> testAOT(String dillPath,
{bool useAsm = false,
bool forceDrops = false,
bool stripUtil = false, // Note: forced true if useAsm.
bool stripFlag = false,
bool disassemble = false}) async {
Future<void> testAOT(
String dillPath, {
bool useAsm = false,
bool forceDrops = false,
bool stripUtil = false, // Note: forced true if useAsm.
bool stripFlag = false,
bool disassemble = false,
}) async {
if (const bool.fromEnvironment('dart.vm.product') && disassemble) {
Expect.isFalse(disassemble, 'no use of disassembler in PRODUCT mode');
}
@@ -51,11 +53,14 @@ Future<void> testAOT(String dillPath,
}
final description = descriptionBuilder.toString();
Expect.isTrue(_seenDescriptions.add(description),
"test configuration $description would be run multiple times");
Expect.isTrue(
_seenDescriptions.add(description),
"test configuration $description would be run multiple times",
);
await withTempDir('analyze_snapshot_binary-$description',
(String tempDir) async {
await withTempDir('analyze_snapshot_binary-$description', (
String tempDir,
) async {
// Generate the snapshot
final snapshotPath = path.join(tempDir, 'test.snap');
final commonSnapshotArgs = [
@@ -63,7 +68,7 @@ Future<void> testAOT(String dillPath,
if (forceDrops) ...[
'--dwarf-stack-traces',
'--no-retain-function-objects',
'--no-retain-code-objects'
'--no-retain-code-objects',
],
if (disassemble) '--disassemble', // Not defined in PRODUCT mode.
dillPath,
@@ -100,11 +105,15 @@ Future<void> testAOT(String dillPath,
final textSections = elf.namedSections(".text");
Expect.isNotEmpty(textSections);
Expect.isTrue(
textSections.length <= 2, "More text sections than expected");
textSections.length <= 2,
"More text sections than expected",
);
final dataSections = elf.namedSections(".rodata");
Expect.isNotEmpty(dataSections);
Expect.isTrue(
dataSections.length <= 2, "More data sections than expected");
dataSections.length <= 2,
"More data sections than expected",
);
}
final analyzerOutputPath = path.join(tempDir, 'analyze_test.json');
@@ -118,11 +127,17 @@ Future<void> testAOT(String dillPath,
final analyzerJsonBytes = await readFile(analyzerOutputPath);
final analyzerJson = json.decode(analyzerJsonBytes);
Expect.isFalse(analyzerJson.isEmpty);
Expect.isTrue(analyzerJson.keys
.toSet()
.containsAll(['snapshot_data', 'objects', 'metadata']));
Expect.isTrue(
analyzerJson.keys.toSet().containsAll([
'snapshot_data',
'objects',
'metadata',
]),
);
final objects = (analyzerJson['objects'] as List).map((o) => o as Map).toList();
final objects = (analyzerJson['objects'] as List)
.map((o) => o as Map)
.toList();
final classes = objects.where((o) => o['type'] == 'Class').toList();
final classnames = <int, String>{};
final superclass = <int, int>{};
@@ -138,51 +153,66 @@ Future<void> testAOT(String dillPath,
}
// Find MethodChannel class.
final methodChannelId =
classnames.entries.singleWhere((e) => e.value == 'MethodChannel').key;
final methodChannelId = classnames.entries
.singleWhere((e) => e.value == 'MethodChannel')
.key;
// Find string instance.
final stringList = objects
.where((o) => o['type'] == 'String' && o['value'] == 'constChannel1')
.toList();
Expect.isTrue(stringList.length == 1,
'one "constChannel1" string must exist in output');
Expect.isTrue(
stringList.length == 1,
'one "constChannel1" string must exist in output',
);
final int stringObjId = stringList.first['id'];
// Find MethodChannel instance.
final instanceList = objects
.where((o) =>
o['type'] == 'Instance' &&
o['class'] == methodChannelId &&
o['references'].contains(stringObjId))
.where(
(o) =>
o['type'] == 'Instance' &&
o['class'] == methodChannelId &&
o['references'].contains(stringObjId),
)
.toList();
Expect.isTrue(instanceList.length == 1, '''one instance of MethodChannel
with reference to "constChannel1" must exist in output''');
// Test class hierarchy information
final myBaseClassId =
classnames.entries.singleWhere((e) => e.value == 'MyBase').key;
final mySubClassId =
classnames.entries.singleWhere((e) => e.value == 'MySub').key;
final myInterfaceClassId =
classnames.entries.singleWhere((e) => e.value == 'MyInterface').key;
final myBaseClassId = classnames.entries
.singleWhere((e) => e.value == 'MyBase')
.key;
final mySubClassId = classnames.entries
.singleWhere((e) => e.value == 'MySub')
.key;
final myInterfaceClassId = classnames.entries
.singleWhere((e) => e.value == 'MyInterface')
.key;
Expect.equals(myBaseClassId, superclass[mySubClassId]);
Expect.equals(myInterfaceClassId, implementedInterfaces[mySubClassId]!.single);
Expect.isTrue(analyzerJson['metadata'].containsKey('analyzer_version'),
'snapshot analyzer version must be reported');
Expect.isTrue(analyzerJson['metadata']['analyzer_version'] == 2,
'invalid snapshot analyzer version');
Expect.equals(
myInterfaceClassId,
implementedInterfaces[mySubClassId]!.single,
);
Expect.isTrue(
analyzerJson['metadata'].containsKey('analyzer_version'),
'snapshot analyzer version must be reported',
);
Expect.isTrue(
analyzerJson['metadata']['analyzer_version'] == 2,
'invalid snapshot analyzer version',
);
});
}
main() async {
void printSkip(String description) =>
print('Skipping $description for ${path.basename(buildDir)} '
'on ${Platform.operatingSystem}' +
(clangBuildToolsDir == null ? ' without //buildtools' : ''));
void printSkip(String description) => print(
'Skipping $description for ${path.basename(buildDir)} '
'on ${Platform.operatingSystem}' +
(clangBuildToolsDir == null ? ' without //buildtools' : ''),
);
// We don't have access to the SDK on Android.
if (Platform.isAndroid) {
@@ -192,8 +222,14 @@ main() async {
await withTempDir('analyze_snapshot_binary', (String tempDir) async {
// We only need to generate the dill file once for all JIT tests.
final _thisTestPath = path.join(sdkDir, 'runtime', 'tests', 'vm', 'dart',
'analyze_snapshot_program.dart');
final _thisTestPath = path.join(
sdkDir,
'runtime',
'tests',
'vm',
'dart',
'analyze_snapshot_program.dart',
);
// We only need to generate the dill file once for all AOT tests.
final aotDillPath = path.join(tempDir, 'aot_test.dill');
@@ -201,13 +237,15 @@ main() async {
'--aot',
'--platform',
platformDill,
...Platform.executableArguments.where((arg) =>
arg.startsWith('--enable-experiment=') ||
arg == '--sound-null-safety' ||
arg == '--no-sound-null-safety'),
...Platform.executableArguments.where(
(arg) =>
arg.startsWith('--enable-experiment=') ||
arg == '--sound-null-safety' ||
arg == '--no-sound-null-safety',
),
'-o',
aotDillPath,
_thisTestPath
_thisTestPath,
]);
// Just as a reminder for AOT tests:
@@ -233,9 +271,7 @@ main() async {
}
// Test unstripped ELF generation that is then externally stripped.
await Future.wait([
testAOT(aotDillPath, stripUtil: true),
]);
await Future.wait([testAOT(aotDillPath, stripUtil: true)]);
// Dont test assembled snapshot for simulated platforms
if (!buildDir.endsWith("SIMARM64") && !buildDir.endsWith("SIMARM64C")) {
@@ -19,9 +19,13 @@ void matchIL$compareUnboxedToConstant(FlowGraph graph) {
'value' << match.Parameter(index: 0),
if (is32BitConfiguration)
'value_32' << match.IntConverter('value', from: 'int64', to: 'int32'),
match.Branch(match.EqualityCompare(
is32BitConfiguration ? 'value_32' : 'value', match.any,
kind: '==')),
match.Branch(
match.EqualityCompare(
is32BitConfiguration ? 'value_32' : 'value',
match.any,
kind: '==',
),
),
]),
]);
}
@@ -39,9 +43,13 @@ void matchIL$compareUnboxedToSmi(FlowGraph graph) {
'value' << match.Parameter(index: 0),
if (is32BitConfiguration)
'value_32' << match.IntConverter('value', from: 'int64', to: 'int32'),
match.Branch(match.EqualityCompare(
is32BitConfiguration ? 'value_32' : 'value', match.any,
kind: '==')),
match.Branch(
match.EqualityCompare(
is32BitConfiguration ? 'value_32' : 'value',
match.any,
kind: '==',
),
),
]),
]);
}
@@ -63,7 +71,8 @@ void matchIL$compareTwoBoxedSmis(FlowGraph graph) {
'list2.length' <<
match.LoadField('list2', slot: 'GrowableObjectArray.length'),
match.Branch(
match.StrictCompare('list1.length', 'list2.length', kind: '===')),
match.StrictCompare('list1.length', 'list2.length', kind: '==='),
),
]),
]);
}
@@ -88,7 +97,8 @@ void matchIL$compareBoxedSmiToBoxedInt(FlowGraph graph) {
match.LoadField('list2', slot: 'GrowableObjectArray.data'),
'list2.data[0]' << match.LoadIndexed('list2.data', match.any),
match.Branch(
match.StrictCompare('list1.length', 'list2.data[0]', kind: '===')),
match.StrictCompare('list1.length', 'list2.data[0]', kind: '==='),
),
]),
]);
}
@@ -14,4 +14,5 @@ import 'dart:io' show Platform;
import 'snapshot_test_helper.dart';
Future<void> main() => runAppJitTest(
Platform.script.resolve('appjit_field_guard_deopt_test_body.dart'));
Platform.script.resolve('appjit_field_guard_deopt_test_body.dart'),
);
@@ -13,4 +13,5 @@ import 'dart:io' show Platform;
import 'snapshot_test_helper.dart';
Future<void> main() => runAppJitTest(
Platform.script.resolve('appjit_load_static_licm_test_body.dart'));
Platform.script.resolve('appjit_load_static_licm_test_body.dart'),
);
+14 -10
View File
@@ -7,14 +7,18 @@
import "package:expect/expect.dart";
main(List<String> args) {
Expect.throws(() {
assert(/* this */ args.length == -1 && /* that */ args.length == 0);
}, (e) {
if (e is! AssertionError) {
return false;
}
print('Exception: $e');
return e.toString().contains(
"asserts_test.dart': Failed assertion: line 11 pos 23: 'args.length == -1 && /* that */ args.length == 0':");
});
Expect.throws(
() {
assert(/* this */ args.length == -1 && /* that */ args.length == 0);
},
(e) {
if (e is! AssertionError) {
return false;
}
print('Exception: $e');
return e.toString().contains(
"asserts_test.dart': Failed assertion: line 12 pos 25: 'args.length == -1 && /* that */ args.length == 0':",
);
},
);
}
@@ -18,29 +18,46 @@ class TestZone {
static T run<T>(String name, T Function() callback) {
final tz = TestZone(name);
final zone = Zone.current.fork(
specification: ZoneSpecification(
runUnary: tz.runUnary,
runBinary: tz.runBinary,
registerUnaryCallback: tz.registerUnaryCallback,
registerBinaryCallback: tz.registerBinaryCallback,
scheduleMicrotask: tz.scheduleMicrotask));
specification: ZoneSpecification(
runUnary: tz.runUnary,
runBinary: tz.runBinary,
registerUnaryCallback: tz.registerUnaryCallback,
registerBinaryCallback: tz.registerBinaryCallback,
scheduleMicrotask: tz.scheduleMicrotask,
),
);
return zone.run(callback);
}
R runUnary<R, T>(
Zone self, ZoneDelegate parent, Zone zone, R Function(T arg) f, T arg) {
Zone self,
ZoneDelegate parent,
Zone zone,
R Function(T arg) f,
T arg,
) {
log.add('$name.runUnary');
return parent.runUnary(zone, f, arg);
}
R runBinary<R, T1, T2>(Zone self, ZoneDelegate parent, Zone zone,
R Function(T1 arg1, T2 arg2) f, T1 arg1, T2 arg2) {
R runBinary<R, T1, T2>(
Zone self,
ZoneDelegate parent,
Zone zone,
R Function(T1 arg1, T2 arg2) f,
T1 arg1,
T2 arg2,
) {
log.add('$name.runBinary');
return parent.runBinary(zone, f, arg1, arg2);
}
ZoneUnaryCallback<R, T> registerUnaryCallback<R, T>(
Zone self, ZoneDelegate parent, Zone zone, R Function(T arg) f) {
Zone self,
ZoneDelegate parent,
Zone zone,
R Function(T arg) f,
) {
log.add('$name.registerUnaryCallback');
return parent.registerUnaryCallback(zone, (T arg) {
log.add('$name.unaryCallback');
@@ -48,8 +65,12 @@ class TestZone {
});
}
ZoneBinaryCallback<R, T1, T2> registerBinaryCallback<R, T1, T2>(Zone self,
ZoneDelegate parent, Zone zone, R Function(T1 arg1, T2 arg2) f) {
ZoneBinaryCallback<R, T1, T2> registerBinaryCallback<R, T1, T2>(
Zone self,
ZoneDelegate parent,
Zone zone,
R Function(T1 arg1, T2 arg2) f,
) {
log.add('$name.registerBinaryCallback');
return parent.registerBinaryCallback(zone, (T1 arg1, T2 arg2) {
log.add('$name.binaryCallback');
@@ -37,8 +37,9 @@ void main() async {
}
final isolate = currentMirrorSystem().isolate;
final library = await isolate
.loadUri(Uri.parse("await_type_check_with_dynamic_loading_lib.dart"));
final library = await isolate.loadUri(
Uri.parse("await_type_check_with_dynamic_loading_lib.dart"),
);
final (Object expected, A x) = library.invoke(#makeNewFuture, []).reflectee;
await test2(expected, x);
}
@@ -93,6 +93,6 @@ final currentExpectations = [
#3 runTest (harness.dart)
<asynchronous suspension>
#4 main (%test%)
<asynchronous suspension>"""
<asynchronous suspension>""",
];
// CURRENT EXPECTATIONS END
@@ -39,7 +39,8 @@ class _DartFrame extends _ParsedFrame {
});
static final _pattern = RegExp(
r'^#(?<no>\d+)\s+(?<symbol>[^(]+)(\((?<location>((\w+://)?[/\w]+:)?[^:]+)(:(?<line>\d+)(:(?<column>\d+))?)?\))?$');
r'^#(?<no>\d+)\s+(?<symbol>[^(]+)(\((?<location>((\w+://)?[/\w]+:)?[^:]+)(:(?<line>\d+)(:(?<column>\d+))?)?\))?$',
);
static _DartFrame parse(String frame) {
final match = _pattern.firstMatch(frame);
@@ -55,8 +56,8 @@ class _DartFrame extends _ParsedFrame {
}
final lineNo =
location.endsWith('utils.dart') || location.endsWith('tests.dart')
? match.namedGroup('line')
: null;
? match.namedGroup('line')
: null;
return _DartFrame(
no: no,
@@ -118,8 +119,10 @@ var _testIndex = 0;
late final Dwarf? _dwarf;
void configure(List<String> currentExpectations,
{String debugInfoFilename = 'debug.so'}) {
void configure(
List<String> currentExpectations, {
String debugInfoFilename = 'debug.so',
}) {
try {
final testCompilationDir = Platform.environment['TEST_COMPILATION_DIR'];
if (testCompilationDir != null) {
@@ -175,7 +178,10 @@ $st
}
Expect.equals(
expectedFrames.length, gotFrames.length, 'wrong number of frames');
expectedFrames.length,
gotFrames.length,
'wrong number of frames',
);
for (var i = 0; i < expectedFrames.length; i++) {
final expectedFrame = expectedFrames[i];
final gotFrame = gotFrames[i];
@@ -184,12 +190,21 @@ $st
}
if (expectedFrame is _DartFrame && gotFrame is _DartFrame) {
Expect.equals(expectedFrame.symbol, gotFrame.symbol,
'at frame #$i mismatched function name');
Expect.equals(expectedFrame.location, gotFrame.location,
'at frame #$i mismatched location');
Expect.equals(expectedFrame.lineNo, gotFrame.lineNo,
'at frame #$i mismatched line location');
Expect.equals(
expectedFrame.symbol,
gotFrame.symbol,
'at frame #$i mismatched function name',
);
Expect.equals(
expectedFrame.location,
gotFrame.location,
'at frame #$i mismatched location',
);
Expect.equals(
expectedFrame.lineNo,
gotFrame.lineNo,
'at frame #$i mismatched line location',
);
}
Expect.equals(expectedFrame, gotFrame);
@@ -212,10 +227,12 @@ void updateExpectations([String? expectationsFile]) {
final source = sourceFile.readAsStringSync();
final expectationsStart = source.lastIndexOf('// CURRENT EXPECTATIONS BEGIN');
final updatedExpectationsString =
[for (var s in _updatedExpectations) '"""\n$s"""'].join(",\n");
final updatedExpectationsString = [
for (var s in _updatedExpectations) '"""\n$s"""',
].join(",\n");
final newSource = source.substring(0, expectationsStart) +
final newSource =
source.substring(0, expectationsStart) +
"""
// CURRENT EXPECTATIONS BEGIN
final currentExpectations = [${updatedExpectationsString}];
@@ -1441,6 +1441,6 @@ final currentExpectations = [
#4 runTest (%test%)
<asynchronous suspension>
#5 main (%test%)
<asynchronous suspension>"""
<asynchronous suspension>""",
];
// CURRENT EXPECTATIONS END
@@ -52,6 +52,6 @@ final currentExpectations = [
#4 Declarer.test.<anonymous closure> (declarer.dart)
<asynchronous suspension>
#5 Invoker._waitForOutstandingCallbacks.<anonymous closure> (invoker.dart)
<asynchronous suspension>"""
<asynchronous suspension>""",
];
// CURRENT EXPECTATIONS END
@@ -33,36 +33,42 @@ Future<void> foo() async {
Future<void> bar() async {
await foo();
stacktraces.add(StackTrace.current);
await Completer().future.timeout(Duration(milliseconds: 1), onTimeout: () {
stacktraces.add(StackTrace.current);
});
await Completer().future.timeout(
Duration(milliseconds: 1),
onTimeout: () {
stacktraces.add(StackTrace.current);
},
);
}
Future<void> runTest() {
final Zone testZone = Zone.current.fork(
specification: ZoneSpecification(
registerUnaryCallback: _registerUnaryCallback,
registerBinaryCallback: _registerBinaryCallback,
));
specification: ZoneSpecification(
registerUnaryCallback: _registerUnaryCallback,
registerBinaryCallback: _registerBinaryCallback,
),
);
return testZone.run(bar);
}
final stacktraces = <StackTrace>[];
ZoneUnaryCallback<R, T> _registerUnaryCallback<R, T>(
Zone self,
ZoneDelegate parent,
Zone zone,
@pragma('vm:awaiter-link') R Function(T) f) {
Zone self,
ZoneDelegate parent,
Zone zone,
@pragma('vm:awaiter-link') R Function(T) f,
) {
stacktraces.add(StackTrace.current);
return parent.registerUnaryCallback(zone, (v) => f(v));
}
ZoneBinaryCallback<R, T1, T2> _registerBinaryCallback<R, T1, T2>(
Zone self,
ZoneDelegate parent,
Zone zone,
@pragma('vm:awaiter-link') R Function(T1, T2) f) {
Zone self,
ZoneDelegate parent,
Zone zone,
@pragma('vm:awaiter-link') R Function(T1, T2) f,
) {
stacktraces.add(StackTrace.current);
return parent.registerBinaryCallback(zone, (a, b) => f(a, b));
}
@@ -167,6 +173,6 @@ final currentExpectations = [
#4 bar (%test%)
<asynchronous suspension>
#5 main (%test%)
<asynchronous suspension>"""
<asynchronous suspension>""",
];
// CURRENT EXPECTATIONS END
+1 -1
View File
@@ -20,7 +20,7 @@ void main() async {
'--deterministic',
'--optimization-counter-threshold=10',
'--no-use-osr',
testBody.path
testBody.path,
]);
if (result.exitCode != 0) {
print('''
@@ -31,12 +31,8 @@ int and0(int x) {
void matchIL$and0(FlowGraph graph) {
graph.dump();
graph.match([
match.block('Graph', [
'c_zero' << match.UnboxedConstant(value: 0),
]),
match.block('Function', [
match.DartReturn('c_zero'),
]),
match.block('Graph', ['c_zero' << match.UnboxedConstant(value: 0)]),
match.block('Function', [match.DartReturn('c_zero')]),
]);
}
@@ -100,12 +96,8 @@ int or_1(int x) {
void matchIL$or_1(FlowGraph graph) {
graph.dump();
graph.match([
match.block('Graph', [
'c_minus_one' << match.UnboxedConstant(value: -1),
]),
match.block('Function', [
match.DartReturn('c_minus_one'),
]),
match.block('Graph', ['c_minus_one' << match.UnboxedConstant(value: -1)]),
match.block('Function', [match.DartReturn('c_minus_one')]),
]);
}
@@ -118,12 +110,8 @@ int xor(int x) {
void matchIL$xor(FlowGraph graph) {
graph.dump();
graph.match([
match.block('Graph', [
'c_zero' << match.UnboxedConstant(value: 0),
]),
match.block('Function', [
match.DartReturn('c_zero'),
]),
match.block('Graph', ['c_zero' << match.UnboxedConstant(value: 0)]),
match.block('Function', [match.DartReturn('c_zero')]),
]);
}
@@ -170,12 +158,8 @@ int sub(int x) {
void matchIL$sub(FlowGraph graph) {
graph.dump();
graph.match([
match.block('Graph', [
'c_zero' << match.UnboxedConstant(value: 0),
]),
match.block('Function', [
match.DartReturn('c_zero'),
]),
match.block('Graph', ['c_zero' << match.UnboxedConstant(value: 0)]),
match.block('Function', [match.DartReturn('c_zero')]),
]);
}
@@ -205,12 +189,8 @@ int mul0(int x) {
void matchIL$mul0(FlowGraph graph) {
graph.dump();
graph.match([
match.block('Graph', [
'c_zero' << match.UnboxedConstant(value: 0),
]),
match.block('Function', [
match.DartReturn('c_zero'),
]),
match.block('Graph', ['c_zero' << match.UnboxedConstant(value: 0)]),
match.block('Function', [match.DartReturn('c_zero')]),
]);
}
@@ -308,12 +288,8 @@ int srl64(int x) {
void matchIL$srl64(FlowGraph graph) {
graph.dump();
graph.match([
match.block('Graph', [
'c_zero' << match.UnboxedConstant(value: 0),
]),
match.block('Function', [
match.DartReturn('c_zero'),
]),
match.block('Graph', ['c_zero' << match.UnboxedConstant(value: 0)]),
match.block('Function', [match.DartReturn('c_zero')]),
]);
}
@@ -73,64 +73,42 @@ void main(List<String> args) {
void matchIL$loop(FlowGraph graph) {
graph.match(inCodegenBlockOrder: true, [
match.block('Graph'),
match.block('Function', [
match.Goto('loop_header'),
]),
match.block('Function', [match.Goto('loop_header')]),
'loop_header' <<
match.block('Join', [
match.Branch(match.any, ifTrue: 'loop_body'),
]),
match.block('Join', [match.Branch(match.any, ifTrue: 'loop_body')]),
'loop_body' <<
match.block('Target', [
match.Branch(match.any, ifFalse: 'loop_inc'),
]),
'loop_inc' <<
match.block('Target', [
match.Goto('loop_header'),
]),
match.block('Target', [match.Branch(match.any, ifFalse: 'loop_inc')]),
'loop_inc' << match.block('Target', [match.Goto('loop_header')]),
]);
}
void matchIL$loop2(FlowGraph graph) {
graph.match(inCodegenBlockOrder: true, [
match.block('Graph'),
match.block('Function', [
match.Goto('loop_header_1'),
]),
match.block('Function', [match.Goto('loop_header_1')]),
'loop_header_1' <<
match.block('Join', [
match.Branch(match.any, ifTrue: 'loop_body_1'),
]),
'loop_body_1' <<
match.block('Target', [
match.Goto('loop_header_2'),
]),
match.block('Join', [match.Branch(match.any, ifTrue: 'loop_body_1')]),
'loop_body_1' << match.block('Target', [match.Goto('loop_header_2')]),
'loop_header_2' <<
match.block('Join', [
match.Branch(match.any,
ifTrue: 'loop_body_2', ifFalse: 'loop_body_2_exit_1'),
match.Branch(
match.any,
ifTrue: 'loop_body_2',
ifFalse: 'loop_body_2_exit_1',
),
]),
'loop_body_2' <<
match.block('Target', [
match.Branch(match.any,
ifTrue: 'loop_body_2_exit_2', ifFalse: 'loop_inc_2'),
]),
'loop_inc_2' <<
match.block('Target', [
match.Goto('loop_header_2'),
]),
'loop_body_2_exit_2' <<
match.block('Target', [
match.Goto('loop_inc_1'),
]),
'loop_body_2_exit_1' <<
match.block('Target', [
match.Goto('loop_inc_1'),
]),
'loop_inc_1' <<
match.block('Join', [
match.Goto('loop_header_1'),
match.Branch(
match.any,
ifTrue: 'loop_body_2_exit_2',
ifFalse: 'loop_inc_2',
),
]),
'loop_inc_2' << match.block('Target', [match.Goto('loop_header_2')]),
'loop_body_2_exit_2' << match.block('Target', [match.Goto('loop_inc_1')]),
'loop_body_2_exit_1' << match.block('Target', [match.Goto('loop_inc_1')]),
'loop_inc_1' << match.block('Join', [match.Goto('loop_header_1')]),
]);
}
@@ -147,9 +125,7 @@ void matchIL$bodyAlwaysThrows(FlowGraph graph) {
void matchIL$throwInALoop(FlowGraph graph) {
graph.match(inCodegenBlockOrder: true, [
match.block('Graph'),
match.block('Function', [
match.Goto('loop_header'),
]),
match.block('Function', [match.Goto('loop_header')]),
'loop_header' <<
match.block('Join', [
'i' << match.Phi(match.any, 'inc_i'),
@@ -157,8 +133,11 @@ void matchIL$throwInALoop(FlowGraph graph) {
]),
'loop_body' <<
match.block('Target', [
match.Branch(match.any,
ifTrue: 'return_found', ifFalse: 'loop_body_cont'),
match.Branch(
match.any,
ifTrue: 'return_found',
ifFalse: 'loop_body_cont',
),
]),
'loop_body_cont' <<
match.block('Target', [
@@ -176,17 +155,8 @@ void matchIL$throwInALoop(FlowGraph graph) {
],
match.Goto('loop_header'),
]),
'return_found' <<
match.block('Target', [
match.DartReturn('i'),
]),
'return_fail' <<
match.block('Target', [
match.DartReturn(match.any),
]),
'throw' <<
match.block('Target', [
match.Throw(match.any),
]),
'return_found' << match.block('Target', [match.DartReturn('i')]),
'return_fail' << match.block('Target', [match.DartReturn(match.any)]),
'throw' << match.block('Target', [match.Throw(match.any)]),
]);
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -86,8 +86,18 @@ void testManyArguments() {
@pragma('vm:never-inline')
@pragma('vm:cachable-idempotent')
int manyArguments(int i1, int i2, int i3, int i4, int i5, int i6, int i7,
int i8, int i9, int i10) {
int manyArguments(
int i1,
int i2,
int i3,
int i4,
int i5,
int i6,
int i7,
int i8,
int i9,
int i10,
) {
return i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8 + i9 + i10;
}
@@ -147,30 +157,12 @@ bool is64bitsArch() => sizeOf<Pointer>() == 8;
@pragma('vm:force-optimize')
void testIntArguments() {
final result = lotsOfIntArguments(
1,
2,
3,
4,
5,
6,
7,
8,
);
final result = lotsOfIntArguments(1, 2, 3, 4, 5, 6, 7, 8);
Expect.equals(36, result);
// Do a second call with different values to prevent the argument values
// propagating to the function body in TFA.
final result2 = lotsOfIntArguments(
101,
102,
103,
104,
105,
106,
107,
108,
);
final result2 = lotsOfIntArguments(101, 102, 103, 104, 105, 106, 107, 108);
Expect.equals(836, result2);
}
@@ -192,16 +184,7 @@ int lotsOfIntArguments(
@pragma('vm:force-optimize')
void testDoubleArguments() {
final result = lotsOfDoubleArguments(
1.0,
2.0,
3.0,
4.0,
5.0,
6.0,
7.0,
8.0,
);
final result = lotsOfDoubleArguments(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0);
Expect.equals(36, result);
// Do a second call with different values to prevent the argument values
@@ -137,11 +137,9 @@ void testDirectCalls3(String str, int ia, int ib) {
}
void main(List<String> args) {
runTests(args, [
...directCallsTests,
testDirectCalls3,
], [
...childClassFactories,
ChildWithBoxedParameterOverride.new,
]);
runTests(
args,
[...directCallsTests, testDirectCalls3],
[...childClassFactories, ChildWithBoxedParameterOverride.new],
);
}
@@ -319,9 +319,10 @@ void testVirtualCalls(Base child, int ia, int ib) {
}
void runTests(
List<String> args,
List<void Function(String, int, int)> directCallsTests,
List<Base Function(String)> childClassFactories) {
List<String> args,
List<void Function(String, int, int)> directCallsTests,
List<Base Function(String)> childClassFactories,
) {
final ia = args.length >= 1 ? int.parse(args[0]) : 42;
final ib = args.length >= 2 ? int.parse(args[1]) : 100;
final str = args.length >= 3 ? args[2] : 'ok+';
@@ -343,8 +344,11 @@ void main(List<String> args) {
runTests(args, directCallsTests, childClassFactories);
}
void _matchIL(FlowGraph graph,
{required List<String?> parameters, bool argDesc = false}) {
void _matchIL(
FlowGraph graph, {
required List<String?> parameters,
bool argDesc = false,
}) {
graph.match([
match.block('Graph'),
match.block('Function', [
@@ -353,7 +357,7 @@ void _matchIL(FlowGraph graph,
match.Parameter(index: i, location: parameters[i]),
if (argDesc)
match.Parameter(index: parameters.length, location: 'reg(cpu)'),
])
]),
]);
}
@@ -370,19 +374,25 @@ void matchIL$ChildSimple$fNamed(FlowGraph graph) {
}
void matchIL$ChildSimple$fIntInt(FlowGraph graph) {
_matchIL(graph, parameters: [
'reg(cpu)',
is32BitConfiguration ? '(reg(cpu), reg(cpu))' : 'reg(cpu)',
'stack(word)',
]);
_matchIL(
graph,
parameters: [
'reg(cpu)',
is32BitConfiguration ? '(reg(cpu), reg(cpu))' : 'reg(cpu)',
'stack(word)',
],
);
}
void matchIL$ChildSimple$fIntDouble(FlowGraph graph) {
_matchIL(graph, parameters: [
'reg(cpu)',
is32BitConfiguration ? '(reg(cpu), reg(cpu))' : 'reg(cpu)',
'stack(word)',
]);
_matchIL(
graph,
parameters: [
'reg(cpu)',
is32BitConfiguration ? '(reg(cpu), reg(cpu))' : 'reg(cpu)',
'stack(word)',
],
);
}
void matchIL$ChildSimple$fDoubleDouble(FlowGraph graph) {
@@ -426,42 +436,50 @@ void matchIL$ChildConvertingParametersToOptional$fNamed(FlowGraph graph) {
}
void matchIL$ChildConvertingParametersToOptional$fIntInt(FlowGraph graph) {
_matchIL(graph,
parameters: [
'reg(cpu)',
is32BitConfiguration ? '(reg(cpu), reg(cpu))' : 'reg(cpu)',
null,
],
argDesc: true);
_matchIL(
graph,
parameters: [
'reg(cpu)',
is32BitConfiguration ? '(reg(cpu), reg(cpu))' : 'reg(cpu)',
null,
],
argDesc: true,
);
}
void matchIL$ChildConvertingParametersToOptional$fIntDouble(FlowGraph graph) {
_matchIL(graph,
parameters: [
'reg(cpu)',
is32BitConfiguration ? '(reg(cpu), reg(cpu))' : 'reg(cpu)',
null,
],
argDesc: true);
_matchIL(
graph,
parameters: [
'reg(cpu)',
is32BitConfiguration ? '(reg(cpu), reg(cpu))' : 'reg(cpu)',
null,
],
argDesc: true,
);
}
void matchIL$ChildConvertingParametersToOptional$fDoubleDouble(
FlowGraph graph) {
FlowGraph graph,
) {
_matchIL(graph, parameters: ['reg(cpu)', 'reg(fpu)', null], argDesc: true);
}
void matchIL$ChildConvertingParametersToOptional$fIntOptionalInt(
FlowGraph graph) {
FlowGraph graph,
) {
matchIL$ChildSimple$fIntOptionalInt(graph);
}
void matchIL$ChildConvertingParametersToOptional$fIntOptionalDouble(
FlowGraph graph) {
FlowGraph graph,
) {
matchIL$ChildSimple$fIntOptionalDouble(graph);
}
void matchIL$ChildConvertingParametersToOptional$fDoubleOptionalDouble(
FlowGraph graph) {
FlowGraph graph,
) {
matchIL$ChildSimple$fDoubleOptionalDouble(graph);
}
@@ -470,11 +488,13 @@ void matchIL$ChildConvertingParametersToOptional$fIntNamedInt(FlowGraph graph) {
}
void matchIL$ChildConvertingParametersToOptional$fIntNamedDouble(
FlowGraph graph) {
FlowGraph graph,
) {
matchIL$ChildSimple$fIntNamedDouble(graph);
}
void matchIL$ChildConvertingParametersToOptional$fDoubleNamedDouble(
FlowGraph graph) {
FlowGraph graph,
) {
matchIL$ChildSimple$fDoubleNamedDouble(graph);
}
@@ -37,11 +37,15 @@ void testThrow(bool shouldThrow) {
Expect.equals(1275.0, dbl);
Expect.equals(0x70000000 | 50, i32);
Expect.equals(0x80000000 | 50, i64);
Expect.listEquals([1275.0, -1275.0, 1275.0, -1275.0],
[f32x4.x, f32x4.y, f32x4.z, f32x4.w]);
Expect.listEquals(
[1275.0, -1275.0, 1275.0, -1275.0],
[f32x4.x, f32x4.y, f32x4.z, f32x4.w],
);
Expect.listEquals([1275.0, -1275.0], [f64x2.x, f64x2.y]);
Expect.listEquals(
[-1275, 1275, -1275, 1275], [i32x4.x, i32x4.y, i32x4.z, i32x4.w]);
[-1275, 1275, -1275, 1275],
[i32x4.x, i32x4.y, i32x4.z, i32x4.w],
);
}
}
@@ -50,6 +50,6 @@ final currentExpectations = [
#0 B.takesA (%test%)
#1 main (%test%)
#2 _delayEntrypointInvocation.<anonymous closure> (isolate_patch.dart)
#3 _RawReceivePort._handleMessage (isolate_patch.dart)"""
#3 _RawReceivePort._handleMessage (isolate_patch.dart)""",
];
// CURRENT EXPECTATIONS END
@@ -42,17 +42,14 @@ void matchIL$strictCompareValueEqConstant(FlowGraph graph) {
]),
match.block('Function', [
'value' << match.Parameter(index: 0),
match.Branch(match.StrictCompare('value', 'A(0)', kind: '==='),
ifTrue: 'B1', ifFalse: 'B2'),
match.Branch(
match.StrictCompare('value', 'A(0)', kind: '==='),
ifTrue: 'B1',
ifFalse: 'B2',
),
]),
'B1' <<
match.block('Target', [
match.DartReturn('int 0'),
]),
'B2' <<
match.block('Target', [
match.DartReturn('int 42'),
]),
'B1' << match.block('Target', [match.DartReturn('int 0')]),
'B2' << match.block('Target', [match.DartReturn('int 42')]),
]);
}
@@ -75,17 +72,14 @@ void matchIL$strictCompareConstantEqValue(FlowGraph graph) {
]),
match.block('Function', [
'value' << match.Parameter(index: 0),
match.Branch(match.StrictCompare('value', 'A(0)', kind: '==='),
ifTrue: 'B1', ifFalse: 'B2'),
match.Branch(
match.StrictCompare('value', 'A(0)', kind: '==='),
ifTrue: 'B1',
ifFalse: 'B2',
),
]),
'B1' <<
match.block('Target', [
match.DartReturn('int 0'),
]),
'B2' <<
match.block('Target', [
match.DartReturn('int 42'),
]),
'B1' << match.block('Target', [match.DartReturn('int 0')]),
'B2' << match.block('Target', [match.DartReturn('int 42')]),
]);
}
@@ -108,17 +102,14 @@ void matchIL$strictCompareValueNeConstant(FlowGraph graph) {
]),
match.block('Function', [
'value' << match.Parameter(index: 0),
match.Branch(match.StrictCompare('value', 'A(0)', kind: '!=='),
ifTrue: 'B1', ifFalse: 'B2'),
match.Branch(
match.StrictCompare('value', 'A(0)', kind: '!=='),
ifTrue: 'B1',
ifFalse: 'B2',
),
]),
'B1' <<
match.block('Target', [
match.DartReturn('int 42'),
]),
'B2' <<
match.block('Target', [
match.DartReturn('int 0'),
]),
'B1' << match.block('Target', [match.DartReturn('int 42')]),
'B2' << match.block('Target', [match.DartReturn('int 0')]),
]);
}
@@ -141,17 +132,14 @@ void matchIL$strictCompareConstantNeValue(FlowGraph graph) {
]),
match.block('Function', [
'value' << match.Parameter(index: 0),
match.Branch(match.StrictCompare('value', 'A(0)', kind: '!=='),
ifTrue: 'B1', ifFalse: 'B2'),
match.Branch(
match.StrictCompare('value', 'A(0)', kind: '!=='),
ifTrue: 'B1',
ifFalse: 'B2',
),
]),
'B1' <<
match.block('Target', [
match.DartReturn('int 42'),
]),
'B2' <<
match.block('Target', [
match.DartReturn('int 0'),
]),
'B1' << match.block('Target', [match.DartReturn('int 42')]),
'B2' << match.block('Target', [match.DartReturn('int 0')]),
]);
}
@@ -174,17 +162,14 @@ void matchIL$strictCompareBoolEqTrue(FlowGraph graph) {
]),
match.block('Function', [
'value' << match.Parameter(index: 0),
match.Branch(match.StrictCompare('value', 'true', kind: '==='),
ifTrue: 'B1', ifFalse: 'B2'),
match.Branch(
match.StrictCompare('value', 'true', kind: '==='),
ifTrue: 'B1',
ifFalse: 'B2',
),
]),
'B1' <<
match.block('Target', [
match.DartReturn('false'),
]),
'B2' <<
match.block('Target', [
match.DartReturn('true'),
]),
'B1' << match.block('Target', [match.DartReturn('false')]),
'B2' << match.block('Target', [match.DartReturn('true')]),
]);
}
@@ -207,17 +192,14 @@ void matchIL$strictCompareBoolNeTrue(FlowGraph graph) {
]),
match.block('Function', [
'value' << match.Parameter(index: 0),
match.Branch(match.StrictCompare('value', 'true', kind: '!=='),
ifTrue: 'B1', ifFalse: 'B2'),
match.Branch(
match.StrictCompare('value', 'true', kind: '!=='),
ifTrue: 'B1',
ifFalse: 'B2',
),
]),
'B1' <<
match.block('Target', [
match.DartReturn('true'),
]),
'B2' <<
match.block('Target', [
match.DartReturn('false'),
]),
'B1' << match.block('Target', [match.DartReturn('true')]),
'B2' << match.block('Target', [match.DartReturn('false')]),
]);
}
@@ -240,17 +222,14 @@ void matchIL$equalityCompareValueEqConstant(FlowGraph graph) {
]),
match.block('Function', [
'value' << match.Parameter(index: 0),
match.Branch(match.EqualityCompare('value', 'int 0', kind: '=='),
ifTrue: 'B1', ifFalse: 'B2'),
match.Branch(
match.EqualityCompare('value', 'int 0', kind: '=='),
ifTrue: 'B1',
ifFalse: 'B2',
),
]),
'B1' <<
match.block('Target', [
match.DartReturn('int 1'),
]),
'B2' <<
match.block('Target', [
match.DartReturn('int 42'),
]),
'B1' << match.block('Target', [match.DartReturn('int 1')]),
'B2' << match.block('Target', [match.DartReturn('int 42')]),
]);
}
@@ -277,17 +256,14 @@ void matchIL$foldingOfRepeatedComparison(FlowGraph graph) {
]),
match.block('Function', [
'value' << match.Parameter(index: 0),
match.Branch(match.RelationalOp('value', 'int 1', kind: '>='),
ifTrue: 'B1', ifFalse: 'B2'),
match.Branch(
match.RelationalOp('value', 'int 1', kind: '>='),
ifTrue: 'B1',
ifFalse: 'B2',
),
]),
'B1' <<
match.block('Target', [
match.DartReturn('int 1'),
]),
'B2' <<
match.block('Target', [
match.DartReturn('int 42'),
]),
'B1' << match.block('Target', [match.DartReturn('int 1')]),
'B2' << match.block('Target', [match.DartReturn('int 42')]),
]);
}
@@ -8,8 +8,10 @@ import "package:expect/async_helper.dart";
import "package:expect/expect.dart";
Uri toDartDataUri(String source) {
return Uri.parse("data:application/dart;charset=utf-8,"
"${Uri.encodeComponent(source)}");
return Uri.parse(
"data:application/dart;charset=utf-8,"
"${Uri.encodeComponent(source)}",
);
}
main() {
+9 -7
View File
@@ -11,13 +11,15 @@ import "package:expect/expect.dart";
main(List<String> args) async {
if (args.length == 0) {
final result = await Process.run(Platform.executable, [
...Platform.executableArguments,
Platform.script.toString(),
"with_tz_set"
], environment: <String, String>{
"TZ": "GMT-1"
});
final result = await Process.run(
Platform.executable,
[
...Platform.executableArguments,
Platform.script.toString(),
"with_tz_set",
],
environment: <String, String>{"TZ": "GMT-1"},
);
print('stdout: ${result.stdout}');
print('stderr: ${result.stderr}');
Expect.equals(result.exitCode, 0);
@@ -10,8 +10,10 @@ import 'package:expect/expect.dart';
import "gc/splay_test.dart" deferred as splay;
worker(SendPort sendPort) {
Expect.throws(() => splay.main(),
(e) => e.toString() == "Deferred library splay was not loaded.");
Expect.throws(
() => splay.main(),
(e) => e.toString() == "Deferred library splay was not loaded.",
);
sendPort.send(true);
}
@@ -59,11 +59,14 @@ Future<void> main(List<String> args) async {
'--always_generate_trampolines_for_testing',
'--snapshot-kind=app-aot-elf',
'--elf=$elfFile',
scriptDill
scriptDill,
]);
// Run the AOT runtime with the disassemble flags set.
await run(dartPrecompiledRuntime,
<String>['--disassemble', '--disassemble_stubs', elfFile]);
await run(dartPrecompiledRuntime, <String>[
'--disassemble',
'--disassemble_stubs',
elfFile,
]);
});
}
@@ -33,31 +33,27 @@ Future<void> main(List<String> args) async {
return; // Our IA32 code is not position independent.
}
final result1 = await runDart(
'GENERATE DISASSEMBLY 1',
[
'--deterministic',
'--disassemble',
'--disassemble-relative',
Platform.script.toFilePath(),
'--child'
],
printOut: false);
final result1 = await runDart('GENERATE DISASSEMBLY 1', [
'--deterministic',
'--disassemble',
'--disassemble-relative',
Platform.script.toFilePath(),
'--child',
], printOut: false);
final asm1 = result1.processResult.stderr;
final result2 = await runDart(
'GENERATE DISASSEMBLY 2',
[
'--deterministic',
'--disassemble',
'--disassemble-relative',
Platform.script.toFilePath(),
'--child'
],
printOut: false);
final result2 = await runDart('GENERATE DISASSEMBLY 2', [
'--deterministic',
'--disassemble',
'--disassemble-relative',
Platform.script.toFilePath(),
'--child',
], printOut: false);
final asm2 = result2.processResult.stderr;
Expect.isTrue(
asm1.contains("Code for function"), "Printed at least one function");
asm1.contains("Code for function"),
"Printed at least one function",
);
Expect.stringEquals(asm1, asm2);
}
+3 -2
View File
@@ -18,8 +18,9 @@ ffi.DynamicLibrary dlopenPlatformSpecific(String name, {String path = ""}) {
return ffi.DynamicLibrary.open(fullPath);
}
ffi.DynamicLibrary ffiTestFunctions =
dlopenPlatformSpecific("ffi_test_functions");
ffi.DynamicLibrary ffiTestFunctions = dlopenPlatformSpecific(
"ffi_test_functions",
);
final triggerGc = ffiTestFunctions
.lookupFunction<ffi.Void Function(), void Function()>("TriggerGC");
@@ -181,10 +181,7 @@ void matchIL$callA2(FlowGraph graph) {
match.InstanceCall('obj'),
match.Goto('B12'),
]),
'B12' <<
match.block('Join', [
match.DartReturn(match.any),
]),
'B12' << match.block('Join', [match.DartReturn(match.any)]),
]);
}
@@ -286,18 +283,13 @@ void matchIL$testCallInTryWithControlFlow(FlowGraph graph) {
'value_length' << match.Phi('value_length1', 'value_length2'),
'value_length_unboxed' << match.UnboxInt64('value_length'),
match.Branch(
match.EqualityCompare('pos', 'value_length_unboxed', kind: '=='),
ifTrue: 'B3',
ifFalse: 'B4'),
]),
'B3' <<
match.block('Target', [
match.Goto('B9'),
]),
'B4' <<
match.block('Target', [
match.Goto('B5'),
match.EqualityCompare('pos', 'value_length_unboxed', kind: '=='),
ifTrue: 'B3',
ifFalse: 'B4',
),
]),
'B3' << match.block('Target', [match.Goto('B9')]),
'B4' << match.block('Target', [match.Goto('B5')]),
'B5' << match.tryBlock(tryBody: 'B6', catches: 'B8'),
'B6' <<
match.block('Join', [
@@ -327,17 +319,8 @@ void matchIL$testCallInTryWithControlFlow(FlowGraph graph) {
match.StaticCall('value_substring'),
match.Goto('B7'),
]),
'B8' <<
match.block('CatchBlock', [
match.Goto('B7'),
]),
'B7' <<
match.block('Join', [
match.Goto('B9'),
]),
'B9' <<
match.block('Join', [
match.DartReturn(match.any),
]),
'B8' << match.block('CatchBlock', [match.Goto('B7')]),
'B7' << match.block('Join', [match.Goto('B9')]),
'B9' << match.block('Join', [match.DartReturn(match.any)]),
]);
}
@@ -39,21 +39,11 @@ void main() {
void matchIL$bar(FlowGraph graph) {
graph.dump();
graph.match([
match.block('Graph', [
'c_42' << match.UnboxedConstant(value: 42),
]),
match.block('Function', [
match.Goto('B3', skipUntilMatched: false),
]),
match.block('Graph', ['c_42' << match.UnboxedConstant(value: 42)]),
match.block('Function', [match.Goto('B3', skipUntilMatched: false)]),
'B3' << match.tryBlock(tryBody: 'B4', catches: 'B7'),
'B4' <<
match.block('Join', [
match.Goto('B6', skipUntilMatched: false),
]),
'B6' <<
match.block('Join', [
match.DartReturn('c_42'),
]),
'B4' << match.block('Join', [match.Goto('B6', skipUntilMatched: false)]),
'B6' << match.block('Join', [match.DartReturn('c_42')]),
'B7' << match.block('CatchBlock'),
]);
}
@@ -65,7 +65,9 @@ void _validateFn(String _, int ep) => _validateHelper(ep, null);
// actual target.
_validateTearoffFn(String name, int ep) {
_validateHelper(
ep, name.endsWith("#tearoff") ? tearoffEntryPoint : entryPoint);
ep,
name.endsWith("#tearoff") ? tearoffEntryPoint : entryPoint,
);
}
@pragma("vm:entry-point", "get")
@@ -39,60 +39,76 @@ main(List<String> args) {
}
Expect.throws(
() => myNull.foo(),
(e) =>
e is NoSuchMethodError &&
e.toString().startsWith(
'NoSuchMethodError: The method \'foo\' was called on null.'));
() => myNull.foo(),
(e) =>
e is NoSuchMethodError &&
e.toString().startsWith(
'NoSuchMethodError: The method \'foo\' was called on null.',
),
);
Expect.throws(
() => myNull.foo,
(e) =>
e is NoSuchMethodError &&
e.toString().startsWith(
'NoSuchMethodError: The getter \'foo\' was called on null.'));
() => myNull.foo,
(e) =>
e is NoSuchMethodError &&
e.toString().startsWith(
'NoSuchMethodError: The getter \'foo\' was called on null.',
),
);
Expect.throws(
() => myNull.bar,
(e) =>
e is NoSuchMethodError &&
e.toString().startsWith(
'NoSuchMethodError: The getter \'bar\' was called on null.'));
() => myNull.bar,
(e) =>
e is NoSuchMethodError &&
e.toString().startsWith(
'NoSuchMethodError: The getter \'bar\' was called on null.',
),
);
Expect.throws(
() => myNull.bar(),
(e) =>
e is NoSuchMethodError &&
e.toString().startsWith(
'NoSuchMethodError: The method \'bar\' was called on null.'));
() => myNull.bar(),
(e) =>
e is NoSuchMethodError &&
e.toString().startsWith(
'NoSuchMethodError: The method \'bar\' was called on null.',
),
);
Expect.throws(
() => myNull!,
(e) =>
e is TypeError &&
e.toString().contains('Null check operator used on a null value'));
Expect.throws(() {
myNull.bazz = 3;
},
(e) =>
e is NoSuchMethodError &&
e.toString().startsWith(
'NoSuchMethodError: The setter \'bazz=\' was called on null.'));
() => myNull!,
(e) =>
e is TypeError &&
e.toString().contains('Null check operator used on a null value'),
);
Expect.throws(
() => doubleNull + 2.17,
(e) =>
e is NoSuchMethodError &&
e.toString().startsWith(
'NoSuchMethodError: The method \'+\' was called on null.'));
() {
myNull.bazz = 3;
},
(e) =>
e is NoSuchMethodError &&
e.toString().startsWith(
'NoSuchMethodError: The setter \'bazz=\' was called on null.',
),
);
Expect.throws(
() => doubleNull + 2.17,
(e) =>
e is NoSuchMethodError &&
e.toString().startsWith(
'NoSuchMethodError: The method \'+\' was called on null.',
),
);
Expect.throws(() => 9.81 - doubleNull, (e) => e is TypeError);
Expect.throws(
() => intNull * 7,
(e) =>
e is NoSuchMethodError &&
e.toString().startsWith(
'NoSuchMethodError: The method \'*\' was called on null.'));
() => intNull * 7,
(e) =>
e is NoSuchMethodError &&
e.toString().startsWith(
'NoSuchMethodError: The method \'*\' was called on null.',
),
);
}
@@ -160,9 +160,7 @@ void matchIL$testCreation2(FlowGraph graph) {
'error' << match.AllocateObject(),
match.Throw('error'),
]),
match.block('Target', [
match.DartReturn('S'),
]),
match.block('Target', [match.DartReturn('S')]),
]);
}
@@ -69,13 +69,14 @@ Future testNormalExit() async {
}
@pragma('vm:never-inline')
Future<Finalizer?> testSendAndExitHelper(
{bool trySendFinalizer = false}) async {
Future<Finalizer?> testSendAndExitHelper({
bool trySendFinalizer = false,
}) async {
final port = ReceivePort();
await Isolate.spawn(
runIsolateAttachFinalizer,
[port.sendPort, trySendFinalizer],
);
await Isolate.spawn(runIsolateAttachFinalizer, [
port.sendPort,
trySendFinalizer,
]);
final message = await port.first as List;
print('Received message ($message).');
final value = message[0] as Nonce;
@@ -53,15 +53,18 @@ Future<void> testFinalizerZone() async {
Future<void> testFinalizerException() async {
Object? caughtError;
final finalizer = runZonedGuarded(() {
void callback(Object token) {
throw 'uncaught!';
}
final finalizer = runZonedGuarded(
() {
void callback(Object token) {
throw 'uncaught!';
}
return Finalizer<Nonce>(callback);
}, (Object error, StackTrace stack) {
caughtError = error;
})!;
return Finalizer<Nonce>(callback);
},
(Object error, StackTrace stack) {
caughtError = error;
},
)!;
final detach = Nonce(2022);
final token = Nonce(42);
+5 -2
View File
@@ -17,8 +17,11 @@ class Nonce {
/// Never inline to ensure `object` becomes unreachable.
@pragma('vm:never-inline')
void makeObjectWithFinalizer<T>(Finalizer<T> finalizer, T token,
{Object? detach}) {
void makeObjectWithFinalizer<T>(
Finalizer<T> finalizer,
T token, {
Object? detach,
}) {
final value = Nonce(1);
finalizer.attach(value, token, detach: detach);
}
@@ -8,7 +8,8 @@
void main() async {
final RegExp _dateTimeFULLExp = RegExp(
r'([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2][0-9]|3[0-1])(T([01][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)(\.[0-9]+)?(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00)))?)?)?');
r'([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2][0-9]|3[0-1])(T([01][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)(\.[0-9]+)?(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00)))?)?)?',
);
String a = "2023-01-07T16:51:24.868498+01:00";
@@ -6,47 +6,178 @@ import 'package:expect/expect.dart';
dynamic global;
class Foo<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9,
T10, T11, T12, T13, T14, T15, T16, T17, T18, T19,
T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
T30, T31> {
class Foo<
T0,
T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
T9,
T10,
T11,
T12,
T13,
T14,
T15,
T16,
T17,
T18,
T19,
T20,
T21,
T22,
T23,
T24,
T25,
T26,
T27,
T28,
T29,
T30,
T31
> {
@pragma('vm:never-inline')
Generic<T31> testForT31(dynamic arg) {
global = '''$T0 $T1 $T2 $T3 $T4 $T5 $T6 $T7 $T8 $T9
global =
'''$T0 $T1 $T2 $T3 $T4 $T5 $T6 $T7 $T8 $T9
$T10 $T11 $T12 $T13 $T14 $T15 $T16 $T17 $T18 $T19
$T20 $T21 $T22 $T23 $T24 $T25 $T26 $T27 $T28 $T29
$T30 $T31''';
return arg as Generic<T31>;
}
}
@pragma('vm:never-inline')
Generic<T31> foo<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9,
T10, T11, T12, T13, T14, T15, T16, T17, T18, T19,
T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
T30, T31>(dynamic arg) {
global = '''$T0 $T1 $T2 $T3 $T4 $T5 $T6 $T7 $T8 $T9
Generic<T31> foo<
T0,
T1,
T2,
T3,
T4,
T5,
T6,
T7,
T8,
T9,
T10,
T11,
T12,
T13,
T14,
T15,
T16,
T17,
T18,
T19,
T20,
T21,
T22,
T23,
T24,
T25,
T26,
T27,
T28,
T29,
T30,
T31
>(dynamic arg) {
global =
'''$T0 $T1 $T2 $T3 $T4 $T5 $T6 $T7 $T8 $T9
$T10 $T11 $T12 $T13 $T14 $T15 $T16 $T17 $T18 $T19
$T20 $T21 $T22 $T23 $T24 $T25 $T26 $T27 $T28 $T29
$T30 $T31''';
return arg as Generic<T31>;
return arg as Generic<T31>;
}
class Generic<T> {}
main() {
final genericString = Generic<String>();
Expect.isTrue(identical(Foo<bool, bool, bool, bool, bool, bool, bool, bool, bool, bool,
bool, bool, bool, bool, bool, bool, bool, bool, bool, bool,
bool, bool, bool, bool, bool, bool, bool, bool, bool, bool,
bool, String>().testForT31(genericString), genericString));
Expect.isTrue(
identical(
Foo<
bool,
bool,
bool,
bool,
bool,
bool,
bool,
bool,
bool,
bool,
bool,
bool,
bool,
bool,
bool,
bool,
bool,
bool,
bool,
bool,
bool,
bool,
bool,
bool,
bool,
bool,
bool,
bool,
bool,
bool,
bool,
String
>()
.testForT31(genericString),
genericString,
),
);
Expect.isTrue((global as String).endsWith('bool String'));
Expect.isTrue(identical(
foo<int, int, int, int, int, int, int, int, int, int,
int, int, int, int, int, int, int, int, int, int,
int, int, int, int, int, int, int, int, int, int,
int, String>(genericString), genericString));
Expect.isTrue(
identical(
foo<
int,
int,
int,
int,
int,
int,
int,
int,
int,
int,
int,
int,
int,
int,
int,
int,
int,
int,
int,
int,
int,
int,
int,
int,
int,
int,
int,
int,
int,
int,
int,
String
>(genericString),
genericString,
),
);
Expect.isTrue((global as String).endsWith('int String'));
}
@@ -41,7 +41,8 @@ class Foo {
var field31 = ++_next;
@pragma('vm:never-inline')
String toString() => '$field0 $field1 $field2 $field3 $field4 $field5'
String toString() =>
'$field0 $field1 $field2 $field3 $field4 $field5'
'$field6 $field7 $field8 $field9 $field10 $field11'
'$field12 $field13 $field14 $field15 $field16 $field17'
'$field18 $field19 $field20 $field21 $field22 $field23'
@@ -246,14 +246,18 @@ void main(List<String> args) {
testNarrowingThroughIndexedLoadFromGrowableArray([a1]);
testNarrowingThroughIndexedLoadFromGrowableArray([a0]);
testNarrowingThroughIndexedLoadFromFixedArray(
List<A1>.filled(1, a1, growable: false));
List<A1>.filled(1, a1, growable: false),
);
testNarrowingThroughIndexedLoadFromFixedArray(
List<A0>.filled(1, a0, growable: false));
List<A0>.filled(1, a0, growable: false),
);
}
}
void matchIL$B$testNarrowingThroughThisCallWithPositionalParam(
FlowGraph beforeLICM, FlowGraph afterLICM) {
FlowGraph beforeLICM,
FlowGraph afterLICM,
) {
final env = beforeLICM.match([
match.block('Graph'),
match.block('Function', [
@@ -265,14 +269,18 @@ void matchIL$B$testNarrowingThroughThisCallWithPositionalParam(
'B1' <<
match.block('Join', [
match.CheckStackOverflow(),
match.Branch(match.RelationalOp(match.any, match.any, kind: '<'),
ifTrue: 'B2'),
match.Branch(
match.RelationalOp(match.any, match.any, kind: '<'),
ifTrue: 'B2',
),
]),
'B2' <<
match.block('Target', [
'this_cid' << match.LoadClassId('this'),
match.Branch(match.EqualityCompare('this_cid', match.any, kind: '=='),
ifTrue: 'B3'),
match.Branch(
match.EqualityCompare('this_cid', match.any, kind: '=='),
ifTrue: 'B3',
),
]),
'B3' <<
match.block('Target', [
@@ -297,13 +305,17 @@ void matchIL$B$testNarrowingThroughThisCallWithPositionalParam(
'B1' <<
match.block('Join', [
match.CheckStackOverflow(),
match.Branch(match.RelationalOp(match.any, match.any, kind: '<'),
ifTrue: 'B2'),
match.Branch(
match.RelationalOp(match.any, match.any, kind: '<'),
ifTrue: 'B2',
),
]),
'B2' <<
match.block('Target', [
match.Branch(match.EqualityCompare('this_cid', match.any, kind: '=='),
ifTrue: 'B3'),
match.Branch(
match.EqualityCompare('this_cid', match.any, kind: '=='),
ifTrue: 'B3',
),
]),
'B3' <<
match.block('Target', [
@@ -316,14 +328,20 @@ void matchIL$B$testNarrowingThroughThisCallWithPositionalParam(
}
void matchIL$B$testNarrowingThroughThisCallWithNamedParams(
FlowGraph beforeLICM, FlowGraph afterLICM) {
FlowGraph beforeLICM,
FlowGraph afterLICM,
) {
// Graph shape is basically the same.
matchIL$B$testNarrowingThroughThisCallWithPositionalParam(
beforeLICM, afterLICM);
beforeLICM,
afterLICM,
);
}
void matchIL$testNarrowingThroughIsCheckOnSubclass(
FlowGraph beforeLICM, FlowGraph afterLICM) {
FlowGraph beforeLICM,
FlowGraph afterLICM,
) {
final env = beforeLICM.match([
match.block('Graph'),
match.block('Function', [
@@ -334,14 +352,18 @@ void matchIL$testNarrowingThroughIsCheckOnSubclass(
'B1' <<
match.block('Join', [
match.CheckStackOverflow(),
match.Branch(match.RelationalOp(match.any, match.any, kind: '<'),
ifTrue: 'B2'),
match.Branch(
match.RelationalOp(match.any, match.any, kind: '<'),
ifTrue: 'B2',
),
]),
'B2' <<
match.block('Target', [
'b_cid' << match.LoadClassId('b'),
match.Branch(match.EqualityCompare('b_cid', match.any, kind: '=='),
ifTrue: 'B3'),
match.Branch(
match.EqualityCompare('b_cid', match.any, kind: '=='),
ifTrue: 'B3',
),
]),
'B3' <<
match.block('Target', [
@@ -364,13 +386,17 @@ void matchIL$testNarrowingThroughIsCheckOnSubclass(
'B1' <<
match.block('Join', [
match.CheckStackOverflow(),
match.Branch(match.RelationalOp(match.any, match.any, kind: '<'),
ifTrue: 'B2'),
match.Branch(
match.RelationalOp(match.any, match.any, kind: '<'),
ifTrue: 'B2',
),
]),
'B2' <<
match.block('Target', [
match.Branch(match.EqualityCompare('b_cid', match.any, kind: '=='),
ifTrue: 'B3'),
match.Branch(
match.EqualityCompare('b_cid', match.any, kind: '=='),
ifTrue: 'B3',
),
]),
'B3' <<
match.block('Target', [
@@ -381,7 +407,9 @@ void matchIL$testNarrowingThroughIsCheckOnSubclass(
}
void matchIL$testNarrowingThroughIsCheckWithTypeArgMonomorphic(
FlowGraph beforeLICM, FlowGraph afterLICM) {
FlowGraph beforeLICM,
FlowGraph afterLICM,
) {
final env = beforeLICM.match([
match.block('Graph'),
match.block('Function', [
@@ -392,15 +420,18 @@ void matchIL$testNarrowingThroughIsCheckWithTypeArgMonomorphic(
'B1' <<
match.block('Join', [
match.CheckStackOverflow(),
match.Branch(match.RelationalOp(match.any, match.any, kind: '<'),
ifTrue: 'B2'),
match.Branch(
match.RelationalOp(match.any, match.any, kind: '<'),
ifTrue: 'B2',
),
]),
'B2' <<
match.block('Target', [
'b_is_B<A1>' << match.InstanceOf('b', match.any, match.any),
match.Branch(
match.StrictCompare('b_is_B<A1>', match.any, kind: '==='),
ifTrue: 'B3'),
match.StrictCompare('b_is_B<A1>', match.any, kind: '==='),
ifTrue: 'B3',
),
]),
'B3' <<
match.block('Target', [
@@ -422,15 +453,18 @@ void matchIL$testNarrowingThroughIsCheckWithTypeArgMonomorphic(
'B1' <<
match.block('Join', [
match.CheckStackOverflow(),
match.Branch(match.RelationalOp(match.any, match.any, kind: '<'),
ifTrue: 'B2'),
match.Branch(
match.RelationalOp(match.any, match.any, kind: '<'),
ifTrue: 'B2',
),
]),
'B2' <<
match.block('Target', [
'b_is_B<A1>' << match.InstanceOf('b', match.any, match.any),
match.Branch(
match.StrictCompare('b_is_B<A1>', match.any, kind: '==='),
ifTrue: 'B3'),
match.StrictCompare('b_is_B<A1>', match.any, kind: '==='),
ifTrue: 'B3',
),
]),
'B3' <<
match.block('Target', [
@@ -441,7 +475,9 @@ void matchIL$testNarrowingThroughIsCheckWithTypeArgMonomorphic(
}
void matchIL$testNarrowingThroughAsCheckWithTypeArgPolymorphic(
FlowGraph beforeLICM, FlowGraph afterLICM) {
FlowGraph beforeLICM,
FlowGraph afterLICM,
) {
final env = beforeLICM.match([
match.block('Graph'),
match.block('Function', [
@@ -452,13 +488,18 @@ void matchIL$testNarrowingThroughAsCheckWithTypeArgPolymorphic(
'B1' <<
match.block('Join', [
match.CheckStackOverflow(),
match.Branch(match.RelationalOp(match.any, match.any, kind: '<'),
ifTrue: 'B2'),
match.Branch(
match.RelationalOp(match.any, match.any, kind: '<'),
ifTrue: 'B2',
),
]),
'B2' <<
match.block('Target', [
match.Branch(match.EqualityCompare(match.any, match.any, kind: '=='),
ifTrue: 'B3', ifFalse: 'B4'),
match.Branch(
match.EqualityCompare(match.any, match.any, kind: '=='),
ifTrue: 'B3',
ifFalse: 'B4',
),
]),
'B3' << match.block('Target', [match.Throw(match.any)]),
'B4' <<
@@ -481,13 +522,18 @@ void matchIL$testNarrowingThroughAsCheckWithTypeArgPolymorphic(
'B1' <<
match.block('Join', [
match.CheckStackOverflow(),
match.Branch(match.RelationalOp(match.any, match.any, kind: '<'),
ifTrue: 'B2'),
match.Branch(
match.RelationalOp(match.any, match.any, kind: '<'),
ifTrue: 'B2',
),
]),
'B2' <<
match.block('Target', [
match.Branch(match.EqualityCompare(match.any, match.any, kind: '=='),
ifTrue: 'B3', ifFalse: 'B4'),
match.Branch(
match.EqualityCompare(match.any, match.any, kind: '=='),
ifTrue: 'B3',
ifFalse: 'B4',
),
]),
'B3' << match.block('Target', [match.Throw(match.any)]),
'B4' <<
@@ -500,7 +546,9 @@ void matchIL$testNarrowingThroughAsCheckWithTypeArgPolymorphic(
}
void matchIL$testNarrowingThroughPhiOfAsChecksWithTypeArgPolymorphic(
FlowGraph beforeLICM, FlowGraph afterLICM) {
FlowGraph beforeLICM,
FlowGraph afterLICM,
) {
final env = beforeLICM.match([
match.block('Graph'),
match.block('Function', [
@@ -511,19 +559,27 @@ void matchIL$testNarrowingThroughPhiOfAsChecksWithTypeArgPolymorphic(
'B1' <<
match.block('Join', [
match.CheckStackOverflow(),
match.Branch(match.RelationalOp(match.any, match.any, kind: '<'),
ifTrue: 'B2'),
match.Branch(
match.RelationalOp(match.any, match.any, kind: '<'),
ifTrue: 'B2',
),
]),
'B2' <<
match.block('Target', [
match.Branch(match.EqualityCompare(match.any, match.any, kind: '=='),
ifTrue: 'B3', ifFalse: 'B4'),
match.Branch(
match.EqualityCompare(match.any, match.any, kind: '=='),
ifTrue: 'B3',
ifFalse: 'B4',
),
]),
'B3' << match.block('Target', [match.Throw(match.any)]),
'B4' <<
match.block('Target', [
match.Branch(match.EqualityCompare(match.any, match.any, kind: '=='),
ifTrue: 'B5', ifFalse: 'B6'),
match.Branch(
match.EqualityCompare(match.any, match.any, kind: '=='),
ifTrue: 'B5',
ifFalse: 'B6',
),
]),
'B5' <<
match.block('Target', [
@@ -557,19 +613,27 @@ void matchIL$testNarrowingThroughPhiOfAsChecksWithTypeArgPolymorphic(
'B1' <<
match.block('Join', [
match.CheckStackOverflow(),
match.Branch(match.RelationalOp(match.any, match.any, kind: '<'),
ifTrue: 'B2'),
match.Branch(
match.RelationalOp(match.any, match.any, kind: '<'),
ifTrue: 'B2',
),
]),
'B2' <<
match.block('Target', [
match.Branch(match.EqualityCompare(match.any, match.any, kind: '=='),
ifTrue: 'B3', ifFalse: 'B4'),
match.Branch(
match.EqualityCompare(match.any, match.any, kind: '=='),
ifTrue: 'B3',
ifFalse: 'B4',
),
]),
'B3' << match.block('Target', [match.Throw(match.any)]),
'B4' <<
match.block('Target', [
match.Branch(match.EqualityCompare(match.any, match.any, kind: '=='),
ifTrue: 'B5', ifFalse: 'B6'),
match.Branch(
match.EqualityCompare(match.any, match.any, kind: '=='),
ifTrue: 'B5',
ifFalse: 'B6',
),
]),
'B5' <<
match.block('Target', [
@@ -590,7 +654,9 @@ void matchIL$testNarrowingThroughPhiOfAsChecksWithTypeArgPolymorphic(
}
void matchIL$testNarrowingThroughIndexedLoadFromGrowableArray(
FlowGraph beforeLICM, FlowGraph afterLICM) {
FlowGraph beforeLICM,
FlowGraph afterLICM,
) {
final env = beforeLICM.match([
match.block('Graph'),
match.block('Function', [
@@ -602,15 +668,18 @@ void matchIL$testNarrowingThroughIndexedLoadFromGrowableArray(
'B1' <<
match.block('Join', [
match.CheckStackOverflow(),
match.Branch(match.RelationalOp(match.any, match.any, kind: '<'),
ifTrue: 'B2'),
match.Branch(
match.RelationalOp(match.any, match.any, kind: '<'),
ifTrue: 'B2',
),
]),
'B2' <<
match.block('Target', [
'this_is_List' << match.InstanceOf('this', match.any, match.any),
match.Branch(
match.StrictCompare('this_is_List', match.any, kind: '==='),
ifTrue: 'B3'),
match.StrictCompare('this_is_List', match.any, kind: '==='),
ifTrue: 'B3',
),
]),
'B3' <<
match.block('Target', [
@@ -632,15 +701,18 @@ void matchIL$testNarrowingThroughIndexedLoadFromGrowableArray(
'B1' <<
match.block('Join', [
match.CheckStackOverflow(),
match.Branch(match.RelationalOp(match.any, match.any, kind: '<'),
ifTrue: 'B2'),
match.Branch(
match.RelationalOp(match.any, match.any, kind: '<'),
ifTrue: 'B2',
),
]),
'B2' <<
match.block('Target', [
'this_is_List' << match.InstanceOf('this', match.any, match.any),
match.Branch(
match.StrictCompare('this_is_List', match.any, kind: '==='),
ifTrue: 'B3'),
match.StrictCompare('this_is_List', match.any, kind: '==='),
ifTrue: 'B3',
),
]),
'B3' <<
match.block('Target', [
@@ -650,13 +722,19 @@ void matchIL$testNarrowingThroughIndexedLoadFromGrowableArray(
}
void matchIL$testNarrowingThroughIsCheckWithTypeArgPolymorphic(
FlowGraph beforeLICM, FlowGraph afterLICM) {
FlowGraph beforeLICM,
FlowGraph afterLICM,
) {
matchIL$testNarrowingThroughIsCheckWithTypeArgMonomorphic(
beforeLICM, afterLICM);
beforeLICM,
afterLICM,
);
}
void matchIL$testNarrowingThroughIndexedLoadFromFixedArray(
FlowGraph beforeLICM, FlowGraph afterLICM) {
FlowGraph beforeLICM,
FlowGraph afterLICM,
) {
final env = beforeLICM.match([
match.block('Graph'),
match.block('Function', [
@@ -667,15 +745,18 @@ void matchIL$testNarrowingThroughIndexedLoadFromFixedArray(
'B1' <<
match.block('Join', [
match.CheckStackOverflow(),
match.Branch(match.RelationalOp(match.any, match.any, kind: '<'),
ifTrue: 'B2'),
match.Branch(
match.RelationalOp(match.any, match.any, kind: '<'),
ifTrue: 'B2',
),
]),
'B2' <<
match.block('Target', [
'this_is_List' << match.InstanceOf('this', match.any, match.any),
match.Branch(
match.StrictCompare('this_is_List', match.any, kind: '==='),
ifTrue: 'B3'),
match.StrictCompare('this_is_List', match.any, kind: '==='),
ifTrue: 'B3',
),
]),
'B3' <<
match.block('Target', [
@@ -696,15 +777,18 @@ void matchIL$testNarrowingThroughIndexedLoadFromFixedArray(
'B1' <<
match.block('Join', [
match.CheckStackOverflow(),
match.Branch(match.RelationalOp(match.any, match.any, kind: '<'),
ifTrue: 'B2'),
match.Branch(
match.RelationalOp(match.any, match.any, kind: '<'),
ifTrue: 'B2',
),
]),
'B2' <<
match.block('Target', [
'this_is_List' << match.InstanceOf('this', match.any, match.any),
match.Branch(
match.StrictCompare('this_is_List', match.any, kind: '==='),
ifTrue: 'B3'),
match.StrictCompare('this_is_List', match.any, kind: '==='),
ifTrue: 'B3',
),
]),
'B3' <<
match.block('Target', [
@@ -30,7 +30,8 @@ Future main() async {
});
}
String dartTestFile(String zoneKey, String zoneValue) => '''
String dartTestFile(String zoneKey, String zoneValue) =>
'''
import 'dart:async';
import 'dart:convert';
import 'dart:isolate';
@@ -77,10 +77,18 @@ List<dynamic> testAllVariants(dynamic Function(bool, bool) f) {
void main(List<String> args) {
shouldPrint = args.contains("shouldPrint");
Expect.listEquals(
[10, 10, null, null], testAllVariants(testDelayAllocationsUnsunk));
Expect.listEquals(
[10, 10, 42, null], testAllVariants(testDelayAllocationsSunk));
Expect.listEquals([
10,
10,
null,
null,
], testAllVariants(testDelayAllocationsUnsunk));
Expect.listEquals([
10,
10,
42,
null,
], testAllVariants(testDelayAllocationsSunk));
}
void matchIL$testDelayAllocationsUnsunk(FlowGraph afterDelayAllocations) {
@@ -89,8 +97,8 @@ void matchIL$testDelayAllocationsUnsunk(FlowGraph afterDelayAllocations) {
match.block('Graph'),
match.block('Function', [
// Allocation must stay unsunk
match.AllocateObject()
])
match.AllocateObject(),
]),
]);
}
@@ -100,20 +108,14 @@ void matchIL$testDelayAllocationsSunk(FlowGraph afterDelayAllocations) {
match.block('Graph'),
match.block('Function', [
// Allocation must be sunk from this block.
match.Branch(match.StrictCompare(match.any, match.any, kind: '==='),
ifTrue: 'B3', ifFalse: 'B4'),
match.Branch(
match.StrictCompare(match.any, match.any, kind: '==='),
ifTrue: 'B3',
ifFalse: 'B4',
),
]),
'B3' <<
match.block('Target', [
match.Goto('B5'),
]),
'B4' <<
match.block('Target', [
match.Goto('B5'),
]),
'B5' <<
match.block('Join', [
match.AllocateObject(),
]),
'B3' << match.block('Target', [match.Goto('B5')]),
'B4' << match.block('Target', [match.Goto('B5')]),
'B5' << match.block('Join', [match.AllocateObject()]),
]);
}
@@ -25,138 +25,140 @@ main() {
}
final foo = Foo(
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53,
54,
55,
56,
57,
58,
59,
60,
61,
62,
63,
64);
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53,
54,
55,
56,
57,
58,
59,
60,
61,
62,
63,
64,
);
final foo2 = Foo(
2 * 0,
2 * 1,
2 * 2,
2 * 3,
2 * 4,
2 * 5,
2 * 6,
2 * 7,
2 * 8,
2 * 9,
2 * 10,
2 * 11,
2 * 12,
2 * 13,
2 * 14,
2 * 15,
2 * 16,
2 * 17,
2 * 18,
2 * 19,
2 * 20,
2 * 21,
2 * 22,
2 * 23,
2 * 24,
2 * 25,
2 * 26,
2 * 27,
2 * 28,
2 * 29,
2 * 30,
2 * 31,
2 * 32,
2 * 33,
2 * 34,
2 * 35,
2 * 36,
2 * 37,
2 * 38,
2 * 39,
2 * 40,
2 * 41,
2 * 42,
2 * 43,
2 * 44,
2 * 45,
2 * 46,
2 * 47,
2 * 48,
2 * 49,
2 * 50,
2 * 51,
2 * 52,
2 * 53,
2 * 54,
2 * 55,
2 * 56,
2 * 57,
2 * 58,
2 * 59,
2 * 60,
2 * 61,
2 * 62,
2 * 63,
2 * 64);
2 * 0,
2 * 1,
2 * 2,
2 * 3,
2 * 4,
2 * 5,
2 * 6,
2 * 7,
2 * 8,
2 * 9,
2 * 10,
2 * 11,
2 * 12,
2 * 13,
2 * 14,
2 * 15,
2 * 16,
2 * 17,
2 * 18,
2 * 19,
2 * 20,
2 * 21,
2 * 22,
2 * 23,
2 * 24,
2 * 25,
2 * 26,
2 * 27,
2 * 28,
2 * 29,
2 * 30,
2 * 31,
2 * 32,
2 * 33,
2 * 34,
2 * 35,
2 * 36,
2 * 37,
2 * 38,
2 * 39,
2 * 40,
2 * 41,
2 * 42,
2 * 43,
2 * 44,
2 * 45,
2 * 46,
2 * 47,
2 * 48,
2 * 49,
2 * 50,
2 * 51,
2 * 52,
2 * 53,
2 * 54,
2 * 55,
2 * 56,
2 * 57,
2 * 58,
2 * 59,
2 * 60,
2 * 61,
2 * 62,
2 * 63,
2 * 64,
);
class Bar {
final int field64;
@@ -236,73 +238,75 @@ class Foo implements Bar {
final int field64;
Foo(
this.field0,
this.field1,
this.field2,
this.field3,
this.field4,
this.field5,
this.field6,
this.field7,
this.field8,
this.field9,
this.field10,
this.field11,
this.field12,
this.field13,
this.field14,
this.field15,
this.field16,
this.field17,
this.field18,
this.field19,
this.field20,
this.field21,
this.field22,
this.field23,
this.field24,
this.field25,
this.field26,
this.field27,
this.field28,
this.field29,
this.field30,
this.field31,
this.field32,
this.field33,
this.field34,
this.field35,
this.field36,
this.field37,
this.field38,
this.field39,
this.field40,
this.field41,
this.field42,
this.field43,
this.field44,
this.field45,
this.field46,
this.field47,
this.field48,
this.field49,
this.field50,
this.field51,
this.field52,
this.field53,
this.field54,
this.field55,
this.field56,
this.field57,
this.field58,
this.field59,
this.field60,
this.field61,
this.field62,
this.field63,
this.field64);
this.field0,
this.field1,
this.field2,
this.field3,
this.field4,
this.field5,
this.field6,
this.field7,
this.field8,
this.field9,
this.field10,
this.field11,
this.field12,
this.field13,
this.field14,
this.field15,
this.field16,
this.field17,
this.field18,
this.field19,
this.field20,
this.field21,
this.field22,
this.field23,
this.field24,
this.field25,
this.field26,
this.field27,
this.field28,
this.field29,
this.field30,
this.field31,
this.field32,
this.field33,
this.field34,
this.field35,
this.field36,
this.field37,
this.field38,
this.field39,
this.field40,
this.field41,
this.field42,
this.field43,
this.field44,
this.field45,
this.field46,
this.field47,
this.field48,
this.field49,
this.field50,
this.field51,
this.field52,
this.field53,
this.field54,
this.field55,
this.field56,
this.field57,
this.field58,
this.field59,
this.field60,
this.field61,
this.field62,
this.field63,
this.field64,
);
toString() => '''
toString() =>
'''
$field0;
$field1;
$field2;
@@ -7,43 +7,92 @@ bool var1 = false;
int var2 = -49;
double var3 = double.maxFinite;
String var4 = '5Cw)';
List<int> var5 = [ 8589934591 ];
Map<int, String> var6 = { 0 : '\u2665', 1 : '7\u{1f600}\u{1f600}t\u2665s', 2 : '\u2665&)I', 3 : 'G\u2665\u{1f600}e' };
List<int> var5 = [8589934591];
Map<int, String> var6 = {
0: '\u2665',
1: '7\u{1f600}\u{1f600}t\u2665s',
2: '\u2665&)I',
3: 'G\u2665\u{1f600}e',
};
List<int> foo0(List<int> par1, int par2, int par3) {
var6 ??= var6;
var4 ??= '';
par1 = var5;
return [ -94 ];
return [-94];
}
int foo1(Map<int, String> par1, bool par2) {
print((-((((var4 == (var4).toLowerCase()) ? false : par2) ? (-(double.nan)) : (var1 ? (((false ? true : var1) ? (par2 ? ((-((double.maxFinite + var3)))).roundToDouble() : (-(var3))) : var3)).abs() : var3)))));
{ List<int> loc0 = [ 95 ];
print(
(-((((var4 == (var4).toLowerCase()) ? false : par2)
? (-(double.nan))
: (var1
? (((false ? true : var1)
? (par2
? ((-((double.maxFinite + var3)))).roundToDouble()
: (-(var3)))
: var3))
.abs()
: var3)))),
);
{
List<int> loc0 = [95];
return var2;
}
}
String foo2() {
var3 += (true ? ((var3).remainder((var1 ? (-(0.20648281590433248)) : double.maxFinite)) + double.maxFinite) : (var3 * var3));
var3 += (true
? ((var3).remainder(
(var1 ? (-(0.20648281590433248)) : double.maxFinite),
) +
double.maxFinite)
: (var3 * var3));
var2 %= (var2--);
var6 = var6;
return (var1 ? (false ? (((!(true)) || false) ? var4 : ((var6).isEmpty ? var4 : 'I#')) : var4) : 'XLH+c\u2665\u2665');
return (var1
? (false
? (((!(true)) || false) ? var4 : ((var6).isEmpty ? var4 : 'I#'))
: var4)
: 'XLH+c\u2665\u2665');
}
class X0 {
class X0 {
String fld0_0 = '\u2665';
String foo0_0() {
if (((({ 0 : 'e\u{1f600}mw', 1 : 'XZPq', 2 : '2l', 3 : 'EI' } ?? { 0 : '1fG', 1 : 'LV\u2665s\u{1f600}s\u2665', 2 : '\u{1f600}#', 3 : 'V' }) ?? { 0 : 'Z6' })).isNotEmpty) {
if (((({0: 'e\u{1f600}mw', 1: 'XZPq', 2: '2l', 3: 'EI'} ??
{
0: '1fG',
1: 'LV\u2665s\u{1f600}s\u2665',
2: '\u{1f600}#',
3: 'V',
}) ??
{0: 'Z6'}))
.isNotEmpty) {
var4 ??= var4;
} else {
if ((var5 == ((var1 ? ((!((false ? var1 : (!((true && (var0 ? (false ? (false ? false : var1) : true) : var1))))))) ? var0 : var1) : false) ? ((([ -9223372030412324863, 21, -97 ] + var5) ?? ([ -9223372034707292160, -16, 6 ] + var5)) + ([ 83, -52, 18 ]).sublist((++var2))) : ((var1 ? var5 : var5)).sublist(foo1(var6, true))))) {
{ int loc0 = (var2--);
if ((var5 ==
((var1
? ((!((false
? var1
: (!((true &&
(var0
? (false ? (false ? false : var1) : true)
: var1)))))))
? var0
: var1)
: false)
? ((([-9223372030412324863, 21, -97] + var5) ??
([-9223372034707292160, -16, 6] + var5)) +
([83, -52, 18]).sublist((++var2)))
: ((var1 ? var5 : var5)).sublist(foo1(var6, true))))) {
{
int loc0 = (var2--);
if (false) {
fld0_0 ??= '\u26655JnN';
{ Map<int, String> loc1 = var6;
{
Map<int, String> loc1 = var6;
return var4;
}
}
@@ -54,8 +103,19 @@ class X0 {
}
void run() {
if ((foo0([ -23, -74, 8589934591 ], (true ? (-(-9223372030412324863)) : var2), (var0 ? var2 : foo1({ 0 : 'kU0', 1 : '\u{1f600}', 2 : '\u2665M' }, (var1 && (var2).isEven)))) == [ 81, -9223372030412324865, 56, 62 ])) {
var6 ??= { 0 : '\u{1f600}\u{1f600}D\u26652', 1 : 'yJb\u26657+' };
if ((foo0(
[-23, -74, 8589934591],
(true ? (-(-9223372030412324863)) : var2),
(var0
? var2
: foo1({
0: 'kU0',
1: '\u{1f600}',
2: '\u2665M',
}, (var1 && (var2).isEven))),
) ==
[81, -9223372030412324865, 56, 62])) {
var6 ??= {0: '\u{1f600}\u{1f600}D\u26652', 1: 'yJb\u26657+'};
return;
} else {
return;
@@ -64,13 +124,21 @@ class X0 {
}
class X1 extends X0 {
double fld1_0 = 0.6358731486904787;
bool foo1_0() {
{ List<int> loc0 = (foo0(var5, (var1 ? foo1({ 0 : '\u26657@MJF', 1 : 'J' }, true) : (~((--var2)))), ([ 6442450945 ]).removeLast()) + foo0([ 58 ], (-(var2)), (var2++)));
print(foo0([ 69 ], 97, 63));
var5 = (((var5).sublist(var2)).sublist(var2)).sublist(((-(var3))).toInt());
{
List<int> loc0 =
(foo0(
var5,
(var1 ? foo1({0: '\u26657@MJF', 1: 'J'}, true) : (~((--var2)))),
([6442450945]).removeLast(),
) +
foo0([58], (-(var2)), (var2++)));
print(foo0([69], 97, 63));
var5 = (((var5).sublist(
var2,
)).sublist(var2)).sublist(((-(var3))).toInt());
}
var1 = (!(var0));
print((!(((-(double.infinity)) != double.minPositive))));
@@ -80,41 +148,80 @@ class X1 extends X0 {
List<int> foo1_1(bool par1, double par2, int par3) {
print(foo2());
fld1_0 = (-(double.infinity));
var0 = (([ -9223372036854775808, -19 ]).remove(foo1(var6, ((-((par3++))) < var2))) ? (var4 == 'Z72') : var1);
return foo0(foo0((foo0(([ 14, -79 ] ?? var5), (-(par3)), ((true ? true : (!(var1))) ? (var0 ? (-73 * par3) : 53) : 66)) + (var1 ? var5 : [ 17 ])), ((true ? var1 : (par1 ? (!(false)) : par1)) ? par3 : var2), foo1(var6, true)), foo1({ 0 : '1okmvo', 1 : 'Cyn', 2 : 'Iq\u{1f600}' }, (!((!(foo1_0()))))), (par1 ? (~((foo1_0() ? (--var2) : -1))) : (par1 ? var2 : 74)));
var0 =
(([
-9223372036854775808,
-19,
]).remove(foo1(var6, ((-((par3++))) < var2)))
? (var4 == 'Z72')
: var1);
return foo0(
foo0(
(foo0(
([14, -79] ?? var5),
(-(par3)),
((true ? true : (!(var1))) ? (var0 ? (-73 * par3) : 53) : 66),
) +
(var1 ? var5 : [17])),
((true ? var1 : (par1 ? (!(false)) : par1)) ? par3 : var2),
foo1(var6, true),
),
foo1({0: '1okmvo', 1: 'Cyn', 2: 'Iq\u{1f600}'}, (!((!(foo1_0()))))),
(par1 ? (~((foo1_0() ? (--var2) : -1))) : (par1 ? var2 : 74)),
);
}
void run() {
super.run();
if ((false ? var0 : ({ 0 : 'SVw', 1 : '\u266576Q', 2 : '\u2665b&E' }).containsValue(var4))) {
if ((false
? var0
: ({0: 'SVw', 1: '\u266576Q', 2: '\u2665b&E'}).containsValue(var4))) {
return;
}
}
}
class X2 extends X1 {
String fld2_0 = '';
Map<int, String> fld2_1 = { 0 : '\u{1f600}\u2665F8', 1 : '\u{1f600}Kd', 2 : 'CW6e@d' };
Map<int, String> fld2_2 = { 0 : 'MM3Ogd\u{1f600}', 1 : 'D', 2 : 'I\u{1f600}2kH4\u{1f600}' };
Map<int, String> fld2_1 = {
0: '\u{1f600}\u2665F8',
1: '\u{1f600}Kd',
2: 'CW6e@d',
};
Map<int, String> fld2_2 = {
0: 'MM3Ogd\u{1f600}',
1: 'D',
2: 'I\u{1f600}2kH4\u{1f600}',
};
List<int>? foo2_0(String par1, double par2, int par3) {
var6 ??= ({ 0 : 'hVMi', 1 : '', 2 : 'S' } ?? { 0 : '9c\u{1f600}\u{1f600}\u{1f600}dW', 1 : 'g(Fu\u{1f600}bX', 2 : 'Pi2Z\u{1f600}', 3 : 'O\u2665' });
var6 ??=
({0: 'hVMi', 1: '', 2: 'S'} ??
{
0: '9c\u{1f600}\u{1f600}\u{1f600}dW',
1: 'g(Fu\u{1f600}bX',
2: 'Pi2Z\u{1f600}',
3: 'O\u2665',
});
for (int loc0 = 0; loc0 < 84; loc0++) {
return (((!((!(var1)))) ? false : false) ? var5 : (false ? var5 : [ -9223372030412324864 ]));
return (((!((!(var1)))) ? false : false)
? var5
: (false ? var5 : [-9223372030412324864]));
}
}
bool foo2_1(int par1, String par2) {
{ double loc0 = var3;
fld2_2 = { 0 : 'mWycw' };
{
double loc0 = var3;
fld2_2 = {0: 'mWycw'};
var0 = true;
}
return (var1 ? ((par1++) != foo1(fld2_1, (!(false)))) : true);
}
Map<int, String> foo2_2() {
{ String loc0 = 'Am 3x';
{
String loc0 = 'Am 3x';
return fld2_1;
}
}
@@ -122,18 +229,47 @@ class X2 extends X1 {
double? foo2_3(List<int> par1) {
var6 = foo2_2();
if (var1) {
print({ 0 : 'K\u{1f600}\u{1f600}\u2665\u{1f600}', 1 : 'lh34LP' });
print({0: 'K\u{1f600}\u{1f600}\u2665\u{1f600}', 1: 'lh34LP'});
print('im\u2665');
{ String loc0 = (var1 ? ('y\u2665E4UQQ' + ('Q0J2 y').substring(-78)) : foo2());
{ bool loc1 = (((-(-92))).isOdd && (!((!(false)))));
{
String loc0 = (var1
? ('y\u2665E4UQQ' + ('Q0J2 y').substring(-78))
: foo2());
{
bool loc1 = (((-(-92))).isOdd && (!((!(false)))));
print(var3);
if ((var2).isEven) {
var3 /= 0.536905815119827;
var2 |= (++var2);
{ double loc2 = var3;
{ int loc3 = foo1({ 0 : 'G(', 1 : '\u{1f600}&a9t', 2 : '\u{1f600}TF', 3 : '\u2665m-' }, true);
var4 ??= (loc0).substring(((((par1 ?? [ -9223372034707292159, 44, -1, 2147483648 ])).remove((false ? -9223372032559808511 : (((++loc3) ~/ (2147483649 | 54))).ceil())) || false) ? (~((loc3++))) : (foo1(fld2_1, (var6 == { 0 : '', 1 : 'KP8' })) >> 50)));
if ((true != ((!(loc1)) ? ((-(40)) >= -32) : foo2_1(9223372034707292159, (foo2_2()).remove((((-((loc3).abs())) ~/ 42)).toSigned(-27))!)))) {
{
double loc2 = var3;
{
int loc3 = foo1({
0: 'G(',
1: '\u{1f600}&a9t',
2: '\u{1f600}TF',
3: '\u2665m-',
}, true);
var4 ??= (loc0).substring(
((((par1 ?? [-9223372034707292159, 44, -1, 2147483648]))
.remove(
(false
? -9223372032559808511
: (((++loc3) ~/ (2147483649 | 54))).ceil()),
) ||
false)
? (~((loc3++)))
: (foo1(fld2_1, (var6 == {0: '', 1: 'KP8'})) >> 50)),
);
if ((true !=
((!(loc1))
? ((-(40)) >= -32)
: foo2_1(
9223372034707292159,
(foo2_2()).remove(
(((-((loc3).abs())) ~/ 42)).toSigned(-27),
)!,
)))) {
if (loc1) {
return loc2;
}
@@ -148,16 +284,45 @@ class X2 extends X1 {
void run() {
super.run();
fld2_2 ??= (var1 ? fld2_2 : { 0 : 'M ', 1 : 'zG', 2 : 'c' });
if (((foo2_1(var2, var4) ? ((false ? ((var1 || (true && foo2_1(9223372032559808512, var4))) ? var5 : var5) : ([ -52 ]).sublist((true ? 24 : var2)))).remove(9223372036854775807) : false) && var0)) {
fld2_2 ??= (var1 ? fld2_2 : {0: 'M ', 1: 'zG', 2: 'c'});
if (((foo2_1(var2, var4)
? ((false
? ((var1 || (true && foo2_1(9223372032559808512, var4)))
? var5
: var5)
: ([-52]).sublist((true ? 24 : var2))))
.remove(9223372036854775807)
: false) &&
var0)) {
for (int loc0 = 0; loc0 < 57; loc0++) {
var5 ??= (([ 26, 82, -9223372032559808512 ]).sublist((-22 >> 27)) + var5);
var5 ??= (([26, 82, -9223372032559808512]).sublist((-22 >> 27)) + var5);
var6 ??= fld2_2;
fld2_0 ??= foo2();
for (int loc1 = 0; loc1 < 67; loc1++) {
for (int loc2 = 0; loc2 < 31; loc2++) {
var4 = foo2();
{ bool loc3 = foo2_1((-(((!(var0)) ? foo1(fld2_2, true) : foo1((foo2_1((false ? ([ -74, -49, -79, 2 ]).length : 9223372034707292161), 'y') ? ({ 0 : '\u{1f600}Jf', 1 : 'NF' } ?? { 0 : '1 y\u{1f600}\u26659' }) : { 0 : '6MO\u2665A\u{1f600})', 1 : 'p\u{1f600}\u{1f600}6J', 2 : 'sg)' }), var0)))), fld2_0);
{
bool loc3 = foo2_1(
(-(((!(var0))
? foo1(fld2_2, true)
: foo1(
(foo2_1(
(false
? ([-74, -49, -79, 2]).length
: 9223372034707292161),
'y',
)
? ({0: '\u{1f600}Jf', 1: 'NF'} ??
{0: '1 y\u{1f600}\u26659'})
: {
0: '6MO\u2665A\u{1f600})',
1: 'p\u{1f600}\u{1f600}6J',
2: 'sg)',
}),
var0,
)))),
fld2_0,
);
var5 ??= var5;
for (int loc4 = 0; loc4 < 78; loc4++) {
return;
@@ -171,11 +336,16 @@ class X2 extends X1 {
}
class X3 extends X2 {
List<int> fld3_0 = [ -4, -4, -79, 34 ];
List<int> fld3_0 = [-4, -4, -79, 34];
bool foo3_0(int par1, List<int> par2) {
return (((var1 ? 60 : var2)).isOdd ? ((var1 ? fld3_0 : par2)).remove(foo1(var6, (var1 != var0))) : (false ? false : (('GB').substring((++var2))).endsWith(('p\u{1f600}f1u\u2665' ?? 'L\u2665OY!ui'))));
return (((var1 ? 60 : var2)).isOdd
? ((var1 ? fld3_0 : par2)).remove(foo1(var6, (var1 != var0)))
: (false
? false
: (('GB').substring(
(++var2),
)).endsWith(('p\u{1f600}f1u\u2665' ?? 'L\u2665OY!ui'))));
}
int foo3_1(List<int> par1, int par2, bool par3) {
@@ -186,13 +356,53 @@ class X3 extends X2 {
List<int>? foo3_2(List<int> par1, List<int> par2) {
for (int loc0 = 0; loc0 < 68; loc0++) {
{ String loc1 = foo2();
var2 -= (~((false ? (~((false ? loc0 : -9223372034707292161))) : (var2--))));
{
String loc1 = foo2();
var2 -= (~((false
? (~((false ? loc0 : -9223372034707292161)))
: (var2--))));
for (int loc2 = 0; loc2 < 95; loc2++) {
var3 ??= ((false ? var3 : (-(var3))) * (var3 ?? ((-(double.negativeInfinity))).remainder((var3 * double.nan))));
var3 ??=
((false ? var3 : (-(var3))) *
(var3 ??
((-(double.negativeInfinity))).remainder(
(var3 * double.nan),
)));
if ((loc1).endsWith('')) {
print((((!(foo3_0(-47, par2))) ? par1 : ([ 2, -52, -9223372032559808512, 2147483649 ] + par2))).removeLast());
var2 -= foo3_1((foo0((foo0(((var0 ? [ -4294967295, -95, -22, 27 ] : [ 38 ]) + [ 2147483647 ]), (var3).truncate(), var2) ?? par1), (~(loc0)), 53)).sublist((--loc0)), ((loc2++) ?? ((!((false || var0))) ? (69 + (47 & (foo0([ 24, -98, 2147483647, -48 ], loc0, 47)).indexOf(37))) : (var4).compareTo((var1 ? loc1 : loc1)))), (foo3_0((var2 + (~(loc2))), foo0(([ 20, 13 ] + par2), loc0, var2)) && (loc1).isNotEmpty));
print(
(((!(foo3_0(-47, par2)))
? par1
: ([2, -52, -9223372032559808512, 2147483649] + par2)))
.removeLast(),
);
var2 -= foo3_1(
(foo0(
(foo0(
((var0 ? [-4294967295, -95, -22, 27] : [38]) +
[2147483647]),
(var3).truncate(),
var2,
) ??
par1),
(~(loc0)),
53,
)).sublist((--loc0)),
((loc2++) ??
((!((false || var0)))
? (69 +
(47 &
(foo0(
[24, -98, 2147483647, -48],
loc0,
47,
)).indexOf(37)))
: (var4).compareTo((var1 ? loc1 : loc1)))),
(foo3_0(
(var2 + (~(loc2))),
foo0(([20, 13] + par2), loc0, var2),
) &&
(loc1).isNotEmpty),
);
for (int loc3 = 0; loc3 < 62; loc3++) {
for (int loc4 = 0; loc4 < 61; loc4++) {
return fld3_0;
@@ -206,15 +416,38 @@ class X3 extends X2 {
bool? foo3_3(List<int> par1, Map<int, String> par2, Map<int, String> par3) {
for (int loc0 = 0; loc0 < 16; loc0++) {
if (foo3_0((-((var0 ? 8589934591 : 65))), foo3_2(fld3_0, (fld3_0).sublist((true ? (0.23821360229648214).toInt() : var2)))!)) {
par1 ??= (((var4 == '&Tze') ? ([ -27, 23, -40 ] != par1) : true) ? [ 23, 21, 4294967295 ] : fld3_0);
print((par2 ?? { 0 : '\u{1f600}\u2665\u{1f600}Jpj&', 1 : '', 2 : '', 3 : '' }));
if (foo3_0(
(-((var0 ? 8589934591 : 65))),
foo3_2(
fld3_0,
(fld3_0).sublist((true ? (0.23821360229648214).toInt() : var2)),
)!,
)) {
par1 ??= (((var4 == '&Tze') ? ([-27, 23, -40] != par1) : true)
? [23, 21, 4294967295]
: fld3_0);
print(
(par2 ?? {0: '\u{1f600}\u2665\u{1f600}Jpj&', 1: '', 2: '', 3: ''}),
);
var4 = var4;
var1 = (((~(((++loc0) ?? loc0)))).isEven == false);
}
for (int loc1 = 0; loc1 < 93; loc1++) {
var4 = 'gngT';
return (foo3_0(((((var3 * (loc1).ceilToDouble()) - ((0.6230577340230226 > var3) ? (var3 - var3) : double.maxFinite)) - double.nan)).ceil(), [ 0 ]) ? ((!(var0)) && foo3_0((-(-59)), [ 8, 1, 12, -9223372030412324863 ])) : foo3_0(foo3_1(foo3_2([ 2, -33, -72 ], [ 30, 58, 0 ])!, loc1, (!(var1))), var5));
return (foo3_0(
((((var3 * (loc1).ceilToDouble()) -
((0.6230577340230226 > var3)
? (var3 - var3)
: double.maxFinite)) -
double.nan))
.ceil(),
[0],
)
? ((!(var0)) && foo3_0((-(-59)), [8, 1, 12, -9223372030412324863]))
: foo3_0(
foo3_1(foo3_2([2, -33, -72], [30, 58, 0])!, loc1, (!(var1))),
var5,
));
}
}
}
@@ -258,14 +258,15 @@ main(List<String> argsIn) async {
}
var exec = Platform.executable;
var args = Platform.executableArguments +
var args =
Platform.executableArguments +
[
"--new_gen_semi_max_size=4" /*MB*/,
"--old_gen_heap_size=15" /*MB*/,
"--verbose_gc",
"--verify_store_buffer",
Platform.script.toFilePath(),
"--testee"
"--testee",
];
print("+ $exec ${args.join(' ')}");
@@ -275,14 +276,20 @@ main(List<String> argsIn) async {
print("Command stderr:");
print(result.stderr);
Expect.equals(255, result.exitCode,
"Should see runtime exception error code, not SEGV");
Expect.equals(
255,
result.exitCode,
"Should see runtime exception error code, not SEGV",
);
Expect.isTrue(
result.stderr.contains("Unhandled exception:\nOut of Memory") ||
result.stderr.contains("Unhandled exception:\r\nOut of Memory"),
"Should see the Dart OutOfMemoryError");
result.stderr.contains("Unhandled exception:\nOut of Memory") ||
result.stderr.contains("Unhandled exception:\r\nOut of Memory"),
"Should see the Dart OutOfMemoryError",
);
Expect.isFalse(result.stderr.contains("error: Out of memory"),
"Should not see the C++ OUT_OF_MEMORY()");
Expect.isFalse(
result.stderr.contains("error: Out of memory"),
"Should not see the C++ OUT_OF_MEMORY()",
);
}
@@ -125,14 +125,15 @@ main(List<String> argsIn) async {
}
var exec = Platform.executable;
var args = Platform.executableArguments +
var args =
Platform.executableArguments +
[
"--old_gen_heap_size=15" /*MB*/,
"--verbose_gc",
"--verify_after_gc",
"--verify_store_buffer",
Platform.script.toFilePath(),
"--testee"
"--testee",
];
print("+ $exec ${args.join(' ')}");
@@ -142,14 +143,20 @@ main(List<String> argsIn) async {
print("Command stderr:");
print(result.stderr);
Expect.equals(255, result.exitCode,
"Should see runtime exception error code, not SEGV");
Expect.equals(
255,
result.exitCode,
"Should see runtime exception error code, not SEGV",
);
Expect.isTrue(
result.stderr.contains("Unhandled exception:\nOut of Memory") ||
result.stderr.contains("Unhandled exception:\r\nOut of Memory"),
"Should see the Dart OutOfMemoryError");
result.stderr.contains("Unhandled exception:\nOut of Memory") ||
result.stderr.contains("Unhandled exception:\r\nOut of Memory"),
"Should see the Dart OutOfMemoryError",
);
Expect.isFalse(result.stderr.contains("error: Out of memory"),
"Should not see the C++ OUT_OF_MEMORY()");
Expect.isFalse(
result.stderr.contains("error: Out of memory"),
"Should not see the C++ OUT_OF_MEMORY()",
);
}
+2 -2
View File
@@ -31,8 +31,8 @@ abstract class Node {
class Leaf {
Leaf(String tag)
: string = "String for key $tag in leaf node",
array = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] {}
: string = "String for key $tag in leaf node",
array = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] {}
String string;
List<num> array;
}
@@ -63,8 +63,7 @@ class Payload {
static generate(depth, tag) {
if (depth == 0) return new Leaf(tag);
return new Payload(generate(depth - 1, tag),
generate(depth - 1, tag));
return new Payload(generate(depth - 1, tag), generate(depth - 1, tag));
}
}
+1 -2
View File
@@ -55,8 +55,7 @@ class Payload {
static generate(depth, tag) {
if (depth == 0) return new Leaf(tag);
return new Payload(generate(depth - 1, tag),
generate(depth - 1, tag));
return new Payload(generate(depth - 1, tag), generate(depth - 1, tag));
}
}
+12 -4
View File
@@ -61,14 +61,18 @@ class Payload {
set left(value) {
leftWeak = new WeakReference(value as Object);
// Indirection: chance for WeakRef to be scanned before target is marked.
leftStrong = [[value]];
leftStrong = [
[value],
];
}
get right => rightWeak?.target;
set right(value) {
rightWeak = new WeakReference(value as Object);
// Indirection: chance for WeakRef to be scanned before target is marked.
rightStrong = [[value]];
rightStrong = [
[value],
];
}
static generate(depth, tag) {
@@ -93,13 +97,17 @@ class WeakNode extends Node {
set left(Node? value) {
leftWeak = value == null ? null : new WeakReference(value);
// Indirection: chance for WeakRef to be scanned before target is marked.
leftStrong = [[value]];
leftStrong = [
[value],
];
}
Node? get right => rightWeak?.target;
set right(Node? value) {
rightWeak = value == null ? null : new WeakReference(value);
// Indirection: chance for WeakRef to be scanned before target is marked.
rightStrong = [[value]];
rightStrong = [
[value],
];
}
}
@@ -22,10 +22,13 @@ Future<void> main() async {
serviceInfo = await Service.getInfo();
}
final isolateId = Service.getIsolateID(I.Isolate.current)!;
final uri = serviceInfo.serverUri!.replace(scheme: 'ws', pathSegments: [
...serviceInfo.serverUri!.pathSegments.where((e) => e != ''),
'ws'
]);
final uri = serviceInfo.serverUri!.replace(
scheme: 'ws',
pathSegments: [
...serviceInfo.serverUri!.pathSegments.where((e) => e != ''),
'ws',
],
);
final service = await vmServiceConnectUri(uri.toString());
final timeExtent = Duration(minutes: 5).inMicroseconds;
final samples = await service.getCpuSamples(isolateId, 0, timeExtent);
@@ -50,43 +50,39 @@ main(List<String> args) async {
});
// Let the test runner handle timeouts.
test(
'Include resolved urls',
() async {
final scriptDill = path.join(tempDir.path, 'test.dill');
test('Include resolved urls', () async {
final scriptDill = path.join(tempDir.path, 'test.dill');
// Compile script to Kernel IR.
await run(genKernel, <String>[
'--aot',
'--packages=$sdkDir/.dart_tool/package_config.json',
'--platform=$platformDill',
'-o',
scriptDill,
scriptUrl,
]);
// Compile script to Kernel IR.
await run(genKernel, <String>[
'--aot',
'--packages=$sdkDir/.dart_tool/package_config.json',
'--platform=$platformDill',
'-o',
scriptDill,
scriptUrl,
]);
final elfFile = path.join(tempDir.path, 'aot.snapshot');
await run(genSnapshot, <String>[
'--snapshot-kind=app-aot-elf',
'--elf=$elfFile',
scriptDill,
]);
final elfFile = path.join(tempDir.path, 'aot.snapshot');
await run(genSnapshot, <String>[
'--snapshot-kind=app-aot-elf',
'--elf=$elfFile',
scriptDill,
]);
// Ensure we can actually run the code.
expect(
await run(dartPrecompiledRuntime, <String>[
'--enable-vm-service=0',
// Spawning DDS in SIMARM configs can be slow and causes this already
// slow test to timeout.
'--no-dds',
'--profiler',
elfFile,
]),
true,
);
},
timeout: Timeout.none,
);
// Ensure we can actually run the code.
expect(
await run(dartPrecompiledRuntime, <String>[
'--enable-vm-service=0',
// Spawning DDS in SIMARM configs can be slow and causes this already
// slow test to timeout.
'--no-dds',
'--profiler',
elfFile,
]),
true,
);
}, timeout: Timeout.none);
}
Future<String> readFile(String file) {
@@ -90,6 +90,8 @@ main() async {
Expect.equals(barClass.classId, fooObjectBarField.classId);
Expect.equals(listClass.classId, fooObjectBar2Field.classId);
Expect.equals(
listClass.fields.length + 1, fooObjectBar2Field.references.length);
listClass.fields.length + 1,
fooObjectBar2Field.references.length,
);
});
}
@@ -28,7 +28,9 @@ main() async {
exception = e;
}
Expect.contains(
'Heap snapshots are only supported in non-product mode.', '$exception');
'Heap snapshots are only supported in non-product mode.',
'$exception',
);
return;
}
@@ -56,11 +58,14 @@ Future runTest() async {
NativeRuntime.writeHeapSnapshotToFile(state3);
final int count1 = countFooInstances(
findReachableObjects(loadHeapSnapshotFromFile(state1)));
findReachableObjects(loadHeapSnapshotFromFile(state1)),
);
final int count2 = countFooInstances(
findReachableObjects(loadHeapSnapshotFromFile(state2)));
findReachableObjects(loadHeapSnapshotFromFile(state2)),
);
final int count3 = countFooInstances(
findReachableObjects(loadHeapSnapshotFromFile(state3)));
findReachableObjects(loadHeapSnapshotFromFile(state3)),
);
Expect.equals(0, count1);
Expect.equals(2, count2);
+222 -196
View File
@@ -77,56 +77,63 @@ testSimpleReadWriteClose() async {
bool doneReading = false;
client.writeEventsEnabled = false;
client.listen((event) {
switch (event) {
case RawSocketEvent.read:
if (doneReading) {
client.listen(
(event) {
switch (event) {
case RawSocketEvent.read:
if (doneReading) {
break;
}
print("client READ event bytesRead = $bytesRead");
assert(bytesWritten == 0);
assert(client.available() > 0);
var buffer = client.read(200)!;
print("client READ event: read ${buffer.length} more bytes");
data.setRange(bytesRead, bytesRead + buffer.length, buffer);
bytesRead += buffer.length;
if (bytesRead == data.length) {
verifyTestData(data);
print("client READ event. Done reading, enabling writes");
client.writeEventsEnabled = true;
doneReading = true;
}
break;
}
print("client READ event bytesRead = $bytesRead");
assert(bytesWritten == 0);
assert(client.available() > 0);
var buffer = client.read(200)!;
print("client READ event: read ${buffer.length} more bytes");
data.setRange(bytesRead, bytesRead + buffer.length, buffer);
bytesRead += buffer.length;
if (bytesRead == data.length) {
verifyTestData(data);
print("client READ event. Done reading, enabling writes");
client.writeEventsEnabled = true;
doneReading = true;
}
break;
case RawSocketEvent.write:
assert(!client.writeEventsEnabled);
bytesWritten +=
client.write(data, bytesWritten, data.length - bytesWritten);
print("client WRITE event: $bytesWritten written");
if (bytesWritten < data.length) {
client.writeEventsEnabled = true;
}
if (bytesWritten == data.length) {
print("client WRITE event: done writing.");
}
break;
case RawSocketEvent.readClosed:
print("client READ_CLOSED event");
client.close();
server.close();
break;
case RawSocketEvent.closed:
assert(!closedEventReceived);
print("client CLOSED event");
closedEventReceived = true;
break;
default:
throw "Unexpected event $event";
}
}, onError: (e) {
print("client ERROR $e");
}, onDone: () {
assert(closedEventReceived);
});
case RawSocketEvent.write:
assert(!client.writeEventsEnabled);
bytesWritten += client.write(
data,
bytesWritten,
data.length - bytesWritten,
);
print("client WRITE event: $bytesWritten written");
if (bytesWritten < data.length) {
client.writeEventsEnabled = true;
}
if (bytesWritten == data.length) {
print("client WRITE event: done writing.");
}
break;
case RawSocketEvent.readClosed:
print("client READ_CLOSED event");
client.close();
server.close();
break;
case RawSocketEvent.closed:
assert(!closedEventReceived);
print("client CLOSED event");
closedEventReceived = true;
break;
default:
throw "Unexpected event $event";
}
},
onError: (e) {
print("client ERROR $e");
},
onDone: () {
assert(closedEventReceived);
},
);
});
{
@@ -137,52 +144,59 @@ testSimpleReadWriteClose() async {
bool closedEventReceived = false;
List<int> data = createTestData();
socket.listen((event) {
switch (event) {
case RawSocketEvent.read:
assert(socket.available() > 0);
print("server READ event: ${bytesRead} read");
var buffer = socket.read()!;
print("server READ event: read ${buffer.length} more bytes");
data.setRange(bytesRead, bytesRead + buffer.length, buffer);
bytesRead += buffer.length;
if (bytesRead == messageSize) {
print("server READ event: done reading");
socket.listen(
(event) {
switch (event) {
case RawSocketEvent.read:
assert(socket.available() > 0);
print("server READ event: ${bytesRead} read");
var buffer = socket.read()!;
print("server READ event: read ${buffer.length} more bytes");
data.setRange(bytesRead, bytesRead + buffer.length, buffer);
bytesRead += buffer.length;
if (bytesRead == messageSize) {
print("server READ event: done reading");
socket.close();
}
break;
case RawSocketEvent.write:
assert(bytesRead == 0);
assert(!socket.writeEventsEnabled);
bytesWritten += socket.write(
data,
bytesWritten,
data.length - bytesWritten,
);
print("server WRITE event: ${bytesWritten} written");
if (bytesWritten < data.length) {
socket.writeEventsEnabled = true;
} else {
print("server WRITE event: done writing");
data = new List<int>.filled(messageSize, -1);
}
break;
case RawSocketEvent.readClosed:
print("server READ_CLOSED event");
verifyTestData(data);
socket.close();
}
break;
case RawSocketEvent.write:
assert(bytesRead == 0);
assert(!socket.writeEventsEnabled);
bytesWritten +=
socket.write(data, bytesWritten, data.length - bytesWritten);
print("server WRITE event: ${bytesWritten} written");
if (bytesWritten < data.length) {
socket.writeEventsEnabled = true;
} else {
print("server WRITE event: done writing");
data = new List<int>.filled(messageSize, -1);
}
break;
case RawSocketEvent.readClosed:
print("server READ_CLOSED event");
verifyTestData(data);
socket.close();
break;
case RawSocketEvent.closed:
assert(!closedEventReceived);
print("server CLOSED event");
closedEventReceived = true;
break;
default:
throw "Unexpected event $event";
}
}, onError: (e) {
print("server ERROR $e");
}, onDone: () {
assert(closedEventReceived);
completer.complete(null);
});
break;
case RawSocketEvent.closed:
assert(!closedEventReceived);
print("server CLOSED event");
closedEventReceived = true;
break;
default:
throw "Unexpected event $event";
}
},
onError: (e) {
print("server ERROR $e");
},
onDone: () {
assert(closedEventReceived);
completer.complete(null);
},
);
return completer.future;
}
@@ -219,62 +233,68 @@ testSimpleReadWriteShutdown({required bool dropReads}) async {
bool doneReading = false;
client.writeEventsEnabled = false;
client.listen((event) {
switch (event) {
case RawSocketEvent.read:
if (doneReading) {
break;
}
if (dropReads) {
if (serverReadCount != 10) {
serverReadCount++;
client.listen(
(event) {
switch (event) {
case RawSocketEvent.read:
if (doneReading) {
break;
} else {
serverReadCount = 0;
}
}
print("client READ event bytesRead = $bytesRead");
assert(bytesWritten == 0);
assert(client.available() > 0);
var buffer = client.read(200)!;
print("client READ event: read ${buffer.length} more bytes");
data.setRange(bytesRead, bytesRead + buffer.length, buffer);
bytesRead += buffer.length;
if (bytesRead == data.length) {
verifyTestData(data);
print("client READ event. Done reading, enabling writes");
client.writeEventsEnabled = true;
doneReading = true;
}
break;
case RawSocketEvent.write:
assert(!client.writeEventsEnabled);
bytesWritten +=
client.write(data, bytesWritten, data.length - bytesWritten);
print("client WRITE event: $bytesWritten written");
if (bytesWritten < data.length) {
client.writeEventsEnabled = true;
}
if (bytesWritten == data.length) {
print("client WRITE event: done writing.");
client.shutdown(SocketDirection.send);
}
break;
case RawSocketEvent.readClosed:
print("client READ_CLOSED event");
server.close();
break;
case RawSocketEvent.closed:
assert(!closedEventReceived);
print("client CLOSED event");
closedEventReceived = true;
break;
default:
throw "Unexpected event $event";
}
}, onDone: () {
assert(closedEventReceived);
});
if (dropReads) {
if (serverReadCount != 10) {
serverReadCount++;
break;
} else {
serverReadCount = 0;
}
}
print("client READ event bytesRead = $bytesRead");
assert(bytesWritten == 0);
assert(client.available() > 0);
var buffer = client.read(200)!;
print("client READ event: read ${buffer.length} more bytes");
data.setRange(bytesRead, bytesRead + buffer.length, buffer);
bytesRead += buffer.length;
if (bytesRead == data.length) {
verifyTestData(data);
print("client READ event. Done reading, enabling writes");
client.writeEventsEnabled = true;
doneReading = true;
}
break;
case RawSocketEvent.write:
assert(!client.writeEventsEnabled);
bytesWritten += client.write(
data,
bytesWritten,
data.length - bytesWritten,
);
print("client WRITE event: $bytesWritten written");
if (bytesWritten < data.length) {
client.writeEventsEnabled = true;
}
if (bytesWritten == data.length) {
print("client WRITE event: done writing.");
client.shutdown(SocketDirection.send);
}
break;
case RawSocketEvent.readClosed:
print("client READ_CLOSED event");
server.close();
break;
case RawSocketEvent.closed:
assert(!closedEventReceived);
print("client CLOSED event");
closedEventReceived = true;
break;
default:
throw "Unexpected event $event";
}
},
onDone: () {
assert(closedEventReceived);
},
);
});
{
@@ -285,54 +305,60 @@ testSimpleReadWriteShutdown({required bool dropReads}) async {
bool closedEventReceived = false;
List<int> data = createTestData();
socket.listen((event) {
switch (event) {
case RawSocketEvent.read:
assert(socket.available() > 0);
if (dropReads) {
if (clientReadCount != 10) {
clientReadCount++;
break;
} else {
clientReadCount = 0;
socket.listen(
(event) {
switch (event) {
case RawSocketEvent.read:
assert(socket.available() > 0);
if (dropReads) {
if (clientReadCount != 10) {
clientReadCount++;
break;
} else {
clientReadCount = 0;
}
}
}
print("server READ event: ${bytesRead} read");
var buffer = socket.read()!;
print("server READ event: read ${buffer.length} more bytes");
data.setRange(bytesRead, bytesRead + buffer.length, buffer);
bytesRead += buffer.length;
break;
case RawSocketEvent.write:
assert(bytesRead == 0);
assert(!socket.writeEventsEnabled);
bytesWritten +=
socket.write(data, bytesWritten, data.length - bytesWritten);
print("server WRITE event: ${bytesWritten} written");
if (bytesWritten < data.length) {
socket.writeEventsEnabled = true;
} else {
print("server WRITE event: done writing");
data = new List<int>.filled(messageSize, -1);
}
break;
case RawSocketEvent.readClosed:
print("server READ_CLOSED event");
verifyTestData(data);
socket.close();
break;
case RawSocketEvent.closed:
assert(!closedEventReceived);
print("server CLOSED event");
closedEventReceived = true;
break;
default:
throw "Unexpected event $event";
}
}, onDone: () {
assert(closedEventReceived);
completer.complete(null);
});
print("server READ event: ${bytesRead} read");
var buffer = socket.read()!;
print("server READ event: read ${buffer.length} more bytes");
data.setRange(bytesRead, bytesRead + buffer.length, buffer);
bytesRead += buffer.length;
break;
case RawSocketEvent.write:
assert(bytesRead == 0);
assert(!socket.writeEventsEnabled);
bytesWritten += socket.write(
data,
bytesWritten,
data.length - bytesWritten,
);
print("server WRITE event: ${bytesWritten} written");
if (bytesWritten < data.length) {
socket.writeEventsEnabled = true;
} else {
print("server WRITE event: done writing");
data = new List<int>.filled(messageSize, -1);
}
break;
case RawSocketEvent.readClosed:
print("server READ_CLOSED event");
verifyTestData(data);
socket.close();
break;
case RawSocketEvent.closed:
assert(!closedEventReceived);
print("server CLOSED event");
closedEventReceived = true;
break;
default:
throw "Unexpected event $event";
}
},
onDone: () {
assert(closedEventReceived);
completer.complete(null);
},
);
return completer.future;
}
@@ -446,7 +472,7 @@ Future testListInterfaces() async {
main(List<String> args) async {
if (args.length >= 1) {
if (args[0] == "infinite-loop") {
while (true);
while (true) ;
}
}
@@ -48,9 +48,13 @@ main(List<String> args) async {
await withTempDir("incompatible-loading-unit-test", (String tempDir) async {
final source1 = path.join(
sdkDir, "runtime/tests/vm/dart/incompatible_loading_unit_1.dart");
sdkDir,
"runtime/tests/vm/dart/incompatible_loading_unit_1.dart",
);
final source2 = path.join(
sdkDir, "runtime/tests/vm/dart/incompatible_loading_unit_2.dart");
sdkDir,
"runtime/tests/vm/dart/incompatible_loading_unit_2.dart",
);
final dill1 = path.join(tempDir, "incompatible_loading_unit_1.dart.dill");
final dill2 = path.join(tempDir, "incompatible_loading_unit_2.dart.dill");
final snapshot1 = path.join(tempDir, "incompatible_loading_unit_1.so");
@@ -87,9 +91,10 @@ main(List<String> args) async {
Expect.equals(2, manifest["loadingUnits"].length);
// Note package:expect doesn't do deep equals on collections.
Expect.equals(
"[[incompatible_loading_unit_1.dart],"
" [incompatible_loading_unit_1_deferred.dart]]",
sanitizedPartitioning(manifest).toString());
"[[incompatible_loading_unit_1.dart],"
" [incompatible_loading_unit_1_deferred.dart]]",
sanitizedPartitioning(manifest).toString(),
);
Expect.isTrue(await new File(deferredSnapshot1).exists());
await run(genSnapshot, <String>[
@@ -101,9 +106,10 @@ main(List<String> args) async {
manifest = jsonDecode(await new File(manifest2).readAsString());
Expect.equals(2, manifest["loadingUnits"].length);
Expect.equals(
"[[incompatible_loading_unit_2.dart],"
" [incompatible_loading_unit_2_deferred.dart]]",
sanitizedPartitioning(manifest).toString());
"[[incompatible_loading_unit_2.dart],"
" [incompatible_loading_unit_2_deferred.dart]]",
sanitizedPartitioning(manifest).toString(),
);
Expect.isTrue(await new File(deferredSnapshot2).exists());
// Works when used normally.
@@ -117,7 +123,8 @@ main(List<String> args) async {
await new File(deferredSnapshot2).rename(deferredSnapshot1);
lines = await runError(dartPrecompiledRuntime, <String>[snapshot1]);
Expect.equals(
"DeferredLoadException: 'Deferred loading unit is from a different program than the main loading unit'",
lines[1]);
"DeferredLoadException: 'Deferred loading unit is from a different program than the main loading unit'",
lines[1],
);
});
}
@@ -64,5 +64,6 @@ void matchIL$calculateRetainers(FlowGraph graph) {
void main() {
// To ensure _calculateRetainers is compiled.
Expect.throws(
() => calculateRetainers(HeapSnapshotGraph.fromChunks(<ByteData>[])));
() => calculateRetainers(HeapSnapshotGraph.fromChunks(<ByteData>[])),
);
}
@@ -42,8 +42,11 @@ void matchIL$main_foo(FlowGraph graph) {
'v5' << match.Phi(match.any, 'v13'),
'v6' << match.Phi(match.any, 'v15'),
match.CheckStackOverflow(),
match.Branch(match.RelationalOp('v6', match.any, kind: '<'),
ifTrue: 'B3', ifFalse: 'B4'),
match.Branch(
match.RelationalOp('v6', match.any, kind: '<'),
ifTrue: 'B3',
ifFalse: 'B4',
),
]),
'B3' <<
match.block('Target', [
@@ -46,7 +46,8 @@ String generateTable() {
sb.writeln('T with FutureOr<int>? = $nonNullableTNullableFutureOrInt');
sb.writeln('T with FutureOr<int?> = $nonNullableTFutureOrNullableInt');
sb.writeln(
'T with FutureOr<int?>? = $nonNullableTNullableFutureOrNullableInt');
'T with FutureOr<int?>? = $nonNullableTNullableFutureOrNullableInt',
);
sb.writeln('T? with FutureOr<int> = $nullableTFutureOrInt');
sb.writeln('T? with FutureOr<int>? = $nullableTNullableFutureOrInt');
sb.writeln('T? with FutureOr<int?> = $nullableTFutureOrNullableInt');
@@ -54,7 +55,8 @@ String generateTable() {
sb.writeln('');
sb.writeln('T with void (() => void)? = $nonNullableTNullableVoidFunction');
sb.writeln(
'T with void (() => void) = $nonNullableTNonNullableVoidFunction');
'T with void (() => void) = $nonNullableTNonNullableVoidFunction',
);
sb.writeln('T? with void (() => void)? = $nullableTNullableVoidFunction');
sb.writeln('T? with void (() => void) = $nullableTNonNullableVoidFunction');
return '$sb';
@@ -115,6 +115,6 @@ final currentExpectations = [
#0 main.<anonymous closure> (%test%)
#1 invisibleClosure (%test%)
#2 main (%test%)
<asynchronous suspension>"""
<asynchronous suspension>""",
];
// CURRENT EXPECTATIONS END
@@ -16,15 +16,17 @@ import '../../../../tests/ffi/dylib_utils.dart';
final ffiTestFunctions = dlopenPlatformSpecific('ffi_test_functions');
final lookupAndCallWorkerThatCallsIsolateExit =
ffiTestFunctions.lookupFunction<Void Function(Int64), void Function(int)>(
'IsolateExitTest_LookupAndCallIsolateExit');
final lookupAndCallWorkerThatCallsIsolateExit = ffiTestFunctions
.lookupFunction<Void Function(Int64), void Function(int)>(
'IsolateExitTest_LookupAndCallIsolateExit',
);
@pragma('vm:entry-point')
void recurseLookupAndCallWorker(int i) {
lookupAndCallWorkerThatCallsIsolateExit(i);
print(
'coming back after $i invocation of lookupAndCallWorkerThatCallsIsolateExit');
'coming back after $i invocation of lookupAndCallWorkerThatCallsIsolateExit',
);
assert(false);
}
@@ -41,8 +43,10 @@ main(List<String> args) async {
print('got back');
return;
}
ProcessResult result = await Process.run(
Platform.executable, <String>[Platform.script.toString(), 'worker']);
ProcessResult result = await Process.run(Platform.executable, <String>[
Platform.script.toString(),
'worker',
]);
Expect.isTrue(result.exitCode != 0);
// The child process should be terminated before it had a chance
// to print "got back".
@@ -25,22 +25,30 @@ main() async {
final rp = RawReceivePort((e) {
Expect.fail('Received unexpected $e, no objects should have arrived');
});
await Isolate.spawn((sendPort) {
for (final pairFunctionName in [
[Locked.new, "Locked"],
[ExtendsLocked.new, "ExtendsLocked"],
[ImplementsLocked.new, "ImplementsLocked"]
]) {
Expect.throws(() {
Isolate.exit(sendPort, (pairFunctionName[0] as Function)());
}, (e) {
return e is ArgumentError &&
e
.toString()
.contains(RegExp("unsendable object .+${pairFunctionName[1]}"));
});
}
}, rp.sendPort, onError: rpError.sendPort, onExit: rpExit.sendPort);
await Isolate.spawn(
(sendPort) {
for (final pairFunctionName in [
[Locked.new, "Locked"],
[ExtendsLocked.new, "ExtendsLocked"],
[ImplementsLocked.new, "ImplementsLocked"],
]) {
Expect.throws(
() {
Isolate.exit(sendPort, (pairFunctionName[0] as Function)());
},
(e) {
return e is ArgumentError &&
e.toString().contains(
RegExp("unsendable object .+${pairFunctionName[1]}"),
);
},
);
}
},
rp.sendPort,
onError: rpError.sendPort,
onExit: rpExit.sendPort,
);
await rpExit.first;
rpError.close();
rp.close();
@@ -22,16 +22,20 @@ main() async {
final rp = ReceivePort();
final re = RegExp('abc');
print(re.hasMatch('kukabcdef'));
await Isolate.spawn(f, <dynamic>[rp.sendPort, re],
onError: rpError.sendPort);
await Isolate.spawn(f, <dynamic>[
rp.sendPort,
re,
], onError: rpError.sendPort);
Expect.isTrue(await rp.first);
}
{
// Test send of uninitialized RegExp(num_groups is null)
final rp = ReceivePort();
final re = RegExp('abc');
await Isolate.spawn(f, <dynamic>[rp.sendPort, re],
onError: rpError.sendPort);
await Isolate.spawn(f, <dynamic>[
rp.sendPort,
re,
], onError: rpError.sendPort);
Expect.isTrue(await rp.first);
}
rpError.close();
@@ -27,7 +27,9 @@ class HashThrower {
}
Future testWithClosure<T>(
void Function(SendPort) entrypoint, T expectedResult) async {
void Function(SendPort) entrypoint,
T expectedResult,
) async {
final rp = ReceivePort();
try {
await Isolate.spawn(entrypoint, rp.sendPort);
@@ -30,15 +30,17 @@ main() async {
// Generate stress test.
File(stressTest).writeAsStringSync(await generateStressTest(testFiles));
final packageConfig =
path.join(path.absolute('.'), '.dart_tool/package_config.json');
final packageConfig = path.join(
path.absolute('.'),
'.dart_tool/package_config.json',
);
// Compile stress test to kernel.
final args = [
'--packages=$packageConfig',
'--snapshot-kind=kernel',
'--snapshot=$stressTestDill',
stressTest
stressTest,
];
print('Running $dartExecutable ${args.join(' ')}');
final process = await Process.start(dartExecutable, args);
@@ -46,14 +48,14 @@ main() async {
.transform(utf8.decoder)
.transform(const LineSplitter())
.listen((String line) {
stdout.writeln(line);
});
stdout.writeln(line);
});
process.stderr
.transform(utf8.decoder)
.transform(const LineSplitter())
.listen((String line) {
stderr.writeln(line);
});
stderr.writeln(line);
});
Expect.equals(0, await process.exitCode);
});
}
@@ -16,8 +16,9 @@ import 'package:ffi/ffi.dart';
import 'test_utils.dart' show isArtificialReloadMode;
import '../../../../../tests/ffi/dylib_utils.dart';
final bool usesDwarfStackTraces = Platform.executableArguments
.any((entry) => RegExp('--dwarf[-_]stack[-_]traces').hasMatch(entry));
final bool usesDwarfStackTraces = Platform.executableArguments.any(
(entry) => RegExp('--dwarf[-_]stack[-_]traces').hasMatch(entry),
);
final bool hasSymbolicStackTraces = !usesDwarfStackTraces;
final sdkRoot = Platform.script.resolve('../../../../../');
@@ -26,35 +27,60 @@ final class Isolate extends Opaque {}
abstract class FfiBindings {
static final ffiTestFunctions = dlopenPlatformSpecific("ffi_test_functions");
static final IGH_MsanUnpoison = ffiTestFunctions.lookupFunction<
Pointer<Isolate> Function(Pointer<Void>, IntPtr),
Pointer<Isolate> Function(Pointer<Void>, int)>('IGH_MsanUnpoison');
static final IGH_MsanUnpoison = ffiTestFunctions
.lookupFunction<
Pointer<Isolate> Function(Pointer<Void>, IntPtr),
Pointer<Isolate> Function(Pointer<Void>, int)
>('IGH_MsanUnpoison');
static final IGH_CreateIsolate = ffiTestFunctions.lookupFunction<
Pointer<Isolate> Function(Pointer<Utf8>, Pointer<Void>),
Pointer<Isolate> Function(
Pointer<Utf8>, Pointer<Void>)>('IGH_CreateIsolate');
static final IGH_CreateIsolate = ffiTestFunctions
.lookupFunction<
Pointer<Isolate> Function(Pointer<Utf8>, Pointer<Void>),
Pointer<Isolate> Function(Pointer<Utf8>, Pointer<Void>)
>('IGH_CreateIsolate');
static final IGH_StartIsolate = ffiTestFunctions.lookupFunction<
Pointer<Void> Function(Pointer<Isolate>, Int64, Pointer<Utf8>,
Pointer<Utf8>, IntPtr, Int64, Int64),
Pointer<Void> Function(Pointer<Isolate>, int, Pointer<Utf8>,
Pointer<Utf8>, int, int, int)>('IGH_StartIsolate');
static final IGH_StartIsolate = ffiTestFunctions
.lookupFunction<
Pointer<Void> Function(
Pointer<Isolate>,
Int64,
Pointer<Utf8>,
Pointer<Utf8>,
IntPtr,
Int64,
Int64,
),
Pointer<Void> Function(
Pointer<Isolate>,
int,
Pointer<Utf8>,
Pointer<Utf8>,
int,
int,
int,
)
>('IGH_StartIsolate');
static final Dart_CurrentIsolate = DynamicLibrary.executable()
.lookupFunction<Pointer<Isolate> Function(), Pointer<Isolate> Function()>(
"Dart_CurrentIsolate");
"Dart_CurrentIsolate",
);
static final Dart_IsolateData = DynamicLibrary.executable().lookupFunction<
Pointer<Isolate> Function(Pointer<Isolate>),
Pointer<Isolate> Function(Pointer<Isolate>)>("Dart_IsolateData");
static final Dart_IsolateData = DynamicLibrary.executable()
.lookupFunction<
Pointer<Isolate> Function(Pointer<Isolate>),
Pointer<Isolate> Function(Pointer<Isolate>)
>("Dart_IsolateData");
static final Dart_PostInteger = DynamicLibrary.executable()
.lookupFunction<IntPtr Function(Int64, Int64), int Function(int, int)>(
"Dart_PostInteger");
"Dart_PostInteger",
);
static Pointer<Isolate> createLightweightIsolate(
String name, Pointer<Void> peer) {
String name,
Pointer<Void> peer,
) {
final cname = name.toNativeUtf8();
IGH_MsanUnpoison(cname.cast(), name.length + 10);
try {
@@ -67,10 +93,16 @@ abstract class FfiBindings {
}
static void invokeTopLevelAndRunLoopAsync(
Pointer<Isolate> isolate, SendPort sendPort, String name,
{bool? errorsAreFatal, SendPort? onError, SendPort? onExit}) {
Pointer<Isolate> isolate,
SendPort sendPort,
String name, {
bool? errorsAreFatal,
SendPort? onError,
SendPort? onExit,
}) {
final dartScriptUri = sdkRoot.resolve(
'runtime/tests/vm/dart/isolates/dart_api_create_lightweight_isolate_test.dart');
'runtime/tests/vm/dart/isolates/dart_api_create_lightweight_isolate_test.dart',
);
final dartScript = dartScriptUri.toString();
final libraryUri = dartScript.toNativeUtf8();
IGH_MsanUnpoison(libraryUri.cast(), dartScript.length + 1);
@@ -78,13 +110,14 @@ abstract class FfiBindings {
IGH_MsanUnpoison(functionName.cast(), name.length + 1);
IGH_StartIsolate(
isolate,
sendPort.nativePort,
libraryUri,
functionName,
errorsAreFatal == false ? 0 : 1,
onError != null ? onError.nativePort : 0,
onExit != null ? onExit.nativePort : 0);
isolate,
sendPort.nativePort,
libraryUri,
functionName,
errorsAreFatal == false ? 0 : 1,
onError != null ? onError.nativePort : 0,
onExit != null ? onExit.nativePort : 0,
);
calloc.free(libraryUri);
calloc.free(functionName);
@@ -126,8 +159,9 @@ Future withPeerPointer(fun(Pointer<Void> peer)) async {
@pragma('vm:entry-point')
void childTestIsolateData(int mainPort) {
final peerIsolateData =
FfiBindings.Dart_IsolateData(FfiBindings.Dart_CurrentIsolate());
final peerIsolateData = FfiBindings.Dart_IsolateData(
FfiBindings.Dart_CurrentIsolate(),
);
FfiBindings.Dart_PostInteger(mainPort, peerIsolateData.address);
}
@@ -137,8 +171,11 @@ Future testIsolateData() async {
final exit = ReceivePort();
final isolate = FfiBindings.createLightweightIsolate('debug-name', peer);
FfiBindings.invokeTopLevelAndRunLoopAsync(
isolate, rp.sendPort, 'childTestIsolateData',
onExit: exit.sendPort);
isolate,
rp.sendPort,
'childTestIsolateData',
onExit: exit.sendPort,
);
Expect.equals(peer.address, await rp.first);
await exit.first;
@@ -165,15 +202,21 @@ Future testMultipleErrors() async {
final exit = ReceivePort();
final isolate = FfiBindings.createLightweightIsolate('debug-name', peer);
FfiBindings.invokeTopLevelAndRunLoopAsync(
isolate, rp.sendPort, 'childTestMultipleErrors',
errorsAreFatal: false, onError: errors.sendPort, onExit: exit.sendPort);
isolate,
rp.sendPort,
'childTestMultipleErrors',
errorsAreFatal: false,
onError: errors.sendPort,
onExit: exit.sendPort,
);
await exit.first;
Expect.equals(10, accumulatedErrors.length);
for (int i = 0; i < 10; ++i) {
Expect.equals('error-$i', accumulatedErrors[i][0]);
if (hasSymbolicStackTraces) {
Expect.isTrue(
accumulatedErrors[i][1].contains('childTestMultipleErrors'));
accumulatedErrors[i][1].contains('childTestMultipleErrors'),
);
}
}
@@ -199,8 +242,13 @@ Future testFatalError() async {
final exit = ReceivePort();
final isolate = FfiBindings.createLightweightIsolate('debug-name', peer);
FfiBindings.invokeTopLevelAndRunLoopAsync(
isolate, rp.sendPort, 'childTestFatalError',
errorsAreFatal: true, onError: errors.sendPort, onExit: exit.sendPort);
isolate,
rp.sendPort,
'childTestFatalError',
errorsAreFatal: true,
onError: errors.sendPort,
onExit: exit.sendPort,
);
await exit.first;
Expect.equals(1, accumulatedErrors.length);
Expect.equals('error-0', accumulatedErrors[0][0]);
@@ -208,213 +208,215 @@ enum Command {
kValue197,
kValue198,
kValue199,
kValue200
kValue200,
}
void tryClose(List list) {
final List commands = list[0];
final SendPort sendPort = list[1];
sendPort.send(identical(commands[0], Command.kValue0) &&
identical(commands[1], Command.kValue1) &&
identical(commands[2], Command.kValue2) &&
identical(commands[3], Command.kValue3) &&
identical(commands[4], Command.kValue4) &&
identical(commands[5], Command.kValue5) &&
identical(commands[6], Command.kValue6) &&
identical(commands[7], Command.kValue7) &&
identical(commands[8], Command.kValue8) &&
identical(commands[9], Command.kValue9) &&
identical(commands[10], Command.kValue10) &&
identical(commands[11], Command.kValue11) &&
identical(commands[12], Command.kValue12) &&
identical(commands[13], Command.kValue13) &&
identical(commands[14], Command.kValue14) &&
identical(commands[15], Command.kValue15) &&
identical(commands[16], Command.kValue16) &&
identical(commands[17], Command.kValue17) &&
identical(commands[18], Command.kValue18) &&
identical(commands[19], Command.kValue19) &&
identical(commands[20], Command.kValue20) &&
identical(commands[21], Command.kValue21) &&
identical(commands[22], Command.kValue22) &&
identical(commands[23], Command.kValue23) &&
identical(commands[24], Command.kValue24) &&
identical(commands[25], Command.kValue25) &&
identical(commands[26], Command.kValue26) &&
identical(commands[27], Command.kValue27) &&
identical(commands[28], Command.kValue28) &&
identical(commands[29], Command.kValue29) &&
identical(commands[30], Command.kValue30) &&
identical(commands[31], Command.kValue31) &&
identical(commands[32], Command.kValue32) &&
identical(commands[33], Command.kValue33) &&
identical(commands[34], Command.kValue34) &&
identical(commands[35], Command.kValue35) &&
identical(commands[36], Command.kValue36) &&
identical(commands[37], Command.kValue37) &&
identical(commands[38], Command.kValue38) &&
identical(commands[39], Command.kValue39) &&
identical(commands[40], Command.kValue40) &&
identical(commands[41], Command.kValue41) &&
identical(commands[42], Command.kValue42) &&
identical(commands[43], Command.kValue43) &&
identical(commands[44], Command.kValue44) &&
identical(commands[45], Command.kValue45) &&
identical(commands[46], Command.kValue46) &&
identical(commands[47], Command.kValue47) &&
identical(commands[48], Command.kValue48) &&
identical(commands[49], Command.kValue49) &&
identical(commands[50], Command.kValue50) &&
identical(commands[51], Command.kValue51) &&
identical(commands[52], Command.kValue52) &&
identical(commands[53], Command.kValue53) &&
identical(commands[54], Command.kValue54) &&
identical(commands[55], Command.kValue55) &&
identical(commands[56], Command.kValue56) &&
identical(commands[57], Command.kValue57) &&
identical(commands[58], Command.kValue58) &&
identical(commands[59], Command.kValue59) &&
identical(commands[60], Command.kValue60) &&
identical(commands[61], Command.kValue61) &&
identical(commands[62], Command.kValue62) &&
identical(commands[63], Command.kValue63) &&
identical(commands[64], Command.kValue64) &&
identical(commands[65], Command.kValue65) &&
identical(commands[66], Command.kValue66) &&
identical(commands[67], Command.kValue67) &&
identical(commands[68], Command.kValue68) &&
identical(commands[69], Command.kValue69) &&
identical(commands[70], Command.kValue70) &&
identical(commands[71], Command.kValue71) &&
identical(commands[72], Command.kValue72) &&
identical(commands[73], Command.kValue73) &&
identical(commands[74], Command.kValue74) &&
identical(commands[75], Command.kValue75) &&
identical(commands[76], Command.kValue76) &&
identical(commands[77], Command.kValue77) &&
identical(commands[78], Command.kValue78) &&
identical(commands[79], Command.kValue79) &&
identical(commands[80], Command.kValue80) &&
identical(commands[81], Command.kValue81) &&
identical(commands[82], Command.kValue82) &&
identical(commands[83], Command.kValue83) &&
identical(commands[84], Command.kValue84) &&
identical(commands[85], Command.kValue85) &&
identical(commands[86], Command.kValue86) &&
identical(commands[87], Command.kValue87) &&
identical(commands[88], Command.kValue88) &&
identical(commands[89], Command.kValue89) &&
identical(commands[90], Command.kValue90) &&
identical(commands[91], Command.kValue91) &&
identical(commands[92], Command.kValue92) &&
identical(commands[93], Command.kValue93) &&
identical(commands[94], Command.kValue94) &&
identical(commands[95], Command.kValue95) &&
identical(commands[96], Command.kValue96) &&
identical(commands[97], Command.kValue97) &&
identical(commands[98], Command.kValue98) &&
identical(commands[99], Command.kValue99) &&
identical(commands[100], Command.kValue100) &&
identical(commands[101], Command.kValue101) &&
identical(commands[102], Command.kValue102) &&
identical(commands[103], Command.kValue103) &&
identical(commands[104], Command.kValue104) &&
identical(commands[105], Command.kValue105) &&
identical(commands[106], Command.kValue106) &&
identical(commands[107], Command.kValue107) &&
identical(commands[108], Command.kValue108) &&
identical(commands[109], Command.kValue109) &&
identical(commands[110], Command.kValue110) &&
identical(commands[111], Command.kValue111) &&
identical(commands[112], Command.kValue112) &&
identical(commands[113], Command.kValue113) &&
identical(commands[114], Command.kValue114) &&
identical(commands[115], Command.kValue115) &&
identical(commands[116], Command.kValue116) &&
identical(commands[117], Command.kValue117) &&
identical(commands[118], Command.kValue118) &&
identical(commands[119], Command.kValue119) &&
identical(commands[120], Command.kValue120) &&
identical(commands[121], Command.kValue121) &&
identical(commands[122], Command.kValue122) &&
identical(commands[123], Command.kValue123) &&
identical(commands[124], Command.kValue124) &&
identical(commands[125], Command.kValue125) &&
identical(commands[126], Command.kValue126) &&
identical(commands[127], Command.kValue127) &&
identical(commands[128], Command.kValue128) &&
identical(commands[129], Command.kValue129) &&
identical(commands[130], Command.kValue130) &&
identical(commands[131], Command.kValue131) &&
identical(commands[132], Command.kValue132) &&
identical(commands[133], Command.kValue133) &&
identical(commands[134], Command.kValue134) &&
identical(commands[135], Command.kValue135) &&
identical(commands[136], Command.kValue136) &&
identical(commands[137], Command.kValue137) &&
identical(commands[138], Command.kValue138) &&
identical(commands[139], Command.kValue139) &&
identical(commands[140], Command.kValue140) &&
identical(commands[141], Command.kValue141) &&
identical(commands[142], Command.kValue142) &&
identical(commands[143], Command.kValue143) &&
identical(commands[144], Command.kValue144) &&
identical(commands[145], Command.kValue145) &&
identical(commands[146], Command.kValue146) &&
identical(commands[147], Command.kValue147) &&
identical(commands[148], Command.kValue148) &&
identical(commands[149], Command.kValue149) &&
identical(commands[150], Command.kValue150) &&
identical(commands[151], Command.kValue151) &&
identical(commands[152], Command.kValue152) &&
identical(commands[153], Command.kValue153) &&
identical(commands[154], Command.kValue154) &&
identical(commands[155], Command.kValue155) &&
identical(commands[156], Command.kValue156) &&
identical(commands[157], Command.kValue157) &&
identical(commands[158], Command.kValue158) &&
identical(commands[159], Command.kValue159) &&
identical(commands[160], Command.kValue160) &&
identical(commands[161], Command.kValue161) &&
identical(commands[162], Command.kValue162) &&
identical(commands[163], Command.kValue163) &&
identical(commands[164], Command.kValue164) &&
identical(commands[165], Command.kValue165) &&
identical(commands[166], Command.kValue166) &&
identical(commands[167], Command.kValue167) &&
identical(commands[168], Command.kValue168) &&
identical(commands[169], Command.kValue169) &&
identical(commands[170], Command.kValue170) &&
identical(commands[171], Command.kValue171) &&
identical(commands[172], Command.kValue172) &&
identical(commands[173], Command.kValue173) &&
identical(commands[174], Command.kValue174) &&
identical(commands[175], Command.kValue175) &&
identical(commands[176], Command.kValue176) &&
identical(commands[177], Command.kValue177) &&
identical(commands[178], Command.kValue178) &&
identical(commands[179], Command.kValue179) &&
identical(commands[180], Command.kValue180) &&
identical(commands[181], Command.kValue181) &&
identical(commands[182], Command.kValue182) &&
identical(commands[183], Command.kValue183) &&
identical(commands[184], Command.kValue184) &&
identical(commands[185], Command.kValue185) &&
identical(commands[186], Command.kValue186) &&
identical(commands[187], Command.kValue187) &&
identical(commands[188], Command.kValue188) &&
identical(commands[189], Command.kValue189) &&
identical(commands[190], Command.kValue190) &&
identical(commands[191], Command.kValue191) &&
identical(commands[192], Command.kValue192) &&
identical(commands[193], Command.kValue193) &&
identical(commands[194], Command.kValue194) &&
identical(commands[195], Command.kValue195) &&
identical(commands[196], Command.kValue196) &&
identical(commands[197], Command.kValue197) &&
identical(commands[198], Command.kValue198) &&
identical(commands[199], Command.kValue199) &&
identical(commands[200], Command.kValue200));
sendPort.send(
identical(commands[0], Command.kValue0) &&
identical(commands[1], Command.kValue1) &&
identical(commands[2], Command.kValue2) &&
identical(commands[3], Command.kValue3) &&
identical(commands[4], Command.kValue4) &&
identical(commands[5], Command.kValue5) &&
identical(commands[6], Command.kValue6) &&
identical(commands[7], Command.kValue7) &&
identical(commands[8], Command.kValue8) &&
identical(commands[9], Command.kValue9) &&
identical(commands[10], Command.kValue10) &&
identical(commands[11], Command.kValue11) &&
identical(commands[12], Command.kValue12) &&
identical(commands[13], Command.kValue13) &&
identical(commands[14], Command.kValue14) &&
identical(commands[15], Command.kValue15) &&
identical(commands[16], Command.kValue16) &&
identical(commands[17], Command.kValue17) &&
identical(commands[18], Command.kValue18) &&
identical(commands[19], Command.kValue19) &&
identical(commands[20], Command.kValue20) &&
identical(commands[21], Command.kValue21) &&
identical(commands[22], Command.kValue22) &&
identical(commands[23], Command.kValue23) &&
identical(commands[24], Command.kValue24) &&
identical(commands[25], Command.kValue25) &&
identical(commands[26], Command.kValue26) &&
identical(commands[27], Command.kValue27) &&
identical(commands[28], Command.kValue28) &&
identical(commands[29], Command.kValue29) &&
identical(commands[30], Command.kValue30) &&
identical(commands[31], Command.kValue31) &&
identical(commands[32], Command.kValue32) &&
identical(commands[33], Command.kValue33) &&
identical(commands[34], Command.kValue34) &&
identical(commands[35], Command.kValue35) &&
identical(commands[36], Command.kValue36) &&
identical(commands[37], Command.kValue37) &&
identical(commands[38], Command.kValue38) &&
identical(commands[39], Command.kValue39) &&
identical(commands[40], Command.kValue40) &&
identical(commands[41], Command.kValue41) &&
identical(commands[42], Command.kValue42) &&
identical(commands[43], Command.kValue43) &&
identical(commands[44], Command.kValue44) &&
identical(commands[45], Command.kValue45) &&
identical(commands[46], Command.kValue46) &&
identical(commands[47], Command.kValue47) &&
identical(commands[48], Command.kValue48) &&
identical(commands[49], Command.kValue49) &&
identical(commands[50], Command.kValue50) &&
identical(commands[51], Command.kValue51) &&
identical(commands[52], Command.kValue52) &&
identical(commands[53], Command.kValue53) &&
identical(commands[54], Command.kValue54) &&
identical(commands[55], Command.kValue55) &&
identical(commands[56], Command.kValue56) &&
identical(commands[57], Command.kValue57) &&
identical(commands[58], Command.kValue58) &&
identical(commands[59], Command.kValue59) &&
identical(commands[60], Command.kValue60) &&
identical(commands[61], Command.kValue61) &&
identical(commands[62], Command.kValue62) &&
identical(commands[63], Command.kValue63) &&
identical(commands[64], Command.kValue64) &&
identical(commands[65], Command.kValue65) &&
identical(commands[66], Command.kValue66) &&
identical(commands[67], Command.kValue67) &&
identical(commands[68], Command.kValue68) &&
identical(commands[69], Command.kValue69) &&
identical(commands[70], Command.kValue70) &&
identical(commands[71], Command.kValue71) &&
identical(commands[72], Command.kValue72) &&
identical(commands[73], Command.kValue73) &&
identical(commands[74], Command.kValue74) &&
identical(commands[75], Command.kValue75) &&
identical(commands[76], Command.kValue76) &&
identical(commands[77], Command.kValue77) &&
identical(commands[78], Command.kValue78) &&
identical(commands[79], Command.kValue79) &&
identical(commands[80], Command.kValue80) &&
identical(commands[81], Command.kValue81) &&
identical(commands[82], Command.kValue82) &&
identical(commands[83], Command.kValue83) &&
identical(commands[84], Command.kValue84) &&
identical(commands[85], Command.kValue85) &&
identical(commands[86], Command.kValue86) &&
identical(commands[87], Command.kValue87) &&
identical(commands[88], Command.kValue88) &&
identical(commands[89], Command.kValue89) &&
identical(commands[90], Command.kValue90) &&
identical(commands[91], Command.kValue91) &&
identical(commands[92], Command.kValue92) &&
identical(commands[93], Command.kValue93) &&
identical(commands[94], Command.kValue94) &&
identical(commands[95], Command.kValue95) &&
identical(commands[96], Command.kValue96) &&
identical(commands[97], Command.kValue97) &&
identical(commands[98], Command.kValue98) &&
identical(commands[99], Command.kValue99) &&
identical(commands[100], Command.kValue100) &&
identical(commands[101], Command.kValue101) &&
identical(commands[102], Command.kValue102) &&
identical(commands[103], Command.kValue103) &&
identical(commands[104], Command.kValue104) &&
identical(commands[105], Command.kValue105) &&
identical(commands[106], Command.kValue106) &&
identical(commands[107], Command.kValue107) &&
identical(commands[108], Command.kValue108) &&
identical(commands[109], Command.kValue109) &&
identical(commands[110], Command.kValue110) &&
identical(commands[111], Command.kValue111) &&
identical(commands[112], Command.kValue112) &&
identical(commands[113], Command.kValue113) &&
identical(commands[114], Command.kValue114) &&
identical(commands[115], Command.kValue115) &&
identical(commands[116], Command.kValue116) &&
identical(commands[117], Command.kValue117) &&
identical(commands[118], Command.kValue118) &&
identical(commands[119], Command.kValue119) &&
identical(commands[120], Command.kValue120) &&
identical(commands[121], Command.kValue121) &&
identical(commands[122], Command.kValue122) &&
identical(commands[123], Command.kValue123) &&
identical(commands[124], Command.kValue124) &&
identical(commands[125], Command.kValue125) &&
identical(commands[126], Command.kValue126) &&
identical(commands[127], Command.kValue127) &&
identical(commands[128], Command.kValue128) &&
identical(commands[129], Command.kValue129) &&
identical(commands[130], Command.kValue130) &&
identical(commands[131], Command.kValue131) &&
identical(commands[132], Command.kValue132) &&
identical(commands[133], Command.kValue133) &&
identical(commands[134], Command.kValue134) &&
identical(commands[135], Command.kValue135) &&
identical(commands[136], Command.kValue136) &&
identical(commands[137], Command.kValue137) &&
identical(commands[138], Command.kValue138) &&
identical(commands[139], Command.kValue139) &&
identical(commands[140], Command.kValue140) &&
identical(commands[141], Command.kValue141) &&
identical(commands[142], Command.kValue142) &&
identical(commands[143], Command.kValue143) &&
identical(commands[144], Command.kValue144) &&
identical(commands[145], Command.kValue145) &&
identical(commands[146], Command.kValue146) &&
identical(commands[147], Command.kValue147) &&
identical(commands[148], Command.kValue148) &&
identical(commands[149], Command.kValue149) &&
identical(commands[150], Command.kValue150) &&
identical(commands[151], Command.kValue151) &&
identical(commands[152], Command.kValue152) &&
identical(commands[153], Command.kValue153) &&
identical(commands[154], Command.kValue154) &&
identical(commands[155], Command.kValue155) &&
identical(commands[156], Command.kValue156) &&
identical(commands[157], Command.kValue157) &&
identical(commands[158], Command.kValue158) &&
identical(commands[159], Command.kValue159) &&
identical(commands[160], Command.kValue160) &&
identical(commands[161], Command.kValue161) &&
identical(commands[162], Command.kValue162) &&
identical(commands[163], Command.kValue163) &&
identical(commands[164], Command.kValue164) &&
identical(commands[165], Command.kValue165) &&
identical(commands[166], Command.kValue166) &&
identical(commands[167], Command.kValue167) &&
identical(commands[168], Command.kValue168) &&
identical(commands[169], Command.kValue169) &&
identical(commands[170], Command.kValue170) &&
identical(commands[171], Command.kValue171) &&
identical(commands[172], Command.kValue172) &&
identical(commands[173], Command.kValue173) &&
identical(commands[174], Command.kValue174) &&
identical(commands[175], Command.kValue175) &&
identical(commands[176], Command.kValue176) &&
identical(commands[177], Command.kValue177) &&
identical(commands[178], Command.kValue178) &&
identical(commands[179], Command.kValue179) &&
identical(commands[180], Command.kValue180) &&
identical(commands[181], Command.kValue181) &&
identical(commands[182], Command.kValue182) &&
identical(commands[183], Command.kValue183) &&
identical(commands[184], Command.kValue184) &&
identical(commands[185], Command.kValue185) &&
identical(commands[186], Command.kValue186) &&
identical(commands[187], Command.kValue187) &&
identical(commands[188], Command.kValue188) &&
identical(commands[189], Command.kValue189) &&
identical(commands[190], Command.kValue190) &&
identical(commands[191], Command.kValue191) &&
identical(commands[192], Command.kValue192) &&
identical(commands[193], Command.kValue193) &&
identical(commands[194], Command.kValue194) &&
identical(commands[195], Command.kValue195) &&
identical(commands[196], Command.kValue196) &&
identical(commands[197], Command.kValue197) &&
identical(commands[198], Command.kValue198) &&
identical(commands[199], Command.kValue199) &&
identical(commands[200], Command.kValue200),
);
}
main(args) async {
@@ -623,9 +625,9 @@ main(args) async {
Command.kValue197,
Command.kValue198,
Command.kValue199,
Command.kValue200
Command.kValue200,
],
rp.sendPort
rp.sendPort,
]);
await si.moveNext();
Expect.equals(true, si.current);
@@ -163,9 +163,7 @@ class SendReceiveTest extends SendReceiveTestBase {
Future testSharable() async {
print('testSharable');
final sharableObjectsCopy = await sendReceive([
...sharableObjects,
]);
final sharableObjectsCopy = await sendReceive([...sharableObjects]);
Expect.notIdentical(sharableObjects, sharableObjectsCopy);
for (int i = 0; i < sharableObjects.length; ++i) {
Expect.identical(sharableObjects[i], sharableObjectsCopy[i]);
@@ -180,7 +178,9 @@ class SendReceiveTest extends SendReceiveTestBase {
]);
Expect.notIdentical(sharableObjects, sharableObjectsCopy);
Expect.equals(
notAllocatableInTLAB[0], (sharableObjectsCopy[0] as Uint8List)[0]);
notAllocatableInTLAB[0],
(sharableObjectsCopy[0] as Uint8List)[0],
);
for (int i = 0; i < sharableObjects.length; ++i) {
Expect.identical(sharableObjects[i], sharableObjectsCopy[i + 1]);
}
@@ -188,10 +188,7 @@ class SendReceiveTest extends SendReceiveTestBase {
Future testCopyableClosures() async {
print('testCopyableClosures');
final copy = await sendReceive([
notAllocatableInTLAB,
...copyableClosures,
]);
final copy = await sendReceive([notAllocatableInTLAB, ...copyableClosures]);
for (int i = 0; i < copyableClosures.length; ++i) {
Expect.notIdentical(copyableClosures[i], copy[1 + i]);
Expect.equals(copyableClosures[i].runtimeType, copy[1 + i].runtimeType);
@@ -214,7 +211,13 @@ class SendReceiveTest extends SendReceiveTestBase {
final bytes = malloc.allocate<Uint8>(count);
msanUnpoison(bytes, count);
final td = createUnmodifiableTypedData(
Dart_TypedData_kUint8, bytes, count, nullptr, 0, nullptr);
Dart_TypedData_kUint8,
bytes,
count,
nullptr,
0,
nullptr,
);
Expect.equals(count, td.length);
{
@@ -231,23 +234,38 @@ main() async {
}
@Native<
Handle Function(
Int, Pointer<Uint8>, IntPtr, Pointer<Void>, IntPtr, Pointer<Void>)>(
symbol: "Dart_NewUnmodifiableExternalTypedDataWithFinalizer")
external Uint8List createUnmodifiableTypedData(int type, Pointer<Uint8> data,
int length, Pointer<Void> peer, int externalSize, Pointer<Void> callback);
Handle Function(
Int,
Pointer<Uint8>,
IntPtr,
Pointer<Void>,
IntPtr,
Pointer<Void>,
)
>(symbol: "Dart_NewUnmodifiableExternalTypedDataWithFinalizer")
external Uint8List createUnmodifiableTypedData(
int type,
Pointer<Uint8> data,
int length,
Pointer<Void> peer,
int externalSize,
Pointer<Void> callback,
);
final msanUnpoisonPointer =
DynamicLibrary.process().providesSymbol("__msan_unpoison")
? DynamicLibrary.process()
.lookup<NativeFunction<Void Function(Pointer<Void>, Size)>>(
"__msan_unpoison")
: nullptr;
? DynamicLibrary.process()
.lookup<NativeFunction<Void Function(Pointer<Void>, Size)>>(
"__msan_unpoison",
)
: nullptr;
void msanUnpoison(Pointer<Uint8> pointer, int size) {
if (msanUnpoisonPointer != nullptr) {
msanUnpoisonPointer.asFunction<void Function(Pointer<Void>, int)>()(
pointer.cast(), size);
pointer.cast(),
size,
);
}
}
@@ -56,19 +56,28 @@ Uint8List initializeUint8List(Uint8List l) {
return l;
}
final Uint8List largeExternalTypedData =
initializeUint8List(File(Platform.resolvedExecutable).readAsBytesSync());
final Uint8List largeInternalTypedData =
initializeUint8List(Uint8List(20 * 1024 * 1024));
final Uint8List largeExternalTypedData = initializeUint8List(
File(Platform.resolvedExecutable).readAsBytesSync(),
);
final Uint8List largeInternalTypedData = initializeUint8List(
Uint8List(20 * 1024 * 1024),
);
final Uint8List smallExternalTypedData =
initializeUint8List(File(Platform.script.toFilePath()).readAsBytesSync());
final Uint8List smallExternalTypedDataView =
Uint8List.view(smallExternalTypedData.buffer, 1, 1);
final Uint8List smallExternalTypedData = initializeUint8List(
File(Platform.script.toFilePath()).readAsBytesSync(),
);
final Uint8List smallExternalTypedDataView = Uint8List.view(
smallExternalTypedData.buffer,
1,
1,
);
final Uint8List smallInternalTypedData = Uint8List.fromList([0, 1, 2]);
final Uint8List smallInternalTypedDataView =
Uint8List.view(smallInternalTypedData.buffer, 1, 1);
final Uint8List smallInternalTypedDataView = Uint8List.view(
smallInternalTypedData.buffer,
1,
1,
);
final Uint8List notAllocatableInTLAB = largeInternalTypedData;
final Object invalidObject = ClassWithNativeFields();
@@ -264,10 +273,7 @@ class SendReceiveTest extends SendReceiveTestBase {
Future testTransferrable() async {
print('testTransferrable');
final td = TransferableTypedData.fromList([Uint8List(10)..[0] = 42]);
final graph = [
td,
invalidObject,
];
final graph = [td, invalidObject];
Expect.throwsArgumentError(() => sendPort.send(graph));
Expect.equals(42, td.materialize().asInt8List()[0]);
}
@@ -275,11 +281,7 @@ class SendReceiveTest extends SendReceiveTestBase {
Future testTransferrable2() async {
print('testTransferrable2');
final td = TransferableTypedData.fromList([Uint8List(10)..[0] = 42]);
final graph = [
td,
notAllocatableInTLAB,
invalidObject,
];
final graph = [td, notAllocatableInTLAB, invalidObject];
Expect.throwsArgumentError(() => sendPort.send(graph));
Expect.equals(42, td.materialize().asInt8List()[0]);
}
@@ -287,9 +289,7 @@ class SendReceiveTest extends SendReceiveTestBase {
Future testTransferrable3() async {
print('testTransferrable3');
final td = TransferableTypedData.fromList([Uint8List(10)..[0] = 42]);
final graph = [
td,
];
final graph = [td];
final result = await sendReceive(graph);
Expect.throwsArgumentError(() => td.materialize());
final tdCopy = result[0];
@@ -299,10 +299,7 @@ class SendReceiveTest extends SendReceiveTestBase {
Future testTransferrable4() async {
print('testTransferrable4');
final td = TransferableTypedData.fromList([Uint8List(10)..[0] = 42]);
final graph = [
notAllocatableInTLAB,
td,
];
final graph = [notAllocatableInTLAB, td];
final result = await sendReceive(graph);
Expect.throwsArgumentError(() => td.materialize());
final tdCopy = result[1] as TransferableTypedData;
@@ -319,10 +316,7 @@ class SendReceiveTest extends SendReceiveTestBase {
Future testExternalTypedData() async {
print('testExternalTypedData');
final graph = [
notAllocatableInTLAB,
largeExternalTypedData,
];
final graph = [notAllocatableInTLAB, largeExternalTypedData];
for (int i = 0; i < 10; ++i) {
final result = await sendReceive(graph);
final etd = result[1];
@@ -332,10 +326,7 @@ class SendReceiveTest extends SendReceiveTestBase {
Future testExternalTypedData2() async {
print('testExternalTypedData2');
final graph = [
largeExternalTypedData,
notAllocatableInTLAB,
];
final graph = [largeExternalTypedData, notAllocatableInTLAB];
for (int i = 0; i < 10; ++i) {
final result = await sendReceive(graph);
final etd = result[0];
@@ -345,20 +336,13 @@ class SendReceiveTest extends SendReceiveTestBase {
Future testExternalTypedData3() async {
print('testExternalTypedData3');
final graph = [
notAllocatableInTLAB,
largeExternalTypedData,
invalidObject,
];
final graph = [notAllocatableInTLAB, largeExternalTypedData, invalidObject];
Expect.throwsArgumentError(() => sendPort.send(graph));
}
Future testExternalTypedData4() async {
print('testExternalTypedData4');
final graph = [
largeExternalTypedData,
invalidObject,
];
final graph = [largeExternalTypedData, invalidObject];
Expect.throwsArgumentError(() => sendPort.send(graph));
}
@@ -382,10 +366,7 @@ class SendReceiveTest extends SendReceiveTestBase {
Future testInternalTypedDataView() async {
print('testInternalTypedDataView');
final graph = [
smallInternalTypedDataView,
smallInternalTypedData,
];
final graph = [smallInternalTypedDataView, smallInternalTypedData];
final copiedGraph = await sendReceive(graph);
Expect.notIdentical(graph[0], copiedGraph[0]);
Expect.notIdentical(graph[1], copiedGraph[1]);
@@ -395,10 +376,7 @@ class SendReceiveTest extends SendReceiveTestBase {
Future testInternalTypedDataView2() async {
print('testInternalTypedDataView2');
final graph = [
smallInternalTypedData,
smallInternalTypedDataView,
];
final graph = [smallInternalTypedData, smallInternalTypedDataView];
final copiedGraph = await sendReceive(graph);
Expect.notIdentical(graph[0], copiedGraph[0]);
Expect.notIdentical(graph[1], copiedGraph[1]);
@@ -436,10 +414,7 @@ class SendReceiveTest extends SendReceiveTestBase {
Future testExternalTypedDataView() async {
print('testExternalTypedDataView');
final graph = [
smallExternalTypedDataView,
smallExternalTypedData,
];
final graph = [smallExternalTypedDataView, smallExternalTypedData];
final copiedGraph = await sendReceive(graph);
Expect.notIdentical(graph[0], copiedGraph[0]);
Expect.notIdentical(graph[1], copiedGraph[1]);
@@ -449,10 +424,7 @@ class SendReceiveTest extends SendReceiveTestBase {
Future testExternalTypedDataView2() async {
print('testExternalTypedDataView2');
final graph = [
smallExternalTypedData,
smallExternalTypedDataView,
];
final graph = [smallExternalTypedData, smallExternalTypedDataView];
final copiedGraph = await sendReceive(graph);
Expect.notIdentical(graph[0], copiedGraph[0]);
Expect.notIdentical(graph[1], copiedGraph[1]);
@@ -512,7 +484,9 @@ class SendReceiveTest extends SendReceiveTestBase {
Expect.equals(42, mapCopy.values.single);
Expect.notIdentical(obj, mapCopy.keys.single);
Expect.notEquals(
identityHashCode(obj), identityHashCode(mapCopy.keys.single));
identityHashCode(obj),
identityHashCode(mapCopy.keys.single),
);
Expect.equals(null, mapCopy[obj]);
Expect.equals(42, mapCopy[mapCopy.keys.single]);
}
@@ -529,7 +503,9 @@ class SendReceiveTest extends SendReceiveTestBase {
Expect.equals(42, mapCopy.values.single);
Expect.notIdentical(obj, mapCopy.keys.single);
Expect.notEquals(
identityHashCode(obj), identityHashCode(mapCopy.keys.single));
identityHashCode(obj),
identityHashCode(mapCopy.keys.single),
);
Expect.equals(null, mapCopy[obj]);
Expect.equals(42, mapCopy[mapCopy.keys.single]);
}
@@ -582,7 +558,9 @@ class SendReceiveTest extends SendReceiveTestBase {
Expect.equals(obj.runtimeType, setCopy.toList()[1].runtimeType);
Expect.notIdentical(obj, setCopy.toList()[1]);
Expect.notEquals(
identityHashCode(obj), identityHashCode(setCopy.toList()[1]));
identityHashCode(obj),
identityHashCode(setCopy.toList()[1]),
);
Expect.isFalse(setCopy.contains(obj));
Expect.isTrue(setCopy.contains(setCopy.toList()[1]));
}
@@ -601,7 +579,9 @@ class SendReceiveTest extends SendReceiveTestBase {
Expect.equals(obj.runtimeType, setCopy.toList()[1].runtimeType);
Expect.notIdentical(obj, setCopy.toList()[1]);
Expect.notEquals(
identityHashCode(obj), identityHashCode(setCopy.toList()[1]));
identityHashCode(obj),
identityHashCode(setCopy.toList()[1]),
);
Expect.isFalse(setCopy.contains(obj));
Expect.isTrue(setCopy.contains(setCopy.toList()[1]));
}
@@ -632,12 +612,16 @@ class SendReceiveTest extends SendReceiveTestBase {
Future testSlowOnly() async {
print('testSlowOnly');
for (final smallPrimitive in smallPrimitives) {
expectGraphsMatch([notAllocatableInTLAB, smallPrimitive],
await sendReceive([notAllocatableInTLAB, smallPrimitive]));
expectGraphsMatch([
notAllocatableInTLAB,
smallPrimitive,
], await sendReceive([notAllocatableInTLAB, smallPrimitive]));
}
for (final smallContainer in smallContainers) {
expectGraphsMatch([notAllocatableInTLAB, smallContainer],
await sendReceive([notAllocatableInTLAB, smallContainer]));
expectGraphsMatch([
notAllocatableInTLAB,
smallContainer,
], await sendReceive([notAllocatableInTLAB, smallContainer]));
}
}
@@ -654,10 +638,7 @@ class SendReceiveTest extends SendReceiveTestBase {
expando4[expando4] = {'foo': 'bar'};
{
final result = await sendReceive([
key,
expando1,
]);
final result = await sendReceive([key, expando1]);
final keyCopy = result[0];
final expando1Copy = result[1] as Expando;
final expando2Copy = expando1Copy[keyCopy] as Expando;
@@ -666,10 +647,7 @@ class SendReceiveTest extends SendReceiveTestBase {
Expect.equals('bar', (expando4Copy[expando4Copy] as Map)['foo']);
}
{
final result = await sendReceive([
expando1,
key,
]);
final result = await sendReceive([expando1, key]);
final expando1Copy = result[0] as Expando;
final keyCopy = result[1];
final expando2Copy = expando1Copy[keyCopy] as Expando;
@@ -678,11 +656,7 @@ class SendReceiveTest extends SendReceiveTestBase {
Expect.equals('bar', (expando4Copy[expando4Copy] as Map)['foo']);
}
{
final result = await sendReceive([
expando1,
notAllocatableInTLAB,
key,
]);
final result = await sendReceive([expando1, notAllocatableInTLAB, key]);
final expando1Copy = result[0] as Expando;
final keyCopy = result[2];
final expando2Copy = expando1Copy[keyCopy] as Expando;
@@ -691,11 +665,7 @@ class SendReceiveTest extends SendReceiveTestBase {
Expect.equals('bar', (expando4Copy[expando4Copy] as Map)['foo']);
}
{
final result = await sendReceive([
key,
notAllocatableInTLAB,
expando1,
]);
final result = await sendReceive([key, notAllocatableInTLAB, expando1]);
final keyCopy = result[0];
final expando1Copy = result[2] as Expando;
final expando2Copy = expando1Copy[keyCopy] as Expando;
@@ -800,7 +770,8 @@ class SendReceiveTest extends SendReceiveTestBase {
}
for (final closure in nonCopyableClosures) {
Expect.throwsArgumentError(
() => sendPort.send([notAllocatableInTLAB, closure]));
() => sendPort.send([notAllocatableInTLAB, closure]),
);
}
}
}
@@ -15,7 +15,8 @@ import 'package:expect/expect.dart';
import '../timeline_utils.dart';
final int wordSize = sizeOf<IntPtr>();
final bool useCompressedPointers = wordSize == 8 &&
final bool useCompressedPointers =
wordSize == 8 &&
(Platform.isAndroid ||
Platform.isIOS ||
Platform.executable.contains('64C'));
@@ -47,9 +48,11 @@ Future main(List<String> args) async {
final sendPort = rp.sendPort;
sendPort.send(Object());
sendPort.send(List<dynamic>.filled(2, null)
..[0] = Object()
..[1] = Object());
sendPort.send(
List<dynamic>.filled(2, null)
..[0] = Object()
..[1] = Object(),
);
sendPort.send(Uint8List(11));
rp.close();
@@ -70,12 +73,16 @@ Future main(List<String> args) async {
Expect.equals(objectSize(0), copyOperations[0].bytesCopied);
Expect.equals(
arraySize(2) + 2 * objectSize(0), copyOperations[1].bytesCopied);
arraySize(2) + 2 * objectSize(0),
copyOperations[1].bytesCopied,
);
Expect.equals(typedDataSize(11), copyOperations[2].bytesCopied);
}
List<ObjectCopyOperation> getCopyOperations(
List<TimelineEvent> events, String isolateId) {
List<TimelineEvent> events,
String isolateId,
) {
final copyOperations = <ObjectCopyOperation>[];
TimelineEvent? start = null;
@@ -89,11 +96,14 @@ List<ObjectCopyOperation> getCopyOperations(
final us = e.ts - start.ts;
final threadUs = e.tts != null ? (e.tts! - start.tts!) : 0;
copyOperations.add(ObjectCopyOperation(
copyOperations.add(
ObjectCopyOperation(
us,
threadUs,
int.parse(e.args['AllocatedBytes']!),
int.parse(e.args['CopiedObjects']!)));
int.parse(e.args['CopiedObjects']!),
),
);
start = null;
continue;
@@ -112,7 +122,11 @@ class ObjectCopyOperation {
final int objectsCopied;
ObjectCopyOperation(
this.us, this.threadUs, this.bytesCopied, this.objectsCopied);
this.us,
this.threadUs,
this.bytesCopied,
this.objectsCopied,
);
String toString() =>
'ObjectCopyOperation($us, $threadUs, $bytesCopied, $objectsCopied)';
@@ -17,8 +17,12 @@ main() async {
asyncStart();
ReceivePort onExit = ReceivePort();
ReceivePort workerStarted = ReceivePort();
final isolate = await Isolate.spawn(worker, workerStarted.sendPort,
onExit: onExit.sendPort, errorsAreFatal: true);
final isolate = await Isolate.spawn(
worker,
workerStarted.sendPort,
onExit: onExit.sendPort,
errorsAreFatal: true,
);
await workerStarted.first;
print('worker started, now killing worker');
isolate.kill(priority: Isolate.immediate);
@@ -36,8 +36,9 @@ main() {
Isolate.spawn(worker, <dynamic>[r, i, rps[i].sendPort]);
}
Future.wait(List<Future<dynamic>>.generate(nWorkers, (i) => rps[i].first))
.whenComplete(() {
Future.wait(
List<Future<dynamic>>.generate(nWorkers, (i) => rps[i].first),
).whenComplete(() {
rps.forEach((rp) => rp.close());
asyncEnd();
});
@@ -31,8 +31,12 @@ main() async {
exitCode = 250;
});
for (int i = 0; i < isolateCount; ++i) {
await Isolate.spawn(isolate, i,
onExit: onExit.sendPort, onError: onError.sendPort);
await Isolate.spawn(
isolate,
i,
onExit: onExit.sendPort,
onError: onError.sendPort,
);
}
final onExits = StreamIterator(onExit);
for (int i = 0; i < isolateCount; ++i) {
@@ -78,5 +82,5 @@ class B implements A {
void sleep(int us) {
final sw = Stopwatch()..start();
while (sw.elapsedMicroseconds < us);
while (sw.elapsedMicroseconds < us) ;
}
@@ -32,8 +32,10 @@ void main() async {
}
// Generate an AOT snapshot.
final spawnTest =
path.join(sdkDir, 'runtime/tests/vm/dart/isolates/func.dart');
final spawnTest = path.join(
sdkDir,
'runtime/tests/vm/dart/isolates/func.dart',
);
Expect.isTrue(File(spawnTest).existsSync(), "Can't locate $spawnTest");
final kernelOutput = File.fromUri(d.uri.resolve('func.dill')).path;
final aotOutput = File.fromUri(d.uri.resolve('func.aot')).path;
@@ -32,7 +32,8 @@ main() async {
});
}
String dartTestFile(int N) => '''
String dartTestFile(int N) =>
'''
import 'dart:async';
import 'dart:isolate';
@@ -35,7 +35,8 @@ main() async {
});
}
String dartTestFile(int N) => '''
String dartTestFile(int N) =>
'''
import 'dart:async';
import 'dart:isolate';
@@ -32,7 +32,8 @@ main() async {
});
}
String dartTestFile(int N) => '''
String dartTestFile(int N) =>
'''
import 'dart:async';
import 'dart:isolate';
@@ -129,7 +129,7 @@ Future<Reloader> launchOn(String file, {bool verbose = false}) async {
'--enable-vm-service:0',
'--no-dds',
'--disable-service-auth-codes',
file
file,
];
final env = Platform.environment;
final executable = Platform.executable;
@@ -157,16 +157,16 @@ class Reloader {
.transform(utf8.decoder)
.transform(const LineSplitter())
.listen((line) {
print('stdout: $line');
_addStdout(line);
});
print('stdout: $line');
_addStdout(line);
});
_process.stderr
.transform(utf8.decoder)
.transform(const LineSplitter())
.listen((line) {
print('stderr: $line');
_addStderr(line);
});
print('stderr: $line');
_addStderr(line);
});
}
Future _waitUntilService() async {
@@ -273,7 +273,11 @@ class Reloader {
}
Future<String> _waitUntilContains(
List<String> lines, Set<_Filter> filterSet, String needle, int N) {
List<String> lines,
Set<_Filter> filterSet,
String needle,
int N,
) {
int count = 0;
bool handleLine(String line) {
@@ -291,13 +295,15 @@ class Reloader {
if (handleLine(line)) return Future.value(line);
}
final c = Completer<String>();
filterSet.add(_Filter(needle, (line) {
if (handleLine(line)) {
c.complete(line);
return true;
}
return false;
}));
filterSet.add(
_Filter(needle, (line) {
if (handleLine(line)) {
c.complete(line);
return true;
}
return false;
}),
);
return c.future;
}
@@ -14,79 +14,107 @@ import 'package:expect/async_helper.dart';
void main(List<String> args) async {
asyncStart();
if (args.length == 0) {
await Isolate.spawnUri(Platform.script, [
"42"
], <Uint8List>[
Uint8List.fromList([1])
]);
await Isolate.spawnUri(Platform.script, [
"42"
], <Uint8ClampedList>[
Uint8ClampedList.fromList([1])
]);
await Isolate.spawnUri(Platform.script, [
"42"
], <Uint16List>[
Uint16List.fromList([1])
]);
await Isolate.spawnUri(Platform.script, [
"42"
], <Uint32List>[
Uint32List.fromList([1])
]);
await Isolate.spawnUri(Platform.script, [
"42"
], <Uint64List>[
Uint64List.fromList([1])
]);
await Isolate.spawnUri(
Platform.script,
["42"],
<Uint8List>[
Uint8List.fromList([1]),
],
);
await Isolate.spawnUri(
Platform.script,
["42"],
<Uint8ClampedList>[
Uint8ClampedList.fromList([1]),
],
);
await Isolate.spawnUri(
Platform.script,
["42"],
<Uint16List>[
Uint16List.fromList([1]),
],
);
await Isolate.spawnUri(
Platform.script,
["42"],
<Uint32List>[
Uint32List.fromList([1]),
],
);
await Isolate.spawnUri(
Platform.script,
["42"],
<Uint64List>[
Uint64List.fromList([1]),
],
);
await Isolate.spawnUri(Platform.script, [
"42"
], <Int8List>[
Int8List.fromList([1])
]);
await Isolate.spawnUri(Platform.script, [
"42"
], <Int16List>[
Int16List.fromList([1])
]);
await Isolate.spawnUri(Platform.script, [
"42"
], <Int32List>[
Int32List.fromList([1])
]);
await Isolate.spawnUri(Platform.script, [
"42"
], <Int64List>[
Int64List.fromList([1])
]);
await Isolate.spawnUri(
Platform.script,
["42"],
<Int8List>[
Int8List.fromList([1]),
],
);
await Isolate.spawnUri(
Platform.script,
["42"],
<Int16List>[
Int16List.fromList([1]),
],
);
await Isolate.spawnUri(
Platform.script,
["42"],
<Int32List>[
Int32List.fromList([1]),
],
);
await Isolate.spawnUri(
Platform.script,
["42"],
<Int64List>[
Int64List.fromList([1]),
],
);
await Isolate.spawnUri(Platform.script, [
"42"
], <Float32List>[
Float32List.fromList([1])
]);
await Isolate.spawnUri(Platform.script, [
"42"
], <Float64List>[
Float64List.fromList([1])
]);
await Isolate.spawnUri(
Platform.script,
["42"],
<Float32List>[
Float32List.fromList([1]),
],
);
await Isolate.spawnUri(
Platform.script,
["42"],
<Float64List>[
Float64List.fromList([1]),
],
);
await Isolate.spawnUri(Platform.script, [
"42"
], <Int32x4List>[
Int32x4List.fromList([Int32x4(1, 2, 3, 4)])
]);
await Isolate.spawnUri(Platform.script, [
"42"
], <Float32x4List>[
Float32x4List.fromList([Float32x4(1, 2, 3, 4)])
]);
await Isolate.spawnUri(Platform.script, [
"42"
], <Float64x2List>[
Float64x2List.fromList([Float64x2(1, 2)])
]);
await Isolate.spawnUri(
Platform.script,
["42"],
<Int32x4List>[
Int32x4List.fromList([Int32x4(1, 2, 3, 4)]),
],
);
await Isolate.spawnUri(
Platform.script,
["42"],
<Float32x4List>[
Float32x4List.fromList([Float32x4(1, 2, 3, 4)]),
],
);
await Isolate.spawnUri(
Platform.script,
["42"],
<Float64x2List>[
Float64x2List.fromList([Float64x2(1, 2)]),
],
);
}
asyncEnd();
}
@@ -19,8 +19,11 @@ Future<void> main(args, message) async {
if (message == null) {
final receivePort = ReceivePort();
final isolate = await Isolate.spawnUri(
Platform.script, <String>[], <SendPort>[receivePort.sendPort],
errorsAreFatal: true);
Platform.script,
<String>[],
<SendPort>[receivePort.sendPort],
errorsAreFatal: true,
);
final result = await receivePort.first;
Expect.equals("done", result);
return;
@@ -37,8 +40,11 @@ Future<void> main(args, message) async {
final receivePort = ReceivePort();
try {
final isolate = await Isolate.spawnUri(
Platform.script, <String>["worker"], <SendPort>[receivePort.sendPort],
errorsAreFatal: true);
Platform.script,
<String>["worker"],
<SendPort>[receivePort.sendPort],
errorsAreFatal: true,
);
final result = await receivePort.first;
Expect.equals("done", result);
sendPort.send("done");
@@ -25,19 +25,19 @@ main() async {
try {
final nestedList = await buildNestedList(<dynamic>[], NESTED_DEPTH);
// Send closure capturing nestedList
await Isolate.spawn((arg) {
arg();
}, () {
print('$nestedList');
});
await Isolate.spawn(
(arg) {
arg();
},
() {
print('$nestedList');
},
);
} catch (e) {
print(e);
Expect.isTrue(checkForRetainingPath(e, <String>[
'NativeClass',
'Baz',
'Fu',
'closure',
]));
Expect.isTrue(
checkForRetainingPath(e, <String>['NativeClass', 'Baz', 'Fu', 'closure']),
);
final msg = e.toString();
Expect.isTrue(msg.split('\n').length > NESTED_DEPTH * 2);
@@ -13,11 +13,9 @@ worker(SendPort sp) async {
try {
Isolate.exit(sp, Fu.unsendable('fu'));
} catch (e) {
Expect.isTrue(checkForRetainingPath(e, <String>[
'NativeClass',
'Baz',
'Fu',
]));
Expect.isTrue(
checkForRetainingPath(e, <String>['NativeClass', 'Baz', 'Fu']),
);
sp.send(true);
}
}
@@ -23,27 +23,34 @@ main() async {
final foo2 = Foo();
await () async {
final foo3 = Foo();
await Isolate.spawn((arg) {
arg();
}, () {
print('${fu.label} $foo1 $foo2 $foo3');
Expect.fail('This closure should fail to be sent, '
'shouldn\'t be called');
});
await Isolate.spawn(
(arg) {
arg();
},
() {
print('${fu.label} $foo1 $foo2 $foo3');
Expect.fail(
'This closure should fail to be sent, '
'shouldn\'t be called',
);
},
);
}();
}();
}();
} catch (e) {
Expect.isTrue(checkForRetainingPath(e, <String>[
'Baz',
'Fu',
if (isAOTRuntime) ...[
'Context',
'main.<anonymous closure>'
] else ...[
'field fu in main.<anonymous closure>'
],
]));
Expect.isTrue(
checkForRetainingPath(e, <String>[
'Baz',
'Fu',
if (isAOTRuntime) ...[
'Context',
'main.<anonymous closure>',
] else ...[
'field fu in main.<anonymous closure>',
],
]),
);
asyncEnd();
}
}
@@ -23,8 +23,11 @@ Future<void> main(args, message) async {
if (message == null) {
final receivePort = ReceivePort();
final isolate = await Isolate.spawnUri(
Platform.script, <String>['worker'], <SendPort>[receivePort.sendPort],
errorsAreFatal: true);
Platform.script,
<String>['worker'],
<SendPort>[receivePort.sendPort],
errorsAreFatal: true,
);
final result = await receivePort.first;
Expect.equals('done', result);
return;
@@ -32,19 +35,25 @@ Future<void> main(args, message) async {
Expect.equals('worker', args[0]);
final SendPort sendPort = message[0] as SendPort;
Expect.throws(() {
sendPort.send(<dynamic>[
<dynamic>[
<dynamic>[const ConstFoo("42")],
],
]);
}, (e) {
print(e);
Expect.isTrue(checkForRetainingPath(e, <String>['ConstFoo']));
Expect.throws(
() {
sendPort.send(<dynamic>[
<dynamic>[
<dynamic>[const ConstFoo("42")],
],
]);
},
(e) {
print(e);
Expect.isTrue(checkForRetainingPath(e, <String>['ConstFoo']));
final msg = e.toString();
Expect.equals(3, msg.split('\n').where((s) => s.contains('_List')).length);
return true;
});
final msg = e.toString();
Expect.equals(
3,
msg.split('\n').where((s) => s.contains('_List')).length,
);
return true;
},
);
sendPort.send('done');
}
@@ -70,27 +70,29 @@ main() async {
for (final pair in [
[
() => Fu.unsendable('fu'),
["NativeClass", "Baz", "Fu"]
["NativeClass", "Baz", "Fu"],
],
[
() => Future.value(123),
["Future"]
["Future"],
],
[
Locked.new,
["Locked"]
["Locked"],
],
[
ExtendsLocked.new,
["ExtendsLocked"]
["ExtendsLocked"],
],
[
ImplementsLocked.new,
["ImplementsLocked"]
]
["ImplementsLocked"],
],
]) {
Expect.throws(() => rp.sendPort.send((pair[0] as Function)()),
(e) => checkForRetainingPath(e, pair[1] as List<String>));
Expect.throws(
() => rp.sendPort.send((pair[0] as Function)()),
(e) => checkForRetainingPath(e, pair[1] as List<String>),
);
}
try {
@@ -30,51 +30,54 @@ void main() {}
''');
{
final process = await Process.start(dartExecutable,
<String>[...Platform.executableArguments, sharedUseTest]);
final process = await Process.start(dartExecutable, <String>[
...Platform.executableArguments,
sharedUseTest,
]);
process.stdout
.transform(utf8.decoder)
.transform(const LineSplitter())
.listen((String line) {
stdout.writeln('stdout:>$line');
stdout.writeln(line);
});
stdout.writeln('stdout:>$line');
stdout.writeln(line);
});
final sb = StringBuffer();
process.stderr
.transform(utf8.decoder)
.transform(const LineSplitter())
.listen((String line) {
stderr.writeln('stderr:>$line');
sb.writeln(line);
});
stderr.writeln('stderr:>$line');
sb.writeln(line);
});
Expect.notEquals(0, await process.exitCode);
Expect.contains(
"Encountered vm:shared when functionality is disabled. "
"Pass --experimental-shared-data",
sb.toString());
"Encountered vm:shared when functionality is disabled. "
"Pass --experimental-shared-data",
sb.toString(),
);
}
{
final process = await Process.start(dartExecutable, <String>[
...Platform.executableArguments,
'--experimental_shared_data',
sharedUseTest
sharedUseTest,
]);
process.stdout
.transform(utf8.decoder)
.transform(const LineSplitter())
.listen((String line) {
stdout.writeln('stdout:>$line');
stdout.writeln(line);
});
stdout.writeln('stdout:>$line');
stdout.writeln(line);
});
final sb = StringBuffer();
process.stderr
.transform(utf8.decoder)
.transform(const LineSplitter())
.listen((String line) {
stderr.writeln('stderr:>$line');
sb.writeln(line);
});
stderr.writeln('stderr:>$line');
sb.writeln(line);
});
final exitCode = await process.exitCode;
if (Platform.version.contains('(main)') ||
Platform.version.contains('(dev)')) {
@@ -82,9 +85,10 @@ void main() {}
} else {
Expect.notEquals(0, exitCode);
Expect.contains(
"Shared memory multithreading in only available for "
"experimentation in dev or main",
sb.toString());
"Shared memory multithreading in only available for "
"experimentation in dev or main",
sb.toString(),
);
}
}
} finally {
@@ -31,47 +31,53 @@ void main(List<String> args) async {
asyncStart();
final testerScriptPath = Platform.script.toFilePath();
final testeeScriptPath =
Platform.script.resolve('shared_primitives_test_body.dart').toFilePath();
final testeeScriptPath = Platform.script
.resolve('shared_primitives_test_body.dart')
.toFilePath();
final Directory tempDir = Directory.systemTemp.createTempSync();
try {
if (isVmAotConfiguration) {
final scriptDill =
path.join(tempDir.path, 'shared_primitives_test_body.dart.dill');
final scriptDill = path.join(
tempDir.path,
'shared_primitives_test_body.dart.dill',
);
await run(
path.joinAll([
'pkg',
'vm',
'tool',
'gen_kernel${Platform.isWindows ? ".bat" : ""}'
]),
<String>[
'--aot',
'--platform=$platformDill',
'-o',
scriptDill,
testeeScriptPath
]);
path.joinAll([
'pkg',
'vm',
'tool',
'gen_kernel${Platform.isWindows ? ".bat" : ""}',
]),
<String>[
'--aot',
'--platform=$platformDill',
'-o',
scriptDill,
testeeScriptPath,
],
);
final elfFile =
path.join(tempDir.path, 'shared_primitives_test_body.dart.dill.elf');
final elfFile = path.join(
tempDir.path,
'shared_primitives_test_body.dart.dill.elf',
);
final stderr = (await runError(genSnapshot, <String>[
'--snapshot-kind=app-aot-elf',
'--elf=$elfFile',
scriptDill,
]))
.join('\n');
])).join('\n');
print('stderr: $stderr');
Expect.contains(
'Encountered dart:concurrent when functionality is disabled. '
'Pass --experimental-shared-data',
stderr);
'Encountered dart:concurrent when functionality is disabled. '
'Pass --experimental-shared-data',
stderr,
);
} else {
final result = await Process.run(Platform.executable, <String>[
...Platform.executableArguments,
'--experimental_shared_data',
testeeScriptPath
testeeScriptPath,
]);
if (Platform.version.contains('(main)') ||
Platform.version.contains('(dev)')) {
@@ -83,9 +89,10 @@ void main(List<String> args) async {
} else {
Expect.notEquals(0, result.exitCode);
Expect.contains(
'Shared memory multithreading in only available for '
'experimentation in dev or main',
result.stderr);
'Shared memory multithreading in only available for '
'experimentation in dev or main',
result.stderr,
);
}
}
} finally {
+27 -24
View File
@@ -27,45 +27,47 @@ void main(List<String> args) async {
asyncStart();
final testerScriptPath = Platform.script.toFilePath();
final testeeScriptPath =
Platform.script.resolve('shared_test_body.dart').toFilePath();
final testeeScriptPath = Platform.script
.resolve('shared_test_body.dart')
.toFilePath();
final Directory tempDir = Directory.systemTemp.createTempSync();
try {
if (isVmAotConfiguration) {
final scriptDill = path.join(tempDir.path, 'shared_test_body.dart.dill');
await run(
path.joinAll([
'pkg',
'vm',
'tool',
'gen_kernel${Platform.isWindows ? ".bat" : ""}'
]),
<String>[
'--aot',
'--platform=$platformDill',
'-o',
scriptDill,
testeeScriptPath
]);
path.joinAll([
'pkg',
'vm',
'tool',
'gen_kernel${Platform.isWindows ? ".bat" : ""}',
]),
<String>[
'--aot',
'--platform=$platformDill',
'-o',
scriptDill,
testeeScriptPath,
],
);
final elfFile = path.join(tempDir.path, 'shared_test_body.dart.dill.elf');
final stderr = (await runError(genSnapshot, <String>[
'--snapshot-kind=app-aot-elf',
'--elf=$elfFile',
scriptDill,
]))
.join('\n');
])).join('\n');
print('stderr: $stderr');
Expect.contains(
'Encountered dart:concurrent when functionality is disabled. '
'Pass --experimental-shared-data',
stderr);
'Encountered dart:concurrent when functionality is disabled. '
'Pass --experimental-shared-data',
stderr,
);
} else {
final result = await Process.run(Platform.executable, <String>[
...Platform.executableArguments,
'--experimental_shared_data',
testeeScriptPath
testeeScriptPath,
]);
if (Platform.version.contains('(main)') ||
Platform.version.contains('(dev)')) {
@@ -77,9 +79,10 @@ void main(List<String> args) async {
} else {
Expect.notEquals(0, result.exitCode);
Expect.contains(
'Shared memory multithreading in only available for '
'experimentation in dev or main',
result.stderr);
'Shared memory multithreading in only available for '
'experimentation in dev or main',
result.stderr,
);
}
}
} finally {
@@ -84,21 +84,22 @@ void main(List<String> args) async {
var sendPort = rpResults.sendPort;
var list = List.generate(
numberOfWorkers,
(index) => Isolate.run(() async {
int countProcessed = 0;
while (true) {
var mine = mutex.runLocked(() => lastProcessed++);
if (mine >= workItems.length) {
break;
}
workItems[mine].doWork(sendPort);
countProcessed++;
mutex.runLocked(() => SharedState.totalProcessed++);
await Future.delayed(Duration(seconds: 0));
}
print('worker $index processed $countProcessed items');
}, debugName: 'worker $index'));
numberOfWorkers,
(index) => Isolate.run(() async {
int countProcessed = 0;
while (true) {
var mine = mutex.runLocked(() => lastProcessed++);
if (mine >= workItems.length) {
break;
}
workItems[mine].doWork(sendPort);
countProcessed++;
mutex.runLocked(() => SharedState.totalProcessed++);
await Future.delayed(Duration(seconds: 0));
}
print('worker $index processed $countProcessed items');
}, debugName: 'worker $index'),
);
await Future.wait(list);
rpResults.close();
Expect.equals(results.keys.length, totalWorkItems);
+37 -22
View File
@@ -11,10 +11,12 @@ export '../../../../../benchmarks/IsolateFibonacci/dart/IsolateFibonacci.dart'
final bool isDebugMode = Platform.resolvedExecutable.contains('Debug');
final bool isSimulator = Platform.resolvedExecutable.contains('SIM');
final bool isArtificialReloadMode = Platform.executableArguments.any((arg) => [
'--hot-reload-rollback-test-mode',
'--hot-reload-test-mode'
].contains(arg));
final bool isArtificialReloadMode = Platform.executableArguments.any(
(arg) => [
'--hot-reload-rollback-test-mode',
'--hot-reload-test-mode',
].contains(arg),
);
// Implements recursive summation:
// sum(n) => n == 0 ? 0
@@ -65,8 +67,9 @@ class Ring {
for (int i = 0; i < n; ++i) {
final port = ReceivePort();
ports.add(StreamIterator(port));
spawnFutures
.add(Isolate.spawn(_ringEntry, port.sendPort, debugName: 'ring-$i'));
spawnFutures.add(
Isolate.spawn(_ringEntry, port.sendPort, debugName: 'ring-$i'),
);
}
await Future.wait(spawnFutures);
final controlSendPorts = <SendPort>[];
@@ -116,14 +119,19 @@ class Ring {
Future<List> run(RingElement buildRingElement(int id)) async {
for (int i = 0; i < size; i++) {
final nextNeighbor = dataSendPorts[(i + 1) % size];
controlSendPorts[i]
.send([Command.kRun, buildRingElement(i), nextNeighbor]);
controlSendPorts[i].send([
Command.kRun,
buildRingElement(i),
nextNeighbor,
]);
}
final results = await Future.wait(receivePorts.map((si) async {
await si.moveNext();
return si.current;
}).toList());
final results = await Future.wait(
receivePorts.map((si) async {
await si.moveNext();
return si.current;
}).toList(),
);
return results;
}
@@ -131,14 +139,19 @@ class Ring {
Future<List> runAndClose(RingElement buildRingElement(int id)) async {
for (int i = 0; i < size; i++) {
final nextNeighbor = dataSendPorts[(i + 1) % size];
controlSendPorts[i]
.send([Command.kRunAndClose, buildRingElement(i), nextNeighbor]);
controlSendPorts[i].send([
Command.kRunAndClose,
buildRingElement(i),
nextNeighbor,
]);
}
final results = await Future.wait(receivePorts.map((si) async {
await si.moveNext();
return si.current;
}).toList());
final results = await Future.wait(
receivePorts.map((si) async {
await si.moveNext();
return si.current;
}).toList(),
);
finalize();
return results;
}
@@ -147,10 +160,12 @@ class Ring {
for (int i = 0; i < size; i++) {
controlSendPorts[i].send([Command.kClose]);
}
final results = await Future.wait(receivePorts.map((si) async {
await si.moveNext();
return si.current;
}).toList());
final results = await Future.wait(
receivePorts.map((si) async {
await si.moveNext();
return si.current;
}).toList(),
);
finalize();
return results;
}
@@ -27,22 +27,23 @@ typedef Dart_ExitIsolateNFT = Void Function();
final ffiTestFunctions = dlopenPlatformSpecific("ffi_test_functions");
final threadPoolBarrierSync = ffiTestFunctions.lookupFunction<
Void Function(
Pointer<NativeFunction<Dart_CurrentIsolateNFT>>,
Pointer<NativeFunction<Dart_EnterIsolateNFT>>,
Pointer<NativeFunction<Dart_ExitIsolateNFT>>,
IntPtr,
Bool,
),
void Function(
Pointer<NativeFunction<Dart_CurrentIsolateNFT>>,
Pointer<NativeFunction<Dart_EnterIsolateNFT>>,
Pointer<NativeFunction<Dart_ExitIsolateNFT>>,
int,
bool,
)
>('ThreadPoolTest_BarrierSync');
final threadPoolBarrierSync = ffiTestFunctions
.lookupFunction<
Void Function(
Pointer<NativeFunction<Dart_CurrentIsolateNFT>>,
Pointer<NativeFunction<Dart_EnterIsolateNFT>>,
Pointer<NativeFunction<Dart_ExitIsolateNFT>>,
IntPtr,
Bool,
),
void Function(
Pointer<NativeFunction<Dart_CurrentIsolateNFT>>,
Pointer<NativeFunction<Dart_EnterIsolateNFT>>,
Pointer<NativeFunction<Dart_ExitIsolateNFT>>,
int,
bool,
)
>('ThreadPoolTest_BarrierSync');
final Pointer<NativeFunction<Dart_CurrentIsolateNFT>> dartCurrentIsolate =
DynamicLibrary.executable().lookup("Dart_CurrentIsolate").cast();
+7 -3
View File
@@ -14,9 +14,13 @@ main() async {
""");
var exitPort = new ReceivePort();
await Isolate.spawnUri(p.toUri(p.absolute(path)), [], null,
packageConfig: p.toUri(p.absolute(".dart_tool/package_config.json")),
onExit: exitPort.sendPort);
await Isolate.spawnUri(
p.toUri(p.absolute(path)),
[],
null,
packageConfig: p.toUri(p.absolute(".dart_tool/package_config.json")),
onExit: exitPort.sendPort,
);
await exitPort.first;
await sourceFile.delete();
}
@@ -21,20 +21,29 @@ Uint8List generateSampleList(final int size) {
void validateReceivedList(final int expectedSize, final list) {
Expect.equals(expectedSize, list.length);
// probe few elements
for (int i = 0;
i < list.length;
i += max<num>(1, expectedSize ~/ 1000) as int) {
for (
int i = 0;
i < list.length;
i += max<num>(1, expectedSize ~/ 1000) as int
) {
Expect.equals(i % 243, list[i]);
}
}
Future<Null> testSend(
bool transferable, int toIsolateSize, int fromIsolateSize) async {
bool transferable,
int toIsolateSize,
int fromIsolateSize,
) async {
asyncStart();
final port = ReceivePort();
final inbox = StreamIterator(port);
await Isolate.spawn(isolateMain,
[transferable, toIsolateSize, fromIsolateSize, port.sendPort]);
await Isolate.spawn(isolateMain, [
transferable,
toIsolateSize,
fromIsolateSize,
port.sendPort,
]);
await inbox.moveNext();
final outbox = inbox.current;
final workWatch = Stopwatch();
@@ -45,10 +54,9 @@ Future<Null> testSend(
outbox.send(transferable ? TransferableTypedData.fromList([data]) : data);
await inbox.moveNext();
validateReceivedList(
fromIsolateSize,
transferable
? inbox.current.materialize().asUint8List()
: inbox.current);
fromIsolateSize,
transferable ? inbox.current.materialize().asUint8List() : inbox.current,
);
}
print('total ${workWatch.elapsedMilliseconds}ms');
outbox.send(null);
@@ -82,10 +90,9 @@ Future<Null> isolateMain(List config) async {
break;
}
validateReceivedList(
toIsolateSize,
transferable
? inbox.current.materialize().asUint8List()
: inbox.current);
toIsolateSize,
transferable ? inbox.current.materialize().asUint8List() : inbox.current,
);
outbox.send(transferable ? TransferableTypedData.fromList([data]) : data);
}
port.close();
@@ -11,13 +11,16 @@ import 'package:expect/expect.dart';
import 'package:native_stack_traces/native_stack_traces.dart';
import 'package:path/path.dart' as path;
final dwarfPath =
path.join(Platform.environment['TEST_COMPILATION_DIR']!, 'debug.so');
final usesObfuscation =
const String.fromEnvironment("test_runner.configuration")
.contains('obfuscate');
final usesDwarf =
const String.fromEnvironment("test_runner.configuration").contains('dwarf');
final dwarfPath = path.join(
Platform.environment['TEST_COMPILATION_DIR']!,
'debug.so',
);
final usesObfuscation = const String.fromEnvironment(
"test_runner.configuration",
).contains('obfuscate');
final usesDwarf = const String.fromEnvironment(
"test_runner.configuration",
).contains('dwarf');
Future<void> main(List<String> args) async {
if (Platform.isAndroid) return;
@@ -95,9 +98,9 @@ Future<List<String>> run(int n) async {
List<String> lines = s.toString().split('\n');
if (usesDwarf) {
final dwarf = Dwarf.fromFile(dwarfPath)!;
lines = await Stream<String>.fromIterable(lines)
.transform(DwarfStackTraceDecoder(dwarf))
.toList();
lines = await Stream<String>.fromIterable(
lines,
).transform(DwarfStackTraceDecoder(dwarf)).toList();
}
final start = lines.indexWhere((line) => line.startsWith('#0'));
lines = lines.skip(start).take(n).toList();

Some files were not shown because too many files have changed in this diff Show More