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

Side by Side Diff: src/conversions-inl.h

Issue 594493002: [turbofan] Add operators for float32 support. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 6 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 | Annotate | Revision Log
« no previous file with comments | « src/conversions.h ('k') | src/runtime.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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_CONVERSIONS_INL_H_ 5 #ifndef V8_CONVERSIONS_INL_H_
6 #define V8_CONVERSIONS_INL_H_ 6 #define V8_CONVERSIONS_INL_H_
7 7
8 #include <float.h> // Required for DBL_MAX and on Win32 for finite() 8 #include <float.h> // Required for DBL_MAX and on Win32 for finite()
9 #include <limits.h> // Required for INT_MAX etc. 9 #include <limits.h> // Required for INT_MAX etc.
10 #include <stdarg.h> 10 #include <stdarg.h>
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 #endif 60 #endif
61 // Copy least significant 32 bits of mantissa. 61 // Copy least significant 32 bits of mantissa.
62 memcpy(&result, mantissa_ptr, sizeof(result)); 62 memcpy(&result, mantissa_ptr, sizeof(result));
63 return negative ? ~result + 1 : result; 63 return negative ? ~result + 1 : result;
64 } 64 }
65 // Large number (outside uint32 range), Infinity or NaN. 65 // Large number (outside uint32 range), Infinity or NaN.
66 return 0x80000000u; // Return integer indefinite. 66 return 0x80000000u; // Return integer indefinite.
67 } 67 }
68 68
69 69
70 inline float DoubleToFloat32(double x) {
71 // TODO(yanggou): This static_cast is implementation-defined behaviour in C++,
72 // so we may need to do the conversion manually instead to match the spec.
73 volatile float f = static_cast<float>(x);
74 return f;
75 }
76
77
70 inline double DoubleToInteger(double x) { 78 inline double DoubleToInteger(double x) {
71 if (std::isnan(x)) return 0; 79 if (std::isnan(x)) return 0;
72 if (!std::isfinite(x) || x == 0) return x; 80 if (!std::isfinite(x) || x == 0) return x;
73 return (x >= 0) ? std::floor(x) : std::ceil(x); 81 return (x >= 0) ? std::floor(x) : std::ceil(x);
74 } 82 }
75 83
76 84
77 int32_t DoubleToInt32(double x) { 85 int32_t DoubleToInt32(double x) {
78 int32_t i = FastD2I(x); 86 int32_t i = FastD2I(x);
79 if (FastI2D(i) == x) return i; 87 if (FastI2D(i) == x) return i;
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 SLOW_DCHECK(buffer_pos < kBufferSize); 685 SLOW_DCHECK(buffer_pos < kBufferSize);
678 buffer[buffer_pos] = '\0'; 686 buffer[buffer_pos] = '\0';
679 687
680 double converted = Strtod(Vector<const char>(buffer, buffer_pos), exponent); 688 double converted = Strtod(Vector<const char>(buffer, buffer_pos), exponent);
681 return (sign == NEGATIVE) ? -converted : converted; 689 return (sign == NEGATIVE) ? -converted : converted;
682 } 690 }
683 691
684 } } // namespace v8::internal 692 } } // namespace v8::internal
685 693
686 #endif // V8_CONVERSIONS_INL_H_ 694 #endif // V8_CONVERSIONS_INL_H_
OLDNEW
« no previous file with comments | « src/conversions.h ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698