Chromium Code Reviews| Index: lib/compiler/implementation/ssa/codegen.dart |
| diff --git a/lib/compiler/implementation/ssa/codegen.dart b/lib/compiler/implementation/ssa/codegen.dart |
| index 8e49b8ad54f732700bd4d3ea2d8c62f20486e525..0acd5e43d5b1659da394f5f7ec1989e46f18f60f 100644 |
| --- a/lib/compiler/implementation/ssa/codegen.dart |
| +++ b/lib/compiler/implementation/ssa/codegen.dart |
| @@ -1100,6 +1100,21 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor { |
| } |
| } |
| + // We want the outcome of bit-operations to be positive. We use the unsigned |
| + // shift operator to achieve this. |
| + visitBitInvokeBinary(HBinaryBitOp node, String op) { |
| + if (node.builtin){ |
| + JSBinaryOperatorPrecedence unsignedShiftPrecedences = |
|
kasperl
2012/05/03 07:05:50
Could this be cached somewhere? It feels a bit ove
floitsch
2012/05/03 11:10:36
cached as instance field now.
|
| + JSPrecedence.binary['>>>']; |
| + beginExpression(unsignedShiftPrecedences.precedence); |
| + visitInvokeBinary(node, op); |
| + buffer.add(' >>> 0'); |
| + endExpression(unsignedShiftPrecedences.precedence); |
| + } else { |
| + visitInvokeBinary(node, op); |
| + } |
| + } |
| + |
| visitInvokeUnary(HInvokeUnary node, String op) { |
| if (node.builtin) { |
| beginExpression(JSPrecedence.PREFIX_PRECEDENCE); |
| @@ -1111,6 +1126,21 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor { |
| } |
| } |
| + // We want the outcome of bit-operations to be positive. We use the unsigned |
| + // shift operator to achieve this. |
| + visitBitInvokeUnary(HInvokeUnary node, String op) { |
| + if (node.builtin){ |
| + JSBinaryOperatorPrecedence unsignedShiftPrecedences = |
| + JSPrecedence.binary['>>>']; |
| + beginExpression(unsignedShiftPrecedences.precedence); |
| + visitInvokeUnary(node, op); |
| + buffer.add(' >>> 0'); |
| + endExpression(unsignedShiftPrecedences.precedence); |
| + } else { |
| + visitInvokeUnary(node, op); |
| + } |
| + } |
| + |
| visitEquals(HEquals node) { |
| if (node.builtin) { |
| beginExpression(JSPrecedence.EQUALITY_PRECEDENCE); |
| @@ -1140,10 +1170,10 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor { |
| // Modulo cannot be mapped to the native operator (different semantics). |
| visitModulo(HModulo node) => visitInvokeStatic(node); |
| - visitBitAnd(HBitAnd node) => visitInvokeBinary(node, '&'); |
| - visitBitNot(HBitNot node) => visitInvokeUnary(node, '~'); |
| - visitBitOr(HBitOr node) => visitInvokeBinary(node, '|'); |
| - visitBitXor(HBitXor node) => visitInvokeBinary(node, '^'); |
| + visitBitAnd(HBitAnd node) => visitBitInvokeBinary(node, '&'); |
| + visitBitNot(HBitNot node) => visitBitInvokeUnary(node, '~'); |
| + visitBitOr(HBitOr node) => visitBitInvokeBinary(node, '|'); |
| + visitBitXor(HBitXor node) => visitBitInvokeBinary(node, '^'); |
| // We need to check if the left operand is negative in order to use |
| // the native operator. |