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

Unified Diff: runtime/vm/intermediate_language_mips.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_mips.cc
diff --git a/runtime/vm/intermediate_language_mips.cc b/runtime/vm/intermediate_language_mips.cc
index 2c3ac3969bed4ad116b7e666bb08aff7a826aa18..6a2c6238e6224b9f54936756983e32456b0d1687 100644
--- a/runtime/vm/intermediate_language_mips.cc
+++ b/runtime/vm/intermediate_language_mips.cc
@@ -3039,6 +3039,26 @@ void CheckedSmiOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
case Token::kBIT_XOR:
__ xor_(result, left, right);
break;
+ case Token::kSHL:
+ ASSERT(result != left);
+ ASSERT(result != right);
+ __ BranchUnsignedGreater(right, Immediate(Smi::RawValue(Smi::kBits)),
+ slow_path->entry_label());
+ // Check for overflow by shifting left and shifting back arithmetically.
+ // If the result is different from the original, there was overflow.
+ __ delay_slot()->SmiUntag(TMP, right);
+ __ sllv(result, left, TMP);
+ __ srav(CMPRES1, result, TMP);
+ __ bne(CMPRES1, left, slow_path->entry_label());
+ break;
+ case Token::kSHR:
+ __ BranchUnsignedGreater(right, Immediate(Smi::RawValue(Smi::kBits)),
+ slow_path->entry_label());
+ __ delay_slot()->SmiUntag(result, right);
+ __ SmiUntag(TMP, left);
+ __ srav(result, TMP, result);
+ __ SmiTag(result);
+ break;
default:
UNIMPLEMENTED();
}

Powered by Google App Engine
This is Rietveld 408576698