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

Unified Diff: src/base/bits.cc

Issue 2101123005: [turbofan] Introduce integer multiplication with overflow. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE. Created 4 years, 5 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/base/bits.h ('k') | src/code-stub-assembler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/base/bits.cc
diff --git a/src/base/bits.cc b/src/base/bits.cc
index 9b949cc66f8e380a658fbb33dac8bc1e520622ec..909f9deb8c1682ebf8c729cc601781856d9166d0 100644
--- a/src/base/bits.cc
+++ b/src/base/bits.cc
@@ -78,6 +78,22 @@ int64_t SignedSaturatedSub64(int64_t lhs, int64_t rhs) {
return FromCheckedNumeric(rv);
}
+bool SignedMulOverflow32(int32_t lhs, int32_t rhs, int32_t* val) {
+ internal::CheckedNumeric<int32_t> rv(lhs);
+ rv *= rhs;
+ int32_t limit = std::numeric_limits<int32_t>::max();
+ *val = rv.ValueOrDefault(limit);
+ return !rv.IsValid();
+}
+
+bool SignedMulOverflow64(int64_t lhs, int64_t rhs, int64_t* val) {
+ internal::CheckedNumeric<int64_t> rv(lhs);
+ rv *= rhs;
+ int64_t limit = std::numeric_limits<int64_t>::max();
+ *val = rv.ValueOrDefault(limit);
+ return !rv.IsValid();
+}
+
} // namespace bits
} // namespace base
} // namespace v8
« no previous file with comments | « src/base/bits.h ('k') | src/code-stub-assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698