OLD | NEW |
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 3557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3568 Word32And(bitfield, Int32Constant(JSArrayBuffer::WasNeutered::kMask)); | 3568 Word32And(bitfield, Int32Constant(JSArrayBuffer::WasNeutered::kMask)); |
3569 GotoUnless(Word32Equal(neutered_bit, Int32Constant(0)), miss); | 3569 GotoUnless(Word32Equal(neutered_bit, Int32Constant(0)), miss); |
3570 // Backing store = external_pointer + base_pointer. | 3570 // Backing store = external_pointer + base_pointer. |
3571 Node* external_pointer = | 3571 Node* external_pointer = |
3572 LoadObjectField(elements, FixedTypedArrayBase::kExternalPointerOffset, | 3572 LoadObjectField(elements, FixedTypedArrayBase::kExternalPointerOffset, |
3573 MachineType::Pointer()); | 3573 MachineType::Pointer()); |
3574 Node* base_pointer = | 3574 Node* base_pointer = |
3575 LoadObjectField(elements, FixedTypedArrayBase::kBasePointerOffset); | 3575 LoadObjectField(elements, FixedTypedArrayBase::kBasePointerOffset); |
3576 Node* backing_store = IntPtrAdd(external_pointer, base_pointer); | 3576 Node* backing_store = IntPtrAdd(external_pointer, base_pointer); |
3577 | 3577 |
| 3578 Label uint8_elements(this), int8_elements(this), uint16_elements(this), |
| 3579 int16_elements(this), uint32_elements(this), int32_elements(this), |
| 3580 float32_elements(this), float64_elements(this); |
| 3581 Label* elements_kind_labels[] = { |
| 3582 &uint8_elements, &uint8_elements, &int8_elements, |
| 3583 &uint16_elements, &int16_elements, &uint32_elements, |
| 3584 &int32_elements, &float32_elements, &float64_elements}; |
| 3585 int32_t elements_kinds[] = { |
| 3586 UINT8_ELEMENTS, UINT8_CLAMPED_ELEMENTS, INT8_ELEMENTS, |
| 3587 UINT16_ELEMENTS, INT16_ELEMENTS, UINT32_ELEMENTS, |
| 3588 INT32_ELEMENTS, FLOAT32_ELEMENTS, FLOAT64_ELEMENTS}; |
3578 const int kTypedElementsKindCount = LAST_FIXED_TYPED_ARRAY_ELEMENTS_KIND - | 3589 const int kTypedElementsKindCount = LAST_FIXED_TYPED_ARRAY_ELEMENTS_KIND - |
3579 FIRST_FIXED_TYPED_ARRAY_ELEMENTS_KIND + | 3590 FIRST_FIXED_TYPED_ARRAY_ELEMENTS_KIND + |
3580 1; | 3591 1; |
3581 Label* elements_kind_labels[kTypedElementsKindCount]; | 3592 DCHECK_EQ(kTypedElementsKindCount, arraysize(elements_kinds)); |
3582 int32_t elements_kinds[kTypedElementsKindCount]; | 3593 DCHECK_EQ(kTypedElementsKindCount, arraysize(elements_kind_labels)); |
3583 for (int i = 0; i < kTypedElementsKindCount; i++) { | |
3584 elements_kinds[i] = i + FIRST_FIXED_TYPED_ARRAY_ELEMENTS_KIND; | |
3585 elements_kind_labels[i] = new Label(this); | |
3586 } | |
3587 Switch(elements_kind, miss, elements_kinds, elements_kind_labels, | 3594 Switch(elements_kind, miss, elements_kinds, elements_kind_labels, |
3588 static_cast<size_t>(kTypedElementsKindCount)); | 3595 static_cast<size_t>(kTypedElementsKindCount)); |
3589 | 3596 Bind(&uint8_elements); |
3590 for (int i = 0; i < kTypedElementsKindCount; i++) { | 3597 { |
3591 ElementsKind kind = static_cast<ElementsKind>(elements_kinds[i]); | 3598 Comment("UINT8_ELEMENTS"); // Handles UINT8_CLAMPED_ELEMENTS too. |
3592 Bind(elements_kind_labels[i]); | 3599 Return(SmiTag(Load(MachineType::Uint8(), backing_store, key))); |
3593 Comment(ElementsKindToString(kind)); | 3600 } |
3594 switch (kind) { | 3601 Bind(&int8_elements); |
3595 case UINT8_ELEMENTS: | 3602 { |
3596 case UINT8_CLAMPED_ELEMENTS: | 3603 Comment("INT8_ELEMENTS"); |
3597 Return(SmiTag(Load(MachineType::Uint8(), backing_store, key))); | 3604 Return(SmiTag(Load(MachineType::Int8(), backing_store, key))); |
3598 break; | 3605 } |
3599 case INT8_ELEMENTS: | 3606 Bind(&uint16_elements); |
3600 Return(SmiTag(Load(MachineType::Int8(), backing_store, key))); | 3607 { |
3601 break; | 3608 Comment("UINT16_ELEMENTS"); |
3602 case UINT16_ELEMENTS: { | 3609 Node* index = WordShl(key, IntPtrConstant(1)); |
3603 Node* index = WordShl(key, IntPtrConstant(1)); | 3610 Return(SmiTag(Load(MachineType::Uint16(), backing_store, index))); |
3604 Return(SmiTag(Load(MachineType::Uint16(), backing_store, index))); | 3611 } |
3605 break; | 3612 Bind(&int16_elements); |
3606 } | 3613 { |
3607 case INT16_ELEMENTS: { | 3614 Comment("INT16_ELEMENTS"); |
3608 Node* index = WordShl(key, IntPtrConstant(1)); | 3615 Node* index = WordShl(key, IntPtrConstant(1)); |
3609 Return(SmiTag(Load(MachineType::Int16(), backing_store, index))); | 3616 Return(SmiTag(Load(MachineType::Int16(), backing_store, index))); |
3610 break; | 3617 } |
3611 } | 3618 Bind(&uint32_elements); |
3612 case UINT32_ELEMENTS: { | 3619 { |
3613 Node* index = WordShl(key, IntPtrConstant(2)); | 3620 Comment("UINT32_ELEMENTS"); |
3614 Node* element = Load(MachineType::Uint32(), backing_store, index); | 3621 Node* index = WordShl(key, IntPtrConstant(2)); |
3615 Return(ChangeUint32ToTagged(element)); | 3622 Node* element = Load(MachineType::Uint32(), backing_store, index); |
3616 break; | 3623 Return(ChangeUint32ToTagged(element)); |
3617 } | 3624 } |
3618 case INT32_ELEMENTS: { | 3625 Bind(&int32_elements); |
3619 Node* index = WordShl(key, IntPtrConstant(2)); | 3626 { |
3620 Node* element = Load(MachineType::Int32(), backing_store, index); | 3627 Comment("INT32_ELEMENTS"); |
3621 Return(ChangeInt32ToTagged(element)); | 3628 Node* index = WordShl(key, IntPtrConstant(2)); |
3622 break; | 3629 Node* element = Load(MachineType::Int32(), backing_store, index); |
3623 } | 3630 Return(ChangeInt32ToTagged(element)); |
3624 case FLOAT32_ELEMENTS: { | 3631 } |
3625 Node* index = WordShl(key, IntPtrConstant(2)); | 3632 Bind(&float32_elements); |
3626 Node* element = Load(MachineType::Float32(), backing_store, index); | 3633 { |
3627 var_double_value->Bind(ChangeFloat32ToFloat64(element)); | 3634 Comment("FLOAT32_ELEMENTS"); |
3628 Goto(rebox_double); | 3635 Node* index = WordShl(key, IntPtrConstant(2)); |
3629 break; | 3636 Node* element = Load(MachineType::Float32(), backing_store, index); |
3630 } | 3637 var_double_value->Bind(ChangeFloat32ToFloat64(element)); |
3631 case FLOAT64_ELEMENTS: { | 3638 Goto(rebox_double); |
3632 Node* index = WordShl(key, IntPtrConstant(3)); | 3639 } |
3633 Node* element = Load(MachineType::Float64(), backing_store, index); | 3640 Bind(&float64_elements); |
3634 var_double_value->Bind(element); | 3641 { |
3635 Goto(rebox_double); | 3642 Comment("FLOAT64_ELEMENTS"); |
3636 break; | 3643 Node* index = WordShl(key, IntPtrConstant(3)); |
3637 } | 3644 Node* element = Load(MachineType::Float64(), backing_store, index); |
3638 default: | 3645 var_double_value->Bind(element); |
3639 UNREACHABLE(); | 3646 Goto(rebox_double); |
3640 } | |
3641 // Don't forget to clean up. | |
3642 delete elements_kind_labels[i]; | |
3643 } | 3647 } |
3644 } | 3648 } |
3645 } | 3649 } |
3646 | 3650 |
3647 void CodeStubAssembler::HandleLoadICHandlerCase( | 3651 void CodeStubAssembler::HandleLoadICHandlerCase( |
3648 const LoadICParameters* p, Node* handler, Label* miss, | 3652 const LoadICParameters* p, Node* handler, Label* miss, |
3649 ElementSupport support_elements) { | 3653 ElementSupport support_elements) { |
3650 Comment("have_handler"); | 3654 Comment("have_handler"); |
3651 Label call_handler(this); | 3655 Label call_handler(this); |
3652 GotoUnless(WordIsSmi(handler), &call_handler); | 3656 GotoUnless(WordIsSmi(handler), &call_handler); |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3974 Heap::kTheHoleValueRootIndex); | 3978 Heap::kTheHoleValueRootIndex); |
3975 | 3979 |
3976 // Store the WeakCell in the feedback vector. | 3980 // Store the WeakCell in the feedback vector. |
3977 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER, | 3981 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER, |
3978 CodeStubAssembler::SMI_PARAMETERS); | 3982 CodeStubAssembler::SMI_PARAMETERS); |
3979 return cell; | 3983 return cell; |
3980 } | 3984 } |
3981 | 3985 |
3982 } // namespace internal | 3986 } // namespace internal |
3983 } // namespace v8 | 3987 } // namespace v8 |
OLD | NEW |