Chromium Code Reviews| 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 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 629 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, element_k, | 629 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, element_k, |
| 630 Object::GetProperty(&it)); | 630 Object::GetProperty(&it)); |
| 631 if (search_element->StrictEquals(*element_k)) { | 631 if (search_element->StrictEquals(*element_k)) { |
| 632 return *index_obj; | 632 return *index_obj; |
| 633 } | 633 } |
| 634 } | 634 } |
| 635 } | 635 } |
| 636 return Smi::FromInt(-1); | 636 return Smi::FromInt(-1); |
| 637 } | 637 } |
| 638 | 638 |
| 639 RUNTIME_FUNCTION(Runtime_SpreadIterablePrepare) { | |
| 640 HandleScope scope(isolate); | |
| 641 DCHECK_EQ(1, args.length()); | |
| 642 CONVERT_ARG_HANDLE_CHECKED(Object, spread, 0); | |
| 643 | |
| 644 if (spread->IsJSArray()) { | |
| 645 // Check that the spread arg has fast elements | |
| 646 Handle<JSArray> spread_array = Handle<JSArray>::cast(spread); | |
| 647 ElementsKind array_kind = spread_array->GetElementsKind(); | |
| 648 | |
| 649 // And that it has the orignal ArrayPrototype | |
| 650 JSObject* array_proto = JSObject::cast(spread_array->map()->prototype()); | |
| 651 Map* iterator_map = isolate->initial_array_iterator_prototype()->map(); | |
| 652 | |
| 653 // Check that the iterator acts as expected. | |
| 654 // If IsArrayIteratorLookupChainIntact(), then we know that the initial | |
| 655 // ArrayIterator is being used. If the map of the prototype has changed, | |
| 656 // then take the slow path. | |
| 657 | |
| 658 if (isolate->is_initial_array_prototype(array_proto) && | |
| 659 isolate->IsArrayIteratorLookupChainIntact() && | |
| 660 isolate->is_initial_array_iterator_prototype_map(iterator_map)) { | |
| 661 if (array_kind == FAST_SMI_ELEMENTS || array_kind == FAST_ELEMENTS) { | |
|
Yang
2016/11/15 13:12:02
Can we also allow FAST_DOUBLE_ELEMENTS? (test case
Benedikt Meurer
2016/11/15 13:13:46
Yes, please.
petermarshall
2016/11/15 14:24:49
OK, done
| |
| 662 return *spread; | |
| 663 } | |
| 664 if ((array_kind == FAST_HOLEY_SMI_ELEMENTS || | |
| 665 array_kind == FAST_HOLEY_ELEMENTS) && | |
|
Yang
2016/11/15 13:12:02
Same here.
| |
| 666 isolate->IsFastArrayConstructorPrototypeChainIntact()) { | |
| 667 return *spread; | |
| 668 } | |
| 669 } | |
| 670 } | |
| 671 | |
| 672 Handle<JSFunction> spread_iterable_function = isolate->spread_iterable(); | |
| 673 | |
| 674 Handle<Object> spreaded; | |
| 675 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | |
| 676 isolate, spreaded, | |
| 677 Execution::Call(isolate, spread_iterable_function, | |
| 678 isolate->factory()->undefined_value(), 1, &spread)); | |
| 679 | |
| 680 return *spreaded; | |
| 681 } | |
| 682 | |
| 639 } // namespace internal | 683 } // namespace internal |
| 640 } // namespace v8 | 684 } // namespace v8 |
| OLD | NEW |