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/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/conversions-inl.h" | 9 #include "src/conversions-inl.h" |
10 #include "src/elements.h" | 10 #include "src/elements.h" |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 return isolate->heap()->true_value(); | 448 return isolate->heap()->true_value(); |
449 } | 449 } |
450 if (!current->HasDictionaryElements()) continue; | 450 if (!current->HasDictionaryElements()) continue; |
451 if (current->element_dictionary()->HasComplexElements()) { | 451 if (current->element_dictionary()->HasComplexElements()) { |
452 return isolate->heap()->true_value(); | 452 return isolate->heap()->true_value(); |
453 } | 453 } |
454 } | 454 } |
455 return isolate->heap()->false_value(); | 455 return isolate->heap()->false_value(); |
456 } | 456 } |
457 | 457 |
| 458 // ES6 22.1.2.2 Array.isArray |
| 459 RUNTIME_FUNCTION(Runtime_ArrayIsArray) { |
| 460 HandleScope shs(isolate); |
| 461 DCHECK(args.length() == 1); |
| 462 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
| 463 Maybe<bool> result = Object::IsArray(object); |
| 464 MAYBE_RETURN(result, isolate->heap()->exception()); |
| 465 return isolate->heap()->ToBoolean(result.FromJust()); |
| 466 } |
458 | 467 |
459 RUNTIME_FUNCTION(Runtime_IsArray) { | 468 RUNTIME_FUNCTION(Runtime_IsArray) { |
460 SealHandleScope shs(isolate); | 469 SealHandleScope shs(isolate); |
461 DCHECK(args.length() == 1); | 470 DCHECK(args.length() == 1); |
462 CONVERT_ARG_CHECKED(Object, obj, 0); | 471 CONVERT_ARG_CHECKED(Object, obj, 0); |
463 return isolate->heap()->ToBoolean(obj->IsJSArray()); | 472 return isolate->heap()->ToBoolean(obj->IsJSArray()); |
464 } | 473 } |
465 | 474 |
466 | |
467 RUNTIME_FUNCTION(Runtime_HasCachedArrayIndex) { | 475 RUNTIME_FUNCTION(Runtime_HasCachedArrayIndex) { |
468 SealHandleScope shs(isolate); | 476 SealHandleScope shs(isolate); |
469 DCHECK(args.length() == 1); | 477 DCHECK(args.length() == 1); |
470 return isolate->heap()->false_value(); | 478 return isolate->heap()->false_value(); |
471 } | 479 } |
472 | 480 |
473 | 481 |
474 RUNTIME_FUNCTION(Runtime_GetCachedArrayIndex) { | 482 RUNTIME_FUNCTION(Runtime_GetCachedArrayIndex) { |
475 // This can never be reached, because Runtime_HasCachedArrayIndex always | 483 // This can never be reached, because Runtime_HasCachedArrayIndex always |
476 // returns false. | 484 // returns false. |
477 UNIMPLEMENTED(); | 485 UNIMPLEMENTED(); |
478 return nullptr; | 486 return nullptr; |
479 } | 487 } |
480 | 488 |
481 | 489 |
482 RUNTIME_FUNCTION(Runtime_ArraySpeciesConstructor) { | 490 RUNTIME_FUNCTION(Runtime_ArraySpeciesConstructor) { |
483 HandleScope scope(isolate); | 491 HandleScope scope(isolate); |
484 DCHECK(args.length() == 1); | 492 DCHECK(args.length() == 1); |
485 CONVERT_ARG_HANDLE_CHECKED(Object, original_array, 0); | 493 CONVERT_ARG_HANDLE_CHECKED(Object, original_array, 0); |
486 Handle<Object> constructor; | 494 Handle<Object> constructor; |
487 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 495 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
488 isolate, constructor, | 496 isolate, constructor, |
489 Object::ArraySpeciesConstructor(isolate, original_array)); | 497 Object::ArraySpeciesConstructor(isolate, original_array)); |
490 return *constructor; | 498 return *constructor; |
491 } | 499 } |
492 | 500 |
493 } // namespace internal | 501 } // namespace internal |
494 } // namespace v8 | 502 } // namespace v8 |
OLD | NEW |