OLD | NEW |
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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 | 149 |
150 // Returns the absolute value of its argument. | 150 // Returns the absolute value of its argument. |
151 template <typename T> | 151 template <typename T> |
152 T Abs(T a) { | 152 T Abs(T a) { |
153 return a < 0 ? -a : a; | 153 return a < 0 ? -a : a; |
154 } | 154 } |
155 | 155 |
156 | 156 |
157 // Floor(-0.0) == 0.0 | 157 // Floor(-0.0) == 0.0 |
158 inline double Floor(double x) { | 158 inline double Floor(double x) { |
159 #ifdef _MSC_VER | 159 #if V8_CC_MSVC |
160 if (x == 0) return x; // Fix for issue 3477. | 160 if (x == 0) return x; // Fix for issue 3477. |
161 #endif | 161 #endif |
162 return std::floor(x); | 162 return std::floor(x); |
163 } | 163 } |
164 | 164 |
165 | 165 |
166 // TODO(svenpanne) Clean up the whole power-of-2 mess. | 166 // TODO(svenpanne) Clean up the whole power-of-2 mess. |
167 inline int32_t WhichPowerOf2Abs(int32_t x) { | 167 inline int32_t WhichPowerOf2Abs(int32_t x) { |
168 return (x == kMinInt) ? 31 : WhichPowerOf2(Abs(x)); | 168 return (x == kMinInt) ? 31 : WhichPowerOf2(Abs(x)); |
169 } | 169 } |
(...skipping 1314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1484 // Takes the address of the limit variable in order to find out where | 1484 // Takes the address of the limit variable in order to find out where |
1485 // the top of stack is right now. | 1485 // the top of stack is right now. |
1486 uintptr_t limit = reinterpret_cast<uintptr_t>(&limit); | 1486 uintptr_t limit = reinterpret_cast<uintptr_t>(&limit); |
1487 return limit; | 1487 return limit; |
1488 } | 1488 } |
1489 | 1489 |
1490 } // namespace internal | 1490 } // namespace internal |
1491 } // namespace v8 | 1491 } // namespace v8 |
1492 | 1492 |
1493 #endif // V8_UTILS_H_ | 1493 #endif // V8_UTILS_H_ |
OLD | NEW |