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

Unified Diff: runtime/vm/intermediate_language_arm.cc

Issue 2487873003: Speculate on bitwise operators. (Closed)
Patch Set: git cl format Created 4 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: runtime/vm/intermediate_language_arm.cc
diff --git a/runtime/vm/intermediate_language_arm.cc b/runtime/vm/intermediate_language_arm.cc
index fb5cad3e77020ba85e88b4b5c10aa628af41e51b..8d199c498d54b7c62b246226df7448c63566949a 100644
--- a/runtime/vm/intermediate_language_arm.cc
+++ b/runtime/vm/intermediate_language_arm.cc
@@ -3202,6 +3202,30 @@ void CheckedSmiOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
case Token::kBIT_XOR:
__ eor(result, left, Operand(right));
break;
+ case Token::kSHL:
+ ASSERT(result != left);
+ ASSERT(result != right);
+ __ CompareImmediate(right, Smi::RawValue(Smi::kBits));
+ __ b(slow_path->entry_label(), HI);
+
+ __ SmiUntag(TMP, right);
+ // Check for overflow by shifting left and shifting back arithmetically.
+ // If the result is different from the original, there was overflow.
+ __ Lsl(result, left, TMP);
+ __ cmp(left, Operand(result, ASR, TMP));
+ __ b(slow_path->entry_label(), NE);
+ break;
+ case Token::kSHR:
+ ASSERT(result != left);
+ ASSERT(result != right);
+ __ CompareImmediate(right, Smi::RawValue(Smi::kBits));
+ __ b(slow_path->entry_label(), HI);
+
+ __ SmiUntag(result, right);
+ __ SmiUntag(TMP, left);
+ __ Asr(result, TMP, result);
+ __ SmiTag(result);
+ break;
default:
UNREACHABLE();
}

Powered by Google App Engine
This is Rietveld 408576698