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

Side by Side Diff: src/utils.h

Issue 2252863003: [turbofan] Add Float32(Max|Min) machine operators. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Type is number now. Created 4 years, 4 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/compiler/x64/instruction-selector-x64.cc ('k') | src/wasm/wasm-interpreter.cc » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 #ifndef V8_UTILS_H_ 5 #ifndef V8_UTILS_H_
6 #define V8_UTILS_H_ 6 #define V8_UTILS_H_
7 7
8 #include <limits.h> 8 #include <limits.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 return a < b ? b : a; 193 return a < b ? b : a;
194 } 194 }
195 195
196 196
197 // Returns the minimum of the two parameters. 197 // Returns the minimum of the two parameters.
198 template <typename T> 198 template <typename T>
199 T Min(T a, T b) { 199 T Min(T a, T b) {
200 return a < b ? a : b; 200 return a < b ? a : b;
201 } 201 }
202 202
203 // Returns the maximum of the two parameters according to JavaScript semantics.
204 template <typename T>
205 T JSMax(T x, T y) {
206 if (std::isnan(x)) return x;
207 if (std::isnan(y)) return y;
208 if (std::signbit(x) < std::signbit(y)) return x;
209 return x > y ? x : y;
210 }
211
212 // Returns the maximum of the two parameters according to JavaScript semantics.
213 template <typename T>
214 T JSMin(T x, T y) {
215 if (std::isnan(x)) return x;
216 if (std::isnan(y)) return y;
217 if (std::signbit(x) < std::signbit(y)) return y;
218 return x > y ? y : x;
219 }
203 220
204 // Returns the absolute value of its argument. 221 // Returns the absolute value of its argument.
205 template <typename T> 222 template <typename T>
206 T Abs(T a) { 223 T Abs(T a) {
207 return a < 0 ? -a : a; 224 return a < 0 ? -a : a;
208 } 225 }
209 226
210 227
211 // Floor(-0.0) == 0.0 228 // Floor(-0.0) == 0.0
212 inline double Floor(double x) { 229 inline double Floor(double x) {
(...skipping 1357 matching lines...) Expand 10 before | Expand all | Expand 10 after
1570 byte* dst = reinterpret_cast<byte*>(p); 1587 byte* dst = reinterpret_cast<byte*>(p);
1571 for (size_t i = 0; i < sizeof(V); i++) { 1588 for (size_t i = 0; i < sizeof(V); i++) {
1572 dst[i] = src[sizeof(V) - i - 1]; 1589 dst[i] = src[sizeof(V) - i - 1];
1573 } 1590 }
1574 #endif // V8_TARGET_LITTLE_ENDIAN 1591 #endif // V8_TARGET_LITTLE_ENDIAN
1575 } 1592 }
1576 } // namespace internal 1593 } // namespace internal
1577 } // namespace v8 1594 } // namespace v8
1578 1595
1579 #endif // V8_UTILS_H_ 1596 #endif // V8_UTILS_H_
OLDNEW
« no previous file with comments | « src/compiler/x64/instruction-selector-x64.cc ('k') | src/wasm/wasm-interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698