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

Side by Side Diff: src/builtins/builtins-internal-gen.cc

Issue 2843473002: Revert of [builtins] DeleteProperty: Handle last-added fast properties (Closed)
Patch Set: Created 3 years, 8 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 | « no previous file | src/compiler/js-native-context-specialization.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 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 { 167 class DeletePropertyBaseAssembler : public CodeStubAssembler {
168 public: 168 public:
169 explicit DeletePropertyBaseAssembler(compiler::CodeAssemblerState* state) 169 explicit DeletePropertyBaseAssembler(compiler::CodeAssemblerState* state)
170 : CodeStubAssembler(state) {} 170 : CodeStubAssembler(state) {}
171 171
172 void DeleteFastProperty(Node* receiver, Node* receiver_map, Node* properties,
173 Node* name, Label* dont_delete, Label* not_found,
174 Label* slow) {
175 // This builtin implements a special case for fast property deletion:
176 // when the last property in an object is deleted, then instead of
177 // normalizing the properties, we can undo the last map transition,
178 // with a few prerequisites:
179 // (1) The current map must not be marked stable. Otherwise there could
180 // be optimized code that depends on the assumption that no object that
181 // reached this map transitions away from it (without triggering the
182 // "deoptimize dependent code" mechanism).
183 Node* bitfield3 = LoadMapBitField3(receiver_map);
184 GotoIfNot(IsSetWord32<Map::IsUnstable>(bitfield3), slow);
185 // (2) The property to be deleted must be the last property.
186 Node* descriptors = LoadMapDescriptors(receiver_map);
187 Node* nof = DecodeWord32<Map::NumberOfOwnDescriptorsBits>(bitfield3);
188 GotoIf(Word32Equal(nof, Int32Constant(0)), not_found);
189 Node* descriptor_number = Int32Sub(nof, Int32Constant(1));
190 Node* key_index = DescriptorArrayToKeyIndex(descriptor_number);
191 Node* actual_key = LoadFixedArrayElement(descriptors, key_index);
192 // TODO(jkummerow): We could implement full descriptor search in order
193 // to avoid the runtime call for deleting nonexistent properties, but
194 // that's probably a rare case.
195 GotoIf(WordNotEqual(actual_key, name), slow);
196 // (3) The property to be deleted must be deletable.
197 Node* details =
198 LoadDetailsByKeyIndex<DescriptorArray>(descriptors, key_index);
199 GotoIf(IsSetWord32(details, PropertyDetails::kAttributesDontDeleteMask),
200 dont_delete);
201 // (4) The map must have a back pointer.
202 Node* backpointer =
203 LoadObjectField(receiver_map, Map::kConstructorOrBackPointerOffset);
204 GotoIfNot(IsMap(backpointer), slow);
205 // (5) The last transition must have been caused by adding a property
206 // (and not any kind of special transition).
207 Node* previous_nof = DecodeWord32<Map::NumberOfOwnDescriptorsBits>(
208 LoadMapBitField3(backpointer));
209 GotoIfNot(Word32Equal(previous_nof, descriptor_number), slow);
210
211 // Preconditions successful, perform the map rollback!
212 // Zap the property to avoid keeping objects alive.
213 // Zapping is not necessary for properties stored in the descriptor array.
214 Label zapping_done(this);
215 GotoIf(Word32NotEqual(DecodeWord32<PropertyDetails::LocationField>(details),
216 Int32Constant(kField)),
217 &zapping_done);
218 Node* field_index =
219 DecodeWordFromWord32<PropertyDetails::FieldIndexField>(details);
220 Node* inobject_properties = LoadMapInobjectProperties(receiver_map);
221 Label inobject(this), backing_store(this);
222 // We don't need to special-case inobject slack tracking here (by using
223 // the one_pointer_filler_map as filler), because it'll trim objects to
224 // the size of the largest known map anyway, so rolled-back properties
225 // can be zapped with |undefined|.
226 Node* filler = UndefinedConstant();
227 DCHECK(Heap::RootIsImmortalImmovable(Heap::kUndefinedValueRootIndex));
228 Branch(UintPtrLessThan(field_index, inobject_properties), &inobject,
229 &backing_store);
230 BIND(&inobject);
231 {
232 Node* field_offset =
233 IntPtrMul(IntPtrSub(LoadMapInstanceSize(receiver_map),
234 IntPtrSub(inobject_properties, field_index)),
235 IntPtrConstant(kPointerSize));
236 StoreObjectFieldNoWriteBarrier(receiver, field_offset, filler);
237 Goto(&zapping_done);
238 }
239 BIND(&backing_store);
240 {
241 Node* backing_store_index = IntPtrSub(field_index, inobject_properties);
242 StoreFixedArrayElement(properties, backing_store_index, filler,
243 SKIP_WRITE_BARRIER);
244 Goto(&zapping_done);
245 }
246 BIND(&zapping_done);
247 StoreMap(receiver, backpointer);
248 Return(TrueConstant());
249 }
250
251 void DeleteDictionaryProperty(Node* receiver, Node* properties, Node* name, 172 void DeleteDictionaryProperty(Node* receiver, Node* properties, Node* name,
252 Node* context, Label* dont_delete, 173 Node* context, Label* dont_delete,
253 Label* notfound) { 174 Label* notfound) {
254 VARIABLE(var_name_index, MachineType::PointerRepresentation()); 175 VARIABLE(var_name_index, MachineType::PointerRepresentation());
255 Label dictionary_found(this, &var_name_index); 176 Label dictionary_found(this, &var_name_index);
256 NameDictionaryLookup<NameDictionary>(properties, name, &dictionary_found, 177 NameDictionaryLookup<NameDictionary>(properties, name, &dictionary_found,
257 &var_name_index, notfound); 178 &var_name_index, notfound);
258 179
259 BIND(&dictionary_found); 180 BIND(&dictionary_found);
260 Node* key_index = var_name_index.value(); 181 Node* key_index = var_name_index.value();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 { 243 {
323 Comment("key is unique name"); 244 Comment("key is unique name");
324 Node* unique = var_unique.value(); 245 Node* unique = var_unique.value();
325 CheckForAssociatedProtector(unique, &slow); 246 CheckForAssociatedProtector(unique, &slow);
326 247
327 Label dictionary(this), dont_delete(this); 248 Label dictionary(this), dont_delete(this);
328 Node* properties = LoadProperties(receiver); 249 Node* properties = LoadProperties(receiver);
329 Node* properties_map = LoadMap(properties); 250 Node* properties_map = LoadMap(properties);
330 GotoIf(WordEqual(properties_map, LoadRoot(Heap::kHashTableMapRootIndex)), 251 GotoIf(WordEqual(properties_map, LoadRoot(Heap::kHashTableMapRootIndex)),
331 &dictionary); 252 &dictionary);
332 DeleteFastProperty(receiver, receiver_map, properties, unique, &dont_delete, 253 // TODO(jkummerow): Implement support for fast properties?
333 &if_notfound, &slow); 254 Goto(&slow);
334 255
335 BIND(&dictionary); 256 BIND(&dictionary);
336 { 257 {
337 DeleteDictionaryProperty(receiver, properties, unique, context, 258 DeleteDictionaryProperty(receiver, properties, unique, context,
338 &dont_delete, &if_notfound); 259 &dont_delete, &if_notfound);
339 } 260 }
340 261
341 BIND(&dont_delete); 262 BIND(&dont_delete);
342 { 263 {
343 STATIC_ASSERT(LANGUAGE_END == 2); 264 STATIC_ASSERT(LANGUAGE_END == 2);
(...skipping 15 matching lines...) Expand all
359 280
360 BIND(&slow); 281 BIND(&slow);
361 { 282 {
362 TailCallRuntime(Runtime::kDeleteProperty, context, receiver, key, 283 TailCallRuntime(Runtime::kDeleteProperty, context, receiver, key,
363 language_mode); 284 language_mode);
364 } 285 }
365 } 286 }
366 287
367 } // namespace internal 288 } // namespace internal
368 } // namespace v8 289 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler/js-native-context-specialization.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698