Index: src/base/bits.cc |
diff --git a/src/base/bits.cc b/src/base/bits.cc |
index 6daee532a74cf7e5a0e0022afe70f453eb0e3ad3..7a3fb6d33159dfd64c88fb16683aabf2248f05a8 100644 |
--- a/src/base/bits.cc |
+++ b/src/base/bits.cc |
@@ -20,6 +20,25 @@ uint32_t RoundUpToPowerOfTwo32(uint32_t value) { |
return value + 1; |
} |
+ |
+int32_t SignedMulHigh32(int32_t lhs, int32_t rhs) { |
+ int64_t const value = static_cast<int64_t>(lhs) * static_cast<int64_t>(rhs); |
+ return bit_cast<int32_t, uint32_t>(bit_cast<uint64_t>(value) >> 32u); |
+} |
+ |
+ |
+int32_t SignedMulHighAndAdd32(int32_t lhs, int32_t rhs, int32_t acc) { |
+ return bit_cast<int32_t>(bit_cast<uint32_t>(acc) + |
+ bit_cast<uint32_t>(SignedMulHigh32(lhs, rhs))); |
+} |
+ |
+ |
+int32_t SignedMulHighAndSub32(int32_t lhs, int32_t rhs, int32_t acc) { |
+ return bit_cast<int32_t>(bit_cast<uint32_t>(acc) - |
+ bit_cast<uint32_t>(SignedMulHigh32(lhs, rhs))); |
+} |
+ |
+ |
} // namespace bits |
} // namespace base |
} // namespace v8 |