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

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

Issue 2465253011: Fastpath some spread-call desugaring. (Closed)
Patch Set: Use functions for testing initial_* objects 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 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 RUNTIME_FUNCTION(Runtime_SpreadIterablePrepare) {
632 HandleScope scope(isolate);
633 DCHECK_EQ(1, args.length());
634 CONVERT_ARG_HANDLE_CHECKED(Object, spread, 0);
635
636 if (spread->IsJSArray()) {
637 // Check that the spread arg has fast elements
638 Handle<JSArray> spread_array = Handle<JSArray>::cast(spread);
639 ElementsKind array_kind = spread_array->GetElementsKind();
640
641 // And that it has the orignal ArrayPrototype
642 JSObject* array_proto = JSObject::cast(spread_array->map()->prototype());
643 Map* iterator_map = isolate->initial_array_iterator_prototype()->map();
644
645 // Check that the iterator acts as expected.
646 // If IsArrayIteratorLookupChainIntact(), then we know that the initial
647 // ArrayIterator is being used. If the map of the prototype has changed,
648 // then take the slow path.
649 if (IsFastElementsKind(array_kind) &&
Benedikt Meurer 2016/11/14 18:58:24 I don't think this is correct for holey arrays. Th
650 isolate->is_initial_array_prototype(array_proto) &&
651 isolate->IsArrayIteratorLookupChainIntact() &&
652 isolate->is_initial_array_iterator_prototype_map(iterator_map)) {
653 return *spread;
654 }
655 }
656
657 Handle<JSFunction> spread_iterable_function = isolate->spread_iterable();
658
659 Handle<Object> spreaded;
660 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
661 isolate, spreaded,
662 Execution::Call(isolate, spread_iterable_function,
663 isolate->factory()->undefined_value(), 1, &spread));
664
665 return *spreaded;
666 }
667
631 } // namespace internal 668 } // namespace internal
632 } // namespace v8 669 } // 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