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

Unified Diff: runtime/vm/parser.cc

Issue 22640019: Fix for running with --throw_on_javascript_int_overflow: recognize pattern (a << b) & mask and test… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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
Index: runtime/vm/parser.cc
===================================================================
--- runtime/vm/parser.cc (revision 26093)
+++ runtime/vm/parser.cc (working copy)
@@ -7290,6 +7290,29 @@
if ((binary_op == Token::kAND) || (binary_op == Token::kOR)) {
EnsureExpressionTemp();
}
+ if (binary_op == Token::kBIT_AND) {
+ // Normalize so that rhs is a literal if any is.
+ if ((rhs_literal == NULL) && (lhs_literal != NULL)) {
+ // Swap.
+ LiteralNode* temp = rhs_literal;
+ rhs_literal = lhs_literal;
+ lhs_literal = temp;
+ }
+ if ((rhs_literal != NULL) &&
+ (rhs_literal->literal().IsSmi() || rhs_literal->literal().IsMint())) {
+ const int64_t val = Integer::Cast(rhs_literal->literal()).AsInt64Value();
+ if ((0 <= val) && (Utils::IsUint(32, val))) {
+ if (lhs->IsBinaryOpNode() &&
+ (lhs->AsBinaryOpNode()->kind() == Token::kSHL)) {
+ // Merge SHL and BIT_AND into one "SHL with mask" node.
+ BinaryOpNode* old = lhs->AsBinaryOpNode();
+ BinaryOpWithMask32Node* binop = new BinaryOpWithMask32Node(
+ old->token_pos(), old->kind(), old->left(), old->right(), val);
+ return binop;
+ }
+ }
+ }
+ }
return new BinaryOpNode(op_pos, binary_op, lhs, rhs);
}

Powered by Google App Engine
This is Rietveld 408576698