Skip to content

Commit 1a6f6d7

Browse files
author
Dart CI
committed
Version 3.9.0-228.0.dev
Merge 4b3c8a3 into dev
2 parents 7289738 + 4b3c8a3 commit 1a6f6d7

File tree

12 files changed

+336
-120
lines changed

12 files changed

+336
-120
lines changed

pkg/analysis_server/test/support/sdk_paths.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ String get sdkRootPath {
4545
/// When running from source, the server will be compiled to disk for the first
4646
/// request to speed up subsequent tests in the same process.
4747
Future<String> getAnalysisServerPath(String dartSdkPath) async {
48-
var dartBinary = path.join(dartSdkPath, 'bin', 'dart');
48+
// Always use the "real" SDK binary for compilation, not the path provided,
49+
// which might be an incomplete SDK that is the target of the test.
50+
var dartBinary = Platform.resolvedExecutable;
4951
var snapshotPath = path.join(
5052
dartSdkPath,
5153
'bin',

pkg/compiler/lib/src/js_model/js_world.dart

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -542,10 +542,6 @@ class JClosedWorld implements World {
542542
return false;
543543
}
544544

545-
late final ClassEntity _functionLub = getLubOfInstantiatedSubtypes(
546-
commonElements.functionClass,
547-
)!;
548-
549545
/// Returns `true` if [selector] on [receiver] can hit a `call` method on a
550546
/// subclass of `Closure` using the [abstractValueDomain].
551547
///
@@ -559,23 +555,9 @@ class JClosedWorld implements World {
559555
) {
560556
return selector.name == Identifiers.call &&
561557
(receiver == null ||
562-
// This is logically equivalent to the former implementation using
563-
// `abstractValueDomain.contains` (which wrapped `containsMask`).
564-
// The switch to `abstractValueDomain.containsType` is because
565-
// `contains` was generally unsound but happened to work correctly
566-
// here. See https://dart-review.googlesource.com/c/sdk/+/130565
567-
// for further discussion.
568-
//
569-
// This checks if the receiver mask contains the entire type cone
570-
// originating from [_functionLub] and may therefore be unsound if
571-
// the receiver mask contains only part of the type cone. (Is this
572-
// possible?)
573-
//
574-
// TODO(fishythefish): Use `isDisjoint` or equivalent instead of
575-
// `containsType` once we can ensure it's fast enough.
576558
abstractValueDomain
577-
.containsType(receiver, _functionLub)
578-
.isPotentiallyTrue);
559+
.areDisjoint(abstractValueDomain.functionType, receiver)
560+
.isPotentiallyFalse);
579561
}
580562

581563
/// Returns `true` if [selector] on [receiver] can hit a `call` method on a
@@ -591,9 +573,9 @@ class JClosedWorld implements World {
591573
Selector getSelector(ir.Expression node) => elementMap.getSelector(node);
592574

593575
/// Returns all the instance members that may be invoked with the [selector]
594-
/// on the given [receiver] using the [abstractValueDomain]. The returned elements may include noSuchMethod
595-
/// handlers that are potential targets indirectly through the noSuchMethod
596-
/// mechanism.
576+
/// on the given [receiver] using the [abstractValueDomain]. The returned
577+
/// elements may include noSuchMethod handlers that are potential targets
578+
/// indirectly through the noSuchMethod mechanism.
597579
Iterable<MemberEntity> locateMembersInDomain(
598580
Selector selector,
599581
AbstractValue? receiver,

pkg/dartdev/lib/src/commands/compile.dart

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,11 @@ class CompileJitSnapshotCommand extends CompileSubcommandCommand {
360360
abbr: defineOption.abbr,
361361
valueHelp: defineOption.valueHelp,
362362
)
363+
..addFlag(
364+
enableAssertsOption.flag,
365+
negatable: false,
366+
help: enableAssertsOption.help,
367+
)
363368
..addFlag(soundNullSafetyOption.flag,
364369
help: soundNullSafetyOption.help,
365370
defaultsTo: soundNullSafetyOption.flagDefaultsTo,
@@ -409,6 +414,7 @@ class CompileJitSnapshotCommand extends CompileSubcommandCommand {
409414

410415
final enabledExperiments = args.enabledExperiments;
411416
final defines = args.multiOption(defineOption.flag);
417+
final enableAsserts = args.flag(enableAssertsOption.flag);
412418

413419
// Build arguments.
414420
final buildArgs = <String>[];
@@ -439,6 +445,11 @@ class CompileJitSnapshotCommand extends CompileSubcommandCommand {
439445
for (final define in defines) {
440446
buildArgs.add('-D$define');
441447
}
448+
449+
if (enableAsserts) {
450+
buildArgs.add('--${enableAssertsOption.flag}');
451+
}
452+
442453
buildArgs.add(path.canonicalize(sourcePath));
443454

444455
// Add the training arguments.
@@ -493,9 +504,9 @@ class CompileNativeCommand extends CompileSubcommandCommand {
493504
valueHelp: defineOption.valueHelp,
494505
)
495506
..addFlag(
496-
'enable-asserts',
507+
enableAssertsOption.flag,
497508
negatable: false,
498-
help: 'Enable assert statements.',
509+
help: enableAssertsOption.help,
499510
)
500511
..addOption(
501512
packagesOption.flag,
@@ -663,7 +674,7 @@ Remove debugging information from the output and save it separately to the speci
663674
defines: args.multiOption(defineOption.flag),
664675
packages: args.option('packages'),
665676
enableExperiment: args.enabledExperiments.join(','),
666-
enableAsserts: args.flag('enable-asserts'),
677+
enableAsserts: args.flag(enableAssertsOption.flag),
667678
debugFile: args.option('save-debugging-info'),
668679
verbose: verbose,
669680
verbosity: args.option('verbosity')!,
@@ -821,9 +832,9 @@ class CompileWasmCommand extends CompileSubcommandCommand {
821832
negatable: false,
822833
)
823834
..addFlag(
824-
'enable-asserts',
825-
help: 'Enable assert statements.',
835+
enableAssertsOption.flag,
826836
negatable: false,
837+
help: enableAssertsOption.help,
827838
)
828839
..addOption(
829840
'shared-memory',
@@ -977,7 +988,7 @@ class CompileWasmCommand extends CompileSubcommandCommand {
977988
if (packages != null) '--packages=$packages',
978989
if (args.flag('print-wasm')) '--print-wasm',
979990
if (args.flag('print-kernel')) '--print-kernel',
980-
if (args.flag('enable-asserts')) '--enable-asserts',
991+
if (args.flag(enableAssertsOption.flag)) '--${enableAssertsOption.flag}',
981992
if (!generateSourceMap) '--no-source-maps',
982993
for (final define in defines) '-D$define',
983994
if (maxPages != null) ...[
@@ -1074,27 +1085,29 @@ Sets the verbosity level of the compilation.
10741085
flagDefaultsTo: true,
10751086
);
10761087

1077-
final Option defineOption;
1078-
final Option packagesOption;
1079-
1080-
CompileSubcommandCommand(super.name, super.description, super.verbose,
1081-
{super.hidden})
1082-
: defineOption = Option(
1083-
flag: 'define',
1084-
abbr: 'D',
1085-
valueHelp: 'key=value',
1086-
help: '''
1088+
late final Option defineOption = Option(
1089+
flag: 'define',
1090+
abbr: 'D',
1091+
valueHelp: 'key=value',
1092+
help: '''
10871093
Define an environment declaration. To specify multiple declarations, use multiple options or use commas to separate key-value pairs.
10881094
For example: dart compile $name -Da=1,b=2 main.dart''',
1089-
),
1090-
packagesOption = Option(
1091-
flag: 'packages',
1092-
abbr: 'p',
1093-
valueHelp: 'path',
1094-
help:
1095-
'''Get package locations from the specified file instead of .dart_tool/package_config.json.
1095+
);
1096+
1097+
late final Option packagesOption = Option(
1098+
flag: 'packages',
1099+
abbr: 'p',
1100+
valueHelp: 'path',
1101+
help:
1102+
'''Get package locations from the specified file instead of .dart_tool/package_config.json.
10961103
<path> can be relative or absolute.
10971104
For example: dart compile $name --packages=/tmp/pkgs.json main.dart''');
1105+
1106+
final Option enableAssertsOption =
1107+
Option(flag: 'enable-asserts', help: 'Enable assert statements.');
1108+
1109+
CompileSubcommandCommand(super.name, super.description, super.verbose,
1110+
{super.hidden});
10981111
}
10991112

11001113
class CompileCommand extends DartdevCommand {

pkg/dartdev/test/commands/compile_test.dart

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,6 +1481,39 @@ void main() {
14811481
expect(result.exitCode, 254);
14821482
});
14831483

1484+
test('Compile JIT snapshot with asserts', () async {
1485+
final p = project(mainSrc: '''
1486+
void main() {
1487+
assert(int.parse('1') == 2);
1488+
}
1489+
''');
1490+
final inFile = path.canonicalize(path.join(p.dirPath, p.relativeFilePath));
1491+
final outFile = path.canonicalize(path.join(p.dirPath, 'myjit'));
1492+
1493+
var result = await p.run(
1494+
[
1495+
'compile',
1496+
'jit-snapshot',
1497+
'--enable-asserts',
1498+
'-o',
1499+
outFile,
1500+
inFile,
1501+
],
1502+
);
1503+
1504+
// Only printed when -v/--verbose is used, not --verbosity.
1505+
expect(result.stdout, isNot(contains(usingTargetOSMessage)));
1506+
expect(result.stdout, isNot(contains(soundNullSafetyMessage)));
1507+
expect(result.stderr, contains(failedAssertionError));
1508+
expect(result.exitCode, 255);
1509+
1510+
result = await p.run(
1511+
['--enable-asserts', outFile],
1512+
);
1513+
expect(result.stdout, isEmpty);
1514+
expect(result.stderr, contains(failedAssertionError));
1515+
});
1516+
14841517
if (Platform.isMacOS) {
14851518
test('Compile and run executable from signed dartaotruntime', () async {
14861519
// Either the locally built dartaotruntime is already linker signed

pkg/dev_compiler/lib/src/command/command.dart

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -96,57 +96,7 @@ Future<CompilerResult> _compile(
9696
bool useIncrementalCompiler = false,
9797
Map<Uri, List<int>>? inputDigests,
9898
}) async {
99-
// TODO(jmesserly): refactor options to share code with dartdevc CLI.
100-
var argParser = ArgParser(allowTrailingOptions: true)
101-
..addFlag(
102-
'help',
103-
abbr: 'h',
104-
help: 'Display this message.',
105-
negatable: false,
106-
)
107-
..addOption('packages', help: 'The package spec file to use.')
108-
// TODO(jmesserly): is this still useful for us, or can we remove it now?
109-
..addFlag(
110-
'summarize-text',
111-
help: 'Emit API summary and AST in .js.txt and .ast.xml files.',
112-
defaultsTo: false,
113-
hide: true,
114-
)
115-
..addFlag(
116-
'track-widget-creation',
117-
help: 'Enable inspecting of Flutter widgets.',
118-
defaultsTo: false,
119-
hide: true,
120-
)
121-
// TODO(jmesserly): add verbose help to show hidden options
122-
..addOption(
123-
'dart-sdk-summary',
124-
help: 'The path to the Dart SDK summary file.',
125-
hide: true,
126-
)
127-
..addMultiOption(
128-
'multi-root',
129-
help:
130-
'The directories to search when encountering uris with the '
131-
'specified multi-root scheme.',
132-
defaultsTo: [Uri.base.path],
133-
)
134-
..addFlag(
135-
'compile-sdk',
136-
help: 'Build an SDK module.',
137-
defaultsTo: false,
138-
hide: true,
139-
)
140-
..addOption(
141-
'libraries-file',
142-
help: 'The path to the libraries.json file for the sdk.',
143-
)
144-
..addOption(
145-
'used-inputs-file',
146-
help: 'If set, the file to record inputs used.',
147-
hide: true,
148-
);
149-
Options.addArguments(argParser);
99+
var argParser = Options.nonSdkArgParser();
150100
var declaredVariables = parseAndRemoveDeclaredVariables(args);
151101
ArgResults argResults;
152102
try {

pkg/dev_compiler/lib/src/command/options.dart

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ class Options {
153153
summaryModules: _parseCustomSummaryModules(
154154
args['summary'] as List<String>,
155155
),
156+
nonHotReloadablePackages: Set.from(
157+
args['non-hot-reloadable-package'] as List<String>,
158+
),
156159
moduleFormats: parseModuleFormatOption(args),
157160
moduleName: _getModuleName(args),
158161
multiRootScheme: args['multi-root-scheme'] as String,
@@ -194,6 +197,14 @@ class Options {
194197
'API summary file(s) of imported libraries, optionally\n'
195198
'with module import path: -s path.dill=js/import/path',
196199
)
200+
..addMultiOption(
201+
'non-hot-reloadable-package',
202+
help:
203+
'Specifies that a package should not be hot reloaded.\n'
204+
'Hot reload will be rejected when any such package is modified. '
205+
'This allows the compiler to emit these packages with better '
206+
'performance.',
207+
)
197208
..addFlag(
198209
'summarize',
199210
help: 'Emit an API summary file.',
@@ -227,8 +238,8 @@ class Options {
227238
defaultsTo: false,
228239
hide: hide,
229240
)
230-
// TODO(41852) Define a process for breaking changes before graduating
231-
// from experimental.
241+
// TODO(41852) Define a process for breaking changes before graduating from
242+
// experimental.
232243
..addFlag(
233244
'experimental-emit-debug-metadata',
234245
help:
@@ -368,6 +379,63 @@ class Options {
368379
// that build systems do not depend on passing windows-style paths here.
369380
return p.toUri(moduleName).toString();
370381
}
382+
383+
/// Returns an `ArgParser` for arguments compatible with non-SDK DDC
384+
/// compilations.
385+
static ArgParser nonSdkArgParser() {
386+
// TODO(jmesserly): refactor options to share code with dartdevc CLI.
387+
var argParser = ArgParser(allowTrailingOptions: true)
388+
..addFlag(
389+
'help',
390+
abbr: 'h',
391+
help: 'Display this message.',
392+
negatable: false,
393+
)
394+
..addOption('packages', help: 'The package spec file to use.')
395+
// TODO(jmesserly): is this still useful for us, or can we remove it now?
396+
..addFlag(
397+
'summarize-text',
398+
help: 'Emit API summary and AST in .js.txt and .ast.xml files.',
399+
defaultsTo: false,
400+
hide: true,
401+
)
402+
..addFlag(
403+
'track-widget-creation',
404+
help: 'Enable inspecting of Flutter widgets.',
405+
defaultsTo: false,
406+
hide: true,
407+
)
408+
// TODO(jmesserly): add verbose help to show hidden options
409+
..addOption(
410+
'dart-sdk-summary',
411+
help: 'The path to the Dart SDK summary file.',
412+
hide: true,
413+
)
414+
..addMultiOption(
415+
'multi-root',
416+
help:
417+
'The directories to search when encountering uris with the '
418+
'specified multi-root scheme.',
419+
defaultsTo: [Uri.base.path],
420+
)
421+
..addFlag(
422+
'compile-sdk',
423+
help: 'Build an SDK module.',
424+
defaultsTo: false,
425+
hide: true,
426+
)
427+
..addOption(
428+
'libraries-file',
429+
help: 'The path to the libraries.json file for the sdk.',
430+
)
431+
..addOption(
432+
'used-inputs-file',
433+
help: 'If set, the file to record inputs used.',
434+
hide: true,
435+
);
436+
Options.addArguments(argParser);
437+
return argParser;
438+
}
371439
}
372440

373441
/// Finds explicit module names of the form `path=name` in [summaryPaths],

0 commit comments

Comments
 (0)