Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2753)

Unified Diff: pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart

Issue 1201753004: Revert "dart2js cps: Refactor and optimize string concatenations." (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
diff --git a/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart b/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
index 647f48fcafcb6dc8a64a1220a79d81984927ffab..d411ee447d6c30eb897f48d287c059f2754ca35b 100644
--- a/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
+++ b/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
@@ -399,6 +399,8 @@ class IrBuilderSharedState {
/// A stack of collectors for continues.
final List<JumpCollector> continueCollectors = <JumpCollector>[];
+ final List<ConstDeclaration> localConstants = <ConstDeclaration>[];
+
final ExecutableElement currentElement;
final ir.Continuation returnContinuation = new ir.Continuation.retrn();
@@ -596,6 +598,13 @@ abstract class IrBuilder {
return parameter;
}
+ /// Adds the constant [variableElement] to the environment with [value] as its
+ /// constant value.
+ void declareLocalConstant(LocalVariableElement variableElement,
+ ConstantExpression value) {
+ state.localConstants.add(new ConstDeclaration(variableElement, value));
+ }
+
/// Plug an expression into the 'hole' in the context being accumulated. The
/// empty context (just a hole) is represented by root (and current) being
/// null. Since the hole in the current context is filled by this function,
@@ -666,41 +675,54 @@ abstract class IrBuilder {
}
- /// Create a [ir.Constant] from [value] and add it to the CPS term.
- ir.Constant buildConstant(ConstantValue value) {
+ /// Create a [ir.Constant] from [constant] and add it to the CPS term.
+ // TODO(johnniwinther): Remove [value] when [ConstantValue] can be computed
+ // directly from [constant].
+ ir.Constant buildConstant(ConstantExpression constant, ConstantValue value) {
assert(isOpen);
- return addPrimitive(new ir.Constant(value));
+ return addPrimitive(new ir.Constant(constant, value));
}
/// Create an integer constant and add it to the CPS term.
ir.Constant buildIntegerConstant(int value) {
- return buildConstant(state.constantSystem.createInt(value));
+ return buildConstant(
+ new IntConstantExpression(value),
+ state.constantSystem.createInt(value));
}
/// Create a double constant and add it to the CPS term.
ir.Constant buildDoubleConstant(double value) {
- return buildConstant(state.constantSystem.createDouble(value));
+ return buildConstant(
+ new DoubleConstantExpression(value),
+ state.constantSystem.createDouble(value));
}
/// Create a Boolean constant and add it to the CPS term.
ir.Constant buildBooleanConstant(bool value) {
- return buildConstant(state.constantSystem.createBool(value));
+ return buildConstant(
+ new BoolConstantExpression(value),
+ state.constantSystem.createBool(value));
}
/// Create a null constant and add it to the CPS term.
ir.Constant buildNullConstant() {
- return buildConstant(state.constantSystem.createNull());
+ return buildConstant(
+ new NullConstantExpression(),
+ state.constantSystem.createNull());
}
/// Create a string constant and add it to the CPS term.
ir.Constant buildStringConstant(String value) {
return buildConstant(
+ new StringConstantExpression(value),
state.constantSystem.createString(new ast.DartString.literal(value)));
}
/// Create a string constant and add it to the CPS term.
ir.Constant buildDartStringConstant(ast.DartString value) {
- return buildConstant(state.constantSystem.createString(value));
+ return buildConstant(
+ new StringConstantExpression(value.slowToString()),
+ state.constantSystem.createString(value));
}
/// Creates a non-constant list literal of the provided [type] and with the
@@ -1068,17 +1090,11 @@ abstract class IrBuilder {
DartType type,
List<ir.Primitive> arguments);
- ir.Primitive buildStringify(ir.Primitive argument);
-
- /// Concatenate string values.
- ///
- /// The arguments must be strings; usually a call to [buildStringify] is
- /// needed to ensure the proper conversion takes places.
+ /// Create a string concatenation of the [arguments].
ir.Primitive buildStringConcatenation(List<ir.Primitive> arguments) {
assert(isOpen);
- return addPrimitive(new ir.ApplyBuiltinOperator(
- ir.BuiltinOperator.StringConcatenate,
- arguments));
+ return _continueWithExpression(
+ (k) => new ir.ConcatenateStrings(arguments, k));
}
/// Create an invocation of the `call` method of [functionExpression], where
@@ -1985,7 +2001,9 @@ abstract class IrBuilder {
ir.Continuation elseContinuation = new ir.Continuation([]);
ir.Constant makeBoolConstant(bool value) {
- return new ir.Constant(state.constantSystem.createBool(value));
+ return new ir.Constant(
+ new BoolConstantExpression(value),
+ state.constantSystem.createBool(value));
}
ir.Constant trueConstant = makeBoolConstant(true);
@@ -2538,14 +2556,6 @@ class JsIrBuilder extends IrBuilder {
ir.Primitive right = buildNullConstant();
return addPrimitive(new ir.Identical(value, right));
}
-
- /// Convert the given value to a string.
- ir.Primitive buildStringify(ir.Primitive value) {
- return buildStaticFunctionInvocation(
- program.stringifyFunction,
- new CallStructure.unnamed(1),
- <ir.Primitive>[value]);
- }
}
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/builtin_operator.dart ('k') | pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698