Chromium Code Reviews| Index: src/code-stub-assembler.cc |
| diff --git a/src/code-stub-assembler.cc b/src/code-stub-assembler.cc |
| index d84c363a4b80c5383118f7379babfaa3e8373a52..74f07212e1c208ea1e1367a784870e5173257693 100644 |
| --- a/src/code-stub-assembler.cc |
| +++ b/src/code-stub-assembler.cc |
| @@ -4418,6 +4418,64 @@ template Node* CodeStubAssembler::EntryToIndex<GlobalDictionary>(Node*, int); |
| template Node* CodeStubAssembler::EntryToIndex<SeededNumberDictionary>(Node*, |
| int); |
| +template <class ContainerType> |
| +Node* CodeStubAssembler::LoadDetailsForKeyIndex(Node* container, |
|
Igor Sheludko
2017/02/09 09:14:09
WDYT about s/For/By/ here and below?
I'd just inl
Jakob Kummerow
2017/02/09 22:21:28
Done.
|
| + Node* key_index) { |
| + const int kKeyToDetailsOffset = |
| + (ContainerType::kEntryDetailsIndex - ContainerType::kEntryKeyIndex) * |
| + kPointerSize; |
| + return LoadAndUntagToWord32FixedArrayElement(container, key_index, |
| + kKeyToDetailsOffset); |
| +} |
| + |
| +template Node* CodeStubAssembler::LoadDetailsForKeyIndex<DescriptorArray>( |
| + Node*, Node*); |
| +template Node* CodeStubAssembler::LoadDetailsForKeyIndex<NameDictionary>(Node*, |
| + Node*); |
| +template Node* |
| +CodeStubAssembler::LoadDetailsForKeyIndex<SeededNumberDictionary>(Node*, Node*); |
| + |
| +template <class ContainerType> |
| +Node* CodeStubAssembler::LoadValueForKeyIndex(Node* container, |
| + Node* key_index) { |
| + const int kKeyToValueOffset = |
| + (ContainerType::kEntryValueIndex - ContainerType::kEntryKeyIndex) * |
| + kPointerSize; |
| + return LoadFixedArrayElement(container, key_index, kKeyToValueOffset); |
| +} |
| + |
| +template Node* CodeStubAssembler::LoadValueForKeyIndex<GlobalDictionary>(Node*, |
| + Node*); |
| +template Node* CodeStubAssembler::LoadValueForKeyIndex<NameDictionary>(Node*, |
| + Node*); |
| +template Node* CodeStubAssembler::LoadValueForKeyIndex<SeededNumberDictionary>( |
| + Node*, Node*); |
| + |
| +template <class ContainerType> |
| +void CodeStubAssembler::StoreDetailsForKeyIndex(Node* container, |
| + Node* key_index, |
| + Node* details) { |
| + const int kKeyToDetailsOffset = |
| + (ContainerType::kEntryDetailsIndex - ContainerType::kEntryKeyIndex) * |
| + kPointerSize; |
| + StoreFixedArrayElement(container, key_index, details, SKIP_WRITE_BARRIER, |
| + kKeyToDetailsOffset); |
| +} |
| + |
| +template <class ContainerType> |
| +void CodeStubAssembler::StoreValueForKeyIndex(Node* container, Node* key_index, |
| + Node* value) { |
| + const int kKeyToValueOffset = |
| + (ContainerType::kEntryValueIndex - ContainerType::kEntryKeyIndex) * |
| + kPointerSize; |
| + StoreFixedArrayElement(container, key_index, value, UPDATE_WRITE_BARRIER, |
| + kKeyToValueOffset); |
| +} |
| + |
| +template void CodeStubAssembler::StoreValueForKeyIndex<NameDictionary>(Node*, |
| + Node*, |
| + Node*); |
| + |
| Node* CodeStubAssembler::HashTableComputeCapacity(Node* at_least_space_for) { |
| Node* capacity = IntPtrRoundUpToPowerOfTwo32( |
| WordShl(at_least_space_for, IntPtrConstant(1))); |
| @@ -4658,11 +4716,7 @@ void CodeStubAssembler::InsertEntry<NameDictionary>(Node* dictionary, |
| Node* enum_index) { |
| // Store name and value. |
| StoreFixedArrayElement(dictionary, index, name); |
| - const int kNameToValueOffset = |
| - (NameDictionary::kEntryValueIndex - NameDictionary::kEntryKeyIndex) * |
| - kPointerSize; |
| - StoreFixedArrayElement(dictionary, index, value, UPDATE_WRITE_BARRIER, |
| - kNameToValueOffset); |
| + StoreValueForKeyIndex<NameDictionary>(dictionary, index, value); |
| // Prepare details of the new property. |
| const int kInitialIndex = 0; |
| @@ -4686,11 +4740,8 @@ void CodeStubAssembler::InsertEntry<NameDictionary>(Node* dictionary, |
| Bind(¬_private); |
| // Finally, store the details. |
| - const int kNameToDetailsOffset = |
| - (NameDictionary::kEntryDetailsIndex - NameDictionary::kEntryKeyIndex) * |
| - kPointerSize; |
| - StoreFixedArrayElement(dictionary, index, var_details.value(), |
| - SKIP_WRITE_BARRIER, kNameToDetailsOffset); |
| + StoreDetailsForKeyIndex<NameDictionary>(dictionary, index, |
| + var_details.value()); |
| } |
| template <> |
| @@ -4749,7 +4800,7 @@ void CodeStubAssembler::DescriptorLookupLinear(Node* unique_name, |
| Variable* var_name_index, |
| Label* if_not_found) { |
| Node* first_inclusive = IntPtrConstant(DescriptorArray::ToKeyIndex(0)); |
| - Node* factor = IntPtrConstant(DescriptorArray::kDescriptorSize); |
| + Node* factor = IntPtrConstant(DescriptorArray::kEntrySize); |
| Node* last_exclusive = IntPtrAdd(first_inclusive, IntPtrMul(nof, factor)); |
| BuildFastLoop(last_exclusive, first_inclusive, |
| @@ -4760,7 +4811,7 @@ void CodeStubAssembler::DescriptorLookupLinear(Node* unique_name, |
| var_name_index->Bind(name_index); |
| GotoIf(WordEqual(candidate_name, unique_name), if_found); |
| }, |
| - -DescriptorArray::kDescriptorSize, INTPTR_PARAMETERS, |
| + -DescriptorArray::kEntrySize, INTPTR_PARAMETERS, |
| IndexAdvanceMode::kPre); |
| Goto(if_not_found); |
| } |
| @@ -4868,15 +4919,8 @@ void CodeStubAssembler::LoadPropertyFromFastObject(Node* object, Node* map, |
| DCHECK_EQ(MachineRepresentation::kTagged, var_value->rep()); |
| Comment("[ LoadPropertyFromFastObject"); |
| - const int name_to_details_offset = |
| - (DescriptorArray::kDescriptorDetails - DescriptorArray::kDescriptorKey) * |
| - kPointerSize; |
| - const int name_to_value_offset = |
| - (DescriptorArray::kDescriptorValue - DescriptorArray::kDescriptorKey) * |
| - kPointerSize; |
| - |
| - Node* details = LoadAndUntagToWord32FixedArrayElement(descriptors, name_index, |
| - name_to_details_offset); |
| + Node* details = |
| + LoadDetailsForKeyIndex<DescriptorArray>(descriptors, name_index); |
| var_details->Bind(details); |
| Node* location = DecodeWord32<PropertyDetails::LocationField>(details); |
| @@ -4959,9 +5003,8 @@ void CodeStubAssembler::LoadPropertyFromFastObject(Node* object, Node* map, |
| } |
| Bind(&if_in_descriptor); |
| { |
| - Node* value = |
| - LoadFixedArrayElement(descriptors, name_index, name_to_value_offset); |
| - var_value->Bind(value); |
| + var_value->Bind( |
| + LoadValueForKeyIndex<DescriptorArray>(descriptors, name_index)); |
| Goto(&done); |
| } |
| Bind(&done); |
| @@ -4975,19 +5018,10 @@ void CodeStubAssembler::LoadPropertyFromNameDictionary(Node* dictionary, |
| Variable* var_value) { |
| Comment("LoadPropertyFromNameDictionary"); |
| CSA_ASSERT(this, IsDictionary(dictionary)); |
| - const int name_to_details_offset = |
| - (NameDictionary::kEntryDetailsIndex - NameDictionary::kEntryKeyIndex) * |
| - kPointerSize; |
| - const int name_to_value_offset = |
| - (NameDictionary::kEntryValueIndex - NameDictionary::kEntryKeyIndex) * |
| - kPointerSize; |
| - |
| - Node* details = LoadAndUntagToWord32FixedArrayElement(dictionary, name_index, |
| - name_to_details_offset); |
| - var_details->Bind(details); |
| - var_value->Bind( |
| - LoadFixedArrayElement(dictionary, name_index, name_to_value_offset)); |
| + var_details->Bind( |
| + LoadDetailsForKeyIndex<NameDictionary>(dictionary, name_index)); |
| + var_value->Bind(LoadValueForKeyIndex<NameDictionary>(dictionary, name_index)); |
| Comment("] LoadPropertyFromNameDictionary"); |
| } |
| @@ -5000,12 +5034,8 @@ void CodeStubAssembler::LoadPropertyFromGlobalDictionary(Node* dictionary, |
| Comment("[ LoadPropertyFromGlobalDictionary"); |
| CSA_ASSERT(this, IsDictionary(dictionary)); |
| - const int name_to_value_offset = |
| - (GlobalDictionary::kEntryValueIndex - GlobalDictionary::kEntryKeyIndex) * |
| - kPointerSize; |
| - |
| Node* property_cell = |
| - LoadFixedArrayElement(dictionary, name_index, name_to_value_offset); |
| + LoadValueForKeyIndex<GlobalDictionary>(dictionary, name_index); |
| Node* value = LoadObjectField(property_cell, PropertyCell::kValueOffset); |
| GotoIf(WordEqual(value, TheHoleConstant()), if_deleted); |