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

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

Issue 2465253011: Fastpath some spread-call desugaring. (Closed)
Patch Set: Rename array protector valid values 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 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 // And that it has the orignal ArrayPrototype
653 Object* current_proto = spread_array->map()->prototype();
654 Object* original_proto = *isolate->initial_array_prototype();
Yang 2016/11/14 12:59:01 this unnecessarily wraps the context field into a
petermarshall 2016/11/14 13:37:19 That is much nicer, and we can do it for checking
655
656 // Check that the iterator acts as expected.
657 // If IsArrayIteratorLookupChainIntact(), then we know that the initial
658 // ArrayIterator is being used. If the map of the prototype has changed,
659 // then take the slow path.
660 if (IsFastElementsKind(array_kind) && current_proto == original_proto &&
661 isolate->IsArrayIteratorLookupChainIntact() &&
662 IteratorProtoMapUnchanged(isolate)) {
663 return *spread;
664 }
665 }
666
667 Handle<JSFunction> spread_iterable_function = isolate->spread_iterable();
668
669 Handle<Object> spreaded;
670 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
671 isolate, spreaded,
672 Execution::Call(isolate, spread_iterable_function,
673 isolate->factory()->undefined_value(), 1, &spread));
674
675 return *spreaded;
676 }
677
631 } // namespace internal 678 } // namespace internal
632 } // namespace v8 679 } // 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