Skip to content

Commit a643e53

Browse files
mralephcommit-bot@chromium.org
authored andcommitted
[vm/infra] Improve IL testing framework
* Add support for dumping flow graphs in JSON (to make it machine readable); * Add support for controlling which functions are dumped through a pragma annotation: `@pragma('vm:testing:print-flow-graph'[, "passes filter"])` * Replace simple matching DSL with programmatic matching * Support obfuscated builds Fixes #47340 TEST=vm/dart{,_2}/aot_prefer_equality_comparison_il_test Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-release-x64-try Change-Id: Ie067ba451d311e6019a8c3a88c012231b0c50eb5 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/219240 Commit-Queue: Slava Egorov <vegorov@google.com> Reviewed-by: Alexander Markov <alexmarkov@google.com>
1 parent c8595fd commit a643e53

19 files changed

+955
-319
lines changed

pkg/test_runner/lib/src/compiler_configuration.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,9 @@ class PrecompilerCompilerConfiguration extends CompilerConfiguration
828828
if (_configuration.useQemu) '--no-use-integer-division',
829829
if (arguments.contains('--print-flow-graph-optimized'))
830830
'--redirect-isolate-log-to=$tempDir/out.il',
831+
if (arguments.contains('--print-flow-graph-optimized') &&
832+
(_configuration.isMinified || arguments.contains('--obfuscate')))
833+
'--save-obfuscation_map=$tempDir/renames.json',
831834
..._replaceDartFiles(arguments, tempKernelFile(tempDir)),
832835
];
833836

@@ -844,6 +847,7 @@ class PrecompilerCompilerConfiguration extends CompilerConfiguration
844847
var args = [
845848
arguments.firstWhere((arg) => arg.endsWith('_il_test.dart')),
846849
'$tempDir/out.il',
850+
if (arguments.contains('--obfuscate')) '$tempDir/renames.json',
847851
];
848852

849853
return CompilationCommand('compare_il', tempDir, bootstrapDependencies(),
@@ -965,9 +969,10 @@ class PrecompilerCompilerConfiguration extends CompilerConfiguration
965969
List<String> computeCompilerArguments(
966970
TestFile testFile, List<String> vmOptions, List<String> args) {
967971
return [
968-
if (testFile.ilMatches.isNotEmpty) ...[
972+
if (testFile.isVmIntermediateLanguageTest) ...[
969973
'--print-flow-graph-optimized',
970-
'--print-flow-graph-filter=${testFile.ilMatches.join(',')}'
974+
'--print-flow-graph-as-json',
975+
'--print-flow-graph-filter=@pragma',
971976
],
972977
if (_enableAsserts) '--enable_asserts',
973978
...filterVmOptions(vmOptions),

pkg/test_runner/lib/src/test_file.dart

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,7 @@ class TestFile extends _TestFileBase {
211211
throw FormatException('Unknown feature "$name" in test $filePath');
212212
});
213213

214-
var ilMatches = filePath.endsWith('_il_test.dart')
215-
? _parseStringOption(filePath, contents, r'MatchIL\[AOT\]',
216-
allowMultiple: true)
217-
: const <String>[];
214+
final isVmIntermediateLanguageTest = filePath.endsWith('_il_test.dart');
218215

219216
// VM options.
220217
var vmOptions = <List<String>>[];
@@ -341,7 +338,7 @@ class TestFile extends _TestFileBase {
341338
sharedObjects: sharedObjects,
342339
otherResources: otherResources,
343340
experiments: experiments,
344-
ilMatches: ilMatches);
341+
isVmIntermediateLanguageTest: isVmIntermediateLanguageTest);
345342
}
346343

347344
/// A special fake test file for representing a VM unit test written in C++.
@@ -363,7 +360,7 @@ class TestFile extends _TestFileBase {
363360
sharedObjects = [],
364361
otherResources = [],
365362
experiments = [],
366-
ilMatches = [],
363+
isVmIntermediateLanguageTest = false,
367364
super(null, null, []);
368365

369366
TestFile._(Path suiteDirectory, Path path, List<StaticError> expectedErrors,
@@ -384,7 +381,7 @@ class TestFile extends _TestFileBase {
384381
this.sharedObjects,
385382
this.otherResources,
386383
this.experiments,
387-
this.ilMatches = const <String>[]})
384+
this.isVmIntermediateLanguageTest = false})
388385
: super(suiteDirectory, path, expectedErrors) {
389386
assert(!isMultitest || dartOptions.isEmpty);
390387
}
@@ -403,6 +400,7 @@ class TestFile extends _TestFileBase {
403400
final bool hasRuntimeError;
404401
final bool hasStaticWarning;
405402
final bool hasCrash;
403+
final bool isVmIntermediateLanguageTest;
406404

407405
/// The features that a test configuration must support in order to run this
408406
/// test.
@@ -411,9 +409,6 @@ class TestFile extends _TestFileBase {
411409
/// requirements, the test is implicitly skipped.
412410
final List<Feature> requirements;
413411

414-
/// List of functions which will have their IL verified (in AOT mode).
415-
final List<String> ilMatches;
416-
417412
final List<String> sharedOptions;
418413
final List<String> dartOptions;
419414
final List<String> dart2jsOptions;
@@ -479,6 +474,7 @@ class _MultitestFile extends _TestFileBase implements TestFile {
479474
final bool hasStaticWarning;
480475
final bool hasSyntaxError;
481476
bool get hasCrash => _origin.hasCrash;
477+
bool get isVmIntermediateLanguageTest => _origin.isVmIntermediateLanguageTest;
482478

483479
_MultitestFile(this._origin, Path path, this.multitestKey,
484480
List<StaticError> expectedErrors,
@@ -493,7 +489,6 @@ class _MultitestFile extends _TestFileBase implements TestFile {
493489
String get packages => _origin.packages;
494490

495491
List<Feature> get requirements => _origin.requirements;
496-
List<String> get ilMatches => _origin.ilMatches;
497492
List<String> get dart2jsOptions => _origin.dart2jsOptions;
498493
List<String> get dartOptions => _origin.dartOptions;
499494
List<String> get ddcOptions => _origin.ddcOptions;

0 commit comments

Comments
 (0)