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

Unified Diff: sdk/lib/_internal/compiler/implementation/ssa/nodes.dart

Issue 15724021: Move array and string related HType from const to a field in the backend. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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: sdk/lib/_internal/compiler/implementation/ssa/nodes.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/ssa/nodes.dart (revision 23812)
+++ sdk/lib/_internal/compiler/implementation/ssa/nodes.dart (working copy)
@@ -162,29 +162,26 @@
return result;
}
- static HType mapConstantTypeToSsaType(Constant constant) {
+ static HType mapConstantTypeToSsaType(Constant constant, Compiler compiler) {
+ JavaScriptBackend backend = compiler.backend;
if (constant.isNull()) return HType.NULL;
if (constant.isBool()) return HType.BOOLEAN;
if (constant.isInt()) return HType.INTEGER;
if (constant.isDouble()) return HType.DOUBLE;
- if (constant.isString()) return HType.STRING;
- if (constant.isList()) return HType.READABLE_ARRAY;
+ if (constant.isString()) return backend.stringType;
+ if (constant.isList()) return backend.readableArrayType;
if (constant.isFunction()) return HType.UNKNOWN;
if (constant.isSentinel()) return HType.UNKNOWN;
// TODO(sra): What is the type of the prototype of an interceptor?
if (constant.isInterceptor()) return HType.UNKNOWN;
- // TODO(kasperl): This seems a bit fishy, but we do not have the
- // compiler at hand so we cannot use the usual HType factory
- // methods. At some point this should go away.
ObjectConstant objectConstant = constant;
- TypeMask mask = new TypeMask.nonNullExact(objectConstant.type);
- return new HBoundedType(mask);
+ return new HBoundedType(new TypeMask.nonNullExact(objectConstant.type));
}
- HConstant addConstant(Constant constant) {
+ HConstant addConstant(Constant constant, Compiler compiler) {
HConstant result = constants[constant];
if (result == null) {
- HType type = mapConstantTypeToSsaType(constant);
+ HType type = mapConstantTypeToSsaType(constant, compiler);
result = new HConstant.internal(constant, type);
entry.addAtExit(result);
constants[constant] = result;
@@ -195,26 +192,30 @@
return result;
}
- HConstant addConstantInt(int i, ConstantSystem constantSystem) {
- return addConstant(constantSystem.createInt(i));
+ HConstant addConstantInt(int i, Compiler compiler) {
+ return addConstant(compiler.backend.constantSystem.createInt(i), compiler);
}
- HConstant addConstantDouble(double d, ConstantSystem constantSystem) {
- return addConstant(constantSystem.createDouble(d));
+ HConstant addConstantDouble(double d, Compiler compiler) {
+ return addConstant(
+ compiler.backend.constantSystem.createDouble(d), compiler);
}
HConstant addConstantString(DartString str,
Node diagnosticNode,
- ConstantSystem constantSystem) {
- return addConstant(constantSystem.createString(str, diagnosticNode));
+ Compiler compiler) {
+ return addConstant(
+ compiler.backend.constantSystem.createString(str, diagnosticNode),
+ compiler);
}
- HConstant addConstantBool(bool value, ConstantSystem constantSystem) {
- return addConstant(constantSystem.createBool(value));
+ HConstant addConstantBool(bool value, Compiler compiler) {
+ return addConstant(
+ compiler.backend.constantSystem.createBool(value), compiler);
}
- HConstant addConstantNull(ConstantSystem constantSystem) {
- return addConstant(constantSystem.createNull());
+ HConstant addConstantNull(Compiler compiler) {
+ return addConstant(compiler.backend.constantSystem.createNull(), compiler);
}
void finalize() {
@@ -836,6 +837,12 @@
instructionType.isExtendableArray(compiler);
bool isFixedArray(Compiler compiler) =>
instructionType.isFixedArray(compiler);
+ bool isString(Compiler compiler) =>
+ instructionType.isString(compiler);
+ bool isPrimitive(Compiler compiler) =>
+ instructionType.isPrimitive(compiler);
+ bool isPrimitiveOrNull(Compiler compiler) =>
+ instructionType.isPrimitiveOrNull(compiler);
bool isBoolean() => instructionType.isBoolean();
bool isInteger() => instructionType.isInteger();
bool isIntegerOrNull() => instructionType.isIntegerOrNull();
@@ -843,9 +850,6 @@
bool isDoubleOrNull() => instructionType.isDoubleOrNull();
bool isNumber() => instructionType.isNumber();
bool isNumberOrNull() => instructionType.isNumberOrNull();
- bool isString() => instructionType.isString();
- bool isPrimitive() => instructionType.isPrimitive();
- bool isPrimitiveOrNull() => instructionType.isPrimitiveOrNull();
bool isNull() => instructionType.isNull();
bool canBeNull() => instructionType.canBeNull();
bool canBePrimitive(Compiler compiler) =>
@@ -2137,9 +2141,7 @@
}
class HLiteralList extends HInstruction {
- HLiteralList(inputs) : super(inputs) {
- instructionType = HType.EXTENDABLE_ARRAY;
- }
+ HLiteralList(inputs) : super(inputs);
Johnni Winther 2013/06/12 08:58:49 Add parameter for [instructionType].
ngeoffray 2013/06/12 09:55:50 Done.
toString() => 'literal list';
accept(HVisitor visitor) => visitor.visitLiteralList(this);
}
@@ -2316,7 +2318,6 @@
// concats bunched with stringified inputs for much better looking code with
// fewer temps.
sideEffects.setDependsOnSomething();
- instructionType = HType.STRING;
}
HInstruction get left => inputs[0];
@@ -2335,7 +2336,6 @@
HStringify(HInstruction input, this.node) : super(<HInstruction>[input]) {
sideEffects.setAllSideEffects();
sideEffects.setDependsOnSomething();
- instructionType = HType.STRING;
}
accept(HVisitor visitor) => visitor.visitStringify(this);

Powered by Google App Engine
This is Rietveld 408576698