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

Side by Side Diff: src/elements.cc

Issue 2538693002: Revert of [ic] Use validity cells to protect keyed element stores against object's prototype chain… (Closed)
Patch Set: Created 4 years 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/compiler/types.cc ('k') | src/factory.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/elements.h" 5 #include "src/elements.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/conversions.h" 8 #include "src/conversions.h"
9 #include "src/factory.h" 9 #include "src/factory.h"
10 #include "src/isolate-inl.h" 10 #include "src/isolate-inl.h"
(...skipping 1413 matching lines...) Expand 10 before | Expand all | Expand 10 after
1424 1424
1425 static void AddImpl(Handle<JSObject> object, uint32_t index, 1425 static void AddImpl(Handle<JSObject> object, uint32_t index,
1426 Handle<Object> value, PropertyAttributes attributes, 1426 Handle<Object> value, PropertyAttributes attributes,
1427 uint32_t new_capacity) { 1427 uint32_t new_capacity) {
1428 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell); 1428 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell);
1429 Handle<SeededNumberDictionary> dictionary = 1429 Handle<SeededNumberDictionary> dictionary =
1430 object->HasFastElements() || object->HasFastStringWrapperElements() 1430 object->HasFastElements() || object->HasFastStringWrapperElements()
1431 ? JSObject::NormalizeElements(object) 1431 ? JSObject::NormalizeElements(object)
1432 : handle(SeededNumberDictionary::cast(object->elements())); 1432 : handle(SeededNumberDictionary::cast(object->elements()));
1433 Handle<SeededNumberDictionary> new_dictionary = 1433 Handle<SeededNumberDictionary> new_dictionary =
1434 SeededNumberDictionary::AddNumberEntry(dictionary, index, value, 1434 SeededNumberDictionary::AddNumberEntry(
1435 details, object); 1435 dictionary, index, value, details,
1436 object->map()->is_prototype_map());
1436 if (attributes != NONE) object->RequireSlowElements(*new_dictionary); 1437 if (attributes != NONE) object->RequireSlowElements(*new_dictionary);
1437 if (dictionary.is_identical_to(new_dictionary)) return; 1438 if (dictionary.is_identical_to(new_dictionary)) return;
1438 object->set_elements(*new_dictionary); 1439 object->set_elements(*new_dictionary);
1439 } 1440 }
1440 1441
1441 static bool HasEntryImpl(Isolate* isolate, FixedArrayBase* store, 1442 static bool HasEntryImpl(Isolate* isolate, FixedArrayBase* store,
1442 uint32_t entry) { 1443 uint32_t entry) {
1443 DisallowHeapAllocation no_gc; 1444 DisallowHeapAllocation no_gc;
1444 SeededNumberDictionary* dict = SeededNumberDictionary::cast(store); 1445 SeededNumberDictionary* dict = SeededNumberDictionary::cast(store);
1445 Object* index = dict->KeyAt(entry); 1446 Object* index = dict->KeyAt(entry);
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1765 // normalizing. 1766 // normalizing.
1766 if (IsFastSmiOrObjectElementsKind(kind)) { 1767 if (IsFastSmiOrObjectElementsKind(kind)) {
1767 isolate->UpdateArrayProtectorOnNormalizeElements(object); 1768 isolate->UpdateArrayProtectorOnNormalizeElements(object);
1768 } 1769 }
1769 1770
1770 int capacity = object->GetFastElementsUsage(); 1771 int capacity = object->GetFastElementsUsage();
1771 Handle<SeededNumberDictionary> dictionary = 1772 Handle<SeededNumberDictionary> dictionary =
1772 SeededNumberDictionary::New(isolate, capacity); 1773 SeededNumberDictionary::New(isolate, capacity);
1773 1774
1774 PropertyDetails details = PropertyDetails::Empty(); 1775 PropertyDetails details = PropertyDetails::Empty();
1776 bool used_as_prototype = object->map()->is_prototype_map();
1775 int j = 0; 1777 int j = 0;
1776 for (int i = 0; j < capacity; i++) { 1778 for (int i = 0; j < capacity; i++) {
1777 if (IsHoleyElementsKind(kind)) { 1779 if (IsHoleyElementsKind(kind)) {
1778 if (BackingStore::cast(*store)->is_the_hole(isolate, i)) continue; 1780 if (BackingStore::cast(*store)->is_the_hole(isolate, i)) continue;
1779 } 1781 }
1780 Handle<Object> value = Subclass::GetImpl(isolate, *store, i); 1782 Handle<Object> value = Subclass::GetImpl(isolate, *store, i);
1781 dictionary = SeededNumberDictionary::AddNumberEntry(dictionary, i, value, 1783 dictionary = SeededNumberDictionary::AddNumberEntry(
1782 details, object); 1784 dictionary, i, value, details, used_as_prototype);
1783 j++; 1785 j++;
1784 } 1786 }
1785 return dictionary; 1787 return dictionary;
1786 } 1788 }
1787 1789
1788 static void DeleteAtEnd(Handle<JSObject> obj, 1790 static void DeleteAtEnd(Handle<JSObject> obj,
1789 Handle<BackingStore> backing_store, uint32_t entry) { 1791 Handle<BackingStore> backing_store, uint32_t entry) {
1790 uint32_t length = static_cast<uint32_t>(backing_store->length()); 1792 uint32_t length = static_cast<uint32_t>(backing_store->length());
1791 Isolate* isolate = obj->GetIsolate(); 1793 Isolate* isolate = obj->GetIsolate();
1792 for (; entry > 0; entry--) { 1794 for (; entry > 0; entry--) {
(...skipping 1474 matching lines...) Expand 10 before | Expand all | Expand 10 after
3267 uint32_t new_capacity) { 3269 uint32_t new_capacity) {
3268 Handle<FixedArray> parameter_map(FixedArray::cast(object->elements())); 3270 Handle<FixedArray> parameter_map(FixedArray::cast(object->elements()));
3269 Handle<FixedArrayBase> old_elements( 3271 Handle<FixedArrayBase> old_elements(
3270 FixedArrayBase::cast(parameter_map->get(1))); 3272 FixedArrayBase::cast(parameter_map->get(1)));
3271 Handle<SeededNumberDictionary> dictionary = 3273 Handle<SeededNumberDictionary> dictionary =
3272 old_elements->IsSeededNumberDictionary() 3274 old_elements->IsSeededNumberDictionary()
3273 ? Handle<SeededNumberDictionary>::cast(old_elements) 3275 ? Handle<SeededNumberDictionary>::cast(old_elements)
3274 : JSObject::NormalizeElements(object); 3276 : JSObject::NormalizeElements(object);
3275 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell); 3277 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell);
3276 Handle<SeededNumberDictionary> new_dictionary = 3278 Handle<SeededNumberDictionary> new_dictionary =
3277 SeededNumberDictionary::AddNumberEntry(dictionary, index, value, 3279 SeededNumberDictionary::AddNumberEntry(
3278 details, object); 3280 dictionary, index, value, details,
3281 object->map()->is_prototype_map());
3279 if (attributes != NONE) object->RequireSlowElements(*new_dictionary); 3282 if (attributes != NONE) object->RequireSlowElements(*new_dictionary);
3280 if (*dictionary != *new_dictionary) { 3283 if (*dictionary != *new_dictionary) {
3281 FixedArray::cast(object->elements())->set(1, *new_dictionary); 3284 FixedArray::cast(object->elements())->set(1, *new_dictionary);
3282 } 3285 }
3283 } 3286 }
3284 3287
3285 static void ReconfigureImpl(Handle<JSObject> object, 3288 static void ReconfigureImpl(Handle<JSObject> object,
3286 Handle<FixedArrayBase> store, uint32_t entry, 3289 Handle<FixedArrayBase> store, uint32_t entry,
3287 Handle<Object> value, 3290 Handle<Object> value,
3288 PropertyAttributes attributes) { 3291 PropertyAttributes attributes) {
(...skipping 12 matching lines...) Expand all
3301 parameter_map->set_the_hole(isolate, entry + 2); 3304 parameter_map->set_the_hole(isolate, entry + 2);
3302 // For elements that are still writable we re-establish slow aliasing. 3305 // For elements that are still writable we re-establish slow aliasing.
3303 if ((attributes & READ_ONLY) == 0) { 3306 if ((attributes & READ_ONLY) == 0) {
3304 value = isolate->factory()->NewAliasedArgumentsEntry(context_entry); 3307 value = isolate->factory()->NewAliasedArgumentsEntry(context_entry);
3305 } 3308 }
3306 3309
3307 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell); 3310 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell);
3308 Handle<SeededNumberDictionary> arguments( 3311 Handle<SeededNumberDictionary> arguments(
3309 SeededNumberDictionary::cast(parameter_map->get(1)), isolate); 3312 SeededNumberDictionary::cast(parameter_map->get(1)), isolate);
3310 arguments = SeededNumberDictionary::AddNumberEntry( 3313 arguments = SeededNumberDictionary::AddNumberEntry(
3311 arguments, entry, value, details, object); 3314 arguments, entry, value, details, object->map()->is_prototype_map());
3312 // If the attributes were NONE, we would have called set rather than 3315 // If the attributes were NONE, we would have called set rather than
3313 // reconfigure. 3316 // reconfigure.
3314 DCHECK_NE(NONE, attributes); 3317 DCHECK_NE(NONE, attributes);
3315 object->RequireSlowElements(*arguments); 3318 object->RequireSlowElements(*arguments);
3316 parameter_map->set(1, *arguments); 3319 parameter_map->set(1, *arguments);
3317 } else { 3320 } else {
3318 Handle<FixedArrayBase> arguments( 3321 Handle<FixedArrayBase> arguments(
3319 FixedArrayBase::cast(parameter_map->get(1)), isolate); 3322 FixedArrayBase::cast(parameter_map->get(1)), isolate);
3320 DictionaryElementsAccessor::ReconfigureImpl( 3323 DictionaryElementsAccessor::ReconfigureImpl(
3321 object, arguments, entry - length, value, attributes); 3324 object, arguments, entry - length, value, attributes);
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
3853 insertion_index += len; 3856 insertion_index += len;
3854 } 3857 }
3855 3858
3856 DCHECK_EQ(insertion_index, result_len); 3859 DCHECK_EQ(insertion_index, result_len);
3857 return result_array; 3860 return result_array;
3858 } 3861 }
3859 3862
3860 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; 3863 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL;
3861 } // namespace internal 3864 } // namespace internal
3862 } // namespace v8 3865 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/types.cc ('k') | src/factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698