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

Unified Diff: runtime/vm/intermediate_language_arm.cc

Issue 2487873003: Speculate on bitwise operators. (Closed)
Patch Set: . 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 fd50a1423bf24310b76107a56fbf73f46c8b8f5f..6826b63feca0bd503c7a74949ad79423e56bd76b 100644
--- a/runtime/vm/intermediate_language_arm.cc
+++ b/runtime/vm/intermediate_language_arm.cc
@@ -3259,6 +3259,32 @@ 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.
+ __ mov(result, Operand(left, LSL, TMP));
Florian Schneider 2016/11/11 18:12:20 Can Assembler::LsL be used here as well?
rmacnak 2016/11/11 21:29:02 Done.
+ __ cmp(left, Operand(result, ASR, TMP));
+ __ b(slow_path->entry_label(), NE);
+ break;
+ case Token::kSHR:
+ ASSERT(result != left);
+ ASSERT(result != right);
+ __ CompareImmediate(right, 0);
+ __ b(slow_path->entry_label(), LT);
+
+ __ SmiUntag(result, right);
+ __ CompareImmediate(result, 0x1F);
+ __ LoadImmediate(result, 0x1F, GT);
+ __ SmiUntag(TMP, left);
+ __ mov(result, Operand(TMP, ASR, result));
Florian Schneider 2016/11/11 18:12:20 Use Asr?
rmacnak 2016/11/11 21:29:02 Done.
+ __ SmiTag(result);
+ break;
default:
UNREACHABLE();
}

Powered by Google App Engine
This is Rietveld 408576698