[ddc] Add flag to use the new runtime type system

Currently the flag does nothing. Follow up changes will add support
incrementally.

Add a `--canary` flag to DDC that will enable all features in
development to simplify use in tests and benchmarks.

Issue: https://github.com/dart-lang/sdk/issues/48950

Change-Id: I4878c771bdb4f4c6e8b8cd618737009268b02cbe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237602
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Anna Gringauze <annagrin@google.com>
This commit is contained in:
Nicholas Shahan 2022-05-10 23:47:04 +00:00 committed by Commit Bot
parent 34ebfc6594
commit 112cba1957
2 changed files with 24 additions and 4 deletions

View file

@ -95,6 +95,9 @@ class SharedCompilerOptions {
final bool soundNullSafety;
/// A canary feature that enables a new runtime type representation.
final bool newRuntimeTypes;
SharedCompilerOptions(
{this.sourceMap = true,
this.inlineSourceMap = false,
@ -110,7 +113,10 @@ class SharedCompilerOptions {
this.multiRootScheme,
this.multiRootOutputPath,
this.experiments = const {},
this.soundNullSafety = false});
this.soundNullSafety = false,
bool canaryFeatures = false})
: // Current canary features.
newRuntimeTypes = canaryFeatures;
SharedCompilerOptions.fromArguments(ArgResults args)
: this(
@ -131,7 +137,8 @@ class SharedCompilerOptions {
multiRootOutputPath: args['multi-root-output-path'] as String,
experiments: parseExperimentalArguments(
args['enable-experiment'] as List<String>),
soundNullSafety: args['sound-null-safety'] as bool);
soundNullSafety: args['sound-null-safety'] as bool,
canaryFeatures: args['canary'] as bool);
SharedCompilerOptions.fromSdkRequiredArguments(ArgResults args)
: this(
@ -145,7 +152,8 @@ class SharedCompilerOptions {
multiRootOutputPath: args['multi-root-output-path'] as String,
experiments: parseExperimentalArguments(
args['enable-experiment'] as List<String>),
soundNullSafety: args['sound-null-safety'] as bool);
soundNullSafety: args['sound-null-safety'] as bool,
canaryFeatures: args['canary'] as bool);
static void addArguments(ArgParser parser, {bool hide = true}) {
addSdkRequiredArguments(parser, hide: hide);
@ -213,7 +221,14 @@ class SharedCompilerOptions {
..addFlag('sound-null-safety',
help: 'Compile for sound null safety at runtime.',
negatable: true,
defaultsTo: false);
defaultsTo: false)
..addFlag('canary',
help: 'Enable all compiler features under active development. '
'This option is intended for compiler development only. '
'Canary features are likely to be unstable and can be removed '
'without warning.',
defaultsTo: false,
hide: true);
}
static String _getModuleName(ArgResults args) {

View file

@ -69,6 +69,9 @@ void main(List<String> args) async {
negatable: true)
..addFlag('weak-null-safety-errors',
help: 'Treat weak null safety warnings as errors.', defaultsTo: false)
..addFlag('canary',
help: 'Enable all compiler features under active development.',
defaultsTo: false)
..addFlag('observe',
help:
'Run the compiler in the Dart VM with --observe. Implies --debug.',
@ -128,6 +131,7 @@ void main(List<String> args) async {
var nonNullAsserts = options['null-assertions'] as bool;
var nativeNonNullAsserts = options['native-null-assertions'] as bool;
var weakNullSafetyErrors = options['weak-null-safety-errors'] as bool;
var canaryFeatures = options['canary'] as bool;
var entry = p.canonicalize(options.rest.first);
var out = (options['out'] as String) ?? p.setExtension(entry, '.js');
var libRoot = p.dirname(entry);
@ -240,6 +244,7 @@ void main(List<String> args) async {
if (soundNullSafety) '--sound-null-safety',
if (options['packages'] != null) '--packages=${options['packages']}',
if (emitDebugSymbols) '--emit-debug-symbols',
if (canaryFeatures) '--canary',
'-o',
out,
entry