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

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

Issue 1404283002: Unify ToArrayLength conversions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: addressed comments Created 5 years, 2 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/accessors.cc ('k') | src/objects.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 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 // Copy least significant 32 bits of mantissa. 63 // Copy least significant 32 bits of mantissa.
64 memcpy(&result, mantissa_ptr, sizeof(result)); 64 memcpy(&result, mantissa_ptr, sizeof(result));
65 return negative ? ~result + 1 : result; 65 return negative ? ~result + 1 : result;
66 } 66 }
67 // Large number (outside uint32 range), Infinity or NaN. 67 // Large number (outside uint32 range), Infinity or NaN.
68 return 0x80000000u; // Return integer indefinite. 68 return 0x80000000u; // Return integer indefinite.
69 } 69 }
70 70
71 71
72 inline float DoubleToFloat32(double x) { 72 inline float DoubleToFloat32(double x) {
73 // TODO(yanggou): This static_cast is implementation-defined behaviour in C++, 73 // TODO(yangguo): This static_cast is implementation-defined behaviour in C++,
74 // so we may need to do the conversion manually instead to match the spec. 74 // so we may need to do the conversion manually instead to match the spec.
75 volatile float f = static_cast<float>(x); 75 volatile float f = static_cast<float>(x);
76 return f; 76 return f;
77 } 77 }
78 78
79 79
80 inline double DoubleToInteger(double x) { 80 inline double DoubleToInteger(double x) {
81 if (std::isnan(x)) return 0; 81 if (std::isnan(x)) return 0;
82 if (!std::isfinite(x) || x == 0) return x; 82 if (!std::isfinite(x) || x == 0) return x;
83 return (x >= 0) ? std::floor(x) : std::ceil(x); 83 return (x >= 0) ? std::floor(x) : std::ceil(x);
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 buffer[buffer_pos] = '\0'; 755 buffer[buffer_pos] = '\0';
756 756
757 double converted = Strtod(Vector<const char>(buffer, buffer_pos), exponent); 757 double converted = Strtod(Vector<const char>(buffer, buffer_pos), exponent);
758 return (sign == NEGATIVE) ? -converted : converted; 758 return (sign == NEGATIVE) ? -converted : converted;
759 } 759 }
760 760
761 } // namespace internal 761 } // namespace internal
762 } // namespace v8 762 } // namespace v8
763 763
764 #endif // V8_CONVERSIONS_INL_H_ 764 #endif // V8_CONVERSIONS_INL_H_
OLDNEW
« no previous file with comments | « src/accessors.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698