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

Unified Diff: src/base/bits.h

Issue 1178403004: [turbofan] Use appropriate type for NodeId. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix useless static_cast. Created 5 years, 6 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 | « include/v8config.h ('k') | src/compiler/graph.h » ('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 b237d62bcb1d6f47500a42ffe76bef510e2006d6..abcfd9a9eddce4a45671712d7abbb5da6f0d5fbf 100644
--- a/src/base/bits.h
+++ b/src/base/bits.h
@@ -236,6 +236,19 @@ int32_t SignedDiv32(int32_t lhs, int32_t rhs);
int32_t SignedMod32(int32_t lhs, int32_t rhs);
+// UnsignedAddOverflow32(lhs,rhs,val) performs an unsigned summation of |lhs|
+// and |rhs| and stores the result into the variable pointed to by |val| and
+// returns true if the unsigned summation resulted in an overflow.
+inline bool UnsignedAddOverflow32(uint32_t lhs, uint32_t rhs, uint32_t* val) {
+#if V8_HAS_BUILTIN_SADD_OVERFLOW
+ return __builtin_uadd_overflow(lhs, rhs, val);
+#else
+ *val = lhs + rhs;
+ return *val < (lhs | rhs);
+#endif
+}
+
+
// UnsignedDiv32(lhs, rhs) divides |lhs| by |rhs| and returns the quotient
// truncated to uint32. If |rhs| is zero, then zero is returned.
inline uint32_t UnsignedDiv32(uint32_t lhs, uint32_t rhs) {
« no previous file with comments | « include/v8config.h ('k') | src/compiler/graph.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698