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 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, element_k, | 621 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, element_k, |
622 Object::GetProperty(&it)); | 622 Object::GetProperty(&it)); |
623 if (search_element->StrictEquals(*element_k)) { | 623 if (search_element->StrictEquals(*element_k)) { |
624 return *index_obj; | 624 return *index_obj; |
625 } | 625 } |
626 } | 626 } |
627 } | 627 } |
628 return Smi::FromInt(-1); | 628 return Smi::FromInt(-1); |
629 } | 629 } |
630 | 630 |
| 631 namespace { |
| 632 |
| 633 bool IteratorProtoMapUnchanged(Isolate* isolate) { |
| 634 Map* current_map = isolate->initial_array_iterator_prototype()->map(); |
| 635 Map* original_map = *isolate->initial_array_iterator_prototype_map(); |
| 636 |
| 637 return current_map == original_map; |
| 638 } |
| 639 |
| 640 } // namepsace |
| 641 |
| 642 RUNTIME_FUNCTION(Runtime_SpreadIterablePrepare) { |
| 643 HandleScope scope(isolate); |
| 644 DCHECK_EQ(1, args.length()); |
| 645 CONVERT_ARG_HANDLE_CHECKED(Object, spread, 0); |
| 646 |
| 647 if (spread->IsJSArray()) { |
| 648 // Check that the spread arg has fast elements |
| 649 Handle<JSArray> spread_array = Handle<JSArray>::cast(spread); |
| 650 ElementsKind array_kind = spread_array->GetElementsKind(); |
| 651 |
| 652 // Check that the iterator acts as expected. |
| 653 // If IsArrayIteratorLookupChainIntact(), then we know that the initial |
| 654 // ArrayIterator is being used. If the map of the prototype has changed, |
| 655 // then take the slow path. |
| 656 if (IsFastElementsKind(array_kind) && |
| 657 isolate->IsArrayIteratorLookupChainIntact() && |
| 658 IteratorProtoMapUnchanged(isolate)) { |
| 659 return *spread; |
| 660 } |
| 661 } |
| 662 |
| 663 Handle<JSFunction> spread_iterable_function = isolate->spread_iterable(); |
| 664 |
| 665 Handle<Object> spreaded; |
| 666 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 667 isolate, spreaded, |
| 668 Execution::Call(isolate, spread_iterable_function, |
| 669 isolate->factory()->undefined_value(), 1, &spread)); |
| 670 |
| 671 return *spreaded; |
| 672 } |
| 673 |
631 } // namespace internal | 674 } // namespace internal |
632 } // namespace v8 | 675 } // namespace v8 |
OLD | NEW |