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

Unified Diff: pkg/compiler/lib/src/ssa/codegen.dart

Issue 829913006: Optimize is-check to instanceof when it eliminates an interceptor (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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
« no previous file with comments | « pkg/compiler/lib/src/ssa/builder.dart ('k') | pkg/compiler/lib/src/ssa/codegen_helpers.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/ssa/codegen.dart
diff --git a/pkg/compiler/lib/src/ssa/codegen.dart b/pkg/compiler/lib/src/ssa/codegen.dart
index 4c97c464adcaf3c91da6339ce6fe6fda4845645d..0d4b38911d9bf6777dc1306ee7759f5b0aa1d29d 100644
--- a/pkg/compiler/lib/src/ssa/codegen.dart
+++ b/pkg/compiler/lib/src/ssa/codegen.dart
@@ -2304,6 +2304,19 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
if (!negative) push(new js.Prefix('!', pop()));
}
+ void checkTypeViaInstanceof(
+ HInstruction input, DartType type, bool negative) {
+ registry.registerIsCheck(type);
+
+ use(input);
+
+ js.Expression jsClassReference =
+ backend.emitter.constructorAccess(type.element);
+ push(js.js('# instanceof #', [pop(), jsClassReference]));
+ if (negative) push(new js.Prefix('!', pop()));
+ registry.registerInstantiatedType(type);
+ }
+
void handleNumberOrStringSupertypeCheck(HInstruction input,
HInstruction interceptor,
DartType type,
@@ -2421,6 +2434,10 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
js.Expression numTest = pop();
checkBigInt(input, relation);
push(new js.Binary(negative ? '||' : '&&', numTest, pop()), node);
+ } else if (node.useInstanceOf) {
+ assert(interceptor == null);
+ checkTypeViaInstanceof(input, type, negative);
+ attachLocationToLast(node);
} else if (Elements.isNumberOrStringSupertype(element, compiler)) {
handleNumberOrStringSupertypeCheck(
input, interceptor, type, negative: negative);
« no previous file with comments | « pkg/compiler/lib/src/ssa/builder.dart ('k') | pkg/compiler/lib/src/ssa/codegen_helpers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698