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

Side by Side Diff: src/code-stub-assembler.cc

Issue 2313683002: Reland of [stubs] Port KeyedLoadIC_Generic stub to TurboFan (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix Created 4 years, 3 months 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/code-stub-assembler.h ('k') | src/ic/handler-compiler.cc » ('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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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/code-stub-assembler.h" 5 #include "src/code-stub-assembler.h"
6 #include "src/code-factory.h" 6 #include "src/code-factory.h"
7 #include "src/frames-inl.h" 7 #include "src/frames-inl.h"
8 #include "src/frames.h" 8 #include "src/frames.h"
9 #include "src/ic/handler-configuration.h" 9 #include "src/ic/handler-configuration.h"
10 #include "src/ic/stub-cache.h" 10 #include "src/ic/stub-cache.h"
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 623
624 // Bitwise comparison succeeded, {lhs} and {rhs} considered equal. 624 // Bitwise comparison succeeded, {lhs} and {rhs} considered equal.
625 Goto(if_equal); 625 Goto(if_equal);
626 } 626 }
627 } 627 }
628 628
629 Bind(&if_mapnotsame); 629 Bind(&if_mapnotsame);
630 Goto(if_notequal); 630 Goto(if_notequal);
631 } 631 }
632 632
633 void CodeStubAssembler::BranchIfPrototypesHaveNoElements(
634 Node* receiver_map, Label* definitely_no_elements,
635 Label* possibly_elements) {
636 Variable var_map(this, MachineRepresentation::kTagged);
637 var_map.Bind(receiver_map);
638 Label loop_body(this, &var_map);
639 Node* empty_elements = LoadRoot(Heap::kEmptyFixedArrayRootIndex);
640 Goto(&loop_body);
641
642 Bind(&loop_body);
643 {
644 Node* map = var_map.value();
645 Node* prototype = LoadMapPrototype(map);
646 GotoIf(WordEqual(prototype, NullConstant()), definitely_no_elements);
647 Node* prototype_map = LoadMap(prototype);
648 // Pessimistically assume elements if a Proxy, Special API Object,
649 // or JSValue wrapper is found on the prototype chain. After this
650 // instance type check, it's not necessary to check for interceptors or
651 // access checks.
652 GotoIf(Int32LessThanOrEqual(LoadMapInstanceType(prototype_map),
653 Int32Constant(LAST_CUSTOM_ELEMENTS_RECEIVER)),
654 possibly_elements);
655 GotoIf(WordNotEqual(LoadElements(prototype), empty_elements),
656 possibly_elements);
657 var_map.Bind(prototype_map);
658 Goto(&loop_body);
659 }
660 }
661
633 void CodeStubAssembler::BranchIfFastJSArray(Node* object, Node* context, 662 void CodeStubAssembler::BranchIfFastJSArray(Node* object, Node* context,
634 Label* if_true, Label* if_false) { 663 Label* if_true, Label* if_false) {
635 Node* int32_zero = Int32Constant(0); 664 // Bailout if receiver is a Smi.
636 Node* int32_one = Int32Constant(1);
637
638 Node* empty_elements = LoadRoot(Heap::kEmptyFixedArrayRootIndex);
639
640 Variable last_map(this, MachineRepresentation::kTagged);
641 Label check_prototype(this);
642
643 // Bailout if Smi
644 GotoIf(WordIsSmi(object), if_false); 665 GotoIf(WordIsSmi(object), if_false);
645 666
646 Node* map = LoadMap(object); 667 Node* map = LoadMap(object);
647 last_map.Bind(map);
648 668
649 // Bailout if instance type is not JS_ARRAY_TYPE 669 // Bailout if instance type is not JS_ARRAY_TYPE.
650 GotoIf(WordNotEqual(LoadMapInstanceType(map), Int32Constant(JS_ARRAY_TYPE)), 670 GotoIf(WordNotEqual(LoadMapInstanceType(map), Int32Constant(JS_ARRAY_TYPE)),
651 if_false); 671 if_false);
652 672
653 Node* bit_field2 = LoadMapBitField2(map); 673 Node* bit_field2 = LoadMapBitField2(map);
654 Node* elements_kind = BitFieldDecode<Map::ElementsKindBits>(bit_field2); 674 Node* elements_kind = BitFieldDecode<Map::ElementsKindBits>(bit_field2);
655 675
656 // Bailout if slow receiver elements 676 // Bailout if receiver has slow elements.
657 GotoIf( 677 GotoIf(
658 Int32GreaterThan(elements_kind, Int32Constant(LAST_FAST_ELEMENTS_KIND)), 678 Int32GreaterThan(elements_kind, Int32Constant(LAST_FAST_ELEMENTS_KIND)),
659 if_false); 679 if_false);
660 680
681 // Check prototype chain if receiver does not have packed elements.
661 STATIC_ASSERT(FAST_HOLEY_SMI_ELEMENTS == (FAST_SMI_ELEMENTS | 1)); 682 STATIC_ASSERT(FAST_HOLEY_SMI_ELEMENTS == (FAST_SMI_ELEMENTS | 1));
662 STATIC_ASSERT(FAST_HOLEY_ELEMENTS == (FAST_ELEMENTS | 1)); 683 STATIC_ASSERT(FAST_HOLEY_ELEMENTS == (FAST_ELEMENTS | 1));
663 STATIC_ASSERT(FAST_HOLEY_DOUBLE_ELEMENTS == (FAST_DOUBLE_ELEMENTS | 1)); 684 STATIC_ASSERT(FAST_HOLEY_DOUBLE_ELEMENTS == (FAST_DOUBLE_ELEMENTS | 1));
664 685 Node* holey_elements = Word32And(elements_kind, Int32Constant(1));
665 // Check prototype chain if receiver does not have packed elements 686 GotoIf(Word32Equal(holey_elements, Int32Constant(0)), if_true);
666 Node* holey_elements = Word32And(elements_kind, int32_one); 687 BranchIfPrototypesHaveNoElements(map, if_true, if_false);
667 Branch(Word32Equal(holey_elements, int32_zero), if_true, &check_prototype);
668
669 Bind(&check_prototype);
670 {
671 Label loop_body(this, &last_map);
672 Goto(&loop_body);
673 Bind(&loop_body);
674 Node* current_map = last_map.value();
675 Node* proto = LoadObjectField(current_map, Map::kPrototypeOffset);
676
677 // End loop
678 GotoIf(WordEqual(proto, NullConstant()), if_true);
679
680 // ASSERT: proto->IsHeapObject()
681 Node* proto_map = LoadMap(proto);
682
683 // Bailout if a Proxy, API Object, or JSValue wrapper found in prototype
684 // Because of this bailout, it's not necessary to check for interceptors or
685 // access checks on the prototype chain.
686 GotoIf(Int32LessThanOrEqual(LoadMapInstanceType(proto_map),
687 Int32Constant(LAST_CUSTOM_ELEMENTS_RECEIVER)),
688 if_false);
689
690 // Bailout if prototype contains non-empty elements
691 GotoUnless(WordEqual(LoadElements(proto), empty_elements), if_false);
692
693 last_map.Bind(proto_map);
694 Goto(&loop_body);
695 }
696 } 688 }
697 689
698 Node* CodeStubAssembler::AllocateRawUnaligned(Node* size_in_bytes, 690 Node* CodeStubAssembler::AllocateRawUnaligned(Node* size_in_bytes,
699 AllocationFlags flags, 691 AllocationFlags flags,
700 Node* top_address, 692 Node* top_address,
701 Node* limit_address) { 693 Node* limit_address) {
702 Node* top = Load(MachineType::Pointer(), top_address); 694 Node* top = Load(MachineType::Pointer(), top_address);
703 Node* limit = Load(MachineType::Pointer(), limit_address); 695 Node* limit = Load(MachineType::Pointer(), limit_address);
704 696
705 // If there's not enough space, call the runtime. 697 // If there's not enough space, call the runtime.
(...skipping 2776 matching lines...) Expand 10 before | Expand all | Expand 10 after
3482 Bind(&key_is_smi); 3474 Bind(&key_is_smi);
3483 { 3475 {
3484 var_intptr_key.Bind(SmiUntag(key)); 3476 var_intptr_key.Bind(SmiUntag(key));
3485 Goto(&done); 3477 Goto(&done);
3486 } 3478 }
3487 3479
3488 Bind(&done); 3480 Bind(&done);
3489 return var_intptr_key.value(); 3481 return var_intptr_key.value();
3490 } 3482 }
3491 3483
3492 // |is_jsarray| should be non-zero for JSArrays. 3484 void CodeStubAssembler::EmitFastElementsBoundsCheck(Node* object,
3493 void CodeStubAssembler::EmitBoundsCheck(Node* object, Node* elements, 3485 Node* elements,
3494 Node* intptr_key, Node* is_jsarray, 3486 Node* intptr_key,
3495 Label* miss) { 3487 Node* is_jsarray_condition,
3488 Label* miss) {
3496 Variable var_length(this, MachineRepresentation::kTagged); 3489 Variable var_length(this, MachineRepresentation::kTagged);
3497 Label if_array(this), length_loaded(this, &var_length); 3490 Label if_array(this), length_loaded(this, &var_length);
3498 GotoUnless(WordEqual(is_jsarray, IntPtrConstant(0)), &if_array); 3491 GotoIf(is_jsarray_condition, &if_array);
3499 { 3492 {
3500 var_length.Bind(SmiUntag(LoadFixedArrayBaseLength(elements))); 3493 var_length.Bind(SmiUntag(LoadFixedArrayBaseLength(elements)));
3501 Goto(&length_loaded); 3494 Goto(&length_loaded);
3502 } 3495 }
3503 Bind(&if_array); 3496 Bind(&if_array);
3504 { 3497 {
3505 var_length.Bind(SmiUntag(LoadObjectField(object, JSArray::kLengthOffset))); 3498 var_length.Bind(SmiUntag(LoadObjectField(object, JSArray::kLengthOffset)));
3506 Goto(&length_loaded); 3499 Goto(&length_loaded);
3507 } 3500 }
3508 Bind(&length_loaded); 3501 Bind(&length_loaded);
3509 GotoUnless(UintPtrLessThan(intptr_key, var_length.value()), miss); 3502 GotoUnless(UintPtrLessThan(intptr_key, var_length.value()), miss);
3510 } 3503 }
3511 3504
3512 // |key| should be untagged (int32). 3505 // |key| should be untagged (int32).
3513 void CodeStubAssembler::EmitElementLoad(Node* object, Node* elements, 3506 void CodeStubAssembler::EmitElementLoad(Node* object, Node* elements,
3514 Node* elements_kind, Node* key, 3507 Node* elements_kind, Node* key,
3508 Node* is_jsarray_condition,
3515 Label* if_hole, Label* rebox_double, 3509 Label* if_hole, Label* rebox_double,
3516 Variable* var_double_value, 3510 Variable* var_double_value,
3517 Label* miss) { 3511 Label* unimplemented_elements_kind,
3512 Label* out_of_bounds, Label* miss) {
3518 Label if_typed_array(this), if_fast_packed(this), if_fast_holey(this), 3513 Label if_typed_array(this), if_fast_packed(this), if_fast_holey(this),
3519 if_fast_double(this), if_fast_holey_double(this), 3514 if_fast_double(this), if_fast_holey_double(this), if_nonfast(this),
3520 unimplemented_elements_kind(this); 3515 if_dictionary(this), unreachable(this);
3521 STATIC_ASSERT(LAST_ELEMENTS_KIND == LAST_FIXED_TYPED_ARRAY_ELEMENTS_KIND);
3522 GotoIf( 3516 GotoIf(
3523 IntPtrGreaterThanOrEqual( 3517 IntPtrGreaterThan(elements_kind, IntPtrConstant(LAST_FAST_ELEMENTS_KIND)),
3524 elements_kind, IntPtrConstant(FIRST_FIXED_TYPED_ARRAY_ELEMENTS_KIND)), 3518 &if_nonfast);
3525 &if_typed_array);
3526 3519
3520 EmitFastElementsBoundsCheck(object, elements, key, is_jsarray_condition,
3521 out_of_bounds);
3527 int32_t kinds[] = {// Handled by if_fast_packed. 3522 int32_t kinds[] = {// Handled by if_fast_packed.
3528 FAST_SMI_ELEMENTS, FAST_ELEMENTS, 3523 FAST_SMI_ELEMENTS, FAST_ELEMENTS,
3529 // Handled by if_fast_holey. 3524 // Handled by if_fast_holey.
3530 FAST_HOLEY_SMI_ELEMENTS, FAST_HOLEY_ELEMENTS, 3525 FAST_HOLEY_SMI_ELEMENTS, FAST_HOLEY_ELEMENTS,
3531 // Handled by if_fast_double. 3526 // Handled by if_fast_double.
3532 FAST_DOUBLE_ELEMENTS, 3527 FAST_DOUBLE_ELEMENTS,
3533 // Handled by if_fast_holey_double. 3528 // Handled by if_fast_holey_double.
3534 FAST_HOLEY_DOUBLE_ELEMENTS}; 3529 FAST_HOLEY_DOUBLE_ELEMENTS};
3535 Label* labels[] = {// FAST_{SMI,}_ELEMENTS 3530 Label* labels[] = {// FAST_{SMI,}_ELEMENTS
3536 &if_fast_packed, &if_fast_packed, 3531 &if_fast_packed, &if_fast_packed,
3537 // FAST_HOLEY_{SMI,}_ELEMENTS 3532 // FAST_HOLEY_{SMI,}_ELEMENTS
3538 &if_fast_holey, &if_fast_holey, 3533 &if_fast_holey, &if_fast_holey,
3539 // FAST_DOUBLE_ELEMENTS 3534 // FAST_DOUBLE_ELEMENTS
3540 &if_fast_double, 3535 &if_fast_double,
3541 // FAST_HOLEY_DOUBLE_ELEMENTS 3536 // FAST_HOLEY_DOUBLE_ELEMENTS
3542 &if_fast_holey_double}; 3537 &if_fast_holey_double};
3543 Switch(elements_kind, &unimplemented_elements_kind, kinds, labels, 3538 Switch(elements_kind, unimplemented_elements_kind, kinds, labels,
3544 arraysize(kinds)); 3539 arraysize(kinds));
3545 Bind(&unimplemented_elements_kind);
3546 {
3547 // Crash if we get here.
3548 DebugBreak();
3549 Goto(miss);
3550 }
3551 3540
3552 Bind(&if_fast_packed); 3541 Bind(&if_fast_packed);
3553 { 3542 {
3554 Comment("fast packed elements"); 3543 Comment("fast packed elements");
3555 // TODO(jkummerow): The Load*Element helpers add movsxlq instructions 3544 // TODO(jkummerow): The Load*Element helpers add movsxlq instructions
3556 // on x64 which we don't need here, because |key| is an IntPtr already. 3545 // on x64 which we don't need here, because |key| is an IntPtr already.
3557 // Do something about that. 3546 // Do something about that.
3558 Return(LoadFixedArrayElement(elements, key)); 3547 Return(LoadFixedArrayElement(elements, key));
3559 } 3548 }
3560 3549
(...skipping 25 matching lines...) Expand all
3586 Node* element_upper = LoadFixedDoubleArrayElement( 3575 Node* element_upper = LoadFixedDoubleArrayElement(
3587 elements, key, MachineType::Uint32(), kIeeeDoubleExponentWordOffset); 3576 elements, key, MachineType::Uint32(), kIeeeDoubleExponentWordOffset);
3588 GotoIf(Word32Equal(element_upper, Int32Constant(kHoleNanUpper32)), 3577 GotoIf(Word32Equal(element_upper, Int32Constant(kHoleNanUpper32)),
3589 if_hole); 3578 if_hole);
3590 } 3579 }
3591 var_double_value->Bind( 3580 var_double_value->Bind(
3592 LoadFixedDoubleArrayElement(elements, key, MachineType::Float64())); 3581 LoadFixedDoubleArrayElement(elements, key, MachineType::Float64()));
3593 Goto(rebox_double); 3582 Goto(rebox_double);
3594 } 3583 }
3595 3584
3585 Bind(&if_nonfast);
3586 {
3587 STATIC_ASSERT(LAST_ELEMENTS_KIND == LAST_FIXED_TYPED_ARRAY_ELEMENTS_KIND);
3588 GotoIf(IntPtrGreaterThanOrEqual(
3589 elements_kind,
3590 IntPtrConstant(FIRST_FIXED_TYPED_ARRAY_ELEMENTS_KIND)),
3591 &if_typed_array);
3592 GotoIf(IntPtrEqual(elements_kind, IntPtrConstant(DICTIONARY_ELEMENTS)),
3593 &if_dictionary);
3594 Goto(unimplemented_elements_kind);
3595 }
3596
3597 Bind(&if_dictionary);
3598 {
3599 Comment("dictionary elements");
3600 GotoIf(IntPtrLessThan(key, IntPtrConstant(0)), out_of_bounds);
3601 Variable var_entry(this, MachineRepresentation::kWord32);
3602 Label if_found(this);
3603 NumberDictionaryLookup<SeededNumberDictionary>(elements, key, &if_found,
3604 &var_entry, if_hole);
3605 Bind(&if_found);
3606 // Check that the value is a data property.
3607 Node* details_index = EntryToIndex<SeededNumberDictionary>(
3608 var_entry.value(), SeededNumberDictionary::kEntryDetailsIndex);
3609 Node* details = SmiToWord32(LoadFixedArrayElement(elements, details_index));
3610 Node* kind = BitFieldDecode<PropertyDetails::KindField>(details);
3611 // TODO(jkummerow): Support accessors without missing?
3612 GotoUnless(Word32Equal(kind, Int32Constant(kData)), miss);
3613 // Finally, load the value.
3614 Node* value_index = EntryToIndex<SeededNumberDictionary>(
3615 var_entry.value(), SeededNumberDictionary::kEntryValueIndex);
3616 Return(LoadFixedArrayElement(elements, value_index));
3617 }
3618
3596 Bind(&if_typed_array); 3619 Bind(&if_typed_array);
3597 { 3620 {
3598 Comment("typed elements"); 3621 Comment("typed elements");
3599 // Check if buffer has been neutered. 3622 // Check if buffer has been neutered.
3600 Node* buffer = LoadObjectField(object, JSArrayBufferView::kBufferOffset); 3623 Node* buffer = LoadObjectField(object, JSArrayBufferView::kBufferOffset);
3601 Node* bitfield = LoadObjectField(buffer, JSArrayBuffer::kBitFieldOffset, 3624 Node* bitfield = LoadObjectField(buffer, JSArrayBuffer::kBitFieldOffset,
3602 MachineType::Uint32()); 3625 MachineType::Uint32());
3603 Node* neutered_bit = 3626 Node* neutered_bit =
3604 Word32And(bitfield, Int32Constant(JSArrayBuffer::WasNeutered::kMask)); 3627 Word32And(bitfield, Int32Constant(JSArrayBuffer::WasNeutered::kMask));
3605 GotoUnless(Word32Equal(neutered_bit, Int32Constant(0)), miss); 3628 GotoUnless(Word32Equal(neutered_bit, Int32Constant(0)), miss);
3629
3630 // Bounds check.
3631 Node* length =
3632 SmiUntag(LoadObjectField(object, JSTypedArray::kLengthOffset));
3633 GotoUnless(UintPtrLessThan(key, length), out_of_bounds);
3634
3606 // Backing store = external_pointer + base_pointer. 3635 // Backing store = external_pointer + base_pointer.
3607 Node* external_pointer = 3636 Node* external_pointer =
3608 LoadObjectField(elements, FixedTypedArrayBase::kExternalPointerOffset, 3637 LoadObjectField(elements, FixedTypedArrayBase::kExternalPointerOffset,
3609 MachineType::Pointer()); 3638 MachineType::Pointer());
3610 Node* base_pointer = 3639 Node* base_pointer =
3611 LoadObjectField(elements, FixedTypedArrayBase::kBasePointerOffset); 3640 LoadObjectField(elements, FixedTypedArrayBase::kBasePointerOffset);
3612 Node* backing_store = IntPtrAdd(external_pointer, base_pointer); 3641 Node* backing_store = IntPtrAdd(external_pointer, base_pointer);
3613 3642
3614 Label uint8_elements(this), int8_elements(this), uint16_elements(this), 3643 Label uint8_elements(this), int8_elements(this), uint16_elements(this),
3615 int16_elements(this), uint32_elements(this), int32_elements(this), 3644 int16_elements(this), uint32_elements(this), int32_elements(this),
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
3704 WordAnd(handler_word, IntPtrConstant(LoadHandlerTypeBit::kMask)); 3733 WordAnd(handler_word, IntPtrConstant(LoadHandlerTypeBit::kMask));
3705 GotoUnless( 3734 GotoUnless(
3706 WordEqual(handler_type, IntPtrConstant(kLoadICHandlerForElements)), 3735 WordEqual(handler_type, IntPtrConstant(kLoadICHandlerForElements)),
3707 &property); 3736 &property);
3708 3737
3709 Comment("element_load"); 3738 Comment("element_load");
3710 Node* key = TryToIntptr(p->name, miss); 3739 Node* key = TryToIntptr(p->name, miss);
3711 Node* elements = LoadElements(p->receiver); 3740 Node* elements = LoadElements(p->receiver);
3712 Node* is_jsarray = 3741 Node* is_jsarray =
3713 WordAnd(handler_word, IntPtrConstant(KeyedLoadIsJsArray::kMask)); 3742 WordAnd(handler_word, IntPtrConstant(KeyedLoadIsJsArray::kMask));
3714 EmitBoundsCheck(p->receiver, elements, key, is_jsarray, miss); 3743 Node* is_jsarray_condition = WordNotEqual(is_jsarray, IntPtrConstant(0));
3715 Label if_hole(this); 3744 Node* elements_kind = BitFieldDecode<KeyedLoadElementsKind>(handler_word);
3745 Label if_hole(this), unimplemented_elements_kind(this);
3746 Label* out_of_bounds = miss;
3747 EmitElementLoad(p->receiver, elements, elements_kind, key,
3748 is_jsarray_condition, &if_hole, &rebox_double,
3749 &var_double_value, &unimplemented_elements_kind,
3750 out_of_bounds, miss);
3716 3751
3717 Node* elements_kind = BitFieldDecode<KeyedLoadElementsKind>(handler_word); 3752 Bind(&unimplemented_elements_kind);
3718 3753 {
3719 EmitElementLoad(p->receiver, elements, elements_kind, key, &if_hole, 3754 // Smi handlers should only be installed for supported elements kinds.
3720 &rebox_double, &var_double_value, miss); 3755 // Crash if we get here.
3756 DebugBreak();
3757 Goto(miss);
3758 }
3721 3759
3722 Bind(&if_hole); 3760 Bind(&if_hole);
3723 { 3761 {
3724 Comment("convert hole"); 3762 Comment("convert hole");
3725 Node* convert_hole = 3763 Node* convert_hole =
3726 WordAnd(handler_word, IntPtrConstant(KeyedLoadConvertHole::kMask)); 3764 WordAnd(handler_word, IntPtrConstant(KeyedLoadConvertHole::kMask));
3727 GotoIf(WordEqual(convert_hole, IntPtrConstant(0)), miss); 3765 GotoIf(WordEqual(convert_hole, IntPtrConstant(0)), miss);
3728 Node* protector_cell = LoadRoot(Heap::kArrayProtectorRootIndex); 3766 Node* protector_cell = LoadRoot(Heap::kArrayProtectorRootIndex);
3729 DCHECK(isolate()->heap()->array_protector()->IsPropertyCell()); 3767 DCHECK(isolate()->heap()->array_protector()->IsPropertyCell());
3730 GotoUnless( 3768 GotoUnless(
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
3889 &miss, 1); 3927 &miss, 1);
3890 } 3928 }
3891 Bind(&miss); 3929 Bind(&miss);
3892 { 3930 {
3893 Comment("KeyedLoadIC_miss"); 3931 Comment("KeyedLoadIC_miss");
3894 TailCallRuntime(Runtime::kKeyedLoadIC_Miss, p->context, p->receiver, 3932 TailCallRuntime(Runtime::kKeyedLoadIC_Miss, p->context, p->receiver,
3895 p->name, p->slot, p->vector); 3933 p->name, p->slot, p->vector);
3896 } 3934 }
3897 } 3935 }
3898 3936
3937 void CodeStubAssembler::KeyedLoadICGeneric(const LoadICParameters* p) {
3938 Variable var_index(this, MachineType::PointerRepresentation());
3939 Label if_index(this), if_key_is_not_number(this), if_index_name(this),
3940 if_unique_name(this), if_element_hole(this), if_oob(this), slow(this),
3941 stub_cache_miss(this), if_property_dictionary(this);
3942
3943 Node* receiver = p->receiver;
3944 GotoIf(WordIsSmi(receiver), &slow);
3945 Node* receiver_map = LoadMap(receiver);
3946 Node* instance_type = LoadMapInstanceType(receiver_map);
3947 // Receivers requiring non-standard element accesses (interceptors, access
3948 // checks, strings and string wrappers, proxies) are handled in the runtime.
3949 GotoIf(Int32LessThanOrEqual(instance_type,
3950 Int32Constant(LAST_CUSTOM_ELEMENTS_RECEIVER)),
3951 &slow);
3952
3953 // Check what kind of key we have.
3954 Node* key = p->name;
3955 var_index.Bind(TryToIntptr(key, &if_key_is_not_number));
3956 Goto(&if_index);
3957
3958 Node* hash = nullptr;
3959 // TODO(jkummerow): Unify this with CodeStubAssembler::TryToName().
3960 Bind(&if_key_is_not_number);
3961 {
3962 Node* key_map = LoadMap(key);
3963 Node* key_instance_type = LoadMapInstanceType(key_map);
3964 // Jump to the runtime if key is neither String nor Symbol.
3965 GotoIf(Int32GreaterThan(key_instance_type,
3966 Int32Constant(LAST_UNIQUE_NAME_TYPE)),
3967 &slow);
3968 // Symbols are always unique names.
3969 GotoIf(Word32Equal(key_instance_type, Int32Constant(LAST_UNIQUE_NAME_TYPE)),
3970 &if_unique_name);
3971 // |key| is a String. Check if it has a cached array index.
3972 hash = LoadNameHashField(key);
3973 Node* contains_index =
3974 Word32And(hash, Int32Constant(Name::kContainsCachedArrayIndexMask));
3975 GotoIf(Word32Equal(contains_index, Int32Constant(0)), &if_index_name);
3976 // Otherwise, jump to the runtime if the string is not internalized.
3977 STATIC_ASSERT(kNotInternalizedTag != 0);
3978 Node* not_internalized =
3979 Word32And(key_instance_type, Int32Constant(kIsNotInternalizedMask));
3980 GotoIf(Word32NotEqual(not_internalized, Int32Constant(0)), &slow);
3981 Goto(&if_unique_name);
3982 }
3983
3984 Bind(&if_index_name);
3985 {
3986 Comment("string key with cached array index");
3987 var_index.Bind(BitFieldDecode<String::ArrayIndexValueBits>(hash));
3988 Goto(&if_index);
3989 }
3990
3991 Bind(&if_index);
3992 {
3993 Comment("integer index");
3994 Node* index = var_index.value();
3995 Node* elements = LoadElements(receiver);
3996 Node* bitfield2 = LoadMapBitField2(receiver_map);
3997 Node* elements_kind = BitFieldDecode<Map::ElementsKindBits>(bitfield2);
3998 Node* is_jsarray_condition =
3999 Word32Equal(instance_type, Int32Constant(JS_ARRAY_TYPE));
4000 Variable var_double_value(this, MachineRepresentation::kFloat64);
4001 Label rebox_double(this, &var_double_value);
4002
4003 // Unimplemented elements kinds fall back to a runtime call.
4004 Label* unimplemented_elements_kind = &slow;
4005 IncrementCounter(isolate()->counters()->ic_keyed_load_generic_smi(), 1);
4006 EmitElementLoad(receiver, elements, elements_kind, index,
4007 is_jsarray_condition, &if_element_hole, &rebox_double,
4008 &var_double_value, unimplemented_elements_kind, &if_oob,
4009 &slow);
4010
4011 Bind(&rebox_double);
4012 Return(AllocateHeapNumberWithValue(var_double_value.value()));
4013 }
4014
4015 Bind(&if_oob);
4016 {
4017 Comment("out of bounds");
4018 Node* index = var_index.value();
4019 // Negative keys can't take the fast OOB path.
4020 GotoIf(IntPtrLessThan(index, IntPtrConstant(0)), &slow);
4021 // Positive OOB indices are effectively the same as hole loads.
4022 Goto(&if_element_hole);
4023 }
4024
4025 Bind(&if_element_hole);
4026 {
4027 Comment("found the hole");
4028 Label return_undefined(this);
4029 BranchIfPrototypesHaveNoElements(receiver_map, &return_undefined, &slow);
4030
4031 Bind(&return_undefined);
4032 Return(UndefinedConstant());
4033 }
4034
4035 Node* properties = nullptr;
4036 Bind(&if_unique_name);
4037 {
4038 Comment("key is unique name");
4039 // Check if the receiver has fast or slow properties.
4040 properties = LoadProperties(receiver);
4041 Node* properties_map = LoadMap(properties);
4042 GotoIf(WordEqual(properties_map, LoadRoot(Heap::kHashTableMapRootIndex)),
4043 &if_property_dictionary);
4044
4045 Comment("stub cache probe for fast property load");
4046 Variable var_handler(this, MachineRepresentation::kTagged);
4047 Label found_handler(this, &var_handler), stub_cache_miss(this);
4048 TryProbeStubCache(isolate()->load_stub_cache(), receiver, key,
4049 &found_handler, &var_handler, &stub_cache_miss);
4050 Bind(&found_handler);
4051 { HandleLoadICHandlerCase(p, var_handler.value(), &slow); }
4052
4053 Bind(&stub_cache_miss);
4054 {
4055 Comment("KeyedLoadGeneric_miss");
4056 TailCallRuntime(Runtime::kKeyedLoadIC_Miss, p->context, p->receiver,
4057 p->name, p->slot, p->vector);
4058 }
4059 }
4060
4061 Bind(&if_property_dictionary);
4062 {
4063 Comment("dictionary property load");
4064 // We checked for LAST_CUSTOM_ELEMENTS_RECEIVER before, which rules out
4065 // seeing global objects here (which would need special handling).
4066
4067 Variable var_name_index(this, MachineRepresentation::kWord32);
4068 Label dictionary_found(this, &var_name_index);
4069 NameDictionaryLookup<NameDictionary>(properties, key, &dictionary_found,
4070 &var_name_index, &slow);
4071 Bind(&dictionary_found);
4072 {
4073 Variable var_details(this, MachineRepresentation::kWord32);
4074 Variable var_value(this, MachineRepresentation::kTagged);
4075 LoadPropertyFromNameDictionary(properties, var_name_index.value(),
4076 &var_details, &var_value);
4077 Node* kind =
4078 BitFieldDecode<PropertyDetails::KindField>(var_details.value());
4079 // TODO(jkummerow): Support accessors without missing?
4080 GotoUnless(Word32Equal(kind, Int32Constant(kData)), &slow);
4081 IncrementCounter(isolate()->counters()->ic_keyed_load_generic_symbol(),
4082 1);
4083 Return(var_value.value());
4084 }
4085 }
4086
4087 Bind(&slow);
4088 {
4089 Comment("KeyedLoadGeneric_slow");
4090 IncrementCounter(isolate()->counters()->ic_keyed_load_generic_slow(), 1);
4091 // TODO(jkummerow): Should we use the GetProperty TF stub instead?
4092 TailCallRuntime(Runtime::kKeyedGetProperty, p->context, p->receiver,
4093 p->name);
4094 }
4095 }
4096
3899 void CodeStubAssembler::LoadGlobalIC(const LoadICParameters* p) { 4097 void CodeStubAssembler::LoadGlobalIC(const LoadICParameters* p) {
3900 Label try_handler(this), miss(this); 4098 Label try_handler(this), miss(this);
3901 Node* weak_cell = 4099 Node* weak_cell =
3902 LoadFixedArrayElement(p->vector, p->slot, 0, SMI_PARAMETERS); 4100 LoadFixedArrayElement(p->vector, p->slot, 0, SMI_PARAMETERS);
3903 AssertInstanceType(weak_cell, WEAK_CELL_TYPE); 4101 AssertInstanceType(weak_cell, WEAK_CELL_TYPE);
3904 4102
3905 // Load value or try handler case if the {weak_cell} is cleared. 4103 // Load value or try handler case if the {weak_cell} is cleared.
3906 Node* property_cell = LoadWeakCellValue(weak_cell, &try_handler); 4104 Node* property_cell = LoadWeakCellValue(weak_cell, &try_handler);
3907 AssertInstanceType(property_cell, PROPERTY_CELL_TYPE); 4105 AssertInstanceType(property_cell, PROPERTY_CELL_TYPE);
3908 4106
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
4014 Heap::kTheHoleValueRootIndex); 4212 Heap::kTheHoleValueRootIndex);
4015 4213
4016 // Store the WeakCell in the feedback vector. 4214 // Store the WeakCell in the feedback vector.
4017 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER, 4215 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER,
4018 CodeStubAssembler::SMI_PARAMETERS); 4216 CodeStubAssembler::SMI_PARAMETERS);
4019 return cell; 4217 return cell;
4020 } 4218 }
4021 4219
4022 } // namespace internal 4220 } // namespace internal
4023 } // namespace v8 4221 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-stub-assembler.h ('k') | src/ic/handler-compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698