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

Side by Side Diff: src/utils.h

Issue 2333663002: [turbofan] Do constant folding for Float64Pow. (Closed)
Patch Set: Make sure to have exponent 0/-0 properly. Created 4 years, 3 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/machine-operator-reducer.cc ('k') | src/wasm/wasm-external-refs.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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 227
228 // Floor(-0.0) == 0.0 228 // Floor(-0.0) == 0.0
229 inline double Floor(double x) { 229 inline double Floor(double x) {
230 #if V8_CC_MSVC 230 #if V8_CC_MSVC
231 if (x == 0) return x; // Fix for issue 3477. 231 if (x == 0) return x; // Fix for issue 3477.
232 #endif 232 #endif
233 return std::floor(x); 233 return std::floor(x);
234 } 234 }
235 235
236 inline double Pow(double x, double y) { 236 inline double Pow(double x, double y) {
237 if (y == 0.0) return 1.0;
238 if (std::isnan(y) || ((x == 1 || x == -1) && std::isinf(y))) {
239 return std::numeric_limits<double>::quiet_NaN();
240 }
237 #if (defined(__MINGW64_VERSION_MAJOR) && \ 241 #if (defined(__MINGW64_VERSION_MAJOR) && \
238 (!defined(__MINGW64_VERSION_RC) || __MINGW64_VERSION_RC < 1)) || \ 242 (!defined(__MINGW64_VERSION_RC) || __MINGW64_VERSION_RC < 1)) || \
239 defined(V8_OS_AIX) 243 defined(V8_OS_AIX)
240 // MinGW64 and AIX have a custom implementation for pow. This handles certain 244 // MinGW64 and AIX have a custom implementation for pow. This handles certain
241 // special cases that are different. 245 // special cases that are different.
242 if ((x == 0.0 || std::isinf(x)) && y != 0.0 && std::isfinite(y)) { 246 if ((x == 0.0 || std::isinf(x)) && y != 0.0 && std::isfinite(y)) {
243 double f; 247 double f;
244 double result = ((x == 0.0) ^ (y > 0)) ? V8_INFINITY : 0; 248 double result = ((x == 0.0) ^ (y > 0)) ? V8_INFINITY : 0;
245 /* retain sign if odd integer exponent */ 249 /* retain sign if odd integer exponent */
246 return ((std::modf(y, &f) == 0.0) && (static_cast<int64_t>(y) & 1)) 250 return ((std::modf(y, &f) == 0.0) && (static_cast<int64_t>(y) & 1))
(...skipping 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after
1587 byte* dst = reinterpret_cast<byte*>(p); 1591 byte* dst = reinterpret_cast<byte*>(p);
1588 for (size_t i = 0; i < sizeof(V); i++) { 1592 for (size_t i = 0; i < sizeof(V); i++) {
1589 dst[i] = src[sizeof(V) - i - 1]; 1593 dst[i] = src[sizeof(V) - i - 1];
1590 } 1594 }
1591 #endif // V8_TARGET_LITTLE_ENDIAN 1595 #endif // V8_TARGET_LITTLE_ENDIAN
1592 } 1596 }
1593 } // namespace internal 1597 } // namespace internal
1594 } // namespace v8 1598 } // namespace v8
1595 1599
1596 #endif // V8_UTILS_H_ 1600 #endif // V8_UTILS_H_
OLDNEW
« no previous file with comments | « src/compiler/machine-operator-reducer.cc ('k') | src/wasm/wasm-external-refs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698