OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 #include "src/code-stub-assembler.h" | 4 #include "src/code-stub-assembler.h" |
5 #include "src/code-factory.h" | 5 #include "src/code-factory.h" |
6 #include "src/frames-inl.h" | 6 #include "src/frames-inl.h" |
7 #include "src/frames.h" | 7 #include "src/frames.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
(...skipping 4042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4053 { | 4053 { |
4054 var_result.Bind(NonNumberToNumber(context, input)); | 4054 var_result.Bind(NonNumberToNumber(context, input)); |
4055 Goto(&end); | 4055 Goto(&end); |
4056 } | 4056 } |
4057 } | 4057 } |
4058 | 4058 |
4059 BIND(&end); | 4059 BIND(&end); |
4060 return var_result.value(); | 4060 return var_result.value(); |
4061 } | 4061 } |
4062 | 4062 |
| 4063 // ES#sec-touint32 |
4063 Node* CodeStubAssembler::ToUint32(Node* context, Node* input) { | 4064 Node* CodeStubAssembler::ToUint32(Node* context, Node* input) { |
4064 Node* const float_zero = Float64Constant(0.0); | 4065 Node* const float_zero = Float64Constant(0.0); |
4065 Node* const float_two_32 = Float64Constant(static_cast<double>(1ULL << 32)); | 4066 Node* const float_two_32 = Float64Constant(static_cast<double>(1ULL << 32)); |
4066 | 4067 |
4067 Label out(this); | 4068 Label out(this); |
4068 | 4069 |
4069 Variable var_result(this, MachineRepresentation::kTagged, input); | 4070 Variable var_result(this, MachineRepresentation::kTagged, input); |
4070 | 4071 |
4071 // Early exit for positive smis. | 4072 // Early exit for positive smis. |
4072 { | 4073 { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4130 | 4131 |
4131 { | 4132 { |
4132 // -Infinity. | 4133 // -Infinity. |
4133 Label next(this); | 4134 Label next(this); |
4134 Node* const negative_infinity = | 4135 Node* const negative_infinity = |
4135 Float64Constant(-1.0 * std::numeric_limits<double>::infinity()); | 4136 Float64Constant(-1.0 * std::numeric_limits<double>::infinity()); |
4136 Branch(Float64Equal(value, negative_infinity), &return_zero, &next); | 4137 Branch(Float64Equal(value, negative_infinity), &return_zero, &next); |
4137 BIND(&next); | 4138 BIND(&next); |
4138 } | 4139 } |
4139 | 4140 |
4140 // Return floor({input}) mod 2^32 (assuming mod semantics that always return | 4141 // * Let int be the mathematical value that is the same sign as number and |
4141 // positive results). | 4142 // whose magnitude is floor(abs(number)). |
| 4143 // * Let int32bit be int modulo 2^32. |
| 4144 // * Return int32bit. |
4142 { | 4145 { |
4143 Node* x = Float64Floor(value); | 4146 Node* x = Float64Trunc(value); |
4144 x = Float64Mod(x, float_two_32); | 4147 x = Float64Mod(x, float_two_32); |
4145 x = Float64Add(x, float_two_32); | 4148 x = Float64Add(x, float_two_32); |
4146 x = Float64Mod(x, float_two_32); | 4149 x = Float64Mod(x, float_two_32); |
4147 | 4150 |
4148 Node* const result = ChangeFloat64ToTagged(x); | 4151 Node* const result = ChangeFloat64ToTagged(x); |
4149 var_result.Bind(result); | 4152 var_result.Bind(result); |
4150 Goto(&out); | 4153 Goto(&out); |
4151 } | 4154 } |
4152 | 4155 |
4153 BIND(&return_zero); | 4156 BIND(&return_zero); |
(...skipping 4317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8471 formatted.c_str(), TENURED); | 8474 formatted.c_str(), TENURED); |
8472 CallRuntime(Runtime::kGlobalPrint, NoContextConstant(), | 8475 CallRuntime(Runtime::kGlobalPrint, NoContextConstant(), |
8473 HeapConstant(string)); | 8476 HeapConstant(string)); |
8474 } | 8477 } |
8475 CallRuntime(Runtime::kDebugPrint, NoContextConstant(), tagged_value); | 8478 CallRuntime(Runtime::kDebugPrint, NoContextConstant(), tagged_value); |
8476 #endif | 8479 #endif |
8477 } | 8480 } |
8478 | 8481 |
8479 } // namespace internal | 8482 } // namespace internal |
8480 } // namespace v8 | 8483 } // namespace v8 |
OLD | NEW |