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

Side by Side Diff: src/elements.cc

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

Powered by Google App Engine
This is Rietveld 408576698