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

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: make linker happy 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 4400 matching lines...) Expand 10 before | Expand all | Expand 10 after
4411 Node* entry_index = IntPtrMul(entry, IntPtrConstant(Dictionary::kEntrySize)); 4411 Node* entry_index = IntPtrMul(entry, IntPtrConstant(Dictionary::kEntrySize));
4412 return IntPtrAdd(entry_index, IntPtrConstant(Dictionary::kElementsStartIndex + 4412 return IntPtrAdd(entry_index, IntPtrConstant(Dictionary::kElementsStartIndex +
4413 field_index)); 4413 field_index));
4414 } 4414 }
4415 4415
4416 template Node* CodeStubAssembler::EntryToIndex<NameDictionary>(Node*, int); 4416 template Node* CodeStubAssembler::EntryToIndex<NameDictionary>(Node*, int);
4417 template Node* CodeStubAssembler::EntryToIndex<GlobalDictionary>(Node*, int); 4417 template Node* CodeStubAssembler::EntryToIndex<GlobalDictionary>(Node*, int);
4418 template Node* CodeStubAssembler::EntryToIndex<SeededNumberDictionary>(Node*, 4418 template Node* CodeStubAssembler::EntryToIndex<SeededNumberDictionary>(Node*,
4419 int); 4419 int);
4420 4420
4421 template <class ContainerType>
4422 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.
4423 Node* key_index) {
4424 const int kKeyToDetailsOffset =
4425 (ContainerType::kEntryDetailsIndex - ContainerType::kEntryKeyIndex) *
4426 kPointerSize;
4427 return LoadAndUntagToWord32FixedArrayElement(container, key_index,
4428 kKeyToDetailsOffset);
4429 }
4430
4431 template Node* CodeStubAssembler::LoadDetailsForKeyIndex<DescriptorArray>(
4432 Node*, Node*);
4433 template Node* CodeStubAssembler::LoadDetailsForKeyIndex<NameDictionary>(Node*,
4434 Node*);
4435 template Node*
4436 CodeStubAssembler::LoadDetailsForKeyIndex<SeededNumberDictionary>(Node*, Node*);
4437
4438 template <class ContainerType>
4439 Node* CodeStubAssembler::LoadValueForKeyIndex(Node* container,
4440 Node* key_index) {
4441 const int kKeyToValueOffset =
4442 (ContainerType::kEntryValueIndex - ContainerType::kEntryKeyIndex) *
4443 kPointerSize;
4444 return LoadFixedArrayElement(container, key_index, kKeyToValueOffset);
4445 }
4446
4447 template Node* CodeStubAssembler::LoadValueForKeyIndex<GlobalDictionary>(Node*,
4448 Node*);
4449 template Node* CodeStubAssembler::LoadValueForKeyIndex<NameDictionary>(Node*,
4450 Node*);
4451 template Node* CodeStubAssembler::LoadValueForKeyIndex<SeededNumberDictionary>(
4452 Node*, Node*);
4453
4454 template <class ContainerType>
4455 void CodeStubAssembler::StoreDetailsForKeyIndex(Node* container,
4456 Node* key_index,
4457 Node* details) {
4458 const int kKeyToDetailsOffset =
4459 (ContainerType::kEntryDetailsIndex - ContainerType::kEntryKeyIndex) *
4460 kPointerSize;
4461 StoreFixedArrayElement(container, key_index, details, SKIP_WRITE_BARRIER,
4462 kKeyToDetailsOffset);
4463 }
4464
4465 template <class ContainerType>
4466 void CodeStubAssembler::StoreValueForKeyIndex(Node* container, Node* key_index,
4467 Node* value) {
4468 const int kKeyToValueOffset =
4469 (ContainerType::kEntryValueIndex - ContainerType::kEntryKeyIndex) *
4470 kPointerSize;
4471 StoreFixedArrayElement(container, key_index, value, UPDATE_WRITE_BARRIER,
4472 kKeyToValueOffset);
4473 }
4474
4475 template void CodeStubAssembler::StoreValueForKeyIndex<NameDictionary>(Node*,
4476 Node*,
4477 Node*);
4478
4421 Node* CodeStubAssembler::HashTableComputeCapacity(Node* at_least_space_for) { 4479 Node* CodeStubAssembler::HashTableComputeCapacity(Node* at_least_space_for) {
4422 Node* capacity = IntPtrRoundUpToPowerOfTwo32( 4480 Node* capacity = IntPtrRoundUpToPowerOfTwo32(
4423 WordShl(at_least_space_for, IntPtrConstant(1))); 4481 WordShl(at_least_space_for, IntPtrConstant(1)));
4424 return IntPtrMax(capacity, IntPtrConstant(HashTableBase::kMinCapacity)); 4482 return IntPtrMax(capacity, IntPtrConstant(HashTableBase::kMinCapacity));
4425 } 4483 }
4426 4484
4427 Node* CodeStubAssembler::IntPtrMax(Node* left, Node* right) { 4485 Node* CodeStubAssembler::IntPtrMax(Node* left, Node* right) {
4428 return SelectConstant(IntPtrGreaterThanOrEqual(left, right), left, right, 4486 return SelectConstant(IntPtrGreaterThanOrEqual(left, right), left, right,
4429 MachineType::PointerRepresentation()); 4487 MachineType::PointerRepresentation());
4430 } 4488 }
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
4651 UNREACHABLE(); // Use specializations instead. 4709 UNREACHABLE(); // Use specializations instead.
4652 } 4710 }
4653 4711
4654 template <> 4712 template <>
4655 void CodeStubAssembler::InsertEntry<NameDictionary>(Node* dictionary, 4713 void CodeStubAssembler::InsertEntry<NameDictionary>(Node* dictionary,
4656 Node* name, Node* value, 4714 Node* name, Node* value,
4657 Node* index, 4715 Node* index,
4658 Node* enum_index) { 4716 Node* enum_index) {
4659 // Store name and value. 4717 // Store name and value.
4660 StoreFixedArrayElement(dictionary, index, name); 4718 StoreFixedArrayElement(dictionary, index, name);
4661 const int kNameToValueOffset = 4719 StoreValueForKeyIndex<NameDictionary>(dictionary, index, value);
4662 (NameDictionary::kEntryValueIndex - NameDictionary::kEntryKeyIndex) *
4663 kPointerSize;
4664 StoreFixedArrayElement(dictionary, index, value, UPDATE_WRITE_BARRIER,
4665 kNameToValueOffset);
4666 4720
4667 // Prepare details of the new property. 4721 // Prepare details of the new property.
4668 const int kInitialIndex = 0; 4722 const int kInitialIndex = 0;
4669 PropertyDetails d(kData, NONE, kInitialIndex, PropertyCellType::kNoCell); 4723 PropertyDetails d(kData, NONE, kInitialIndex, PropertyCellType::kNoCell);
4670 enum_index = 4724 enum_index =
4671 SmiShl(enum_index, PropertyDetails::DictionaryStorageField::kShift); 4725 SmiShl(enum_index, PropertyDetails::DictionaryStorageField::kShift);
4672 STATIC_ASSERT(kInitialIndex == 0); 4726 STATIC_ASSERT(kInitialIndex == 0);
4673 Variable var_details(this, MachineRepresentation::kTaggedSigned, 4727 Variable var_details(this, MachineRepresentation::kTaggedSigned,
4674 SmiOr(SmiConstant(d.AsSmi()), enum_index)); 4728 SmiOr(SmiConstant(d.AsSmi()), enum_index));
4675 4729
4676 // Private names must be marked non-enumerable. 4730 // Private names must be marked non-enumerable.
4677 Label not_private(this, &var_details); 4731 Label not_private(this, &var_details);
4678 GotoUnless(IsSymbolMap(LoadMap(name)), &not_private); 4732 GotoUnless(IsSymbolMap(LoadMap(name)), &not_private);
4679 Node* flags = SmiToWord32(LoadObjectField(name, Symbol::kFlagsOffset)); 4733 Node* flags = SmiToWord32(LoadObjectField(name, Symbol::kFlagsOffset));
4680 const int kPrivateMask = 1 << Symbol::kPrivateBit; 4734 const int kPrivateMask = 1 << Symbol::kPrivateBit;
4681 GotoUnless(IsSetWord32(flags, kPrivateMask), &not_private); 4735 GotoUnless(IsSetWord32(flags, kPrivateMask), &not_private);
4682 Node* dont_enum = 4736 Node* dont_enum =
4683 SmiShl(SmiConstant(DONT_ENUM), PropertyDetails::AttributesField::kShift); 4737 SmiShl(SmiConstant(DONT_ENUM), PropertyDetails::AttributesField::kShift);
4684 var_details.Bind(SmiOr(var_details.value(), dont_enum)); 4738 var_details.Bind(SmiOr(var_details.value(), dont_enum));
4685 Goto(&not_private); 4739 Goto(&not_private);
4686 Bind(&not_private); 4740 Bind(&not_private);
4687 4741
4688 // Finally, store the details. 4742 // Finally, store the details.
4689 const int kNameToDetailsOffset = 4743 StoreDetailsForKeyIndex<NameDictionary>(dictionary, index,
4690 (NameDictionary::kEntryDetailsIndex - NameDictionary::kEntryKeyIndex) * 4744 var_details.value());
4691 kPointerSize;
4692 StoreFixedArrayElement(dictionary, index, var_details.value(),
4693 SKIP_WRITE_BARRIER, kNameToDetailsOffset);
4694 } 4745 }
4695 4746
4696 template <> 4747 template <>
4697 void CodeStubAssembler::InsertEntry<GlobalDictionary>(Node* dictionary, 4748 void CodeStubAssembler::InsertEntry<GlobalDictionary>(Node* dictionary,
4698 Node* key, Node* value, 4749 Node* key, Node* value,
4699 Node* index, 4750 Node* index,
4700 Node* enum_index) { 4751 Node* enum_index) {
4701 UNIMPLEMENTED(); 4752 UNIMPLEMENTED();
4702 } 4753 }
4703 4754
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
4742 4793
4743 template void CodeStubAssembler::Add<NameDictionary>(Node*, Node*, Node*, 4794 template void CodeStubAssembler::Add<NameDictionary>(Node*, Node*, Node*,
4744 Label*); 4795 Label*);
4745 4796
4746 void CodeStubAssembler::DescriptorLookupLinear(Node* unique_name, 4797 void CodeStubAssembler::DescriptorLookupLinear(Node* unique_name,
4747 Node* descriptors, Node* nof, 4798 Node* descriptors, Node* nof,
4748 Label* if_found, 4799 Label* if_found,
4749 Variable* var_name_index, 4800 Variable* var_name_index,
4750 Label* if_not_found) { 4801 Label* if_not_found) {
4751 Node* first_inclusive = IntPtrConstant(DescriptorArray::ToKeyIndex(0)); 4802 Node* first_inclusive = IntPtrConstant(DescriptorArray::ToKeyIndex(0));
4752 Node* factor = IntPtrConstant(DescriptorArray::kDescriptorSize); 4803 Node* factor = IntPtrConstant(DescriptorArray::kEntrySize);
4753 Node* last_exclusive = IntPtrAdd(first_inclusive, IntPtrMul(nof, factor)); 4804 Node* last_exclusive = IntPtrAdd(first_inclusive, IntPtrMul(nof, factor));
4754 4805
4755 BuildFastLoop(last_exclusive, first_inclusive, 4806 BuildFastLoop(last_exclusive, first_inclusive,
4756 [this, descriptors, unique_name, if_found, 4807 [this, descriptors, unique_name, if_found,
4757 var_name_index](Node* name_index) { 4808 var_name_index](Node* name_index) {
4758 Node* candidate_name = 4809 Node* candidate_name =
4759 LoadFixedArrayElement(descriptors, name_index); 4810 LoadFixedArrayElement(descriptors, name_index);
4760 var_name_index->Bind(name_index); 4811 var_name_index->Bind(name_index);
4761 GotoIf(WordEqual(candidate_name, unique_name), if_found); 4812 GotoIf(WordEqual(candidate_name, unique_name), if_found);
4762 }, 4813 },
4763 -DescriptorArray::kDescriptorSize, INTPTR_PARAMETERS, 4814 -DescriptorArray::kEntrySize, INTPTR_PARAMETERS,
4764 IndexAdvanceMode::kPre); 4815 IndexAdvanceMode::kPre);
4765 Goto(if_not_found); 4816 Goto(if_not_found);
4766 } 4817 }
4767 4818
4768 void CodeStubAssembler::TryLookupProperty( 4819 void CodeStubAssembler::TryLookupProperty(
4769 Node* object, Node* map, Node* instance_type, Node* unique_name, 4820 Node* object, Node* map, Node* instance_type, Node* unique_name,
4770 Label* if_found_fast, Label* if_found_dict, Label* if_found_global, 4821 Label* if_found_fast, Label* if_found_dict, Label* if_found_global,
4771 Variable* var_meta_storage, Variable* var_name_index, Label* if_not_found, 4822 Variable* var_meta_storage, Variable* var_name_index, Label* if_not_found,
4772 Label* if_bailout) { 4823 Label* if_bailout) {
4773 DCHECK_EQ(MachineRepresentation::kTagged, var_meta_storage->rep()); 4824 DCHECK_EQ(MachineRepresentation::kTagged, var_meta_storage->rep());
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
4861 4912
4862 void CodeStubAssembler::LoadPropertyFromFastObject(Node* object, Node* map, 4913 void CodeStubAssembler::LoadPropertyFromFastObject(Node* object, Node* map,
4863 Node* descriptors, 4914 Node* descriptors,
4864 Node* name_index, 4915 Node* name_index,
4865 Variable* var_details, 4916 Variable* var_details,
4866 Variable* var_value) { 4917 Variable* var_value) {
4867 DCHECK_EQ(MachineRepresentation::kWord32, var_details->rep()); 4918 DCHECK_EQ(MachineRepresentation::kWord32, var_details->rep());
4868 DCHECK_EQ(MachineRepresentation::kTagged, var_value->rep()); 4919 DCHECK_EQ(MachineRepresentation::kTagged, var_value->rep());
4869 Comment("[ LoadPropertyFromFastObject"); 4920 Comment("[ LoadPropertyFromFastObject");
4870 4921
4871 const int name_to_details_offset = 4922 Node* details =
4872 (DescriptorArray::kDescriptorDetails - DescriptorArray::kDescriptorKey) * 4923 LoadDetailsForKeyIndex<DescriptorArray>(descriptors, name_index);
4873 kPointerSize;
4874 const int name_to_value_offset =
4875 (DescriptorArray::kDescriptorValue - DescriptorArray::kDescriptorKey) *
4876 kPointerSize;
4877
4878 Node* details = LoadAndUntagToWord32FixedArrayElement(descriptors, name_index,
4879 name_to_details_offset);
4880 var_details->Bind(details); 4924 var_details->Bind(details);
4881 4925
4882 Node* location = DecodeWord32<PropertyDetails::LocationField>(details); 4926 Node* location = DecodeWord32<PropertyDetails::LocationField>(details);
4883 4927
4884 Label if_in_field(this), if_in_descriptor(this), done(this); 4928 Label if_in_field(this), if_in_descriptor(this), done(this);
4885 Branch(Word32Equal(location, Int32Constant(kField)), &if_in_field, 4929 Branch(Word32Equal(location, Int32Constant(kField)), &if_in_field,
4886 &if_in_descriptor); 4930 &if_in_descriptor);
4887 Bind(&if_in_field); 4931 Bind(&if_in_field);
4888 { 4932 {
4889 Node* field_index = 4933 Node* field_index =
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
4952 Bind(&rebox_double); 4996 Bind(&rebox_double);
4953 { 4997 {
4954 Comment("rebox_double"); 4998 Comment("rebox_double");
4955 Node* heap_number = AllocateHeapNumberWithValue(var_double_value.value()); 4999 Node* heap_number = AllocateHeapNumberWithValue(var_double_value.value());
4956 var_value->Bind(heap_number); 5000 var_value->Bind(heap_number);
4957 Goto(&done); 5001 Goto(&done);
4958 } 5002 }
4959 } 5003 }
4960 Bind(&if_in_descriptor); 5004 Bind(&if_in_descriptor);
4961 { 5005 {
4962 Node* value = 5006 var_value->Bind(
4963 LoadFixedArrayElement(descriptors, name_index, name_to_value_offset); 5007 LoadValueForKeyIndex<DescriptorArray>(descriptors, name_index));
4964 var_value->Bind(value);
4965 Goto(&done); 5008 Goto(&done);
4966 } 5009 }
4967 Bind(&done); 5010 Bind(&done);
4968 5011
4969 Comment("] LoadPropertyFromFastObject"); 5012 Comment("] LoadPropertyFromFastObject");
4970 } 5013 }
4971 5014
4972 void CodeStubAssembler::LoadPropertyFromNameDictionary(Node* dictionary, 5015 void CodeStubAssembler::LoadPropertyFromNameDictionary(Node* dictionary,
4973 Node* name_index, 5016 Node* name_index,
4974 Variable* var_details, 5017 Variable* var_details,
4975 Variable* var_value) { 5018 Variable* var_value) {
4976 Comment("LoadPropertyFromNameDictionary"); 5019 Comment("LoadPropertyFromNameDictionary");
4977 CSA_ASSERT(this, IsDictionary(dictionary)); 5020 CSA_ASSERT(this, IsDictionary(dictionary));
4978 const int name_to_details_offset =
4979 (NameDictionary::kEntryDetailsIndex - NameDictionary::kEntryKeyIndex) *
4980 kPointerSize;
4981 const int name_to_value_offset =
4982 (NameDictionary::kEntryValueIndex - NameDictionary::kEntryKeyIndex) *
4983 kPointerSize;
4984 5021
4985 Node* details = LoadAndUntagToWord32FixedArrayElement(dictionary, name_index, 5022 var_details->Bind(
4986 name_to_details_offset); 5023 LoadDetailsForKeyIndex<NameDictionary>(dictionary, name_index));
4987 5024 var_value->Bind(LoadValueForKeyIndex<NameDictionary>(dictionary, name_index));
4988 var_details->Bind(details);
4989 var_value->Bind(
4990 LoadFixedArrayElement(dictionary, name_index, name_to_value_offset));
4991 5025
4992 Comment("] LoadPropertyFromNameDictionary"); 5026 Comment("] LoadPropertyFromNameDictionary");
4993 } 5027 }
4994 5028
4995 void CodeStubAssembler::LoadPropertyFromGlobalDictionary(Node* dictionary, 5029 void CodeStubAssembler::LoadPropertyFromGlobalDictionary(Node* dictionary,
4996 Node* name_index, 5030 Node* name_index,
4997 Variable* var_details, 5031 Variable* var_details,
4998 Variable* var_value, 5032 Variable* var_value,
4999 Label* if_deleted) { 5033 Label* if_deleted) {
5000 Comment("[ LoadPropertyFromGlobalDictionary"); 5034 Comment("[ LoadPropertyFromGlobalDictionary");
5001 CSA_ASSERT(this, IsDictionary(dictionary)); 5035 CSA_ASSERT(this, IsDictionary(dictionary));
5002 5036
5003 const int name_to_value_offset =
5004 (GlobalDictionary::kEntryValueIndex - GlobalDictionary::kEntryKeyIndex) *
5005 kPointerSize;
5006
5007 Node* property_cell = 5037 Node* property_cell =
5008 LoadFixedArrayElement(dictionary, name_index, name_to_value_offset); 5038 LoadValueForKeyIndex<GlobalDictionary>(dictionary, name_index);
5009 5039
5010 Node* value = LoadObjectField(property_cell, PropertyCell::kValueOffset); 5040 Node* value = LoadObjectField(property_cell, PropertyCell::kValueOffset);
5011 GotoIf(WordEqual(value, TheHoleConstant()), if_deleted); 5041 GotoIf(WordEqual(value, TheHoleConstant()), if_deleted);
5012 5042
5013 var_value->Bind(value); 5043 var_value->Bind(value);
5014 5044
5015 Node* details = LoadAndUntagToWord32ObjectField(property_cell, 5045 Node* details = LoadAndUntagToWord32ObjectField(property_cell,
5016 PropertyCell::kDetailsOffset); 5046 PropertyCell::kDetailsOffset);
5017 var_details->Bind(details); 5047 var_details->Bind(details);
5018 5048
(...skipping 3355 matching lines...) Expand 10 before | Expand all | Expand 10 after
8374 formatted.c_str(), TENURED); 8404 formatted.c_str(), TENURED);
8375 CallRuntime(Runtime::kGlobalPrint, NoContextConstant(), 8405 CallRuntime(Runtime::kGlobalPrint, NoContextConstant(),
8376 HeapConstant(string)); 8406 HeapConstant(string));
8377 } 8407 }
8378 CallRuntime(Runtime::kDebugPrint, NoContextConstant(), tagged_value); 8408 CallRuntime(Runtime::kDebugPrint, NoContextConstant(), tagged_value);
8379 #endif 8409 #endif
8380 } 8410 }
8381 8411
8382 } // namespace internal 8412 } // namespace internal
8383 } // namespace v8 8413 } // 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