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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/base/bits.h ('k') | src/code-stub-assembler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/base/bits.h" 5 #include "src/base/bits.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "src/base/logging.h" 9 #include "src/base/logging.h"
10 #include "src/base/safe_math.h" 10 #include "src/base/safe_math.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 return FromCheckedNumeric(rv); 71 return FromCheckedNumeric(rv);
72 } 72 }
73 73
74 74
75 int64_t SignedSaturatedSub64(int64_t lhs, int64_t rhs) { 75 int64_t SignedSaturatedSub64(int64_t lhs, int64_t rhs) {
76 internal::CheckedNumeric<int64_t> rv(lhs); 76 internal::CheckedNumeric<int64_t> rv(lhs);
77 rv -= rhs; 77 rv -= rhs;
78 return FromCheckedNumeric(rv); 78 return FromCheckedNumeric(rv);
79 } 79 }
80 80
81 bool SignedMulOverflow32(int32_t lhs, int32_t rhs, int32_t* val) {
82 internal::CheckedNumeric<int32_t> rv(lhs);
83 rv *= rhs;
84 int32_t limit = std::numeric_limits<int32_t>::max();
85 *val = rv.ValueOrDefault(limit);
86 return !rv.IsValid();
87 }
88
89 bool SignedMulOverflow64(int64_t lhs, int64_t rhs, int64_t* val) {
90 internal::CheckedNumeric<int64_t> rv(lhs);
91 rv *= rhs;
92 int64_t limit = std::numeric_limits<int64_t>::max();
93 *val = rv.ValueOrDefault(limit);
94 return !rv.IsValid();
95 }
96
81 } // namespace bits 97 } // namespace bits
82 } // namespace base 98 } // namespace base
83 } // namespace v8 99 } // namespace v8
OLDNEW
« 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