From b614253cdbb0cd4ff29986a6d767ebd18a3c38ea Mon Sep 17 00:00:00 2001 From: Johnni Winther Date: Fri, 9 Aug 2019 07:11:52 +0000 Subject: [PATCH] Test CFE constants in side-effects test Change-Id: I720a4e1b574a19aebb93dfab17a372f987f2cb71 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99153 Commit-Queue: Johnni Winther Reviewed-by: Sigmund Cherem --- pkg/compiler/lib/src/ir/visitors.dart | 9 +++++++++ .../dart2js/inference/side_effects/foreign.dart | 12 ++++++++++-- .../dart2js/inference/side_effects_test.dart | 4 +++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/pkg/compiler/lib/src/ir/visitors.dart b/pkg/compiler/lib/src/ir/visitors.dart index a07d2e9aaf39..6c087575ca3b 100644 --- a/pkg/compiler/lib/src/ir/visitors.dart +++ b/pkg/compiler/lib/src/ir/visitors.dart @@ -36,6 +36,15 @@ class Stringifier extends ir.ExpressionVisitor { } return sb.toString(); } + + @override + String visitConstantExpression(ir.ConstantExpression node) { + ir.Constant constant = node.constant; + if (constant is ir.StringConstant) { + return constant.value; + } + return null; + } } /// Visitor that converts a kernel constant expression into a diff --git a/tests/compiler/dart2js/inference/side_effects/foreign.dart b/tests/compiler/dart2js/inference/side_effects/foreign.dart index dc8ad67f6119..1eb5a1f35799 100644 --- a/tests/compiler/dart2js/inference/side_effects/foreign.dart +++ b/tests/compiler/dart2js/inference/side_effects/foreign.dart @@ -29,12 +29,20 @@ jsBuiltin_rawRtiToJsConstructorName() { return JS_BUILTIN('String', JsBuiltin.rawRtiToJsConstructorName, null); } -/*member: jsEmbeddedGlobal_getTypeFromName:SideEffects(reads static; writes nothing)*/ +/*strong.member: jsEmbeddedGlobal_getTypeFromName:SideEffects(reads static; writes nothing)*/ +/*omit.member: jsEmbeddedGlobal_getTypeFromName:SideEffects(reads static; writes nothing)*/ +// With CFE constant we no longer get the noise from the static get if GET_TYPE_FROM_NAME. +/*strongConst.member: jsEmbeddedGlobal_getTypeFromName:SideEffects(reads nothing; writes nothing)*/ +/*omitConst.member: jsEmbeddedGlobal_getTypeFromName:SideEffects(reads nothing; writes nothing)*/ jsEmbeddedGlobal_getTypeFromName() { return JS_EMBEDDED_GLOBAL('', GET_TYPE_FROM_NAME); } -/*member: jsEmbeddedGlobal_libraries:SideEffects(reads static; writes nothing)*/ +/*strong.member: jsEmbeddedGlobal_libraries:SideEffects(reads static; writes nothing)*/ +/*omit.member: jsEmbeddedGlobal_libraries:SideEffects(reads static; writes nothing)*/ +// With CFE constant we no longer get the noise from the static get if LIBRARIES. +/*strongConst.member: jsEmbeddedGlobal_libraries:SideEffects(reads nothing; writes nothing)*/ +/*omitConst.member: jsEmbeddedGlobal_libraries:SideEffects(reads nothing; writes nothing)*/ jsEmbeddedGlobal_libraries() { return JS_EMBEDDED_GLOBAL('JSExtendableArray|Null', LIBRARIES); } diff --git a/tests/compiler/dart2js/inference/side_effects_test.dart b/tests/compiler/dart2js/inference/side_effects_test.dart index ec23f4e2ca85..09f0bb403767 100644 --- a/tests/compiler/dart2js/inference/side_effects_test.dart +++ b/tests/compiler/dart2js/inference/side_effects_test.dart @@ -21,7 +21,9 @@ main(List args) { Directory dataDir = new Directory.fromUri(Platform.script.resolve('side_effects')); await checkTests(dataDir, const SideEffectsDataComputer(), - args: args, options: [stopAfterTypeInference]); + args: args, + options: [stopAfterTypeInference], + testedConfigs: allInternalConfigs); }); }