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 #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 1318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1329 if (Heap::RootIsImmortalImmovable(root_index)) { | 1329 if (Heap::RootIsImmortalImmovable(root_index)) { |
1330 return StoreObjectFieldNoWriteBarrier(object, offset, LoadRoot(root_index)); | 1330 return StoreObjectFieldNoWriteBarrier(object, offset, LoadRoot(root_index)); |
1331 } else { | 1331 } else { |
1332 return StoreObjectField(object, offset, LoadRoot(root_index)); | 1332 return StoreObjectField(object, offset, LoadRoot(root_index)); |
1333 } | 1333 } |
1334 } | 1334 } |
1335 | 1335 |
1336 Node* CodeStubAssembler::StoreFixedArrayElement(Node* object, Node* index_node, | 1336 Node* CodeStubAssembler::StoreFixedArrayElement(Node* object, Node* index_node, |
1337 Node* value, | 1337 Node* value, |
1338 WriteBarrierMode barrier_mode, | 1338 WriteBarrierMode barrier_mode, |
| 1339 int additional_offset, |
1339 ParameterMode parameter_mode) { | 1340 ParameterMode parameter_mode) { |
1340 DCHECK(barrier_mode == SKIP_WRITE_BARRIER || | 1341 DCHECK(barrier_mode == SKIP_WRITE_BARRIER || |
1341 barrier_mode == UPDATE_WRITE_BARRIER); | 1342 barrier_mode == UPDATE_WRITE_BARRIER); |
1342 Node* offset = | 1343 int header_size = |
1343 ElementOffsetFromIndex(index_node, FAST_HOLEY_ELEMENTS, parameter_mode, | 1344 FixedArray::kHeaderSize + additional_offset - kHeapObjectTag; |
1344 FixedArray::kHeaderSize - kHeapObjectTag); | 1345 Node* offset = ElementOffsetFromIndex(index_node, FAST_HOLEY_ELEMENTS, |
| 1346 parameter_mode, header_size); |
1345 MachineRepresentation rep = MachineRepresentation::kTagged; | 1347 MachineRepresentation rep = MachineRepresentation::kTagged; |
1346 if (barrier_mode == SKIP_WRITE_BARRIER) { | 1348 if (barrier_mode == SKIP_WRITE_BARRIER) { |
1347 return StoreNoWriteBarrier(rep, object, offset, value); | 1349 return StoreNoWriteBarrier(rep, object, offset, value); |
1348 } else { | 1350 } else { |
1349 return Store(rep, object, offset, value); | 1351 return Store(rep, object, offset, value); |
1350 } | 1352 } |
1351 } | 1353 } |
1352 | 1354 |
1353 Node* CodeStubAssembler::StoreFixedDoubleArrayElement( | 1355 Node* CodeStubAssembler::StoreFixedDoubleArrayElement( |
1354 Node* object, Node* index_node, Node* value, ParameterMode parameter_mode) { | 1356 Node* object, Node* index_node, Node* value, ParameterMode parameter_mode) { |
(...skipping 2674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4029 Node* capacity = IntPtrRoundUpToPowerOfTwo32( | 4031 Node* capacity = IntPtrRoundUpToPowerOfTwo32( |
4030 WordShl(at_least_space_for, IntPtrConstant(1))); | 4032 WordShl(at_least_space_for, IntPtrConstant(1))); |
4031 return IntPtrMax(capacity, IntPtrConstant(HashTableBase::kMinCapacity)); | 4033 return IntPtrMax(capacity, IntPtrConstant(HashTableBase::kMinCapacity)); |
4032 } | 4034 } |
4033 | 4035 |
4034 Node* CodeStubAssembler::IntPtrMax(Node* left, Node* right) { | 4036 Node* CodeStubAssembler::IntPtrMax(Node* left, Node* right) { |
4035 return Select(IntPtrGreaterThanOrEqual(left, right), left, right, | 4037 return Select(IntPtrGreaterThanOrEqual(left, right), left, right, |
4036 MachineType::PointerRepresentation()); | 4038 MachineType::PointerRepresentation()); |
4037 } | 4039 } |
4038 | 4040 |
| 4041 template <class Dictionary> |
| 4042 Node* CodeStubAssembler::GetNumberOfElements(Node* dictionary) { |
| 4043 return LoadFixedArrayElement( |
| 4044 dictionary, IntPtrConstant(Dictionary::kNumberOfElementsIndex), 0, |
| 4045 INTPTR_PARAMETERS); |
| 4046 } |
| 4047 |
| 4048 template <class Dictionary> |
| 4049 void CodeStubAssembler::SetNumberOfElements(Node* dictionary, |
| 4050 Node* num_elements_smi) { |
| 4051 StoreFixedArrayElement(dictionary, Dictionary::kNumberOfElementsIndex, |
| 4052 num_elements_smi, SKIP_WRITE_BARRIER); |
| 4053 } |
| 4054 |
| 4055 template <class Dictionary> |
| 4056 Node* CodeStubAssembler::GetNumberOfDeletedElements(Node* dictionary) { |
| 4057 return LoadFixedArrayElement( |
| 4058 dictionary, IntPtrConstant(Dictionary::kNumberOfDeletedElementsIndex), 0, |
| 4059 INTPTR_PARAMETERS); |
| 4060 } |
| 4061 |
| 4062 template <class Dictionary> |
| 4063 Node* CodeStubAssembler::GetCapacity(Node* dictionary) { |
| 4064 return LoadFixedArrayElement(dictionary, |
| 4065 IntPtrConstant(Dictionary::kCapacityIndex), 0, |
| 4066 INTPTR_PARAMETERS); |
| 4067 } |
| 4068 |
| 4069 template <class Dictionary> |
| 4070 Node* CodeStubAssembler::GetNextEnumerationIndex(Node* dictionary) { |
| 4071 return LoadFixedArrayElement( |
| 4072 dictionary, IntPtrConstant(Dictionary::kNextEnumerationIndexIndex), 0, |
| 4073 INTPTR_PARAMETERS); |
| 4074 } |
| 4075 |
| 4076 template <class Dictionary> |
| 4077 void CodeStubAssembler::SetNextEnumerationIndex(Node* dictionary, |
| 4078 Node* next_enum_index_smi) { |
| 4079 StoreFixedArrayElement(dictionary, Dictionary::kNextEnumerationIndexIndex, |
| 4080 next_enum_index_smi, SKIP_WRITE_BARRIER); |
| 4081 } |
| 4082 |
4039 template <typename Dictionary> | 4083 template <typename Dictionary> |
4040 void CodeStubAssembler::NameDictionaryLookup(Node* dictionary, | 4084 void CodeStubAssembler::NameDictionaryLookup(Node* dictionary, |
4041 Node* unique_name, Label* if_found, | 4085 Node* unique_name, Label* if_found, |
4042 Variable* var_name_index, | 4086 Variable* var_name_index, |
4043 Label* if_not_found, | 4087 Label* if_not_found, |
4044 int inlined_probes) { | 4088 int inlined_probes, |
| 4089 LookupMode mode) { |
4045 CSA_ASSERT(this, IsDictionary(dictionary)); | 4090 CSA_ASSERT(this, IsDictionary(dictionary)); |
4046 DCHECK_EQ(MachineType::PointerRepresentation(), var_name_index->rep()); | 4091 DCHECK_EQ(MachineType::PointerRepresentation(), var_name_index->rep()); |
| 4092 DCHECK_IMPLIES(mode == kFindInsertionIndex, |
| 4093 inlined_probes == 0 && if_found == nullptr); |
4047 Comment("NameDictionaryLookup"); | 4094 Comment("NameDictionaryLookup"); |
4048 | 4095 |
4049 Node* capacity = SmiUntag(LoadFixedArrayElement( | 4096 Node* capacity = SmiUntag(GetCapacity<Dictionary>(dictionary)); |
4050 dictionary, IntPtrConstant(Dictionary::kCapacityIndex), 0, | |
4051 INTPTR_PARAMETERS)); | |
4052 Node* mask = IntPtrSub(capacity, IntPtrConstant(1)); | 4097 Node* mask = IntPtrSub(capacity, IntPtrConstant(1)); |
4053 Node* hash = ChangeUint32ToWord(LoadNameHash(unique_name)); | 4098 Node* hash = ChangeUint32ToWord(LoadNameHash(unique_name)); |
4054 | 4099 |
4055 // See Dictionary::FirstProbe(). | 4100 // See Dictionary::FirstProbe(). |
4056 Node* count = IntPtrConstant(0); | 4101 Node* count = IntPtrConstant(0); |
4057 Node* entry = WordAnd(hash, mask); | 4102 Node* entry = WordAnd(hash, mask); |
4058 | 4103 |
4059 for (int i = 0; i < inlined_probes; i++) { | 4104 for (int i = 0; i < inlined_probes; i++) { |
4060 Node* index = EntryToIndex<Dictionary>(entry); | 4105 Node* index = EntryToIndex<Dictionary>(entry); |
4061 var_name_index->Bind(index); | 4106 var_name_index->Bind(index); |
4062 | 4107 |
4063 Node* current = | 4108 Node* current = |
4064 LoadFixedArrayElement(dictionary, index, 0, INTPTR_PARAMETERS); | 4109 LoadFixedArrayElement(dictionary, index, 0, INTPTR_PARAMETERS); |
4065 GotoIf(WordEqual(current, unique_name), if_found); | 4110 GotoIf(WordEqual(current, unique_name), if_found); |
4066 | 4111 |
4067 // See Dictionary::NextProbe(). | 4112 // See Dictionary::NextProbe(). |
4068 count = IntPtrConstant(i + 1); | 4113 count = IntPtrConstant(i + 1); |
4069 entry = WordAnd(IntPtrAdd(entry, count), mask); | 4114 entry = WordAnd(IntPtrAdd(entry, count), mask); |
4070 } | 4115 } |
| 4116 if (mode == kFindInsertionIndex) { |
| 4117 // Appease the variable merging algorithm for "Goto(&loop)" below. |
| 4118 var_name_index->Bind(IntPtrConstant(0)); |
| 4119 } |
4071 | 4120 |
4072 Node* undefined = UndefinedConstant(); | 4121 Node* undefined = UndefinedConstant(); |
| 4122 Node* the_hole = mode == kFindExisting ? nullptr : TheHoleConstant(); |
4073 | 4123 |
4074 Variable var_count(this, MachineType::PointerRepresentation()); | 4124 Variable var_count(this, MachineType::PointerRepresentation()); |
4075 Variable var_entry(this, MachineType::PointerRepresentation()); | 4125 Variable var_entry(this, MachineType::PointerRepresentation()); |
4076 Variable* loop_vars[] = {&var_count, &var_entry, var_name_index}; | 4126 Variable* loop_vars[] = {&var_count, &var_entry, var_name_index}; |
4077 Label loop(this, 3, loop_vars); | 4127 Label loop(this, 3, loop_vars); |
4078 var_count.Bind(count); | 4128 var_count.Bind(count); |
4079 var_entry.Bind(entry); | 4129 var_entry.Bind(entry); |
4080 Goto(&loop); | 4130 Goto(&loop); |
4081 Bind(&loop); | 4131 Bind(&loop); |
4082 { | 4132 { |
4083 Node* count = var_count.value(); | 4133 Node* count = var_count.value(); |
4084 Node* entry = var_entry.value(); | 4134 Node* entry = var_entry.value(); |
4085 | 4135 |
4086 Node* index = EntryToIndex<Dictionary>(entry); | 4136 Node* index = EntryToIndex<Dictionary>(entry); |
4087 var_name_index->Bind(index); | 4137 var_name_index->Bind(index); |
4088 | 4138 |
4089 Node* current = | 4139 Node* current = |
4090 LoadFixedArrayElement(dictionary, index, 0, INTPTR_PARAMETERS); | 4140 LoadFixedArrayElement(dictionary, index, 0, INTPTR_PARAMETERS); |
4091 GotoIf(WordEqual(current, undefined), if_not_found); | 4141 GotoIf(WordEqual(current, undefined), if_not_found); |
4092 GotoIf(WordEqual(current, unique_name), if_found); | 4142 if (mode == kFindExisting) { |
| 4143 GotoIf(WordEqual(current, unique_name), if_found); |
| 4144 } else { |
| 4145 DCHECK_EQ(kFindInsertionIndex, mode); |
| 4146 GotoIf(WordEqual(current, the_hole), if_not_found); |
| 4147 } |
4093 | 4148 |
4094 // See Dictionary::NextProbe(). | 4149 // See Dictionary::NextProbe(). |
4095 count = IntPtrAdd(count, IntPtrConstant(1)); | 4150 count = IntPtrAdd(count, IntPtrConstant(1)); |
4096 entry = WordAnd(IntPtrAdd(entry, count), mask); | 4151 entry = WordAnd(IntPtrAdd(entry, count), mask); |
4097 | 4152 |
4098 var_count.Bind(count); | 4153 var_count.Bind(count); |
4099 var_entry.Bind(entry); | 4154 var_entry.Bind(entry); |
4100 Goto(&loop); | 4155 Goto(&loop); |
4101 } | 4156 } |
4102 } | 4157 } |
4103 | 4158 |
4104 // Instantiate template methods to workaround GCC compilation issue. | 4159 // Instantiate template methods to workaround GCC compilation issue. |
4105 template void CodeStubAssembler::NameDictionaryLookup<NameDictionary>( | 4160 template void CodeStubAssembler::NameDictionaryLookup<NameDictionary>( |
4106 Node*, Node*, Label*, Variable*, Label*, int); | 4161 Node*, Node*, Label*, Variable*, Label*, int, LookupMode); |
4107 template void CodeStubAssembler::NameDictionaryLookup<GlobalDictionary>( | 4162 template void CodeStubAssembler::NameDictionaryLookup<GlobalDictionary>( |
4108 Node*, Node*, Label*, Variable*, Label*, int); | 4163 Node*, Node*, Label*, Variable*, Label*, int, LookupMode); |
4109 | 4164 |
4110 Node* CodeStubAssembler::ComputeIntegerHash(Node* key, Node* seed) { | 4165 Node* CodeStubAssembler::ComputeIntegerHash(Node* key, Node* seed) { |
4111 // See v8::internal::ComputeIntegerHash() | 4166 // See v8::internal::ComputeIntegerHash() |
4112 Node* hash = key; | 4167 Node* hash = key; |
4113 hash = Word32Xor(hash, seed); | 4168 hash = Word32Xor(hash, seed); |
4114 hash = Int32Add(Word32Xor(hash, Int32Constant(0xffffffff)), | 4169 hash = Int32Add(Word32Xor(hash, Int32Constant(0xffffffff)), |
4115 Word32Shl(hash, Int32Constant(15))); | 4170 Word32Shl(hash, Int32Constant(15))); |
4116 hash = Word32Xor(hash, Word32Shr(hash, Int32Constant(12))); | 4171 hash = Word32Xor(hash, Word32Shr(hash, Int32Constant(12))); |
4117 hash = Int32Add(hash, Word32Shl(hash, Int32Constant(2))); | 4172 hash = Int32Add(hash, Word32Shl(hash, Int32Constant(2))); |
4118 hash = Word32Xor(hash, Word32Shr(hash, Int32Constant(4))); | 4173 hash = Word32Xor(hash, Word32Shr(hash, Int32Constant(4))); |
4119 hash = Int32Mul(hash, Int32Constant(2057)); | 4174 hash = Int32Mul(hash, Int32Constant(2057)); |
4120 hash = Word32Xor(hash, Word32Shr(hash, Int32Constant(16))); | 4175 hash = Word32Xor(hash, Word32Shr(hash, Int32Constant(16))); |
4121 return Word32And(hash, Int32Constant(0x3fffffff)); | 4176 return Word32And(hash, Int32Constant(0x3fffffff)); |
4122 } | 4177 } |
4123 | 4178 |
4124 template <typename Dictionary> | 4179 template <typename Dictionary> |
4125 void CodeStubAssembler::NumberDictionaryLookup(Node* dictionary, | 4180 void CodeStubAssembler::NumberDictionaryLookup(Node* dictionary, |
4126 Node* intptr_index, | 4181 Node* intptr_index, |
4127 Label* if_found, | 4182 Label* if_found, |
4128 Variable* var_entry, | 4183 Variable* var_entry, |
4129 Label* if_not_found) { | 4184 Label* if_not_found) { |
4130 CSA_ASSERT(this, IsDictionary(dictionary)); | 4185 CSA_ASSERT(this, IsDictionary(dictionary)); |
4131 DCHECK_EQ(MachineType::PointerRepresentation(), var_entry->rep()); | 4186 DCHECK_EQ(MachineType::PointerRepresentation(), var_entry->rep()); |
4132 Comment("NumberDictionaryLookup"); | 4187 Comment("NumberDictionaryLookup"); |
4133 | 4188 |
4134 Node* capacity = SmiUntag(LoadFixedArrayElement( | 4189 Node* capacity = SmiUntag(GetCapacity<Dictionary>(dictionary)); |
4135 dictionary, IntPtrConstant(Dictionary::kCapacityIndex), 0, | |
4136 INTPTR_PARAMETERS)); | |
4137 Node* mask = IntPtrSub(capacity, IntPtrConstant(1)); | 4190 Node* mask = IntPtrSub(capacity, IntPtrConstant(1)); |
4138 | 4191 |
4139 Node* int32_seed; | 4192 Node* int32_seed; |
4140 if (Dictionary::ShapeT::UsesSeed) { | 4193 if (Dictionary::ShapeT::UsesSeed) { |
4141 int32_seed = HashSeed(); | 4194 int32_seed = HashSeed(); |
4142 } else { | 4195 } else { |
4143 int32_seed = Int32Constant(kZeroHashSeed); | 4196 int32_seed = Int32Constant(kZeroHashSeed); |
4144 } | 4197 } |
4145 Node* hash = ChangeUint32ToWord(ComputeIntegerHash(intptr_index, int32_seed)); | 4198 Node* hash = ChangeUint32ToWord(ComputeIntegerHash(intptr_index, int32_seed)); |
4146 Node* key_as_float64 = RoundIntPtrToFloat64(intptr_index); | 4199 Node* key_as_float64 = RoundIntPtrToFloat64(intptr_index); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4190 // See Dictionary::NextProbe(). | 4243 // See Dictionary::NextProbe(). |
4191 count = IntPtrAdd(count, IntPtrConstant(1)); | 4244 count = IntPtrAdd(count, IntPtrConstant(1)); |
4192 entry = WordAnd(IntPtrAdd(entry, count), mask); | 4245 entry = WordAnd(IntPtrAdd(entry, count), mask); |
4193 | 4246 |
4194 var_count.Bind(count); | 4247 var_count.Bind(count); |
4195 var_entry->Bind(entry); | 4248 var_entry->Bind(entry); |
4196 Goto(&loop); | 4249 Goto(&loop); |
4197 } | 4250 } |
4198 } | 4251 } |
4199 | 4252 |
| 4253 template <class Dictionary> |
| 4254 void CodeStubAssembler::FindInsertionEntry(Node* dictionary, Node* key, |
| 4255 Variable* var_key_index) { |
| 4256 UNREACHABLE(); |
| 4257 } |
| 4258 |
| 4259 template <> |
| 4260 void CodeStubAssembler::FindInsertionEntry<NameDictionary>( |
| 4261 Node* dictionary, Node* key, Variable* var_key_index) { |
| 4262 Label done(this); |
| 4263 NameDictionaryLookup<NameDictionary>(dictionary, key, nullptr, var_key_index, |
| 4264 &done, 0, kFindInsertionIndex); |
| 4265 Bind(&done); |
| 4266 } |
| 4267 |
| 4268 template <class Dictionary> |
| 4269 void CodeStubAssembler::InsertEntry(Node* dictionary, Node* key, Node* value, |
| 4270 Node* index, Node* enum_index) { |
| 4271 UNREACHABLE(); // Use specializations instead. |
| 4272 } |
| 4273 |
| 4274 template <> |
| 4275 void CodeStubAssembler::InsertEntry<NameDictionary>(Node* dictionary, |
| 4276 Node* name, Node* value, |
| 4277 Node* index, |
| 4278 Node* enum_index) { |
| 4279 // Store name and value. |
| 4280 StoreFixedArrayElement(dictionary, index, name, UPDATE_WRITE_BARRIER, 0, |
| 4281 INTPTR_PARAMETERS); |
| 4282 const int kNameToValueOffset = |
| 4283 (NameDictionary::kEntryValueIndex - NameDictionary::kEntryKeyIndex) * |
| 4284 kPointerSize; |
| 4285 StoreFixedArrayElement(dictionary, index, value, UPDATE_WRITE_BARRIER, |
| 4286 kNameToValueOffset, INTPTR_PARAMETERS); |
| 4287 |
| 4288 // Prepare details of the new property. |
| 4289 Variable var_details(this, MachineRepresentation::kTaggedSigned); |
| 4290 const int kInitialIndex = 0; |
| 4291 PropertyDetails d(NONE, DATA, kInitialIndex, PropertyCellType::kNoCell); |
| 4292 enum_index = |
| 4293 WordShl(enum_index, PropertyDetails::DictionaryStorageField::kShift); |
| 4294 STATIC_ASSERT(kInitialIndex == 0); |
| 4295 var_details.Bind(WordOr(SmiConstant(d.AsSmi()), enum_index)); |
| 4296 |
| 4297 // Private names must be marked non-enumerable. |
| 4298 Label not_private(this, &var_details); |
| 4299 GotoUnless(IsSymbolMap(LoadMap(name)), ¬_private); |
| 4300 Node* flags = SmiToWord32(LoadObjectField(name, Symbol::kFlagsOffset)); |
| 4301 const int kPrivateMask = 1 << Symbol::kPrivateBit; |
| 4302 GotoUnless(IsSetWord32(flags, kPrivateMask), ¬_private); |
| 4303 Node* dont_enum = |
| 4304 WordShl(SmiConstant(DONT_ENUM), PropertyDetails::AttributesField::kShift); |
| 4305 var_details.Bind(WordOr(var_details.value(), dont_enum)); |
| 4306 Goto(¬_private); |
| 4307 Bind(¬_private); |
| 4308 |
| 4309 // Finally, store the details. |
| 4310 const int kNameToDetailsOffset = |
| 4311 (NameDictionary::kEntryDetailsIndex - NameDictionary::kEntryKeyIndex) * |
| 4312 kPointerSize; |
| 4313 StoreFixedArrayElement(dictionary, index, var_details.value(), |
| 4314 SKIP_WRITE_BARRIER, kNameToDetailsOffset, |
| 4315 INTPTR_PARAMETERS); |
| 4316 } |
| 4317 |
| 4318 template <> |
| 4319 void CodeStubAssembler::InsertEntry<GlobalDictionary>(Node* dictionary, |
| 4320 Node* key, Node* value, |
| 4321 Node* index, |
| 4322 Node* enum_index) { |
| 4323 UNIMPLEMENTED(); |
| 4324 } |
| 4325 |
| 4326 template <class Dictionary> |
| 4327 void CodeStubAssembler::Add(Node* dictionary, Node* key, Node* value, |
| 4328 Label* bailout) { |
| 4329 Node* capacity = GetCapacity<Dictionary>(dictionary); |
| 4330 Node* nof = GetNumberOfElements<Dictionary>(dictionary); |
| 4331 Node* new_nof = SmiAdd(nof, SmiConstant(1)); |
| 4332 // Require 33% to still be free after adding additional_elements. |
| 4333 // Computing "x + (x >> 1)" on a Smi x does not return a valid Smi! |
| 4334 // But that's OK here because it's only used for a comparison. |
| 4335 Node* required_capacity_pseudo_smi = SmiAdd(new_nof, WordShr(new_nof, 1)); |
| 4336 GotoIf(UintPtrLessThan(capacity, required_capacity_pseudo_smi), bailout); |
| 4337 // Require rehashing if more than 50% of free elements are deleted elements. |
| 4338 Node* deleted = GetNumberOfDeletedElements<Dictionary>(dictionary); |
| 4339 CSA_ASSERT(this, UintPtrGreaterThan(capacity, new_nof)); |
| 4340 Node* half_of_free_elements = WordShr(SmiSub(capacity, new_nof), 1); |
| 4341 GotoIf(UintPtrGreaterThan(deleted, half_of_free_elements), bailout); |
| 4342 Node* enum_index = nullptr; |
| 4343 if (Dictionary::kIsEnumerable) { |
| 4344 enum_index = GetNextEnumerationIndex<Dictionary>(dictionary); |
| 4345 Node* new_enum_index = SmiAdd(enum_index, SmiConstant(1)); |
| 4346 Node* max_enum_index = |
| 4347 SmiConstant(PropertyDetails::DictionaryStorageField::kMax); |
| 4348 GotoIf(UintPtrGreaterThan(new_enum_index, max_enum_index), bailout); |
| 4349 |
| 4350 // No more bailouts after this point. |
| 4351 // Operations from here on can have side effects. |
| 4352 |
| 4353 SetNextEnumerationIndex<Dictionary>(dictionary, new_enum_index); |
| 4354 } else { |
| 4355 USE(enum_index); |
| 4356 } |
| 4357 SetNumberOfElements<Dictionary>(dictionary, new_nof); |
| 4358 |
| 4359 Variable var_key_index(this, MachineType::PointerRepresentation()); |
| 4360 FindInsertionEntry<Dictionary>(dictionary, key, &var_key_index); |
| 4361 InsertEntry<Dictionary>(dictionary, key, value, var_key_index.value(), |
| 4362 enum_index); |
| 4363 } |
| 4364 |
| 4365 template void CodeStubAssembler::Add<NameDictionary>(Node*, Node*, Node*, |
| 4366 Label*); |
| 4367 |
4200 void CodeStubAssembler::DescriptorLookupLinear(Node* unique_name, | 4368 void CodeStubAssembler::DescriptorLookupLinear(Node* unique_name, |
4201 Node* descriptors, Node* nof, | 4369 Node* descriptors, Node* nof, |
4202 Label* if_found, | 4370 Label* if_found, |
4203 Variable* var_name_index, | 4371 Variable* var_name_index, |
4204 Label* if_not_found) { | 4372 Label* if_not_found) { |
4205 Node* first_inclusive = IntPtrConstant(DescriptorArray::ToKeyIndex(0)); | 4373 Node* first_inclusive = IntPtrConstant(DescriptorArray::ToKeyIndex(0)); |
4206 Node* factor = IntPtrConstant(DescriptorArray::kDescriptorSize); | 4374 Node* factor = IntPtrConstant(DescriptorArray::kDescriptorSize); |
4207 Node* last_exclusive = IntPtrAdd(first_inclusive, IntPtrMul(nof, factor)); | 4375 Node* last_exclusive = IntPtrAdd(first_inclusive, IntPtrMul(nof, factor)); |
4208 | 4376 |
4209 BuildFastLoop( | 4377 BuildFastLoop( |
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5187 STATIC_ASSERT(Context::kHeaderSize == FixedArray::kHeaderSize); | 5355 STATIC_ASSERT(Context::kHeaderSize == FixedArray::kHeaderSize); |
5188 DCHECK_EQ(Context::SlotOffset(0) + kHeapObjectTag, | 5356 DCHECK_EQ(Context::SlotOffset(0) + kHeapObjectTag, |
5189 FixedArray::OffsetOfElementAt(0)); | 5357 FixedArray::OffsetOfElementAt(0)); |
5190 if (is_load) { | 5358 if (is_load) { |
5191 Node* result = LoadFixedArrayElement(the_context, mapped_index, 0, | 5359 Node* result = LoadFixedArrayElement(the_context, mapped_index, 0, |
5192 INTPTR_PARAMETERS); | 5360 INTPTR_PARAMETERS); |
5193 CSA_ASSERT(this, WordNotEqual(result, TheHoleConstant())); | 5361 CSA_ASSERT(this, WordNotEqual(result, TheHoleConstant())); |
5194 var_result.Bind(result); | 5362 var_result.Bind(result); |
5195 } else { | 5363 } else { |
5196 StoreFixedArrayElement(the_context, mapped_index, value, | 5364 StoreFixedArrayElement(the_context, mapped_index, value, |
5197 UPDATE_WRITE_BARRIER, INTPTR_PARAMETERS); | 5365 UPDATE_WRITE_BARRIER, 0, INTPTR_PARAMETERS); |
5198 } | 5366 } |
5199 Goto(&end); | 5367 Goto(&end); |
5200 } | 5368 } |
5201 | 5369 |
5202 Bind(&if_unmapped); | 5370 Bind(&if_unmapped); |
5203 { | 5371 { |
5204 Node* backing_store = LoadFixedArrayElement(elements, IntPtrConstant(1), 0, | 5372 Node* backing_store = LoadFixedArrayElement(elements, IntPtrConstant(1), 0, |
5205 INTPTR_PARAMETERS); | 5373 INTPTR_PARAMETERS); |
5206 GotoIf(WordNotEqual(LoadMap(backing_store), FixedArrayMapConstant()), | 5374 GotoIf(WordNotEqual(LoadMap(backing_store), FixedArrayMapConstant()), |
5207 bailout); | 5375 bailout); |
5208 | 5376 |
5209 Node* backing_store_length = | 5377 Node* backing_store_length = |
5210 LoadAndUntagFixedArrayBaseLength(backing_store); | 5378 LoadAndUntagFixedArrayBaseLength(backing_store); |
5211 GotoIf(UintPtrGreaterThanOrEqual(key, backing_store_length), bailout); | 5379 GotoIf(UintPtrGreaterThanOrEqual(key, backing_store_length), bailout); |
5212 | 5380 |
5213 // The key falls into unmapped range. | 5381 // The key falls into unmapped range. |
5214 if (is_load) { | 5382 if (is_load) { |
5215 Node* result = | 5383 Node* result = |
5216 LoadFixedArrayElement(backing_store, key, 0, INTPTR_PARAMETERS); | 5384 LoadFixedArrayElement(backing_store, key, 0, INTPTR_PARAMETERS); |
5217 GotoIf(WordEqual(result, TheHoleConstant()), bailout); | 5385 GotoIf(WordEqual(result, TheHoleConstant()), bailout); |
5218 var_result.Bind(result); | 5386 var_result.Bind(result); |
5219 } else { | 5387 } else { |
5220 StoreFixedArrayElement(backing_store, key, value, UPDATE_WRITE_BARRIER, | 5388 StoreFixedArrayElement(backing_store, key, value, UPDATE_WRITE_BARRIER, 0, |
5221 INTPTR_PARAMETERS); | 5389 INTPTR_PARAMETERS); |
5222 } | 5390 } |
5223 Goto(&end); | 5391 Goto(&end); |
5224 } | 5392 } |
5225 | 5393 |
5226 Bind(&end); | 5394 Bind(&end); |
5227 return var_result.value(); | 5395 return var_result.value(); |
5228 } | 5396 } |
5229 | 5397 |
5230 Node* CodeStubAssembler::LoadScriptContext(Node* context, int context_index) { | 5398 Node* CodeStubAssembler::LoadScriptContext(Node* context, int context_index) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5293 return; | 5461 return; |
5294 } | 5462 } |
5295 | 5463 |
5296 WriteBarrierMode barrier_mode = | 5464 WriteBarrierMode barrier_mode = |
5297 IsFastSmiElementsKind(kind) ? SKIP_WRITE_BARRIER : UPDATE_WRITE_BARRIER; | 5465 IsFastSmiElementsKind(kind) ? SKIP_WRITE_BARRIER : UPDATE_WRITE_BARRIER; |
5298 if (IsFastDoubleElementsKind(kind)) { | 5466 if (IsFastDoubleElementsKind(kind)) { |
5299 // Make sure we do not store signalling NaNs into double arrays. | 5467 // Make sure we do not store signalling NaNs into double arrays. |
5300 value = Float64SilenceNaN(value); | 5468 value = Float64SilenceNaN(value); |
5301 StoreFixedDoubleArrayElement(elements, index, value, mode); | 5469 StoreFixedDoubleArrayElement(elements, index, value, mode); |
5302 } else { | 5470 } else { |
5303 StoreFixedArrayElement(elements, index, value, barrier_mode, mode); | 5471 StoreFixedArrayElement(elements, index, value, barrier_mode, 0, mode); |
5304 } | 5472 } |
5305 } | 5473 } |
5306 | 5474 |
5307 void CodeStubAssembler::EmitElementStore(Node* object, Node* key, Node* value, | 5475 void CodeStubAssembler::EmitElementStore(Node* object, Node* key, Node* value, |
5308 bool is_jsarray, | 5476 bool is_jsarray, |
5309 ElementsKind elements_kind, | 5477 ElementsKind elements_kind, |
5310 KeyedAccessStoreMode store_mode, | 5478 KeyedAccessStoreMode store_mode, |
5311 Label* bailout) { | 5479 Label* bailout) { |
5312 Node* elements = LoadElements(object); | 5480 Node* elements = LoadElements(object); |
5313 if (IsFastSmiOrObjectElementsKind(elements_kind) && | 5481 if (IsFastSmiOrObjectElementsKind(elements_kind) && |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5685 Node* next_site = LoadBufferObject(site_list, 0); | 5853 Node* next_site = LoadBufferObject(site_list, 0); |
5686 | 5854 |
5687 // TODO(mvstanton): This is a store to a weak pointer, which we may want to | 5855 // TODO(mvstanton): This is a store to a weak pointer, which we may want to |
5688 // mark as such in order to skip the write barrier, once we have a unified | 5856 // mark as such in order to skip the write barrier, once we have a unified |
5689 // system for weakness. For now we decided to keep it like this because having | 5857 // system for weakness. For now we decided to keep it like this because having |
5690 // an initial write barrier backed store makes this pointer strong until the | 5858 // an initial write barrier backed store makes this pointer strong until the |
5691 // next GC, and allocation sites are designed to survive several GCs anyway. | 5859 // next GC, and allocation sites are designed to survive several GCs anyway. |
5692 StoreObjectField(site, AllocationSite::kWeakNextOffset, next_site); | 5860 StoreObjectField(site, AllocationSite::kWeakNextOffset, next_site); |
5693 StoreNoWriteBarrier(MachineRepresentation::kTagged, site_list, site); | 5861 StoreNoWriteBarrier(MachineRepresentation::kTagged, site_list, site); |
5694 | 5862 |
5695 StoreFixedArrayElement(feedback_vector, slot, site, UPDATE_WRITE_BARRIER, | 5863 StoreFixedArrayElement(feedback_vector, slot, site, UPDATE_WRITE_BARRIER, 0, |
5696 CodeStubAssembler::SMI_PARAMETERS); | 5864 CodeStubAssembler::SMI_PARAMETERS); |
5697 return site; | 5865 return site; |
5698 } | 5866 } |
5699 | 5867 |
5700 Node* CodeStubAssembler::CreateWeakCellInFeedbackVector(Node* feedback_vector, | 5868 Node* CodeStubAssembler::CreateWeakCellInFeedbackVector(Node* feedback_vector, |
5701 Node* slot, | 5869 Node* slot, |
5702 Node* value) { | 5870 Node* value) { |
5703 Node* size = IntPtrConstant(WeakCell::kSize); | 5871 Node* size = IntPtrConstant(WeakCell::kSize); |
5704 Node* cell = Allocate(size, CodeStubAssembler::kPretenured); | 5872 Node* cell = Allocate(size, CodeStubAssembler::kPretenured); |
5705 | 5873 |
5706 // Initialize the WeakCell. | 5874 // Initialize the WeakCell. |
5707 StoreObjectFieldRoot(cell, WeakCell::kMapOffset, Heap::kWeakCellMapRootIndex); | 5875 StoreObjectFieldRoot(cell, WeakCell::kMapOffset, Heap::kWeakCellMapRootIndex); |
5708 StoreObjectField(cell, WeakCell::kValueOffset, value); | 5876 StoreObjectField(cell, WeakCell::kValueOffset, value); |
5709 StoreObjectFieldRoot(cell, WeakCell::kNextOffset, | 5877 StoreObjectFieldRoot(cell, WeakCell::kNextOffset, |
5710 Heap::kTheHoleValueRootIndex); | 5878 Heap::kTheHoleValueRootIndex); |
5711 | 5879 |
5712 // Store the WeakCell in the feedback vector. | 5880 // Store the WeakCell in the feedback vector. |
5713 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER, | 5881 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER, 0, |
5714 CodeStubAssembler::SMI_PARAMETERS); | 5882 CodeStubAssembler::SMI_PARAMETERS); |
5715 return cell; | 5883 return cell; |
5716 } | 5884 } |
5717 | 5885 |
5718 void CodeStubAssembler::BuildFastLoop( | 5886 void CodeStubAssembler::BuildFastLoop( |
5719 const CodeStubAssembler::VariableList& vars, | 5887 const CodeStubAssembler::VariableList& vars, |
5720 MachineRepresentation index_rep, Node* start_index, Node* end_index, | 5888 MachineRepresentation index_rep, Node* start_index, Node* end_index, |
5721 std::function<void(CodeStubAssembler* assembler, Node* index)> body, | 5889 std::function<void(CodeStubAssembler* assembler, Node* index)> body, |
5722 int increment, IndexAdvanceMode mode) { | 5890 int increment, IndexAdvanceMode mode) { |
5723 Variable var(this, index_rep); | 5891 Variable var(this, index_rep); |
(...skipping 1987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7711 | 7879 |
7712 compiler::Node* CodeStubAssembler::IsDebugActive() { | 7880 compiler::Node* CodeStubAssembler::IsDebugActive() { |
7713 Node* is_debug_active = Load( | 7881 Node* is_debug_active = Load( |
7714 MachineType::Uint8(), | 7882 MachineType::Uint8(), |
7715 ExternalConstant(ExternalReference::debug_is_active_address(isolate()))); | 7883 ExternalConstant(ExternalReference::debug_is_active_address(isolate()))); |
7716 return WordNotEqual(is_debug_active, Int32Constant(0)); | 7884 return WordNotEqual(is_debug_active, Int32Constant(0)); |
7717 } | 7885 } |
7718 | 7886 |
7719 } // namespace internal | 7887 } // namespace internal |
7720 } // namespace v8 | 7888 } // namespace v8 |
OLD | NEW |