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

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

Issue 1294283005: Recognize corelib.identical. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/cps_ir/type_propagation.dart
diff --git a/pkg/compiler/lib/src/cps_ir/type_propagation.dart b/pkg/compiler/lib/src/cps_ir/type_propagation.dart
index d93f05154e3baff2b274c9ff9ab737d14b9abd1f..c85af372c1d3d572a896b598a8b9a57493478012 100644
--- a/pkg/compiler/lib/src/cps_ir/type_propagation.dart
+++ b/pkg/compiler/lib/src/cps_ir/type_propagation.dart
@@ -1610,6 +1610,19 @@ class TransformingVisitor extends LeafVisitor {
Continuation cont = node.continuation.definition;
Primitive arg(int n) => node.arguments[n].definition;
AbstractValue argType(int n) => getValue(arg(n));
+
+ bool replaceWithBinary(BuiltinOperator operator,
+ Primitive left,
+ Primitive right) {
+ Primitive prim =
+ new ApplyBuiltinOperator(operator, <Primitive>[left, right],
+ node.sourceInformation);
+ LetPrim let = makeLetPrimInvoke(prim, cont);
+ replaceSubtree(node, let);
+ push(let);
+ return true; // So returning early is more convenient.
+ }
+
if (node.target.library.isInternalLibrary) {
switch(node.target.name) {
case InternalMethod.Stringify:
@@ -1622,6 +1635,14 @@ class TransformingVisitor extends LeafVisitor {
}
break;
}
+ } else if (node.target.library.isDartCore) {
+ switch(node.target.name) {
+ case CorelibMethod.Identical:
+ if (node.arguments.length == 2) {
+ return replaceWithBinary(BuiltinOperator.Identical, arg(0), arg(1));
+ }
+ break;
+ }
}
return false;
}
@@ -2511,6 +2532,11 @@ abstract class InternalMethod {
static const String Stringify = 'S';
}
+/// Enum-like class with the names of dart:core methods we care about.
+abstract class CorelibMethod {
+ static const String Identical = 'identical';
+}
+
/// Suggested name for a synthesized loop index.
class LoopIndexEntity extends Entity {
String get name => 'i';
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698