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

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

Issue 87783003: Add UInt32 and UInt31 types to better infer bit operations. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month 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 30666)
+++ sdk/lib/_internal/compiler/implementation/ssa/invoke_dynamic_specializers.dart (working copy)
@@ -135,7 +135,7 @@
// integer or throw an error.
JavaScriptBackend backend = compiler.backend;
if (instruction.inputs[1].isPrimitiveOrNull(compiler)) {
- return backend.intType;
+ return backend.uint32Type;
}
return super.computeTypeFromInputTypes(instruction, compiler);
}
@@ -145,7 +145,8 @@
JavaScriptBackend backend = compiler.backend;
HInstruction input = instruction.inputs[1];
if (input.isNumber(compiler)) {
- return new HBitNot(input, instruction.selector, backend.intType);
+ return new HBitNot(input, instruction.selector,
+ computeTypeFromInputTypes(instruction, compiler));
}
return null;
}
@@ -331,7 +332,7 @@
HInstruction left = instruction.inputs[1];
JavaScriptBackend backend = compiler.backend;
if (left.isPrimitiveOrNull(compiler)) {
- return backend.intType;
+ return backend.uint32Type;
}
return super.computeTypeFromInputTypes(instruction, compiler);
}
@@ -344,10 +345,10 @@
return count >= 0 && count <= 31;
}
- bool isPositive(HInstruction instruction) {
+ bool isPositive(HInstruction instruction, Compiler compiler) {
// TODO: We should use the value range analysis. Currently, ranges
// are discarded just after the analysis.
- return instruction is HBinaryBitOp;
+ return instruction.isUInt32(compiler);
}
}
@@ -379,19 +380,28 @@
JavaScriptBackend backend = compiler.backend;
return new HShiftLeft(
instruction.inputs[1], instruction.inputs[2],
- instruction.selector, backend.intType);
+ instruction.selector, computeTypeFromInputTypes(instruction, compiler));
}
}
class ShiftRightSpecializer extends BinaryBitOpSpecializer {
const ShiftRightSpecializer();
+ TypeMask computeTypeFromInputTypes(HInvokeDynamic instruction,
+ Compiler compiler) {
+ HInstruction left = instruction.inputs[1];
+ HInstruction right = instruction.inputs[2];
+ JavaScriptBackend backend = compiler.backend;
+ if (left.isUInt32(compiler)) return left.instructionType;
+ return super.computeTypeFromInputTypes(instruction, compiler);
+ }
+
HInstruction tryConvertToBuiltin(HInvokeDynamic instruction,
Compiler compiler) {
HInstruction left = instruction.inputs[1];
HInstruction right = instruction.inputs[2];
if (left.isNumber(compiler)) {
- if (argumentLessThan32(right) && isPositive(left)) {
+ if (argumentLessThan32(right) && isPositive(left, compiler)) {
return newBuiltinVariant(instruction, compiler);
}
// Even if there is no builtin equivalent instruction, we know
@@ -407,7 +417,7 @@
JavaScriptBackend backend = compiler.backend;
return new HShiftRight(
instruction.inputs[1], instruction.inputs[2],
- instruction.selector, backend.intType);
+ instruction.selector, computeTypeFromInputTypes(instruction, compiler));
}
BinaryOperation operation(ConstantSystem constantSystem) {
@@ -422,12 +432,23 @@
return constantSystem.bitOr;
}
+ TypeMask computeTypeFromInputTypes(HInvokeDynamic instruction,
+ Compiler compiler) {
+ HInstruction left = instruction.inputs[1];
+ HInstruction right = instruction.inputs[2];
+ JavaScriptBackend backend = compiler.backend;
+ if (left.isUInt31(compiler) && right.isUInt31(compiler)) {
+ return backend.uint31Type;
+ }
+ return super.computeTypeFromInputTypes(instruction, compiler);
+ }
+
HInstruction newBuiltinVariant(HInvokeDynamic instruction,
Compiler compiler) {
JavaScriptBackend backend = compiler.backend;
return new HBitOr(
instruction.inputs[1], instruction.inputs[2],
- instruction.selector, backend.intType);
+ instruction.selector, computeTypeFromInputTypes(instruction, compiler));
}
}
@@ -438,12 +459,23 @@
return constantSystem.bitAnd;
}
+ TypeMask computeTypeFromInputTypes(HInvokeDynamic instruction,
+ Compiler compiler) {
+ HInstruction left = instruction.inputs[1];
+ HInstruction right = instruction.inputs[2];
+ JavaScriptBackend backend = compiler.backend;
+ if (left.isUInt31(compiler) || right.isUInt31(compiler)) {
+ return backend.uint31Type;
+ }
+ return super.computeTypeFromInputTypes(instruction, compiler);
+ }
+
HInstruction newBuiltinVariant(HInvokeDynamic instruction,
Compiler compiler) {
JavaScriptBackend backend = compiler.backend;
return new HBitAnd(
instruction.inputs[1], instruction.inputs[2],
- instruction.selector, backend.intType);
+ instruction.selector, computeTypeFromInputTypes(instruction, compiler));
}
}
@@ -454,12 +486,23 @@
return constantSystem.bitXor;
}
+ TypeMask computeTypeFromInputTypes(HInvokeDynamic instruction,
+ Compiler compiler) {
+ HInstruction left = instruction.inputs[1];
+ HInstruction right = instruction.inputs[2];
+ JavaScriptBackend backend = compiler.backend;
+ if (left.isUInt31(compiler) && right.isUInt31(compiler)) {
+ return backend.uint31Type;
+ }
+ return super.computeTypeFromInputTypes(instruction, compiler);
+ }
+
HInstruction newBuiltinVariant(HInvokeDynamic instruction,
Compiler compiler) {
JavaScriptBackend backend = compiler.backend;
return new HBitXor(
instruction.inputs[1], instruction.inputs[2],
- instruction.selector, backend.intType);
+ instruction.selector, computeTypeFromInputTypes(instruction, compiler));
}
}
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/codegen.dart ('k') | sdk/lib/_internal/compiler/implementation/ssa/nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698