| 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 | |
| 13 #ifndef _STLP_VENDOR_CSTD | |
| 14 // STLPort doesn't import isless into the std namespace. | |
| 15 using std::isless; | |
| 16 #endif | |
| 17 | |
| 18 namespace v8 { | 12 namespace v8 { |
| 19 namespace internal { | 13 namespace internal { |
| 20 | 14 |
| 21 RUNTIME_FUNCTION(Runtime_NumberToRadixString) { | 15 RUNTIME_FUNCTION(Runtime_NumberToRadixString) { |
| 22 HandleScope scope(isolate); | 16 HandleScope scope(isolate); |
| 23 DCHECK(args.length() == 2); | 17 DCHECK(args.length() == 2); |
| 24 CONVERT_SMI_ARG_CHECKED(radix, 1); | 18 CONVERT_SMI_ARG_CHECKED(radix, 1); |
| 25 RUNTIME_ASSERT(2 <= radix && radix <= 36); | 19 RUNTIME_ASSERT(2 <= radix && radix <= 36); |
| 26 | 20 |
| 27 // Fast case where the result is a one character string. | 21 // Fast case where the result is a one character string. |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 | 219 |
| 226 // We rely on implementation-defined behavior below, but at least not on | 220 // We rely on implementation-defined behavior below, but at least not on |
| 227 // undefined behavior. | 221 // undefined behavior. |
| 228 CONVERT_NUMBER_CHECKED(uint32_t, x, Int32, args[0]); | 222 CONVERT_NUMBER_CHECKED(uint32_t, x, Int32, args[0]); |
| 229 CONVERT_NUMBER_CHECKED(uint32_t, y, Int32, args[1]); | 223 CONVERT_NUMBER_CHECKED(uint32_t, y, Int32, args[1]); |
| 230 int32_t product = static_cast<int32_t>(x * y); | 224 int32_t product = static_cast<int32_t>(x * y); |
| 231 return *isolate->factory()->NewNumberFromInt(product); | 225 return *isolate->factory()->NewNumberFromInt(product); |
| 232 } | 226 } |
| 233 | 227 |
| 234 | 228 |
| 235 RUNTIME_FUNCTION(Runtime_NumberCompare) { | |
| 236 SealHandleScope shs(isolate); | |
| 237 DCHECK(args.length() == 3); | |
| 238 | |
| 239 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | |
| 240 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | |
| 241 CONVERT_ARG_HANDLE_CHECKED(Object, uncomparable_result, 2) | |
| 242 if (std::isnan(x) || std::isnan(y)) return *uncomparable_result; | |
| 243 if (x == y) return Smi::FromInt(EQUAL); | |
| 244 if (isless(x, y)) return Smi::FromInt(LESS); | |
| 245 return Smi::FromInt(GREATER); | |
| 246 } | |
| 247 | |
| 248 | |
| 249 // Compare two Smis as if they were converted to strings and then | 229 // Compare two Smis as if they were converted to strings and then |
| 250 // compared lexicographically. | 230 // compared lexicographically. |
| 251 RUNTIME_FUNCTION(Runtime_SmiLexicographicCompare) { | 231 RUNTIME_FUNCTION(Runtime_SmiLexicographicCompare) { |
| 252 SealHandleScope shs(isolate); | 232 SealHandleScope shs(isolate); |
| 253 DCHECK(args.length() == 2); | 233 DCHECK(args.length() == 2); |
| 254 CONVERT_SMI_ARG_CHECKED(x_value, 0); | 234 CONVERT_SMI_ARG_CHECKED(x_value, 0); |
| 255 CONVERT_SMI_ARG_CHECKED(y_value, 1); | 235 CONVERT_SMI_ARG_CHECKED(y_value, 1); |
| 256 | 236 |
| 257 // If the integers are equal so are the string representations. | 237 // If the integers are equal so are the string representations. |
| 258 if (x_value == y_value) return Smi::FromInt(EQUAL); | 238 if (x_value == y_value) return Smi::FromInt(EQUAL); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 | 318 |
| 339 | 319 |
| 340 RUNTIME_FUNCTION(Runtime_GetRootNaN) { | 320 RUNTIME_FUNCTION(Runtime_GetRootNaN) { |
| 341 SealHandleScope shs(isolate); | 321 SealHandleScope shs(isolate); |
| 342 DCHECK(args.length() == 0); | 322 DCHECK(args.length() == 0); |
| 343 return isolate->heap()->nan_value(); | 323 return isolate->heap()->nan_value(); |
| 344 } | 324 } |
| 345 | 325 |
| 346 } // namespace internal | 326 } // namespace internal |
| 347 } // namespace v8 | 327 } // namespace v8 |
| OLD | NEW |