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/objects.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 | « 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);
3465 // Either new_map adds an kDescriptor property, or a kField property for 3461 // Either new_map adds an kDescriptor property, or a kField property for
3466 // which there is still space, and which does not require a mutable double 3462 // which there is still space, and which does not require a mutable double
3467 // box (an out-of-object double). 3463 // box (an out-of-object double).
3468 if (details.location() == kDescriptor || 3464 if (details.location() == kDescriptor ||
3469 (have_space && 3465 (old_map->unused_property_fields() > 0 &&
3470 ((FLAG_unbox_double_fields && object->properties()->length() == 0) || 3466 ((FLAG_unbox_double_fields && object->properties()->length() == 0) ||
3471 !details.representation().IsDouble()))) { 3467 !details.representation().IsDouble()))) {
3472 object->synchronized_set_map(*new_map); 3468 object->synchronized_set_map(*new_map);
3473 return; 3469 return;
3474 } 3470 }
3475 3471
3476 // If there is still space in the object, we need to allocate a mutable 3472 // If there is still space in the object, we need to allocate a mutable
3477 // double box. 3473 // double box.
3478 if (have_space) { 3474 if (old_map->unused_property_fields() > 0) {
3479 FieldIndex index = 3475 FieldIndex index =
3480 FieldIndex::ForDescriptor(*new_map, new_map->LastAdded()); 3476 FieldIndex::ForDescriptor(*new_map, new_map->LastAdded());
3481 DCHECK(details.representation().IsDouble()); 3477 DCHECK(details.representation().IsDouble());
3482 DCHECK(!new_map->IsUnboxedDoubleField(index)); 3478 DCHECK(!new_map->IsUnboxedDoubleField(index));
3483 Handle<Object> value = isolate->factory()->NewMutableHeapNumber(); 3479 Handle<Object> value = isolate->factory()->NewMutableHeapNumber();
3484 object->RawFastPropertyAtPut(index, *value); 3480 object->RawFastPropertyAtPut(index, *value);
3485 object->synchronized_set_map(*new_map); 3481 object->synchronized_set_map(*new_map);
3486 return; 3482 return;
3487 } 3483 }
3488 3484
3489 // This migration is a transition from a map that has run out of property 3485 // This migration is a transition from a map that has run out of property
3490 // space. Extend the backing store. 3486 // space. Extend the backing store.
3491 int grow_by = new_map->unused_property_fields() + 1; 3487 int grow_by = new_map->unused_property_fields() + 1;
3492 Handle<FixedArray> old_storage = handle(object->properties(), isolate); 3488 Handle<FixedArray> old_storage = handle(object->properties(), isolate);
3493 Handle<FixedArray> new_storage = 3489 Handle<FixedArray> new_storage =
3494 isolate->factory()->CopyFixedArrayAndGrow(old_storage, grow_by); 3490 isolate->factory()->CopyFixedArrayAndGrow(old_storage, grow_by);
3495 3491
3496 // Properly initialize newly added property. 3492 // Properly initialize newly added property.
3497 Handle<Object> value; 3493 Handle<Object> value;
3498 if (details.representation().IsDouble()) { 3494 if (details.representation().IsDouble()) {
3499 value = isolate->factory()->NewMutableHeapNumber(); 3495 value = isolate->factory()->NewMutableHeapNumber();
3500 } else { 3496 } else {
3501 value = isolate->factory()->uninitialized_value(); 3497 value = isolate->factory()->uninitialized_value();
3502 } 3498 }
3503 DCHECK_EQ(kField, details.location()); 3499 DCHECK_EQ(kField, details.location());
3504 DCHECK_EQ(kData, details.kind()); 3500 DCHECK_EQ(kData, details.kind());
3501 int target_index = details.field_index() - new_map->GetInObjectProperties();
3505 DCHECK(target_index >= 0); // Must be a backing store index. 3502 DCHECK(target_index >= 0); // Must be a backing store index.
3506 new_storage->set(target_index, *value); 3503 new_storage->set(target_index, *value);
3507 3504
3508 // From here on we cannot fail and we shouldn't GC anymore. 3505 // From here on we cannot fail and we shouldn't GC anymore.
3509 DisallowHeapAllocation no_allocation; 3506 DisallowHeapAllocation no_allocation;
3510 3507
3511 // Set the new property value and do the map transition. 3508 // Set the new property value and do the map transition.
3512 object->set_properties(*new_storage); 3509 object->set_properties(*new_storage);
3513 object->synchronized_set_map(*new_map); 3510 object->synchronized_set_map(*new_map);
3514 return; 3511 return;
(...skipping 17162 matching lines...) Expand 10 before | Expand all | Expand 10 after
20677 // depend on this. 20674 // depend on this.
20678 return DICTIONARY_ELEMENTS; 20675 return DICTIONARY_ELEMENTS;
20679 } 20676 }
20680 DCHECK_LE(kind, LAST_ELEMENTS_KIND); 20677 DCHECK_LE(kind, LAST_ELEMENTS_KIND);
20681 return kind; 20678 return kind;
20682 } 20679 }
20683 } 20680 }
20684 20681
20685 } // namespace internal 20682 } // namespace internal
20686 } // namespace v8 20683 } // 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