Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(208)

Side by Side Diff: src/runtime/runtime-array.cc

Issue 2465253011: Fastpath some spread-call desugaring. (Closed)
Patch Set: Handles double arrays too Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/runtime/runtime.h ('k') | test/cctest/interpreter/bytecode_expectations/CallRuntime.golden » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 (IsFastPackedElementsKind(array_kind)) {
662 return *spread;
663 }
664 if (IsFastHoleyElementsKind(array_kind) &&
665 isolate->IsFastArrayConstructorPrototypeChainIntact()) {
666 return *spread;
667 }
668 }
669 }
670
671 Handle<JSFunction> spread_iterable_function = isolate->spread_iterable();
672
673 Handle<Object> spreaded;
674 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
675 isolate, spreaded,
676 Execution::Call(isolate, spread_iterable_function,
677 isolate->factory()->undefined_value(), 1, &spread));
678
679 return *spreaded;
680 }
681
639 } // namespace internal 682 } // namespace internal
640 } // namespace v8 683 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | test/cctest/interpreter/bytecode_expectations/CallRuntime.golden » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698