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

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

Issue 12974002: Convert a == to a builtin identity check if the receiver type can only hit Object==. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 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/invoke_dynamic_specializers.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/ssa/invoke_dynamic_specializers.dart (revision 20274)
+++ sdk/lib/_internal/compiler/implementation/ssa/invoke_dynamic_specializers.dart (working copy)
@@ -24,7 +24,8 @@
return instruction.instructionType;
}
- HInstruction tryConvertToBuiltin(HInvokeDynamic instruction) {
+ HInstruction tryConvertToBuiltin(HInvokeDynamic instruction,
+ Compiler compiler) {
return null;
}
@@ -96,7 +97,8 @@
return HType.UNKNOWN;
}
- HInstruction tryConvertToBuiltin(HInvokeDynamic instruction) {
+ HInstruction tryConvertToBuiltin(HInvokeDynamic instruction,
+ Compiler compiler) {
if (instruction.inputs[1].isMutableArray()) {
return new HIndexAssign(instruction.inputs[1],
instruction.inputs[2],
@@ -124,7 +126,8 @@
return HType.UNKNOWN;
}
- HInstruction tryConvertToBuiltin(HInvokeDynamic instruction) {
+ HInstruction tryConvertToBuiltin(HInvokeDynamic instruction,
+ Compiler compiler) {
if (instruction.inputs[1].isIndexablePrimitive()) {
return new HIndex(instruction.inputs[1], instruction.inputs[2]);
}
@@ -159,7 +162,8 @@
return instruction.instructionType;
}
- HInstruction tryConvertToBuiltin(HInvokeDynamic instruction) {
+ HInstruction tryConvertToBuiltin(HInvokeDynamic instruction,
+ Compiler compiler) {
HInstruction input = instruction.inputs[1];
if (input.isNumber()) return new HBitNot(input);
return null;
@@ -194,7 +198,8 @@
return instruction.instructionType;
}
- HInstruction tryConvertToBuiltin(HInvokeDynamic instruction) {
+ HInstruction tryConvertToBuiltin(HInvokeDynamic instruction,
+ Compiler compiler) {
HInstruction input = instruction.inputs[1];
if (input.isNumber()) return new HNegate(input);
return null;
@@ -249,7 +254,8 @@
&& instruction.inputs[2].isNumber();
}
- HInstruction tryConvertToBuiltin(HInvokeDynamic instruction) {
+ HInstruction tryConvertToBuiltin(HInvokeDynamic instruction,
+ Compiler compiler) {
if (isBuiltin(instruction)) {
HInstruction builtin =
newBuiltinVariant(instruction.inputs[1], instruction.inputs[2]);
@@ -392,7 +398,8 @@
return constantSystem.shiftLeft;
}
- HInstruction tryConvertToBuiltin(HInvokeDynamic instruction) {
+ HInstruction tryConvertToBuiltin(HInvokeDynamic instruction,
+ Compiler compiler) {
HInstruction left = instruction.inputs[1];
HInstruction right = instruction.inputs[2];
if (!left.isNumber() || !right.isConstantInteger()) return null;
@@ -487,7 +494,8 @@
return HType.UNKNOWN;
}
- HInstruction tryConvertToBuiltin(HInvokeDynamic instruction) {
+ HInstruction tryConvertToBuiltin(HInvokeDynamic instruction,
+ Compiler compiler) {
HInstruction left = instruction.inputs[1];
HInstruction right = instruction.inputs[2];
if (left.isNumber() && right.isNumber()) {
@@ -528,12 +536,23 @@
return HType.UNKNOWN;
}
- HInstruction tryConvertToBuiltin(HInvokeDynamic instruction) {
+ HInstruction tryConvertToBuiltin(HInvokeDynamic instruction,
+ Compiler compiler) {
HInstruction left = instruction.inputs[1];
HInstruction right = instruction.inputs[2];
- if (left.instructionType.isPrimitiveOrNull() || right.isConstantNull()) {
+ HType instructionType = left.instructionType;
+ if (right.isConstantNull() || instructionType.isPrimitiveOrNull()) {
return newBuiltinVariant(left, right);
}
+ // Make the mask non-nullable to avoid finding a potential
+ // JSNull::operator==.
kasperl 2013/03/21 07:07:04 Do we need the JSNull operator ==? If we ignore it
ngeoffray 2013/03/21 08:59:01 We can't get rid of it. If we have no clue what th
sra1 2013/03/21 08:59:07 I'm not sure whether you mean get rid of this chec
+ TypeMask mask = instructionType.computeMask(compiler).nonNullable();
+ Selector selector = new TypedSelector(mask, instruction.selector);
+ World world = compiler.world;
+ JavaScriptBackend backend = compiler.backend;
+ if (world.locateSingleElement(selector) == backend.objectEquals) {
+ return newBuiltinVariant(left, right);
+ }
return null;
}

Powered by Google App Engine
This is Rietveld 408576698