Skip to content

Commit 7baae76

Browse files
johnniwinthercommit-bot@chromium.org
authored andcommitted
Always use ir constants in annotations when constant-update-2018 is enabled
Change-Id: Ib5ba6a908904c36a8580f6f47424b6982800dddd Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98002 Commit-Queue: Johnni Winther <[email protected]> Reviewed-by: Sigmund Cherem <[email protected]>
1 parent 10abacb commit 7baae76

File tree

6 files changed

+9
-22
lines changed

6 files changed

+9
-22
lines changed

pkg/compiler/lib/src/kernel/kernel_strategy.dart

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class KernelFrontEndStrategy extends FrontendStrategyBase {
7070
@override
7171
void registerLoadedLibraries(KernelResult kernelResult) {
7272
_elementMap.addComponent(kernelResult.component);
73-
if (useIrAnnotationsDataForTesting) {
73+
if (_options.useCFEConstants) {
7474
_irAnnotationData = processAnnotations(kernelResult.component);
7575
}
7676
_annotationProcessor = new KernelAnnotationProcessor(
@@ -322,10 +322,6 @@ class KernelWorkItem implements WorkItem {
322322
/// the world impact computation.
323323
bool useImpactDataForTesting = false;
324324

325-
/// If `true` pragma annotations are computed directly on kernel. This is a
326-
/// pre-step to modularizing the world impact computation.
327-
bool useIrAnnotationsDataForTesting = false;
328-
329325
class KernelModularStrategy extends ModularStrategy {
330326
final CompilerTask _compilerTask;
331327
final KernelToElementMapImpl _elementMap;
@@ -334,7 +330,7 @@ class KernelModularStrategy extends ModularStrategy {
334330

335331
@override
336332
List<PragmaAnnotationData> getPragmaAnnotationData(ir.Member node) {
337-
if (useIrAnnotationsDataForTesting) {
333+
if (_elementMap.options.useCFEConstants) {
338334
return computePragmaAnnotationDataFromIr(node);
339335
} else {
340336
return computePragmaAnnotationData(_elementMap.commonElements,

pkg/compiler/lib/src/options.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ class CompilerOptions implements DiagnosticOptions {
9696
/// Flags enabling language experiments.
9797
Map<fe.ExperimentalFlag, bool> languageExperiments = {};
9898

99+
/// `true` if CFE performs constant evaluation.
100+
bool get useCFEConstants =>
101+
languageExperiments[fe.ExperimentalFlag.constantUpdate2018];
102+
99103
/// A possibly null state object for kernel compilation.
100104
fe.InitializedCompilerState kernelInitializedCompilerState;
101105

tests/compiler/dart2js/inference/data/native.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ main() {
77
nativeMethod();
88
}
99

10-
/*strong.element: nativeMethod:[null|subclass=Object]*/
11-
/*omit.element: nativeMethod:[null|subclass=Object]*/
12-
// TODO(johnniwinther): Support native behavior from CFE constants:
13-
/*strongConst.element: nativeMethod:[null]*/
14-
/*omitConst.element: nativeMethod:[null]*/
10+
/*element: nativeMethod:[null|subclass=Object]*/
1511
nativeMethod()
1612
// ignore: NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE
1713
native;

tests/compiler/dart2js/inference/data/native2.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@ main() {
1212
createRectangle();
1313
}
1414

15-
/*strong.element: createElement:[null|subclass=Element]*/
16-
/*omit.element: createElement:[null|subclass=Element]*/
17-
// TODO(johnniwinther): Support native behavior from CFE constants:
18-
/*strongConst.element: createElement:[null]*/
19-
/*omitConst.element: createElement:[null]*/
15+
/*element: createElement:[null|subclass=Element]*/
2016
Element createElement()
2117
// ignore: NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE
2218
native;

tests/compiler/dart2js/inference/data/native3.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ main() {
99
createRectangle();
1010
}
1111

12-
/*strong.element: createRectangle:[null|subclass=DomRectReadOnly]*/
13-
/*omit.element: createRectangle:[null|subclass=DomRectReadOnly]*/
14-
// TODO(johnniwinther): Support native behavior from CFE constants:
15-
/*strongConst.element: createRectangle:[null]*/
16-
/*omitConst.element: createRectangle:[null]*/
12+
/*element: createRectangle:[null|subclass=DomRectReadOnly]*/
1713
Rectangle createRectangle()
1814
// ignore: NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE
1915
native;

tests/compiler/dart2js/model/cfe_annotations_test.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ main(List<String> args) {
186186
List<String> options = getOptions(argResults);
187187

188188
runTest({bool useIr}) async {
189-
useIrAnnotationsDataForTesting = useIr;
190189
CompilationResult result = await runCompiler(
191190
entryPoint: Uri.parse('memory:$pathPrefix/main.dart'),
192191
memorySourceFiles: source,

0 commit comments

Comments
 (0)