Reland "[dart2js] Enable by default and remove the --experiment-late-instance-variables flag."

This is a reland of 681e292b02

Original change's description:
> [dart2js] Enable by default and remove the
> --experiment-late-instance-variables flag.
>
> Change-Id: Ibb3cfa6d7b02883c82909930f7eb1142803dbc0f
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/200902
> Commit-Queue: Mayank Patke <fishythefish@google.com>
> Reviewed-by: Stephen Adams <sra@google.com>

Change-Id: If4d3c12e7f6a71d2c305283597b679e8b925493c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206980
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
This commit is contained in:
Mayank Patke 2021-09-13 21:59:20 +00:00 committed by commit-bot@chromium.org
parent a6c90f1601
commit 14940d1c9c
10 changed files with 80 additions and 134 deletions

View file

@ -54,11 +54,6 @@ class Flags {
static const String experimentNewRti = '--experiment-new-rti';
/// Use the dart2js lowering of late instance variables rather than the CFE
/// lowering.
static const String experimentLateInstanceVariables =
'--experiment-late-instance-variables';
static const String enableLanguageExperiments = '--enable-experiment';
static const String fastStartup = '--fast-startup';

View file

@ -646,7 +646,6 @@ Future<api.CompilationResult> compile(List<String> argv,
new OptionHandler(Flags.experimentUnreachableMethodsThrow, passThrough),
new OptionHandler(Flags.experimentCallInstrumentation, passThrough),
new OptionHandler(Flags.experimentNewRti, ignoreOption),
new OptionHandler(Flags.experimentLateInstanceVariables, passThrough),
new OptionHandler('${Flags.mergeFragmentsThreshold}=.+', passThrough),
// Wire up feature flags.

View file

@ -62,19 +62,6 @@ bool maybeEnableNative(Uri uri) {
return allowedNativeTest(uri) || allowedDartLibrary();
}
int _foldLateLowerings(List<int> lowerings) =>
lowerings.fold(LateLowering.none, (a, b) => a | b);
/// Late lowerings which the frontend performs for dart2js.
const List<int> _allEnabledLateLowerings = [
LateLowering.uninitializedNonFinalInstanceField,
LateLowering.uninitializedFinalInstanceField,
LateLowering.initializedNonFinalInstanceField,
LateLowering.initializedFinalInstanceField,
];
final int _enabledLateLowerings = _foldLateLowerings(_allEnabledLateLowerings);
/// A kernel [Target] to configure the Dart Front End for dart2js.
class Dart2jsTarget extends Target {
@override
@ -90,10 +77,7 @@ class Dart2jsTarget extends Target {
bool get enableNoSuchMethodForwarders => true;
@override
int get enabledLateLowerings =>
(options != null && options!.experimentLateInstanceVariables)
? LateLowering.none
: _enabledLateLowerings;
int get enabledLateLowerings => LateLowering.none;
@override
bool get supportsLateLoweringSentinel => true;

View file

@ -24,7 +24,6 @@ class LateLowering {
final CoreTypes _coreTypes;
final bool _omitLateNames;
final bool _lowerInstanceVariables;
final _Reader _readLocal;
final _Reader _readField;
@ -51,8 +50,6 @@ class LateLowering {
LateLowering(this._coreTypes, CompilerOptions? _options)
: _omitLateNames = _options?.omitLateNames ?? false,
_lowerInstanceVariables =
_options?.experimentLateInstanceVariables ?? false,
_readLocal = _Reader(_coreTypes.cellReadLocal),
_readField = _Reader(_coreTypes.cellReadField),
_readInitialized = _Reader(_coreTypes.initializedCellRead),
@ -72,7 +69,7 @@ class LateLowering {
field.isLate && field.isStatic && field.initializer == null;
bool _shouldLowerInstanceField(Field field) =>
field.isLate && !field.isStatic && _lowerInstanceVariables;
field.isLate && !field.isStatic;
String _mangleFieldName(Field field) {
assert(_shouldLowerInstanceField(field));

View file

@ -491,10 +491,6 @@ class CompilerOptions implements DiagnosticOptions {
/// called.
bool experimentCallInstrumentation = false;
/// Use the dart2js lowering of late instance variables rather than the CFE
/// lowering.
bool experimentLateInstanceVariables = false;
/// When null-safety is enabled, whether the compiler should emit code with
/// unsound or sound semantics.
///
@ -619,8 +615,6 @@ class CompilerOptions implements DiagnosticOptions {
_hasOption(options, Flags.experimentUnreachableMethodsThrow)
..experimentCallInstrumentation =
_hasOption(options, Flags.experimentCallInstrumentation)
..experimentLateInstanceVariables =
_hasOption(options, Flags.experimentLateInstanceVariables)
..generateSourceMap = !_hasOption(options, Flags.noSourceMaps)
..outputUri = _extractUriOption(options, '--out=')
..platformBinaries = platformBinaries

View file

@ -1,33 +1,15 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
import "dart:_internal" as _in;
class C extends core::Object {
field core::int? _#C#a = null;
field core::int? _#C#b = null;
field core::int? _#C#c = null;
field core::int? _#C#d = null;
late field core::int a;
late final [setter] field core::int b;
late field core::int c = 1.{core::int::unary-}(){() → core::int};
late final field core::int d = 1.{core::int::unary-}(){() → core::int};
synthetic constructor •() → self::C
: super core::Object::•()
;
get a() → core::int
return let final core::int? #t1 = this.{self::C::_#C#a}{core::int?} in #t1 == null ?{core::int} throw new _in::LateError::fieldNI("a") : #t1{core::int};
set a(core::int #t2) → void
this.{self::C::_#C#a} = #t2;
get b() → core::int
return let final core::int? #t3 = this.{self::C::_#C#b}{core::int?} in #t3 == null ?{core::int} throw new _in::LateError::fieldNI("b") : #t3{core::int};
set b(core::int #t4) → void
if(this.{self::C::_#C#b}{core::int?} == null)
this.{self::C::_#C#b} = #t4;
else
throw new _in::LateError::fieldAI("b");
get c() → core::int
return let final core::int? #t5 = this.{self::C::_#C#c}{core::int?} in #t5 == null ?{core::int} this.{self::C::_#C#c} = 1.{core::int::unary-}(){() → core::int} : #t5{core::int};
set c(core::int #t6) → void
this.{self::C::_#C#c} = #t6;
get d() → core::int
return let final core::int? #t7 = this.{self::C::_#C#d}{core::int?} in #t7 == null ?{core::int} let final core::int #t8 = 1.{core::int::unary-}(){() → core::int} in this.{self::C::_#C#d}{core::int?} == null ?{core::int} this.{self::C::_#C#d} = #t8 : throw new _in::LateError::fieldADI("d") : #t7{core::int};
static method _#new#tearOff() → self::C
return new self::C::•();
}

View file

@ -1,35 +1,46 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
import "dart:_late_helper" as _la;
import "dart:_internal" as _in;
class C extends core::Object {
field core::int? _#C#a = null;
field core::int? _#C#b = null;
field core::int? _#C#c = null;
field core::int? _#C#d = null;
field core::int _#C#a = _in::createSentinel<core::int>();
field core::int _#C#b = _in::createSentinel<core::int>();
field core::int _#C#c = _in::createSentinel<core::int>();
field core::int _#C#d = _in::createSentinel<core::int>();
synthetic constructor •() → self::C
: super core::Object::•()
;
get a() → core::int
return let final core::int? #t1 = this.{self::C::_#C#a}{core::int?} in #t1 == null ?{core::int} throw new _in::LateError::fieldNI("a") : #t1{core::int};
set a(core::int #t2) → void
this.{self::C::_#C#a} = #t2;
get b() → core::int
return let final core::int? #t3 = this.{self::C::_#C#b}{core::int?} in #t3 == null ?{core::int} throw new _in::LateError::fieldNI("b") : #t3{core::int};
set b(core::int #t4) → void
if(this.{self::C::_#C#b}{core::int?} == null)
this.{self::C::_#C#b} = #t4;
else
throw new _in::LateError::fieldAI("b");
get c() → core::int
return let final core::int? #t5 = this.{self::C::_#C#c}{core::int?} in #t5 == null ?{core::int} this.{self::C::_#C#c} = 1.{core::int::unary-}(){() → core::int} : #t5{core::int};
set c(core::int #t6) → void
this.{self::C::_#C#c} = #t6;
get d() → core::int
return let final core::int? #t7 = this.{self::C::_#C#d}{core::int?} in #t7 == null ?{core::int} let final core::int #t8 = 1.{core::int::unary-}(){() → core::int} in this.{self::C::_#C#d}{core::int?} == null ?{core::int} this.{self::C::_#C#d} = #t8 : throw new _in::LateError::fieldADI("d") : #t7{core::int};
static method _#new#tearOff() → self::C
return new self::C::•();
get a() → core::int
return _la::_lateReadCheck<core::int>(this.{self::C::_#C#a}{core::int}, "a");
set a(core::int value) → void
this.{self::C::_#C#a} = value;
get b() → core::int
return _la::_lateReadCheck<core::int>(this.{self::C::_#C#b}{core::int}, "b");
set b(core::int value) → void {
_la::_lateWriteOnceCheck(this.{self::C::_#C#b}{core::int}, "b");
this.{self::C::_#C#b} = value;
}
get c() → core::int {
core::int value = this.{self::C::_#C#c}{core::int};
if(_in::isSentinel(value))
value = this.{self::C::_#C#c} = 1.{core::int::unary-}(){() → core::int};
return value;
}
set c(core::int value) → void
this.{self::C::_#C#c} = value;
get d() → core::int {
core::int value = this.{self::C::_#C#d}{core::int};
if(_in::isSentinel(value)) {
final core::int result = 1.{core::int::unary-}(){() → core::int};
_la::_lateInitializeOnceCheck(this.{self::C::_#C#d}{core::int}, "d");
value = this.{self::C::_#C#d} = result;
}
return value;
}
}
static field self::C c = new self::C::•();
static method main() → void {
@ -61,5 +72,4 @@ static method testInitializedFinalInstanceField() → void {
Extra constant evaluation status:
Evaluated: InstanceInvocation @ org-dartlang-testcase:///late_fields.dart:15:16 -> DoubleConstant(-1.0)
Evaluated: InstanceInvocation @ org-dartlang-testcase:///late_fields.dart:16:22 -> DoubleConstant(-1.0)
Evaluated: VariableGet @ org-dartlang-testcase:///late_fields.dart:16:18 -> DoubleConstant(-1.0)
Extra constant evaluation: evaluated: 93, effectively constant: 3
Extra constant evaluation: evaluated: 77, effectively constant: 2

View file

@ -1,33 +1,15 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
import "dart:_internal" as _in;
class C extends core::Object {
field core::int? _#C#a = _in::createSentinel<core::int>();
field core::int? _#C#b = _in::createSentinel<core::int>();
field core::int? _#C#c = _in::createSentinel<core::int>();
field core::int? _#C#d = _in::createSentinel<core::int>();
late field core::int a;
late final [setter] field core::int b;
late field core::int c = 1.{core::int::unary-}(){() → core::int};
late final field core::int d = 1.{core::int::unary-}(){() → core::int};
synthetic constructor •() → self::C
: super core::Object::•()
;
get a() → core::int
return let final core::int? #t1 = this.{self::C::_#C#a}{core::int?} in _in::isSentinel(#t1) ?{core::int} throw new _in::LateError::fieldNI("a") : #t1{core::int};
set a(core::int #t2) → void
this.{self::C::_#C#a} = #t2;
get b() → core::int
return let final core::int? #t3 = this.{self::C::_#C#b}{core::int?} in _in::isSentinel(#t3) ?{core::int} throw new _in::LateError::fieldNI("b") : #t3{core::int};
set b(core::int #t4) → void
if(_in::isSentinel(this.{self::C::_#C#b}{core::int?}))
this.{self::C::_#C#b} = #t4;
else
throw new _in::LateError::fieldAI("b");
get c() → core::int
return let final core::int? #t5 = this.{self::C::_#C#c}{core::int?} in _in::isSentinel(#t5) ?{core::int} this.{self::C::_#C#c} = 1.{core::int::unary-}(){() → core::int} : #t5{core::int};
set c(core::int #t6) → void
this.{self::C::_#C#c} = #t6;
get d() → core::int
return let final core::int #t7 = this.{self::C::_#C#d}{core::int?} in _in::isSentinel(#t7) ?{core::int} let final core::int #t8 = 1.{core::int::unary-}(){() → core::int} in _in::isSentinel(this.{self::C::_#C#d}{core::int?}) ?{core::int} this.{self::C::_#C#d} = #t8 : throw new _in::LateError::fieldADI("d") : #t7;
static method _#new#tearOff() → self::C
return new self::C::•();
}

View file

@ -3,19 +3,12 @@ import self as self;
import "dart:core" as core;
class C extends core::Object {
field core::int? _#C#a;
field core::int? _#C#b;
field core::int? _#C#c;
field core::int? _#C#d;
late field core::int a;
late final [setter] field core::int b;
late field core::int c;
late final field core::int d;
synthetic constructor •() → self::C
;
get a() → core::int;
set a(core::int #t1) → void;
get b() → core::int;
set b(core::int #t2) → void;
get c() → core::int;
set c(core::int #t3) → void;
get d() → core::int;
static method _#new#tearOff() → self::C
return new self::C::•();
}

View file

@ -1,35 +1,46 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
import "dart:_late_helper" as _la;
import "dart:_internal" as _in;
class C extends core::Object {
field core::int? _#C#a = _in::createSentinel<core::int>();
field core::int? _#C#b = _in::createSentinel<core::int>();
field core::int? _#C#c = _in::createSentinel<core::int>();
field core::int? _#C#d = _in::createSentinel<core::int>();
field core::int _#C#a = _in::createSentinel<core::int>();
field core::int _#C#b = _in::createSentinel<core::int>();
field core::int _#C#c = _in::createSentinel<core::int>();
field core::int _#C#d = _in::createSentinel<core::int>();
synthetic constructor •() → self::C
: super core::Object::•()
;
get a() → core::int
return let final core::int? #t1 = this.{self::C::_#C#a}{core::int?} in _in::isSentinel(#t1) ?{core::int} throw new _in::LateError::fieldNI("a") : #t1{core::int};
set a(core::int #t2) → void
this.{self::C::_#C#a} = #t2;
get b() → core::int
return let final core::int? #t3 = this.{self::C::_#C#b}{core::int?} in _in::isSentinel(#t3) ?{core::int} throw new _in::LateError::fieldNI("b") : #t3{core::int};
set b(core::int #t4) → void
if(_in::isSentinel(this.{self::C::_#C#b}{core::int?}))
this.{self::C::_#C#b} = #t4;
else
throw new _in::LateError::fieldAI("b");
get c() → core::int
return let final core::int? #t5 = this.{self::C::_#C#c}{core::int?} in _in::isSentinel(#t5) ?{core::int} this.{self::C::_#C#c} = 1.{core::int::unary-}(){() → core::int} : #t5{core::int};
set c(core::int #t6) → void
this.{self::C::_#C#c} = #t6;
get d() → core::int
return let final core::int #t7 = this.{self::C::_#C#d}{core::int?} in _in::isSentinel(#t7) ?{core::int} let final core::int #t8 = 1.{core::int::unary-}(){() → core::int} in _in::isSentinel(this.{self::C::_#C#d}{core::int?}) ?{core::int} this.{self::C::_#C#d} = #t8 : throw new _in::LateError::fieldADI("d") : #t7;
static method _#new#tearOff() → self::C
return new self::C::•();
get a() → core::int
return _la::_lateReadCheck<core::int>(this.{self::C::_#C#a}{core::int}, "a");
set a(core::int value) → void
this.{self::C::_#C#a} = value;
get b() → core::int
return _la::_lateReadCheck<core::int>(this.{self::C::_#C#b}{core::int}, "b");
set b(core::int value) → void {
_la::_lateWriteOnceCheck(this.{self::C::_#C#b}{core::int}, "b");
this.{self::C::_#C#b} = value;
}
get c() → core::int {
core::int value = this.{self::C::_#C#c}{core::int};
if(_in::isSentinel(value))
value = this.{self::C::_#C#c} = 1.{core::int::unary-}(){() → core::int};
return value;
}
set c(core::int value) → void
this.{self::C::_#C#c} = value;
get d() → core::int {
core::int value = this.{self::C::_#C#d}{core::int};
if(_in::isSentinel(value)) {
final core::int result = 1.{core::int::unary-}(){() → core::int};
_la::_lateInitializeOnceCheck(this.{self::C::_#C#d}{core::int}, "d");
value = this.{self::C::_#C#d} = result;
}
return value;
}
}
static field self::C c = new self::C::•();
static method main() → void {
@ -61,5 +72,4 @@ static method testInitializedFinalInstanceField() → void {
Extra constant evaluation status:
Evaluated: InstanceInvocation @ org-dartlang-testcase:///late_fields.dart:15:16 -> DoubleConstant(-1.0)
Evaluated: InstanceInvocation @ org-dartlang-testcase:///late_fields.dart:16:22 -> DoubleConstant(-1.0)
Evaluated: VariableGet @ org-dartlang-testcase:///late_fields.dart:16:18 -> DoubleConstant(-1.0)
Extra constant evaluation: evaluated: 97, effectively constant: 3
Extra constant evaluation: evaluated: 77, effectively constant: 2