Skip to content

Commit 13b5b8a

Browse files
fishythefishCommit Queue
authored andcommitted
[dart2js, ddc] Remove support for SNS checks.
Bug: #60327 Change-Id: I38f04fea4e51dcd0fd43dc93ecc7007a0a816f29 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416120 Reviewed-by: Nate Biggs <[email protected]> Reviewed-by: Nicholas Shahan <[email protected]>
1 parent 38ef374 commit 13b5b8a

File tree

19 files changed

+22
-270
lines changed

19 files changed

+22
-270
lines changed

pkg/compiler/lib/src/dart2js.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ Future<api.CompilationResult> compile(
553553
_OneOption(Flags.experimentToBoolean, passThrough),
554554
_OneOption(Flags.experimentUnreachableMethodsThrow, passThrough),
555555
_OneOption(Flags.experimentCallInstrumentation, passThrough),
556-
_OneOption(Flags.experimentNullSafetyChecks, passThrough),
556+
_OneOption(Flags.experimentNullSafetyChecks, ignoreOption),
557557
_OneOption(Flags.experimentNewRti, ignoreOption),
558558
_OneOption('${Flags.mergeFragmentsThreshold}=.+', passThrough),
559559

pkg/compiler/lib/src/js_backend/specialized_checks.dart

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ class SpecializedChecks {
3232
static IsTestSpecialization? findIsTestSpecialization(
3333
DartType dartType,
3434
MemberEntity compiland,
35-
JClosedWorld closedWorld, {
36-
required bool experimentNullSafetyChecks,
37-
}) {
35+
JClosedWorld closedWorld,
36+
) {
3837
if (dartType is InterfaceType) {
3938
ClassEntity element = dartType.element;
4039
JCommonElements commonElements = closedWorld.commonElements;
@@ -90,10 +89,6 @@ class SpecializedChecks {
9089
return SimpleIsTestSpecialization.isNotNull;
9190
}
9291

93-
if (experimentNullSafetyChecks && dartType.typeArguments.isNotEmpty) {
94-
return null;
95-
}
96-
9792
ClassHierarchy classHierarchy = closedWorld.classHierarchy;
9893
InterceptorData interceptorData = closedWorld.interceptorData;
9994
OutputUnitData outputUnitData = closedWorld.outputUnitData;

pkg/compiler/lib/src/kernel/transformations/global/constant_transformer.dart

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@ import 'package:front_end/src/api_unstable/dart2js.dart'
44
import 'package:kernel/ast.dart';
55
import 'package:kernel/type_environment.dart';
66

7-
import '../../../options.dart';
8-
97
class ConstantTransformer extends Transformer {
108
final TryConstantEvaluator constantEvaluator;
119
late StaticTypeContext _staticTypeContext;
1210

13-
final CompilerOptions _options;
14-
15-
ConstantTransformer(this.constantEvaluator, this._options);
11+
ConstantTransformer(this.constantEvaluator);
1612

1713
Constant _evaluate(Expression node) =>
1814
constantEvaluator.evaluate(_staticTypeContext, node);
@@ -116,18 +112,14 @@ class ConstantTransformer extends Transformer {
116112
@override
117113
TreeNode visitIsExpression(IsExpression node) {
118114
node.transformChildren(this);
119-
if (!_options.experimentNullSafetyChecks && _isConstant(node.operand)) {
120-
return _evaluateAndWrapOrNode(node);
121-
}
115+
if (_isConstant(node.operand)) return _evaluateAndWrapOrNode(node);
122116
return node;
123117
}
124118

125119
@override
126120
TreeNode visitAsExpression(AsExpression node) {
127121
node.transformChildren(this);
128-
if (!_options.experimentNullSafetyChecks && _isConstant(node.operand)) {
129-
return _evaluateAndWrapOrNode(node);
130-
}
122+
if (_isConstant(node.operand)) return _evaluateAndWrapOrNode(node);
131123
return node;
132124
}
133125

pkg/compiler/lib/src/kernel/transformations/global/js_get_flag_lowering.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ class JsGetFlagLowering {
5959
_options.features.useContentSecurityPolicy.isEnabled,
6060
'VARIANCE' => _options.enableVariance,
6161
'LEGACY' => _options.useLegacySubtyping,
62-
'EXTRA_NULL_SAFETY_CHECKS' => _options.experimentNullSafetyChecks,
6362
'PRINT_LEGACY_STARS' => _options.printLegacyStars,
6463
_ => null,
6564
};

pkg/compiler/lib/src/kernel/transformations/global/transform.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class _GlobalTransformer extends ConstantTransformer {
3838
_GlobalTransformer(
3939
super.constantEvaluator,
4040
CoreTypes coreTypes,
41-
super.options,
41+
CompilerOptions options,
4242
) : _jsGetFlagLowering = JsGetFlagLowering(coreTypes, options);
4343

4444
@override

pkg/compiler/lib/src/options.dart

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -656,19 +656,6 @@ class CompilerOptions implements DiagnosticOptions {
656656
/// called.
657657
bool experimentCallInstrumentation = false;
658658

659-
/// Experiment to add additional runtime checks to detect code whose semantics
660-
/// will change when sound null safety is enabled.
661-
///
662-
/// In particular, runtime subtype checks (including those via `is` and `as`)
663-
/// will produce diagnostics when they would provide different results in
664-
/// sound vs. unsound mode. Note that this adds overhead, both to perform the
665-
/// extra checks and because some checks that may have been optimized away
666-
/// will be emitted.
667-
///
668-
/// We assume this option will only be provided when all files have been
669-
/// migrated to null safety (but before sound null safety is enabled).
670-
bool experimentNullSafetyChecks = false;
671-
672659
/// Whether to use legacy subtype semantics rather than null-safe semantics.
673660
/// This is `true` if unsound null-safety semantics are being used, since
674661
/// dart2js does not emit warnings for unsound null-safety.
@@ -944,10 +931,6 @@ class CompilerOptions implements DiagnosticOptions {
944931
options,
945932
Flags.experimentCallInstrumentation,
946933
)
947-
..experimentNullSafetyChecks = _hasOption(
948-
options,
949-
Flags.experimentNullSafetyChecks,
950-
)
951934
..generateSourceMap = !_hasOption(options, Flags.noSourceMaps)
952935
.._outputUri = _extractUriOption(options, '--out=')
953936
..platformBinaries = platformBinaries
@@ -1085,12 +1068,6 @@ class CompilerOptions implements DiagnosticOptions {
10851068
"'${Flags.noInteropNullAssertions}'",
10861069
);
10871070
}
1088-
if (experimentNullSafetyChecks) {
1089-
throw ArgumentError(
1090-
'${Flags.experimentNullSafetyChecks} is incompatible '
1091-
'with sound null safety.',
1092-
);
1093-
}
10941071
}
10951072

10961073
void deriveOptions() {

pkg/compiler/lib/src/phase/load_kernel.dart

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import 'package:kernel/type_environment.dart' as ir;
2020
import 'package:kernel/verifier.dart';
2121

2222
import '../../compiler_api.dart' as api;
23-
import '../commandline_options.dart';
2423
import '../common.dart';
2524
import '../diagnostics/diagnostic_listener.dart';
2625
import '../environment.dart';
@@ -300,16 +299,6 @@ Future<_LoadFromSourceResult> _loadFromSource(
300299
..verbosity = verbosity;
301300
Uri resolvedUri = options.compilationTarget;
302301
bool isLegacy = await fe.uriUsesLegacyLanguageVersion(resolvedUri, feOptions);
303-
if (isLegacy && options.experimentNullSafetyChecks) {
304-
reporter.reportErrorMessage(noLocationSpannable, MessageKind.generic, {
305-
'text':
306-
'The ${Flags.experimentNullSafetyChecks} option may be used '
307-
'only after all libraries have been migrated to null safety. Some '
308-
'libraries reached from $resolvedUri are still opted out of null '
309-
'safety. Please migrate these libraries before passing '
310-
'${Flags.experimentNullSafetyChecks}.',
311-
});
312-
}
313302
if (isLegacy) {
314303
reporter.reportErrorMessage(noLocationSpannable, MessageKind.generic, {
315304
'text':

pkg/compiler/lib/src/ssa/builder.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3314,7 +3314,7 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault<void>
33143314

33153315
final operandType = _getStaticType(operand);
33163316
DartType type = _elementMap.getDartType(node.type);
3317-
if (!options.experimentNullSafetyChecks && !node.isCovarianceCheck) {
3317+
if (!node.isCovarianceCheck) {
33183318
if (_elementMap.types.isSubtype(operandType, type)) {
33193319
// Skip unneeded casts.
33203320
return;

pkg/compiler/lib/src/ssa/nodes.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4599,10 +4599,6 @@ AbstractBool _typeTest(
45994599
CompilerOptions options, {
46004600
required bool isCast,
46014601
}) {
4602-
// The null safety mode may affect the result of a type test, so defer to
4603-
// runtime.
4604-
if (options.experimentNullSafetyChecks) return AbstractBool.maybe;
4605-
46064602
JCommonElements commonElements = closedWorld.commonElements;
46074603
DartTypes dartTypes = closedWorld.dartTypes;
46084604
AbstractValueDomain abstractValueDomain = closedWorld.abstractValueDomain;

pkg/compiler/lib/src/ssa/optimize.dart

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,16 +1237,10 @@ class SsaInstructionSimplifier extends HBaseVisitor<HInstruction>
12371237
);
12381238
if (_closedWorld.dartTypes.isNonNullableIfSound(type.returnType)) {
12391239
node.block!.addBefore(node, invocation);
1240-
final replacementType =
1241-
_options.experimentNullSafetyChecks
1242-
? invocation.instructionType
1243-
: _abstractValueDomain.excludeNull(
1244-
invocation.instructionType,
1245-
);
12461240
replacement = HInvokeStatic(
12471241
commonElements.interopNullAssertion,
12481242
[invocation],
1249-
replacementType,
1243+
_abstractValueDomain.excludeNull(invocation.instructionType),
12501244
const <DartType>[],
12511245
);
12521246
}
@@ -2666,7 +2660,6 @@ class SsaInstructionSimplifier extends HBaseVisitor<HInstruction>
26662660
node.dartType,
26672661
_graph.element,
26682662
_closedWorld,
2669-
experimentNullSafetyChecks: _options.experimentNullSafetyChecks,
26702663
);
26712664

26722665
if (specialization == SimpleIsTestSpecialization.isNull ||

0 commit comments

Comments
 (0)