OLD | NEW |
---|---|
1 // Copyright 2017 the V8 project authors. All rights reserved. | 1 // Copyright 2017 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/builtins/builtins-utils-gen.h" | 5 #include "src/builtins/builtins-utils-gen.h" |
6 #include "src/builtins/builtins.h" | 6 #include "src/builtins/builtins.h" |
7 #include "src/code-stub-assembler.h" | 7 #include "src/code-stub-assembler.h" |
8 #include "src/macro-assembler.h" | 8 #include "src/macro-assembler.h" |
9 #include "src/runtime/runtime.h" | 9 #include "src/runtime/runtime.h" |
10 | 10 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
157 // Allocate in old space (or large object space). | 157 // Allocate in old space (or large object space). |
158 TailCallRuntime(Runtime::kNewArgumentsElements, NoContextConstant(), | 158 TailCallRuntime(Runtime::kNewArgumentsElements, NoContextConstant(), |
159 BitcastWordToTagged(frame), SmiFromWord(length)); | 159 BitcastWordToTagged(frame), SmiFromWord(length)); |
160 } | 160 } |
161 } | 161 } |
162 | 162 |
163 TF_BUILTIN(ReturnReceiver, CodeStubAssembler) { | 163 TF_BUILTIN(ReturnReceiver, CodeStubAssembler) { |
164 Return(Parameter(Descriptor::kReceiver)); | 164 Return(Parameter(Descriptor::kReceiver)); |
165 } | 165 } |
166 | 166 |
167 class DeletePropertyBaseAssembler : public CodeStubAssembler { | |
168 public: | |
169 explicit DeletePropertyBaseAssembler(compiler::CodeAssemblerState* state) | |
170 : CodeStubAssembler(state) {} | |
171 | |
172 void DeleteDictionaryProperty(Node* receiver, Node* properties, Node* name, | |
173 Node* context, Label* dont_delete, | |
174 Label* notfound) { | |
175 VARIABLE(var_name_index, MachineType::PointerRepresentation()); | |
176 Label dictionary_found(this, &var_name_index); | |
177 NameDictionaryLookup<NameDictionary>(properties, name, &dictionary_found, | |
178 &var_name_index, notfound); | |
179 | |
180 BIND(&dictionary_found); | |
181 Node* key_index = var_name_index.value(); | |
182 Node* details = | |
183 LoadDetailsByKeyIndex<NameDictionary>(properties, key_index); | |
184 GotoIf(IsSetWord32(details, PropertyDetails::kAttributesDontDeleteMask), | |
185 dont_delete); | |
186 // Overwrite the entry itself (see NameDictionary::SetEntry). | |
187 Node* filler = TheHoleConstant(); | |
188 StoreFixedArrayElement(properties, key_index, filler); | |
Igor Sheludko
2017/04/20 09:18:42
TheHoleValue is in IMMORTAL_IMMOVABLE_ROOT_LIST so
Jakob Kummerow
2017/04/20 09:52:34
Done.
| |
189 StoreValueByKeyIndex<NameDictionary>(properties, key_index, filler); | |
Igor Sheludko
2017/04/20 09:18:42
and here.
Jakob Kummerow
2017/04/20 09:52:34
Done.
| |
190 StoreDetailsByKeyIndex<NameDictionary>(properties, key_index, | |
191 SmiConstant(Smi::kZero)); | |
192 | |
193 // Update bookkeeping information (see NameDictionary::ElementRemoved). | |
194 Node* nof = GetNumberOfElements<NameDictionary>(properties); | |
195 Node* new_nof = SmiSub(nof, SmiConstant(1)); | |
196 SetNumberOfElements<NameDictionary>(properties, new_nof); | |
197 Node* num_deleted = GetNumberOfDeletedElements<NameDictionary>(properties); | |
198 Node* new_deleted = SmiAdd(num_deleted, SmiConstant(1)); | |
199 SetNumberOfDeletedElements<NameDictionary>(properties, new_deleted); | |
200 | |
201 // Shrink the dictionary if necessary (see NameDictionary::Shrink). | |
202 Label shrinking_done(this); | |
203 Node* capacity = GetCapacity<NameDictionary>(properties); | |
204 GotoIf(SmiGreaterThan(new_nof, SmiShr(capacity, 2)), &shrinking_done); | |
205 GotoIf(SmiLessThan(new_nof, SmiConstant(16)), &shrinking_done); | |
206 CallRuntime(Runtime::kShrinkPropertyDictionary, context, receiver, name); | |
207 Goto(&shrinking_done); | |
208 BIND(&shrinking_done); | |
209 | |
210 Return(TrueConstant()); | |
211 } | |
212 }; | |
213 | |
214 TF_BUILTIN(DeleteProperty, DeletePropertyBaseAssembler) { | |
215 Node* receiver = Parameter(Descriptor::kObject); | |
216 Node* key = Parameter(Descriptor::kKey); | |
217 Node* language_mode = Parameter(Descriptor::kLanguageMode); | |
218 Node* context = Parameter(Descriptor::kContext); | |
219 | |
220 VARIABLE(var_index, MachineType::PointerRepresentation()); | |
221 VARIABLE(var_unique, MachineRepresentation::kTagged, key); | |
222 Label if_index(this), if_unique_name(this), if_notunique(this), | |
223 if_notfound(this), slow(this); | |
224 | |
225 GotoIf(TaggedIsSmi(receiver), &slow); | |
226 Node* receiver_map = LoadMap(receiver); | |
227 Node* instance_type = LoadMapInstanceType(receiver_map); | |
228 GotoIf(Int32LessThanOrEqual(instance_type, | |
229 Int32Constant(LAST_CUSTOM_ELEMENTS_RECEIVER)), | |
230 &slow); | |
231 TryToName(key, &if_index, &var_index, &if_unique_name, &var_unique, &slow, | |
232 &if_notunique); | |
233 | |
234 BIND(&if_index); | |
235 { | |
236 Comment("integer index"); | |
237 Goto(&slow); // TODO(jkummerow): Implement more smarts here. | |
238 } | |
239 | |
240 BIND(&if_unique_name); | |
241 { | |
242 Comment("key is unique name"); | |
243 Node* unique = var_unique.value(); | |
244 CheckForAssociatedProtector(unique, &slow); | |
245 | |
246 Label dictionary(this), dont_delete(this); | |
247 Node* properties = LoadProperties(receiver); | |
248 Node* properties_map = LoadMap(properties); | |
249 GotoIf(WordEqual(properties_map, LoadRoot(Heap::kHashTableMapRootIndex)), | |
250 &dictionary); | |
251 // TODO(jkummerow): Implement support for fast properties? | |
252 Goto(&slow); | |
253 | |
254 BIND(&dictionary); | |
255 { | |
256 DeleteDictionaryProperty(receiver, properties, unique, context, | |
257 &dont_delete, &if_notfound); | |
258 } | |
259 | |
260 BIND(&dont_delete); | |
261 { | |
262 GotoIf(SmiEqual(language_mode, SmiConstant(STRICT)), &slow); | |
Igor Sheludko
2017/04/20 09:18:42
is_strict(lm) is implemented as lm != SLOPPY which
Jakob Kummerow
2017/04/20 09:52:34
Done.
| |
263 Return(FalseConstant()); | |
264 } | |
265 } | |
266 | |
267 BIND(&if_notunique); | |
268 { | |
269 // If the string was not found in the string table, then no object can | |
270 // have a property with that name. | |
271 TryInternalizeString(key, &if_index, &var_index, &if_unique_name, | |
272 &var_unique, &if_notfound, &slow); | |
273 } | |
274 | |
275 BIND(&if_notfound); | |
276 { Return(TrueConstant()); } | |
Igor Sheludko
2017/04/20 09:18:42
I think this line will look nicer without {}.
Jakob Kummerow
2017/04/20 09:52:34
Done.
| |
277 | |
278 BIND(&slow); | |
279 { | |
280 TailCallRuntime(Runtime::kDeleteProperty, context, receiver, key, | |
281 language_mode); | |
282 } | |
283 } | |
284 | |
167 } // namespace internal | 285 } // namespace internal |
168 } // namespace v8 | 286 } // namespace v8 |
OLD | NEW |