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

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

Issue 2830093002: [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
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 e.g. an elements kind change).
Igor Sheludko 2017/04/21 14:17:50 (and not any kind of special transition).
Jakob Kummerow 2017/04/21 17:49:30 Done.
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 Branch(UintPtrLessThan(field_index, inobject_properties), &inobject,
228 &backing_store);
229 BIND(&inobject);
230 {
231 Node* field_offset =
232 IntPtrMul(IntPtrSub(LoadMapInstanceSize(receiver_map),
233 IntPtrSub(inobject_properties, field_index)),
234 IntPtrConstant(kPointerSize));
235 StoreObjectField(receiver, field_offset, filler);
Igor Sheludko 2017/04/21 14:20:49 ... and here.
Jakob Kummerow 2017/04/21 17:49:31 Done.
236 Goto(&zapping_done);
237 }
238 BIND(&backing_store);
239 {
240 Node* backing_store_index = IntPtrSub(field_index, inobject_properties);
241 StoreFixedArrayElement(properties, backing_store_index, filler);
Igor Sheludko 2017/04/21 14:17:50 We can skip write barrier here because UndefinedVa
Jakob Kummerow 2017/04/21 17:49:31 Done.
242 Goto(&zapping_done);
243 }
244 BIND(&zapping_done);
245 StoreMap(receiver, backpointer);
246 Return(TrueConstant());
247 }
248
172 void DeleteDictionaryProperty(Node* receiver, Node* properties, Node* name, 249 void DeleteDictionaryProperty(Node* receiver, Node* properties, Node* name,
173 Node* context, Label* dont_delete, 250 Node* context, Label* dont_delete,
174 Label* notfound) { 251 Label* notfound) {
175 VARIABLE(var_name_index, MachineType::PointerRepresentation()); 252 VARIABLE(var_name_index, MachineType::PointerRepresentation());
176 Label dictionary_found(this, &var_name_index); 253 Label dictionary_found(this, &var_name_index);
177 NameDictionaryLookup<NameDictionary>(properties, name, &dictionary_found, 254 NameDictionaryLookup<NameDictionary>(properties, name, &dictionary_found,
178 &var_name_index, notfound); 255 &var_name_index, notfound);
179 256
180 BIND(&dictionary_found); 257 BIND(&dictionary_found);
181 Node* key_index = var_name_index.value(); 258 Node* key_index = var_name_index.value();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 { 320 {
244 Comment("key is unique name"); 321 Comment("key is unique name");
245 Node* unique = var_unique.value(); 322 Node* unique = var_unique.value();
246 CheckForAssociatedProtector(unique, &slow); 323 CheckForAssociatedProtector(unique, &slow);
247 324
248 Label dictionary(this), dont_delete(this); 325 Label dictionary(this), dont_delete(this);
249 Node* properties = LoadProperties(receiver); 326 Node* properties = LoadProperties(receiver);
250 Node* properties_map = LoadMap(properties); 327 Node* properties_map = LoadMap(properties);
251 GotoIf(WordEqual(properties_map, LoadRoot(Heap::kHashTableMapRootIndex)), 328 GotoIf(WordEqual(properties_map, LoadRoot(Heap::kHashTableMapRootIndex)),
252 &dictionary); 329 &dictionary);
253 // TODO(jkummerow): Implement support for fast properties? 330 DeleteFastProperty(receiver, receiver_map, properties, unique, &dont_delete,
254 Goto(&slow); 331 &if_notfound, &slow);
255 332
256 BIND(&dictionary); 333 BIND(&dictionary);
257 { 334 {
258 DeleteDictionaryProperty(receiver, properties, unique, context, 335 DeleteDictionaryProperty(receiver, properties, unique, context,
259 &dont_delete, &if_notfound); 336 &dont_delete, &if_notfound);
260 } 337 }
261 338
262 BIND(&dont_delete); 339 BIND(&dont_delete);
263 { 340 {
264 STATIC_ASSERT(LANGUAGE_END == 2); 341 STATIC_ASSERT(LANGUAGE_END == 2);
(...skipping 15 matching lines...) Expand all
280 357
281 BIND(&slow); 358 BIND(&slow);
282 { 359 {
283 TailCallRuntime(Runtime::kDeleteProperty, context, receiver, key, 360 TailCallRuntime(Runtime::kDeleteProperty, context, receiver, key,
284 language_mode); 361 language_mode);
285 } 362 }
286 } 363 }
287 364
288 } // namespace internal 365 } // namespace internal
289 } // namespace v8 366 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler/js-native-context-specialization.cc » ('j') | src/ic/accessor-assembler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698