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

Unified Diff: src/base/bits.h

Issue 975283002: Use Rotate*() functions instead of doing this manually. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: . Created 5 years, 10 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 | « src/arm/simulator-arm.cc ('k') | src/mips/simulator-mips.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/base/bits.h
diff --git a/src/base/bits.h b/src/base/bits.h
index 0f4d4c712becc540dd767291b1766b12c526a09e..5c7cd74c610d5f8f59b21214d888d2b284825935 100644
--- a/src/base/bits.h
+++ b/src/base/bits.h
@@ -148,17 +148,30 @@ inline uint32_t RoundDownToPowerOfTwo32(uint32_t value) {
}
+// Precondition: 0 <= shift < 32
hans 2015/03/04 06:02:51 Any reason the preconditions are not some kind of
Nico 2015/03/04 06:21:10 I was worried that this might be performance-criti
inline uint32_t RotateRight32(uint32_t value, uint32_t shift) {
if (shift == 0) return value;
return (value >> shift) | (value << (32 - shift));
}
+// Precondition: 0 <= shift < 32
+inline uint32_t RotateLeft32(uint32_t value, uint32_t shift) {
+ if (shift == 0) return value;
+ return (value << shift) | (value >> (32 - shift));
+}
+// Precondition: 0 <= shift < 64
inline uint64_t RotateRight64(uint64_t value, uint64_t shift) {
if (shift == 0) return value;
return (value >> shift) | (value << (64 - shift));
}
+// Precondition: 0 <= shift < 64
+inline uint64_t RotateLeft64(uint64_t value, uint64_t shift) {
+ if (shift == 0) return value;
+ return (value << shift) | (value >> (64 - shift));
+}
+
// SignedAddOverflow32(lhs,rhs,val) performs a signed summation of |lhs| and
// |rhs| and stores the result into the variable pointed to by |val| and
« no previous file with comments | « src/arm/simulator-arm.cc ('k') | src/mips/simulator-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698