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

Unified Diff: lib/compiler/implementation/ssa/codegen.dart

Issue 10343002: Make bit-operations return a positive result. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebase Created 8 years, 8 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 | « lib/compiler/implementation/lib/js_helper.dart ('k') | tests/standalone/standalone.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « lib/compiler/implementation/lib/js_helper.dart ('k') | tests/standalone/standalone.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698