Chromium Code Reviews| Index: src/utils.h |
| diff --git a/src/utils.h b/src/utils.h |
| index 5422985bc538c641ac3b5d25a03f4909d390be2a..7c4945e1c25fa5540f6b4eb10dba1f6f7cf8db36 100644 |
| --- a/src/utils.h |
| +++ b/src/utils.h |
| @@ -16,6 +16,7 @@ |
| #include "src/list.h" |
| #include "src/platform.h" |
| #include "src/vector.h" |
| +#include "src/base/safe_math.h" |
| namespace v8 { |
| namespace internal { |
| @@ -252,6 +253,20 @@ template<> struct make_unsigned<int64_t> { |
| }; |
| +template<typename T> bool MultiplyOverflows(T x, T y) { |
|
danno
2014/06/18 14:55:04
Do you really need these wrappers? It seems that t
|
| + v8::base::internal::CheckedNumeric<T> checked_result = x; |
| + checked_result = checked_result * y; |
| + return !checked_result.IsValid(); |
| +} |
| + |
| + |
| +template<typename T> bool AdditionOverflows(T x, T y) { |
| + v8::base::internal::CheckedNumeric<T> checked_result = x; |
| + checked_result = checked_result + y; |
| + return !checked_result.IsValid(); |
| +} |
| + |
| + |
| // ---------------------------------------------------------------------------- |
| // BitField is a help template for encoding and decode bitfield with |
| // unsigned content. |