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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/assembler.h" | 8 #include "src/assembler.h" |
9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/runtime/runtime-utils.h" | 10 #include "src/runtime/runtime-utils.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 RUNTIME_UNARY_MATH(Asin, asin) | 27 RUNTIME_UNARY_MATH(Asin, asin) |
28 RUNTIME_UNARY_MATH(Atan, atan) | 28 RUNTIME_UNARY_MATH(Atan, atan) |
29 RUNTIME_UNARY_MATH(LogRT, log) | 29 RUNTIME_UNARY_MATH(LogRT, log) |
30 #undef RUNTIME_UNARY_MATH | 30 #undef RUNTIME_UNARY_MATH |
31 | 31 |
32 | 32 |
33 RUNTIME_FUNCTION(Runtime_DoubleHi) { | 33 RUNTIME_FUNCTION(Runtime_DoubleHi) { |
34 HandleScope scope(isolate); | 34 HandleScope scope(isolate); |
35 DCHECK(args.length() == 1); | 35 DCHECK(args.length() == 1); |
36 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 36 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
37 uint64_t integer = double_to_uint64(x); | 37 uint64_t unsigned64 = double_to_uint64(x); |
38 integer = (integer >> 32) & 0xFFFFFFFFu; | 38 uint32_t unsigned32 = static_cast<uint32_t>(unsigned64 >> 32); |
39 return *isolate->factory()->NewNumber(static_cast<int32_t>(integer)); | 39 int32_t signed32 = bit_cast<int32_t, uint32_t>(unsigned32); |
| 40 return *isolate->factory()->NewNumber(signed32); |
40 } | 41 } |
41 | 42 |
42 | 43 |
43 RUNTIME_FUNCTION(Runtime_DoubleLo) { | 44 RUNTIME_FUNCTION(Runtime_DoubleLo) { |
44 HandleScope scope(isolate); | 45 HandleScope scope(isolate); |
45 DCHECK(args.length() == 1); | 46 DCHECK(args.length() == 1); |
46 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 47 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
47 return *isolate->factory()->NewNumber( | 48 uint64_t unsigned64 = double_to_uint64(x); |
48 static_cast<int32_t>(double_to_uint64(x) & 0xFFFFFFFFu)); | 49 uint32_t unsigned32 = static_cast<uint32_t>(unsigned64); |
| 50 int32_t signed32 = bit_cast<int32_t, uint32_t>(unsigned32); |
| 51 return *isolate->factory()->NewNumber(signed32); |
49 } | 52 } |
50 | 53 |
51 | 54 |
52 RUNTIME_FUNCTION(Runtime_ConstructDouble) { | 55 RUNTIME_FUNCTION(Runtime_ConstructDouble) { |
53 HandleScope scope(isolate); | 56 HandleScope scope(isolate); |
54 DCHECK(args.length() == 2); | 57 DCHECK(args.length() == 2); |
55 CONVERT_NUMBER_CHECKED(uint32_t, hi, Uint32, args[0]); | 58 CONVERT_NUMBER_CHECKED(uint32_t, hi, Uint32, args[0]); |
56 CONVERT_NUMBER_CHECKED(uint32_t, lo, Uint32, args[1]); | 59 CONVERT_NUMBER_CHECKED(uint32_t, lo, Uint32, args[1]); |
57 uint64_t result = (static_cast<uint64_t>(hi) << 32) | lo; | 60 uint64_t result = (static_cast<uint64_t>(hi) << 32) | lo; |
58 return *isolate->factory()->NewNumber(uint64_to_double(result)); | 61 return *isolate->factory()->NewNumber(uint64_to_double(result)); |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 RUNTIME_FUNCTION(RuntimeReference_IsMinusZero) { | 236 RUNTIME_FUNCTION(RuntimeReference_IsMinusZero) { |
234 SealHandleScope shs(isolate); | 237 SealHandleScope shs(isolate); |
235 DCHECK(args.length() == 1); | 238 DCHECK(args.length() == 1); |
236 CONVERT_ARG_CHECKED(Object, obj, 0); | 239 CONVERT_ARG_CHECKED(Object, obj, 0); |
237 if (!obj->IsHeapNumber()) return isolate->heap()->false_value(); | 240 if (!obj->IsHeapNumber()) return isolate->heap()->false_value(); |
238 HeapNumber* number = HeapNumber::cast(obj); | 241 HeapNumber* number = HeapNumber::cast(obj); |
239 return isolate->heap()->ToBoolean(IsMinusZero(number->value())); | 242 return isolate->heap()->ToBoolean(IsMinusZero(number->value())); |
240 } | 243 } |
241 } | 244 } |
242 } // namespace v8::internal | 245 } // namespace v8::internal |
OLD | NEW |