| 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" |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 | 167 |
| 168 RUNTIME_FUNCTION(Runtime_NumberToStringSkipCache) { | 168 RUNTIME_FUNCTION(Runtime_NumberToStringSkipCache) { |
| 169 HandleScope scope(isolate); | 169 HandleScope scope(isolate); |
| 170 DCHECK(args.length() == 1); | 170 DCHECK(args.length() == 1); |
| 171 CONVERT_NUMBER_ARG_HANDLE_CHECKED(number, 0); | 171 CONVERT_NUMBER_ARG_HANDLE_CHECKED(number, 0); |
| 172 | 172 |
| 173 return *isolate->factory()->NumberToString(number, false); | 173 return *isolate->factory()->NumberToString(number, false); |
| 174 } | 174 } |
| 175 | 175 |
| 176 | 176 |
| 177 // TODO(bmeurer): Kill this runtime entry. Uses in date.js are wrong anyway. | |
| 178 RUNTIME_FUNCTION(Runtime_NumberToIntegerMapMinusZero) { | |
| 179 HandleScope scope(isolate); | |
| 180 DCHECK(args.length() == 1); | |
| 181 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); | |
| 182 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, input, Object::ToNumber(input)); | |
| 183 double double_value = DoubleToInteger(input->Number()); | |
| 184 // Map both -0 and +0 to +0. | |
| 185 if (double_value == 0) double_value = 0; | |
| 186 | |
| 187 return *isolate->factory()->NewNumber(double_value); | |
| 188 } | |
| 189 | |
| 190 | |
| 191 // Converts a Number to a Smi, if possible. Returns NaN if the number is not | 177 // Converts a Number to a Smi, if possible. Returns NaN if the number is not |
| 192 // a small integer. | 178 // a small integer. |
| 193 RUNTIME_FUNCTION(Runtime_NumberToSmi) { | 179 RUNTIME_FUNCTION(Runtime_NumberToSmi) { |
| 194 SealHandleScope shs(isolate); | 180 SealHandleScope shs(isolate); |
| 195 DCHECK(args.length() == 1); | 181 DCHECK(args.length() == 1); |
| 196 CONVERT_ARG_CHECKED(Object, obj, 0); | 182 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 197 if (obj->IsSmi()) { | 183 if (obj->IsSmi()) { |
| 198 return obj; | 184 return obj; |
| 199 } | 185 } |
| 200 if (obj->IsHeapNumber()) { | 186 if (obj->IsHeapNumber()) { |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 | 301 |
| 316 RUNTIME_FUNCTION(Runtime_GetHoleNaNLower) { | 302 RUNTIME_FUNCTION(Runtime_GetHoleNaNLower) { |
| 317 HandleScope scope(isolate); | 303 HandleScope scope(isolate); |
| 318 DCHECK(args.length() == 0); | 304 DCHECK(args.length() == 0); |
| 319 return *isolate->factory()->NewNumberFromUint(kHoleNanLower32); | 305 return *isolate->factory()->NewNumberFromUint(kHoleNanLower32); |
| 320 } | 306 } |
| 321 | 307 |
| 322 | 308 |
| 323 } // namespace internal | 309 } // namespace internal |
| 324 } // namespace v8 | 310 } // namespace v8 |
| OLD | NEW |