Skip to content

Commit cce62d3

Browse files
alexmarkovCommit Queue
authored andcommitted
[dyn_modules] Enable pkg/dynamic_modules tests in VM/JIT configuration
Change-Id: Ic7d9ed514969eb72066812f442b51129e4d27204 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426680 Reviewed-by: Sigmund Cherem <[email protected]> Commit-Queue: Alexander Markov <[email protected]>
1 parent 8aa021f commit cce62d3

File tree

7 files changed

+54
-25
lines changed

7 files changed

+54
-25
lines changed

pkg/dynamic_modules/test/data/core_api/modules/entry1.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import 'package:expect/expect.dart';
66

77
@pragma('dyn-module:entry-point')
88
Future<bool> dynamicModuleEntrypoint() async {
9-
final list = ['1','2','3'];
9+
final list = ['1', '2', '3'];
1010
list.add('4');
1111
final list2 = list.map((e) => 'item $e').toList().reversed.toList();
1212
final list3 = <Future>[];

pkg/dynamic_modules/test/data/indirect_expose/shared/private.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,3 @@ class Implementation2 implements Interface {
1212
@override
1313
int method1() => 4;
1414
}
15-

pkg/dynamic_modules/test/runner/main.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import 'dart:io';
99

1010
import 'package:args/args.dart';
1111

12-
import 'aot.dart';
12+
import 'vm.dart';
1313
import 'dart2wasm.dart';
1414
import 'ddc.dart';
1515
import 'load.dart';
@@ -55,7 +55,8 @@ void main(List<String> args) async {
5555
try {
5656
executor = switch (target) {
5757
Target.ddc => DdcExecutor(logger),
58-
Target.aot => AotExecutor(logger),
58+
Target.aot => VmExecutor(logger, mode: VmMode.aot),
59+
Target.jit => VmExecutor(logger, mode: VmMode.jit),
5960
Target.dart2wasm => Dart2wasmExecutor(logger),
6061
};
6162

pkg/dynamic_modules/test/runner/target.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import 'model.dart';
1111
/// Possible backends where the tests can be executed.
1212
enum Target {
1313
aot,
14+
jit,
1415
dart2wasm,
1516
ddc,
1617
}

pkg/dynamic_modules/test/runner/util.dart

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ String _outFolder = Platform.isMacOS ? 'xcodebuild' : 'out';
2929
String configuration = () {
3030
var env = Platform.environment['DART_CONFIGURATION'];
3131
if (env != null) return env;
32-
var folderSegments = _dartBin.resolve('.').pathSegments;
32+
var folderSegments = dartBin.resolve('.').pathSegments;
3333
for (int i = folderSegments.length - 1; i > 0; i--) {
3434
if (folderSegments[i] == _outFolder) {
3535
var candidate = folderSegments[i + 1];
@@ -64,12 +64,12 @@ String _d8Path = (() {
6464
})();
6565

6666
Uri d8Uri = repoRoot.resolve(_d8Path);
67-
Uri _dartBin = Uri.file(Platform.resolvedExecutable);
68-
Uri dartAotBin = _dartBin
67+
Uri dartBin = Uri.file(Platform.resolvedExecutable);
68+
Uri dartAotBin = dartBin
6969
.resolve(Platform.isWindows ? 'dartaotruntime.exe' : 'dartaotruntime');
70-
Uri ddcAotSnapshot = _dartBin.resolve('snapshots/dartdevc_aot.dart.snapshot');
70+
Uri ddcAotSnapshot = dartBin.resolve('snapshots/dartdevc_aot.dart.snapshot');
7171
Uri kernelWorkerAotSnapshot =
72-
_dartBin.resolve('snapshots/kernel_worker_aot.dart.snapshot');
72+
dartBin.resolve('snapshots/kernel_worker_aot.dart.snapshot');
7373
Uri buildRootUri = repoRoot.resolve(buildFolder);
7474
Uri ddcSdkOutline = buildRootUri.resolve('ddc_outline.dill');
7575
Uri ddcSdkJs = buildRootUri.resolve('gen/utils/ddc/stable/sdk/ddc/dart_sdk.js');
@@ -90,8 +90,7 @@ Uri aotRuntimeBin = buildRootUri
9090
.resolve(useProduct ? 'dartaotruntime_product' : 'dartaotruntime');
9191
Uri vmPlatformDill = buildRootUri.resolve('vm_platform_strong.dill');
9292

93-
Uri dart2wasmSnapshot =
94-
_dartBin.resolve('snapshots/dart2wasm_product.snapshot');
93+
Uri dart2wasmSnapshot = dartBin.resolve('snapshots/dart2wasm_product.snapshot');
9594
Uri dart2wasmPlatformDill = buildRootUri.resolve('dart2wasm_platform.dill');
9695
Uri dart2wasmLibrariesSpec = repoRoot.resolve('sdk/lib/libraries.json');
9796
Uri compileBenchmark = repoRoot.resolve('pkg/dart2wasm/tool/compile_benchmark');

pkg/dynamic_modules/test/runner/aot.dart renamed to pkg/dynamic_modules/test/runner/vm.dart

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ import 'model.dart';
1515
import 'util.dart';
1616
import 'target.dart';
1717

18-
/// Logic to build and execute dynamic modules in Dart AOT.
18+
enum VmMode {
19+
aot,
20+
jit,
21+
}
22+
23+
/// Logic to build and execute dynamic modules using Dart VM (AOT or JIT).
1924
///
2025
/// In particular:
2126
/// * The initial app is built as a regular AOT target, except that
@@ -28,13 +33,14 @@ import 'target.dart';
2833
///
2934
/// Note: this assumes that [Platform.resolvedExecutable] is a VM built with the
3035
/// `--dart_dynamic_modules` build flag.
31-
class AotExecutor implements TargetExecutor {
36+
class VmExecutor implements TargetExecutor {
3237
static const rootScheme = 'dev-dart-app';
38+
final VmMode mode;
3339
late final bool _shouldCleanup;
3440
late final Directory _tmp;
3541
final Logger _logger;
3642

37-
AotExecutor(this._logger) {
43+
VmExecutor(this._logger, {required this.mode}) {
3844
/// Allow using an environment variable to run tests on a fixed directory.
3945
/// This prevents the directory from getting deleted too.
4046
var path = Platform.environment['TMP_DIR'] ?? '';
@@ -98,17 +104,23 @@ class AotExecutor implements TargetExecutor {
98104
Future compileApplication(DynamicModuleTest test) async {
99105
_ensureDirectory(test.name);
100106
_logger.info('Compile ${test.name} app');
101-
await _buildKernel(test.name, test.main, test.folder, true);
107+
108+
if (mode == VmMode.aot) {
109+
await _buildKernel(test.name, test.main, test.folder, true);
110+
}
102111
await _buildKernel(test.name, test.main, test.folder, false);
103112

104-
var testDir = _tmp.uri.resolve(test.name).toFilePath();
105-
var args = [
106-
'--snapshot-kind=app-aot-elf',
107-
'--elf=${test.main}.snapshot',
108-
'${test.main}_aot.dill',
109-
];
110-
await runProcess(genSnapshotBin.toFilePath(), args, testDir, _logger,
111-
'aot snapshot ${test.name}/${test.main}');
113+
final testDir = _tmp.uri.resolve(test.name).toFilePath();
114+
115+
if (mode == VmMode.aot) {
116+
var args = [
117+
'--snapshot-kind=app-aot-elf',
118+
'--elf=${test.main}.snapshot',
119+
'${test.main}_aot.dill',
120+
];
121+
await runProcess(genSnapshotBin.toFilePath(), args, testDir, _logger,
122+
'aot snapshot ${test.name}/${test.main}');
123+
}
112124

113125
// The next steps are optional, but done to test trimming of assets used
114126
// by the bytecode compiler.
@@ -184,9 +196,15 @@ class AotExecutor implements TargetExecutor {
184196
// and finally launches the app.
185197
var testDir = _tmp.uri.resolve('${test.name}/');
186198
var result = await runProcess(
187-
aotRuntimeBin.toFilePath(),
199+
switch (mode) {
200+
VmMode.aot => aotRuntimeBin.toFilePath(),
201+
VmMode.jit => dartBin.toFilePath(),
202+
},
188203
[
189-
'${test.main}.snapshot',
204+
switch (mode) {
205+
VmMode.aot => '${test.main}.snapshot',
206+
VmMode.jit => '${test.main}_no_aot.dill',
207+
},
190208
],
191209
testDir.toFilePath(),
192210
_logger,

tools/bots/test_matrix.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,6 +1355,17 @@
13551355
],
13561356
"fileset": "vm",
13571357
"shards": 5
1358+
},
1359+
{
1360+
"name": "dynamic module tests",
1361+
"script": "out/DebugX64/dart",
1362+
"testRunner": true,
1363+
"arguments": [
1364+
"pkg/dynamic_modules/test/runner/main.dart",
1365+
"-nvm-dyn-${system}-${mode}-${arch}",
1366+
"-rjit",
1367+
"--verbose"
1368+
]
13581369
}
13591370
]
13601371
},

0 commit comments

Comments
 (0)