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

Unified Diff: src/utils.h

Issue 335063005: Re-land "Clusterfuzz identified overflow check needed in dehoisting." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Use safe numerics library for overflow checks. Created 6 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 | « src/hydrogen-instructions.h ('k') | test/cctest/test-utils.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « src/hydrogen-instructions.h ('k') | test/cctest/test-utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698