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

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

Issue 2688573003: [cleanup] CSA: add helpers for accessing details/value via key_index (Closed)
Patch Set: rebased Created 3 years, 10 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/heap/mark-compact.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 #include "src/code-stub-assembler.h" 4 #include "src/code-stub-assembler.h"
5 #include "src/code-factory.h" 5 #include "src/code-factory.h"
6 #include "src/frames-inl.h" 6 #include "src/frames-inl.h"
7 #include "src/frames.h" 7 #include "src/frames.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 4620 matching lines...) Expand 10 before | Expand all | Expand 10 after
4631 UNREACHABLE(); // Use specializations instead. 4631 UNREACHABLE(); // Use specializations instead.
4632 } 4632 }
4633 4633
4634 template <> 4634 template <>
4635 void CodeStubAssembler::InsertEntry<NameDictionary>(Node* dictionary, 4635 void CodeStubAssembler::InsertEntry<NameDictionary>(Node* dictionary,
4636 Node* name, Node* value, 4636 Node* name, Node* value,
4637 Node* index, 4637 Node* index,
4638 Node* enum_index) { 4638 Node* enum_index) {
4639 // Store name and value. 4639 // Store name and value.
4640 StoreFixedArrayElement(dictionary, index, name); 4640 StoreFixedArrayElement(dictionary, index, name);
4641 const int kNameToValueOffset = 4641 StoreValueByKeyIndex<NameDictionary>(dictionary, index, value);
4642 (NameDictionary::kEntryValueIndex - NameDictionary::kEntryKeyIndex) *
4643 kPointerSize;
4644 StoreFixedArrayElement(dictionary, index, value, UPDATE_WRITE_BARRIER,
4645 kNameToValueOffset);
4646 4642
4647 // Prepare details of the new property. 4643 // Prepare details of the new property.
4648 const int kInitialIndex = 0; 4644 const int kInitialIndex = 0;
4649 PropertyDetails d(kData, NONE, kInitialIndex, PropertyCellType::kNoCell); 4645 PropertyDetails d(kData, NONE, kInitialIndex, PropertyCellType::kNoCell);
4650 enum_index = 4646 enum_index =
4651 SmiShl(enum_index, PropertyDetails::DictionaryStorageField::kShift); 4647 SmiShl(enum_index, PropertyDetails::DictionaryStorageField::kShift);
4652 STATIC_ASSERT(kInitialIndex == 0); 4648 STATIC_ASSERT(kInitialIndex == 0);
4653 Variable var_details(this, MachineRepresentation::kTaggedSigned, 4649 Variable var_details(this, MachineRepresentation::kTaggedSigned,
4654 SmiOr(SmiConstant(d.AsSmi()), enum_index)); 4650 SmiOr(SmiConstant(d.AsSmi()), enum_index));
4655 4651
4656 // Private names must be marked non-enumerable. 4652 // Private names must be marked non-enumerable.
4657 Label not_private(this, &var_details); 4653 Label not_private(this, &var_details);
4658 GotoUnless(IsSymbolMap(LoadMap(name)), &not_private); 4654 GotoUnless(IsSymbolMap(LoadMap(name)), &not_private);
4659 Node* flags = SmiToWord32(LoadObjectField(name, Symbol::kFlagsOffset)); 4655 Node* flags = SmiToWord32(LoadObjectField(name, Symbol::kFlagsOffset));
4660 const int kPrivateMask = 1 << Symbol::kPrivateBit; 4656 const int kPrivateMask = 1 << Symbol::kPrivateBit;
4661 GotoUnless(IsSetWord32(flags, kPrivateMask), &not_private); 4657 GotoUnless(IsSetWord32(flags, kPrivateMask), &not_private);
4662 Node* dont_enum = 4658 Node* dont_enum =
4663 SmiShl(SmiConstant(DONT_ENUM), PropertyDetails::AttributesField::kShift); 4659 SmiShl(SmiConstant(DONT_ENUM), PropertyDetails::AttributesField::kShift);
4664 var_details.Bind(SmiOr(var_details.value(), dont_enum)); 4660 var_details.Bind(SmiOr(var_details.value(), dont_enum));
4665 Goto(&not_private); 4661 Goto(&not_private);
4666 Bind(&not_private); 4662 Bind(&not_private);
4667 4663
4668 // Finally, store the details. 4664 // Finally, store the details.
4669 const int kNameToDetailsOffset = 4665 StoreDetailsByKeyIndex<NameDictionary>(dictionary, index,
4670 (NameDictionary::kEntryDetailsIndex - NameDictionary::kEntryKeyIndex) * 4666 var_details.value());
4671 kPointerSize;
4672 StoreFixedArrayElement(dictionary, index, var_details.value(),
4673 SKIP_WRITE_BARRIER, kNameToDetailsOffset);
4674 } 4667 }
4675 4668
4676 template <> 4669 template <>
4677 void CodeStubAssembler::InsertEntry<GlobalDictionary>(Node* dictionary, 4670 void CodeStubAssembler::InsertEntry<GlobalDictionary>(Node* dictionary,
4678 Node* key, Node* value, 4671 Node* key, Node* value,
4679 Node* index, 4672 Node* index,
4680 Node* enum_index) { 4673 Node* enum_index) {
4681 UNIMPLEMENTED(); 4674 UNIMPLEMENTED();
4682 } 4675 }
4683 4676
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
4722 4715
4723 template void CodeStubAssembler::Add<NameDictionary>(Node*, Node*, Node*, 4716 template void CodeStubAssembler::Add<NameDictionary>(Node*, Node*, Node*,
4724 Label*); 4717 Label*);
4725 4718
4726 void CodeStubAssembler::DescriptorLookupLinear(Node* unique_name, 4719 void CodeStubAssembler::DescriptorLookupLinear(Node* unique_name,
4727 Node* descriptors, Node* nof, 4720 Node* descriptors, Node* nof,
4728 Label* if_found, 4721 Label* if_found,
4729 Variable* var_name_index, 4722 Variable* var_name_index,
4730 Label* if_not_found) { 4723 Label* if_not_found) {
4731 Node* first_inclusive = IntPtrConstant(DescriptorArray::ToKeyIndex(0)); 4724 Node* first_inclusive = IntPtrConstant(DescriptorArray::ToKeyIndex(0));
4732 Node* factor = IntPtrConstant(DescriptorArray::kDescriptorSize); 4725 Node* factor = IntPtrConstant(DescriptorArray::kEntrySize);
4733 Node* last_exclusive = IntPtrAdd(first_inclusive, IntPtrMul(nof, factor)); 4726 Node* last_exclusive = IntPtrAdd(first_inclusive, IntPtrMul(nof, factor));
4734 4727
4735 BuildFastLoop(last_exclusive, first_inclusive, 4728 BuildFastLoop(last_exclusive, first_inclusive,
4736 [this, descriptors, unique_name, if_found, 4729 [this, descriptors, unique_name, if_found,
4737 var_name_index](Node* name_index) { 4730 var_name_index](Node* name_index) {
4738 Node* candidate_name = 4731 Node* candidate_name =
4739 LoadFixedArrayElement(descriptors, name_index); 4732 LoadFixedArrayElement(descriptors, name_index);
4740 var_name_index->Bind(name_index); 4733 var_name_index->Bind(name_index);
4741 GotoIf(WordEqual(candidate_name, unique_name), if_found); 4734 GotoIf(WordEqual(candidate_name, unique_name), if_found);
4742 }, 4735 },
4743 -DescriptorArray::kDescriptorSize, INTPTR_PARAMETERS, 4736 -DescriptorArray::kEntrySize, INTPTR_PARAMETERS,
4744 IndexAdvanceMode::kPre); 4737 IndexAdvanceMode::kPre);
4745 Goto(if_not_found); 4738 Goto(if_not_found);
4746 } 4739 }
4747 4740
4748 void CodeStubAssembler::TryLookupProperty( 4741 void CodeStubAssembler::TryLookupProperty(
4749 Node* object, Node* map, Node* instance_type, Node* unique_name, 4742 Node* object, Node* map, Node* instance_type, Node* unique_name,
4750 Label* if_found_fast, Label* if_found_dict, Label* if_found_global, 4743 Label* if_found_fast, Label* if_found_dict, Label* if_found_global,
4751 Variable* var_meta_storage, Variable* var_name_index, Label* if_not_found, 4744 Variable* var_meta_storage, Variable* var_name_index, Label* if_not_found,
4752 Label* if_bailout) { 4745 Label* if_bailout) {
4753 DCHECK_EQ(MachineRepresentation::kTagged, var_meta_storage->rep()); 4746 DCHECK_EQ(MachineRepresentation::kTagged, var_meta_storage->rep());
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
4841 4834
4842 void CodeStubAssembler::LoadPropertyFromFastObject(Node* object, Node* map, 4835 void CodeStubAssembler::LoadPropertyFromFastObject(Node* object, Node* map,
4843 Node* descriptors, 4836 Node* descriptors,
4844 Node* name_index, 4837 Node* name_index,
4845 Variable* var_details, 4838 Variable* var_details,
4846 Variable* var_value) { 4839 Variable* var_value) {
4847 DCHECK_EQ(MachineRepresentation::kWord32, var_details->rep()); 4840 DCHECK_EQ(MachineRepresentation::kWord32, var_details->rep());
4848 DCHECK_EQ(MachineRepresentation::kTagged, var_value->rep()); 4841 DCHECK_EQ(MachineRepresentation::kTagged, var_value->rep());
4849 Comment("[ LoadPropertyFromFastObject"); 4842 Comment("[ LoadPropertyFromFastObject");
4850 4843
4851 const int name_to_details_offset = 4844 Node* details =
4852 (DescriptorArray::kDescriptorDetails - DescriptorArray::kDescriptorKey) * 4845 LoadDetailsByKeyIndex<DescriptorArray>(descriptors, name_index);
4853 kPointerSize;
4854 const int name_to_value_offset =
4855 (DescriptorArray::kDescriptorValue - DescriptorArray::kDescriptorKey) *
4856 kPointerSize;
4857
4858 Node* details = LoadAndUntagToWord32FixedArrayElement(descriptors, name_index,
4859 name_to_details_offset);
4860 var_details->Bind(details); 4846 var_details->Bind(details);
4861 4847
4862 Node* location = DecodeWord32<PropertyDetails::LocationField>(details); 4848 Node* location = DecodeWord32<PropertyDetails::LocationField>(details);
4863 4849
4864 Label if_in_field(this), if_in_descriptor(this), done(this); 4850 Label if_in_field(this), if_in_descriptor(this), done(this);
4865 Branch(Word32Equal(location, Int32Constant(kField)), &if_in_field, 4851 Branch(Word32Equal(location, Int32Constant(kField)), &if_in_field,
4866 &if_in_descriptor); 4852 &if_in_descriptor);
4867 Bind(&if_in_field); 4853 Bind(&if_in_field);
4868 { 4854 {
4869 Node* field_index = 4855 Node* field_index =
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
4932 Bind(&rebox_double); 4918 Bind(&rebox_double);
4933 { 4919 {
4934 Comment("rebox_double"); 4920 Comment("rebox_double");
4935 Node* heap_number = AllocateHeapNumberWithValue(var_double_value.value()); 4921 Node* heap_number = AllocateHeapNumberWithValue(var_double_value.value());
4936 var_value->Bind(heap_number); 4922 var_value->Bind(heap_number);
4937 Goto(&done); 4923 Goto(&done);
4938 } 4924 }
4939 } 4925 }
4940 Bind(&if_in_descriptor); 4926 Bind(&if_in_descriptor);
4941 { 4927 {
4942 Node* value = 4928 var_value->Bind(
4943 LoadFixedArrayElement(descriptors, name_index, name_to_value_offset); 4929 LoadValueByKeyIndex<DescriptorArray>(descriptors, name_index));
4944 var_value->Bind(value);
4945 Goto(&done); 4930 Goto(&done);
4946 } 4931 }
4947 Bind(&done); 4932 Bind(&done);
4948 4933
4949 Comment("] LoadPropertyFromFastObject"); 4934 Comment("] LoadPropertyFromFastObject");
4950 } 4935 }
4951 4936
4952 void CodeStubAssembler::LoadPropertyFromNameDictionary(Node* dictionary, 4937 void CodeStubAssembler::LoadPropertyFromNameDictionary(Node* dictionary,
4953 Node* name_index, 4938 Node* name_index,
4954 Variable* var_details, 4939 Variable* var_details,
4955 Variable* var_value) { 4940 Variable* var_value) {
4956 Comment("LoadPropertyFromNameDictionary"); 4941 Comment("LoadPropertyFromNameDictionary");
4957 CSA_ASSERT(this, IsDictionary(dictionary)); 4942 CSA_ASSERT(this, IsDictionary(dictionary));
4958 const int name_to_details_offset =
4959 (NameDictionary::kEntryDetailsIndex - NameDictionary::kEntryKeyIndex) *
4960 kPointerSize;
4961 const int name_to_value_offset =
4962 (NameDictionary::kEntryValueIndex - NameDictionary::kEntryKeyIndex) *
4963 kPointerSize;
4964 4943
4965 Node* details = LoadAndUntagToWord32FixedArrayElement(dictionary, name_index, 4944 var_details->Bind(
4966 name_to_details_offset); 4945 LoadDetailsByKeyIndex<NameDictionary>(dictionary, name_index));
4967 4946 var_value->Bind(LoadValueByKeyIndex<NameDictionary>(dictionary, name_index));
4968 var_details->Bind(details);
4969 var_value->Bind(
4970 LoadFixedArrayElement(dictionary, name_index, name_to_value_offset));
4971 4947
4972 Comment("] LoadPropertyFromNameDictionary"); 4948 Comment("] LoadPropertyFromNameDictionary");
4973 } 4949 }
4974 4950
4975 void CodeStubAssembler::LoadPropertyFromGlobalDictionary(Node* dictionary, 4951 void CodeStubAssembler::LoadPropertyFromGlobalDictionary(Node* dictionary,
4976 Node* name_index, 4952 Node* name_index,
4977 Variable* var_details, 4953 Variable* var_details,
4978 Variable* var_value, 4954 Variable* var_value,
4979 Label* if_deleted) { 4955 Label* if_deleted) {
4980 Comment("[ LoadPropertyFromGlobalDictionary"); 4956 Comment("[ LoadPropertyFromGlobalDictionary");
4981 CSA_ASSERT(this, IsDictionary(dictionary)); 4957 CSA_ASSERT(this, IsDictionary(dictionary));
4982 4958
4983 const int name_to_value_offset =
4984 (GlobalDictionary::kEntryValueIndex - GlobalDictionary::kEntryKeyIndex) *
4985 kPointerSize;
4986
4987 Node* property_cell = 4959 Node* property_cell =
4988 LoadFixedArrayElement(dictionary, name_index, name_to_value_offset); 4960 LoadValueByKeyIndex<GlobalDictionary>(dictionary, name_index);
4989 4961
4990 Node* value = LoadObjectField(property_cell, PropertyCell::kValueOffset); 4962 Node* value = LoadObjectField(property_cell, PropertyCell::kValueOffset);
4991 GotoIf(WordEqual(value, TheHoleConstant()), if_deleted); 4963 GotoIf(WordEqual(value, TheHoleConstant()), if_deleted);
4992 4964
4993 var_value->Bind(value); 4965 var_value->Bind(value);
4994 4966
4995 Node* details = LoadAndUntagToWord32ObjectField(property_cell, 4967 Node* details = LoadAndUntagToWord32ObjectField(property_cell,
4996 PropertyCell::kDetailsOffset); 4968 PropertyCell::kDetailsOffset);
4997 var_details->Bind(details); 4969 var_details->Bind(details);
4998 4970
(...skipping 3355 matching lines...) Expand 10 before | Expand all | Expand 10 after
8354 formatted.c_str(), TENURED); 8326 formatted.c_str(), TENURED);
8355 CallRuntime(Runtime::kGlobalPrint, NoContextConstant(), 8327 CallRuntime(Runtime::kGlobalPrint, NoContextConstant(),
8356 HeapConstant(string)); 8328 HeapConstant(string));
8357 } 8329 }
8358 CallRuntime(Runtime::kDebugPrint, NoContextConstant(), tagged_value); 8330 CallRuntime(Runtime::kDebugPrint, NoContextConstant(), tagged_value);
8359 #endif 8331 #endif
8360 } 8332 }
8361 8333
8362 } // namespace internal 8334 } // namespace internal
8363 } // namespace v8 8335 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-stub-assembler.h ('k') | src/heap/mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698