OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #include "src/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
11 | 11 |
12 | 12 |
13 #ifndef _STLP_VENDOR_CSTD | 13 #ifndef _STLP_VENDOR_CSTD |
14 // STLPort doesn't import fpclassify and isless into the std namespace. | 14 // STLPort doesn't import isless into the std namespace. |
15 using std::fpclassify; | |
16 using std::isless; | 15 using std::isless; |
17 #endif | 16 #endif |
18 | 17 |
19 namespace v8 { | 18 namespace v8 { |
20 namespace internal { | 19 namespace internal { |
21 | 20 |
22 RUNTIME_FUNCTION(Runtime_NumberToRadixString) { | 21 RUNTIME_FUNCTION(Runtime_NumberToRadixString) { |
23 HandleScope scope(isolate); | 22 HandleScope scope(isolate); |
24 DCHECK(args.length() == 2); | 23 DCHECK(args.length() == 2); |
25 CONVERT_SMI_ARG_CHECKED(radix, 1); | 24 CONVERT_SMI_ARG_CHECKED(radix, 1); |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 | 225 |
227 // We rely on implementation-defined behavior below, but at least not on | 226 // We rely on implementation-defined behavior below, but at least not on |
228 // undefined behavior. | 227 // undefined behavior. |
229 CONVERT_NUMBER_CHECKED(uint32_t, x, Int32, args[0]); | 228 CONVERT_NUMBER_CHECKED(uint32_t, x, Int32, args[0]); |
230 CONVERT_NUMBER_CHECKED(uint32_t, y, Int32, args[1]); | 229 CONVERT_NUMBER_CHECKED(uint32_t, y, Int32, args[1]); |
231 int32_t product = static_cast<int32_t>(x * y); | 230 int32_t product = static_cast<int32_t>(x * y); |
232 return *isolate->factory()->NewNumberFromInt(product); | 231 return *isolate->factory()->NewNumberFromInt(product); |
233 } | 232 } |
234 | 233 |
235 | 234 |
236 RUNTIME_FUNCTION(Runtime_NumberEquals) { | |
237 SealHandleScope shs(isolate); | |
238 DCHECK(args.length() == 2); | |
239 | |
240 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | |
241 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | |
242 if (std::isnan(x)) return Smi::FromInt(NOT_EQUAL); | |
243 if (std::isnan(y)) return Smi::FromInt(NOT_EQUAL); | |
244 if (x == y) return Smi::FromInt(EQUAL); | |
245 Object* result; | |
246 if ((fpclassify(x) == FP_ZERO) && (fpclassify(y) == FP_ZERO)) { | |
247 result = Smi::FromInt(EQUAL); | |
248 } else { | |
249 result = Smi::FromInt(NOT_EQUAL); | |
250 } | |
251 return result; | |
252 } | |
253 | |
254 | |
255 RUNTIME_FUNCTION(Runtime_NumberCompare) { | 235 RUNTIME_FUNCTION(Runtime_NumberCompare) { |
256 SealHandleScope shs(isolate); | 236 SealHandleScope shs(isolate); |
257 DCHECK(args.length() == 3); | 237 DCHECK(args.length() == 3); |
258 | 238 |
259 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 239 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
260 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 240 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
261 CONVERT_ARG_HANDLE_CHECKED(Object, uncomparable_result, 2) | 241 CONVERT_ARG_HANDLE_CHECKED(Object, uncomparable_result, 2) |
262 if (std::isnan(x) || std::isnan(y)) return *uncomparable_result; | 242 if (std::isnan(x) || std::isnan(y)) return *uncomparable_result; |
263 if (x == y) return Smi::FromInt(EQUAL); | 243 if (x == y) return Smi::FromInt(EQUAL); |
264 if (isless(x, y)) return Smi::FromInt(LESS); | 244 if (isless(x, y)) return Smi::FromInt(LESS); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 CONVERT_ARG_CHECKED(Object, obj, 0); | 335 CONVERT_ARG_CHECKED(Object, obj, 0); |
356 return isolate->heap()->ToBoolean(obj->IsSmi()); | 336 return isolate->heap()->ToBoolean(obj->IsSmi()); |
357 } | 337 } |
358 | 338 |
359 | 339 |
360 RUNTIME_FUNCTION(Runtime_GetRootNaN) { | 340 RUNTIME_FUNCTION(Runtime_GetRootNaN) { |
361 SealHandleScope shs(isolate); | 341 SealHandleScope shs(isolate); |
362 DCHECK(args.length() == 0); | 342 DCHECK(args.length() == 0); |
363 return isolate->heap()->nan_value(); | 343 return isolate->heap()->nan_value(); |
364 } | 344 } |
| 345 |
365 } // namespace internal | 346 } // namespace internal |
366 } // namespace v8 | 347 } // namespace v8 |
OLD | NEW |