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

Side by Side Diff: src/objects.cc

Issue 2840583002: Reland of [builtins] DeleteProperty: Handle last-added fast properties (Closed)
Patch Set: fix: use OnePointerFiller 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 | « src/ic/accessor-assembler.cc ('k') | test/mjsunit/dictionary-properties.js » ('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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/objects.h" 5 #include "src/objects.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <iomanip> 8 #include <iomanip>
9 #include <memory> 9 #include <memory>
10 #include <sstream> 10 #include <sstream>
(...skipping 3440 matching lines...) Expand 10 before | Expand all | Expand 10 after
3451 // In case of a regular transition. 3451 // In case of a regular transition.
3452 if (new_map->GetBackPointer() == *old_map) { 3452 if (new_map->GetBackPointer() == *old_map) {
3453 // If the map does not add named properties, simply set the map. 3453 // If the map does not add named properties, simply set the map.
3454 if (old_map->NumberOfOwnDescriptors() == 3454 if (old_map->NumberOfOwnDescriptors() ==
3455 new_map->NumberOfOwnDescriptors()) { 3455 new_map->NumberOfOwnDescriptors()) {
3456 object->synchronized_set_map(*new_map); 3456 object->synchronized_set_map(*new_map);
3457 return; 3457 return;
3458 } 3458 }
3459 3459
3460 PropertyDetails details = new_map->GetLastDescriptorDetails(); 3460 PropertyDetails details = new_map->GetLastDescriptorDetails();
3461 int target_index = details.field_index() - new_map->GetInObjectProperties();
3462 bool have_space = old_map->unused_property_fields() > 0 ||
3463 (details.location() == kField && target_index >= 0 &&
3464 object->properties()->length() > target_index);
3461 // Either new_map adds an kDescriptor property, or a kField property for 3465 // Either new_map adds an kDescriptor property, or a kField property for
3462 // which there is still space, and which does not require a mutable double 3466 // which there is still space, and which does not require a mutable double
3463 // box (an out-of-object double). 3467 // box (an out-of-object double).
3464 if (details.location() == kDescriptor || 3468 if (details.location() == kDescriptor ||
3465 (old_map->unused_property_fields() > 0 && 3469 (have_space &&
3466 ((FLAG_unbox_double_fields && object->properties()->length() == 0) || 3470 ((FLAG_unbox_double_fields && object->properties()->length() == 0) ||
3467 !details.representation().IsDouble()))) { 3471 !details.representation().IsDouble()))) {
3468 object->synchronized_set_map(*new_map); 3472 object->synchronized_set_map(*new_map);
3469 return; 3473 return;
3470 } 3474 }
3471 3475
3472 // If there is still space in the object, we need to allocate a mutable 3476 // If there is still space in the object, we need to allocate a mutable
3473 // double box. 3477 // double box.
3474 if (old_map->unused_property_fields() > 0) { 3478 if (have_space) {
3475 FieldIndex index = 3479 FieldIndex index =
3476 FieldIndex::ForDescriptor(*new_map, new_map->LastAdded()); 3480 FieldIndex::ForDescriptor(*new_map, new_map->LastAdded());
3477 DCHECK(details.representation().IsDouble()); 3481 DCHECK(details.representation().IsDouble());
3478 DCHECK(!new_map->IsUnboxedDoubleField(index)); 3482 DCHECK(!new_map->IsUnboxedDoubleField(index));
3479 Handle<Object> value = isolate->factory()->NewMutableHeapNumber(); 3483 Handle<Object> value = isolate->factory()->NewMutableHeapNumber();
3480 object->RawFastPropertyAtPut(index, *value); 3484 object->RawFastPropertyAtPut(index, *value);
3481 object->synchronized_set_map(*new_map); 3485 object->synchronized_set_map(*new_map);
3482 return; 3486 return;
3483 } 3487 }
3484 3488
3485 // This migration is a transition from a map that has run out of property 3489 // This migration is a transition from a map that has run out of property
3486 // space. Extend the backing store. 3490 // space. Extend the backing store.
3487 int grow_by = new_map->unused_property_fields() + 1; 3491 int grow_by = new_map->unused_property_fields() + 1;
3488 Handle<FixedArray> old_storage = handle(object->properties(), isolate); 3492 Handle<FixedArray> old_storage = handle(object->properties(), isolate);
3489 Handle<FixedArray> new_storage = 3493 Handle<FixedArray> new_storage =
3490 isolate->factory()->CopyFixedArrayAndGrow(old_storage, grow_by); 3494 isolate->factory()->CopyFixedArrayAndGrow(old_storage, grow_by);
3491 3495
3492 // Properly initialize newly added property. 3496 // Properly initialize newly added property.
3493 Handle<Object> value; 3497 Handle<Object> value;
3494 if (details.representation().IsDouble()) { 3498 if (details.representation().IsDouble()) {
3495 value = isolate->factory()->NewMutableHeapNumber(); 3499 value = isolate->factory()->NewMutableHeapNumber();
3496 } else { 3500 } else {
3497 value = isolate->factory()->uninitialized_value(); 3501 value = isolate->factory()->uninitialized_value();
3498 } 3502 }
3499 DCHECK_EQ(kField, details.location()); 3503 DCHECK_EQ(kField, details.location());
3500 DCHECK_EQ(kData, details.kind()); 3504 DCHECK_EQ(kData, details.kind());
3501 int target_index = details.field_index() - new_map->GetInObjectProperties();
3502 DCHECK(target_index >= 0); // Must be a backing store index. 3505 DCHECK(target_index >= 0); // Must be a backing store index.
3503 new_storage->set(target_index, *value); 3506 new_storage->set(target_index, *value);
3504 3507
3505 // From here on we cannot fail and we shouldn't GC anymore. 3508 // From here on we cannot fail and we shouldn't GC anymore.
3506 DisallowHeapAllocation no_allocation; 3509 DisallowHeapAllocation no_allocation;
3507 3510
3508 // Set the new property value and do the map transition. 3511 // Set the new property value and do the map transition.
3509 object->set_properties(*new_storage); 3512 object->set_properties(*new_storage);
3510 object->synchronized_set_map(*new_map); 3513 object->synchronized_set_map(*new_map);
3511 return; 3514 return;
(...skipping 17158 matching lines...) Expand 10 before | Expand all | Expand 10 after
20670 // depend on this. 20673 // depend on this.
20671 return DICTIONARY_ELEMENTS; 20674 return DICTIONARY_ELEMENTS;
20672 } 20675 }
20673 DCHECK_LE(kind, LAST_ELEMENTS_KIND); 20676 DCHECK_LE(kind, LAST_ELEMENTS_KIND);
20674 return kind; 20677 return kind;
20675 } 20678 }
20676 } 20679 }
20677 20680
20678 } // namespace internal 20681 } // namespace internal
20679 } // namespace v8 20682 } // namespace v8
OLDNEW
« no previous file with comments | « src/ic/accessor-assembler.cc ('k') | test/mjsunit/dictionary-properties.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698