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

Unified Diff: lib/compiler/implementation/ssa/codegen.dart

Issue 10911006: Collect the types used in is-checks in the resolver phase. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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: lib/compiler/implementation/ssa/codegen.dart
diff --git a/lib/compiler/implementation/ssa/codegen.dart b/lib/compiler/implementation/ssa/codegen.dart
index b377e5f30833e5189f225db2f4204481bfeff93a..46162c5ff8bacba252b0085c45f97abc4ac9f611 100644
--- a/lib/compiler/implementation/ssa/codegen.dart
+++ b/lib/compiler/implementation/ssa/codegen.dart
@@ -2172,19 +2172,19 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
push(new js.Binary('==', pop(), new js.LiteralNull()));
}
- void checkFunction(HInstruction input, Element element) {
+ void checkFunction(HInstruction input, Type type) {
checkTypeOf(input, '===', 'function');
js.Expression functionTest = pop();
checkObject(input, '===');
js.Expression objectTest = pop();
- checkType(input, element);
+ checkType(input, type);
push(new js.Binary('||',
functionTest,
new js.Binary('&&', objectTest, pop())));
}
- void checkType(HInstruction input, Element element, [bool negative = false]) {
- world.registerIsCheck(element);
+ void checkType(HInstruction input, Type type, [bool negative = false]) {
+ Element element = type.element;
use(input);
js.PropertyAccess field =
new js.PropertyAccess.field(pop(), compiler.namer.operatorIs(element));
@@ -2199,31 +2199,31 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
}
}
- void handleStringSupertypeCheck(HInstruction input, Element element) {
+ void handleStringSupertypeCheck(HInstruction input, Type type) {
// Make sure List and String don't share supertypes, otherwise we
// would need to check for List too.
- assert(element !== compiler.listClass
- && !Elements.isListSupertype(element, compiler));
+ assert(type.element !== compiler.listClass
+ && !Elements.isListSupertype(type.element, compiler));
checkString(input, '===');
js.Expression stringTest = pop();
checkObject(input, '===');
js.Expression objectTest = pop();
- checkType(input, element);
+ checkType(input, type);
push(new js.Binary('||',
stringTest,
new js.Binary('&&', objectTest, pop())));
}
- void handleListOrSupertypeCheck(HInstruction input, Element element) {
+ void handleListOrSupertypeCheck(HInstruction input, Type type) {
// Make sure List and String don't share supertypes, otherwise we
// would need to check for String too.
- assert(element !== compiler.stringClass
- && !Elements.isStringSupertype(element, compiler));
+ assert(type.element !== compiler.stringClass
+ && !Elements.isStringSupertype(type.element, compiler));
checkObject(input, '===');
js.Expression objectTest = pop();
checkArray(input, '===');
js.Expression arrayTest = pop();
- checkType(input, element);
+ checkType(input, type);
push(new js.Binary('&&',
objectTest,
new js.Binary('||', arrayTest, pop())));
@@ -2258,7 +2258,7 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
checkBool(input, '===');
attachLocationToLast(node);
} else if (element == compiler.functionClass) {
- checkFunction(input, element);
+ checkFunction(input, type);
attachLocationToLast(node);
} else if (element == compiler.intClass) {
checkNum(input, '===');
@@ -2266,19 +2266,19 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
checkInt(input, '===');
push(new js.Binary('&&', numTest, pop()), node);
} else if (Elements.isStringSupertype(element, compiler)) {
- handleStringSupertypeCheck(input, element);
+ handleStringSupertypeCheck(input, type);
attachLocationToLast(node);
} else if (element === compiler.listClass
|| Elements.isListSupertype(element, compiler)) {
- handleListOrSupertypeCheck(input, element);
+ handleListOrSupertypeCheck(input, type);
attachLocationToLast(node);
} else if (types[input].canBePrimitive() || types[input].canBeNull()) {
checkObject(input, '===');
js.Expression objectTest = pop();
- checkType(input, element);
+ checkType(input, type);
push(new js.Binary('&&', objectTest, pop()), node);
} else {
- checkType(input, element);
+ checkType(input, type);
attachLocationToLast(node);
}
if (node.hasTypeInfo()) {
@@ -2336,8 +2336,8 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
};
if (node.isChecked) {
- Element element = node.type.computeType(compiler).element;
- world.registerIsCheck(element);
+ Type type = node.type.computeType(compiler);
+ Element element = type.element;
SourceString helper;
String additionalArgument;
bool nativeCheck =
@@ -2480,7 +2480,8 @@ class SsaOptimizedCodeGenerator extends SsaCodeGenerator {
void visitTypeGuard(HTypeGuard node) {
HInstruction input = node.guarded;
- Element indexingBehavior = compiler.jsIndexingBehaviorInterface;
+ Type indexingBehavior =
+ compiler.jsIndexingBehaviorInterface.computeType(compiler);
if (node.isInteger(types)) {
// if (input is !int) bailout
checkInt(input, '!==');

Powered by Google App Engine
This is Rietveld 408576698