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

Side by Side Diff: src/elements.cc

Issue 1228113003: Fix non-standard element handling (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix and expand tests Created 5 years, 5 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 | « no previous file | src/lookup.cc » ('j') | src/lookup.cc » ('J')
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/v8.h" 5 #include "src/v8.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/elements.h" 9 #include "src/elements.h"
10 #include "src/messages.h" 10 #include "src/messages.h"
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 942
943 static void SetImpl(FixedArrayBase* store, uint32_t entry, Object* value) { 943 static void SetImpl(FixedArrayBase* store, uint32_t entry, Object* value) {
944 SeededNumberDictionary* dictionary = SeededNumberDictionary::cast(store); 944 SeededNumberDictionary* dictionary = SeededNumberDictionary::cast(store);
945 dictionary->ValueAtPut(entry, value); 945 dictionary->ValueAtPut(entry, value);
946 } 946 }
947 947
948 static void ReconfigureImpl(Handle<JSObject> object, 948 static void ReconfigureImpl(Handle<JSObject> object,
949 Handle<FixedArrayBase> store, uint32_t entry, 949 Handle<FixedArrayBase> store, uint32_t entry,
950 Handle<Object> value, 950 Handle<Object> value,
951 PropertyAttributes attributes) { 951 PropertyAttributes attributes) {
952 SeededNumberDictionary* dictionary = SeededNumberDictionary::cast(*store); 952 Handle<SeededNumberDictionary> dictionary(
953 if (attributes != NONE) dictionary->set_requires_slow_elements(); 953 SeededNumberDictionary::cast(*store));
954 if (attributes != NONE) JSObject::RequireSlowElements(object, dictionary);
954 dictionary->ValueAtPut(entry, *value); 955 dictionary->ValueAtPut(entry, *value);
955 PropertyDetails details = dictionary->DetailsAt(entry); 956 PropertyDetails details = dictionary->DetailsAt(entry);
956 details = PropertyDetails(attributes, DATA, details.dictionary_index(), 957 details = PropertyDetails(attributes, DATA, details.dictionary_index(),
957 PropertyCellType::kNoCell); 958 PropertyCellType::kNoCell);
958 dictionary->DetailsAtPut(entry, details); 959 dictionary->DetailsAtPut(entry, details);
959 } 960 }
960 961
961 static void AddImpl(Handle<JSObject> object, uint32_t index, 962 static void AddImpl(Handle<JSObject> object, uint32_t index,
962 Handle<Object> value, PropertyAttributes attributes, 963 Handle<Object> value, PropertyAttributes attributes,
963 uint32_t new_capacity) { 964 uint32_t new_capacity) {
964 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell); 965 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell);
965 Handle<SeededNumberDictionary> dictionary = 966 Handle<SeededNumberDictionary> dictionary =
966 object->HasFastElements() 967 object->HasFastElements()
967 ? JSObject::NormalizeElements(object) 968 ? JSObject::NormalizeElements(object)
968 : handle(SeededNumberDictionary::cast(object->elements())); 969 : handle(SeededNumberDictionary::cast(object->elements()));
969 Handle<SeededNumberDictionary> new_dictionary = 970 Handle<SeededNumberDictionary> new_dictionary =
970 SeededNumberDictionary::AddNumberEntry(dictionary, index, value, 971 SeededNumberDictionary::AddNumberEntry(dictionary, index, value,
971 details); 972 details);
972 if (attributes != NONE) new_dictionary->set_requires_slow_elements(); 973 if (attributes != NONE) {
974 JSObject::RequireSlowElements(object, new_dictionary);
975 }
973 if (dictionary.is_identical_to(new_dictionary)) return; 976 if (dictionary.is_identical_to(new_dictionary)) return;
974 object->set_elements(*new_dictionary); 977 object->set_elements(*new_dictionary);
975 } 978 }
976 979
977 static bool HasEntryImpl(FixedArrayBase* store, uint32_t entry) { 980 static bool HasEntryImpl(FixedArrayBase* store, uint32_t entry) {
978 DisallowHeapAllocation no_gc; 981 DisallowHeapAllocation no_gc;
979 SeededNumberDictionary* dict = SeededNumberDictionary::cast(store); 982 SeededNumberDictionary* dict = SeededNumberDictionary::cast(store);
980 Object* index = dict->KeyAt(entry); 983 Object* index = dict->KeyAt(entry);
981 return !index->IsTheHole(); 984 return !index->IsTheHole();
982 } 985 }
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
1607 Handle<FixedArrayBase> old_elements( 1610 Handle<FixedArrayBase> old_elements(
1608 FixedArrayBase::cast(parameter_map->get(1))); 1611 FixedArrayBase::cast(parameter_map->get(1)));
1609 Handle<SeededNumberDictionary> dictionary = 1612 Handle<SeededNumberDictionary> dictionary =
1610 old_elements->IsSeededNumberDictionary() 1613 old_elements->IsSeededNumberDictionary()
1611 ? Handle<SeededNumberDictionary>::cast(old_elements) 1614 ? Handle<SeededNumberDictionary>::cast(old_elements)
1612 : JSObject::NormalizeElements(object); 1615 : JSObject::NormalizeElements(object);
1613 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell); 1616 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell);
1614 Handle<SeededNumberDictionary> new_dictionary = 1617 Handle<SeededNumberDictionary> new_dictionary =
1615 SeededNumberDictionary::AddNumberEntry(dictionary, index, value, 1618 SeededNumberDictionary::AddNumberEntry(dictionary, index, value,
1616 details); 1619 details);
1617 if (attributes != NONE) new_dictionary->set_requires_slow_elements(); 1620 if (attributes != NONE) {
1621 JSObject::RequireSlowElements(object, new_dictionary);
1622 }
1618 if (*dictionary != *new_dictionary) { 1623 if (*dictionary != *new_dictionary) {
1619 FixedArray::cast(object->elements())->set(1, *new_dictionary); 1624 FixedArray::cast(object->elements())->set(1, *new_dictionary);
1620 } 1625 }
1621 } 1626 }
1622 1627
1623 static void ReconfigureImpl(Handle<JSObject> object, 1628 static void ReconfigureImpl(Handle<JSObject> object,
1624 Handle<FixedArrayBase> store, uint32_t entry, 1629 Handle<FixedArrayBase> store, uint32_t entry,
1625 Handle<Object> value, 1630 Handle<Object> value,
1626 PropertyAttributes attributes) { 1631 PropertyAttributes attributes) {
1627 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(store); 1632 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(store);
(...skipping 12 matching lines...) Expand all
1640 if ((attributes & READ_ONLY) == 0) { 1645 if ((attributes & READ_ONLY) == 0) {
1641 Isolate* isolate = store->GetIsolate(); 1646 Isolate* isolate = store->GetIsolate();
1642 value = isolate->factory()->NewAliasedArgumentsEntry(context_entry); 1647 value = isolate->factory()->NewAliasedArgumentsEntry(context_entry);
1643 } 1648 }
1644 1649
1645 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell); 1650 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell);
1646 Handle<SeededNumberDictionary> arguments( 1651 Handle<SeededNumberDictionary> arguments(
1647 SeededNumberDictionary::cast(parameter_map->get(1))); 1652 SeededNumberDictionary::cast(parameter_map->get(1)));
1648 arguments = SeededNumberDictionary::AddNumberEntry(arguments, entry, 1653 arguments = SeededNumberDictionary::AddNumberEntry(arguments, entry,
1649 value, details); 1654 value, details);
1655 JSObject::RequireSlowElements(object, arguments);
Igor Sheludko 2015/07/15 10:53:17 Why not "if (attributes != NONE)" here?
1650 parameter_map->set(1, *arguments); 1656 parameter_map->set(1, *arguments);
1651 } else { 1657 } else {
1652 Handle<FixedArrayBase> arguments( 1658 Handle<FixedArrayBase> arguments(
1653 FixedArrayBase::cast(parameter_map->get(1))); 1659 FixedArrayBase::cast(parameter_map->get(1)));
1654 DictionaryElementsAccessor::ReconfigureImpl( 1660 DictionaryElementsAccessor::ReconfigureImpl(
1655 object, arguments, entry - length, value, attributes); 1661 object, arguments, entry - length, value, attributes);
1656 } 1662 }
1657 } 1663 }
1658 }; 1664 };
1659 1665
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
1941 #define ACCESSOR_DELETE(Class, Kind, Store) delete elements_accessors_[Kind]; 1947 #define ACCESSOR_DELETE(Class, Kind, Store) delete elements_accessors_[Kind];
1942 ELEMENTS_LIST(ACCESSOR_DELETE) 1948 ELEMENTS_LIST(ACCESSOR_DELETE)
1943 #undef ACCESSOR_DELETE 1949 #undef ACCESSOR_DELETE
1944 elements_accessors_ = NULL; 1950 elements_accessors_ = NULL;
1945 } 1951 }
1946 1952
1947 1953
1948 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; 1954 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL;
1949 } // namespace internal 1955 } // namespace internal
1950 } // namespace v8 1956 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/lookup.cc » ('j') | src/lookup.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698