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

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: Remove handle 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') | 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/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 932 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 SeededNumberDictionary* dictionary = SeededNumberDictionary::cast(*store);
953 if (attributes != NONE) dictionary->set_requires_slow_elements(); 953 if (attributes != NONE) object->RequireSlowElements(dictionary);
954 dictionary->ValueAtPut(entry, *value); 954 dictionary->ValueAtPut(entry, *value);
955 PropertyDetails details = dictionary->DetailsAt(entry); 955 PropertyDetails details = dictionary->DetailsAt(entry);
956 details = PropertyDetails(attributes, DATA, details.dictionary_index(), 956 details = PropertyDetails(attributes, DATA, details.dictionary_index(),
957 PropertyCellType::kNoCell); 957 PropertyCellType::kNoCell);
958 dictionary->DetailsAtPut(entry, details); 958 dictionary->DetailsAtPut(entry, details);
959 } 959 }
960 960
961 static void AddImpl(Handle<JSObject> object, uint32_t index, 961 static void AddImpl(Handle<JSObject> object, uint32_t index,
962 Handle<Object> value, PropertyAttributes attributes, 962 Handle<Object> value, PropertyAttributes attributes,
963 uint32_t new_capacity) { 963 uint32_t new_capacity) {
964 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell); 964 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell);
965 Handle<SeededNumberDictionary> dictionary = 965 Handle<SeededNumberDictionary> dictionary =
966 object->HasFastElements() 966 object->HasFastElements()
967 ? JSObject::NormalizeElements(object) 967 ? JSObject::NormalizeElements(object)
968 : handle(SeededNumberDictionary::cast(object->elements())); 968 : handle(SeededNumberDictionary::cast(object->elements()));
969 Handle<SeededNumberDictionary> new_dictionary = 969 Handle<SeededNumberDictionary> new_dictionary =
970 SeededNumberDictionary::AddNumberEntry(dictionary, index, value, 970 SeededNumberDictionary::AddNumberEntry(dictionary, index, value,
971 details); 971 details);
972 if (attributes != NONE) new_dictionary->set_requires_slow_elements(); 972 if (attributes != NONE) object->RequireSlowElements(*new_dictionary);
973 if (dictionary.is_identical_to(new_dictionary)) return; 973 if (dictionary.is_identical_to(new_dictionary)) return;
974 object->set_elements(*new_dictionary); 974 object->set_elements(*new_dictionary);
975 } 975 }
976 976
977 static bool HasEntryImpl(FixedArrayBase* store, uint32_t entry) { 977 static bool HasEntryImpl(FixedArrayBase* store, uint32_t entry) {
978 DisallowHeapAllocation no_gc; 978 DisallowHeapAllocation no_gc;
979 SeededNumberDictionary* dict = SeededNumberDictionary::cast(store); 979 SeededNumberDictionary* dict = SeededNumberDictionary::cast(store);
980 Object* index = dict->KeyAt(entry); 980 Object* index = dict->KeyAt(entry);
981 return !index->IsTheHole(); 981 return !index->IsTheHole();
982 } 982 }
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
1607 Handle<FixedArrayBase> old_elements( 1607 Handle<FixedArrayBase> old_elements(
1608 FixedArrayBase::cast(parameter_map->get(1))); 1608 FixedArrayBase::cast(parameter_map->get(1)));
1609 Handle<SeededNumberDictionary> dictionary = 1609 Handle<SeededNumberDictionary> dictionary =
1610 old_elements->IsSeededNumberDictionary() 1610 old_elements->IsSeededNumberDictionary()
1611 ? Handle<SeededNumberDictionary>::cast(old_elements) 1611 ? Handle<SeededNumberDictionary>::cast(old_elements)
1612 : JSObject::NormalizeElements(object); 1612 : JSObject::NormalizeElements(object);
1613 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell); 1613 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell);
1614 Handle<SeededNumberDictionary> new_dictionary = 1614 Handle<SeededNumberDictionary> new_dictionary =
1615 SeededNumberDictionary::AddNumberEntry(dictionary, index, value, 1615 SeededNumberDictionary::AddNumberEntry(dictionary, index, value,
1616 details); 1616 details);
1617 if (attributes != NONE) new_dictionary->set_requires_slow_elements(); 1617 if (attributes != NONE) object->RequireSlowElements(*new_dictionary);
1618 if (*dictionary != *new_dictionary) { 1618 if (*dictionary != *new_dictionary) {
1619 FixedArray::cast(object->elements())->set(1, *new_dictionary); 1619 FixedArray::cast(object->elements())->set(1, *new_dictionary);
1620 } 1620 }
1621 } 1621 }
1622 1622
1623 static void ReconfigureImpl(Handle<JSObject> object, 1623 static void ReconfigureImpl(Handle<JSObject> object,
1624 Handle<FixedArrayBase> store, uint32_t entry, 1624 Handle<FixedArrayBase> store, uint32_t entry,
1625 Handle<Object> value, 1625 Handle<Object> value,
1626 PropertyAttributes attributes) { 1626 PropertyAttributes attributes) {
1627 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(store); 1627 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(store);
(...skipping 12 matching lines...) Expand all
1640 if ((attributes & READ_ONLY) == 0) { 1640 if ((attributes & READ_ONLY) == 0) {
1641 Isolate* isolate = store->GetIsolate(); 1641 Isolate* isolate = store->GetIsolate();
1642 value = isolate->factory()->NewAliasedArgumentsEntry(context_entry); 1642 value = isolate->factory()->NewAliasedArgumentsEntry(context_entry);
1643 } 1643 }
1644 1644
1645 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell); 1645 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell);
1646 Handle<SeededNumberDictionary> arguments( 1646 Handle<SeededNumberDictionary> arguments(
1647 SeededNumberDictionary::cast(parameter_map->get(1))); 1647 SeededNumberDictionary::cast(parameter_map->get(1)));
1648 arguments = SeededNumberDictionary::AddNumberEntry(arguments, entry, 1648 arguments = SeededNumberDictionary::AddNumberEntry(arguments, entry,
1649 value, details); 1649 value, details);
1650 // If the attributes were NONE, we would have called set rather than
1651 // reconfigure.
1652 DCHECK_NE(NONE, attributes);
1653 object->RequireSlowElements(*arguments);
1650 parameter_map->set(1, *arguments); 1654 parameter_map->set(1, *arguments);
1651 } else { 1655 } else {
1652 Handle<FixedArrayBase> arguments( 1656 Handle<FixedArrayBase> arguments(
1653 FixedArrayBase::cast(parameter_map->get(1))); 1657 FixedArrayBase::cast(parameter_map->get(1)));
1654 DictionaryElementsAccessor::ReconfigureImpl( 1658 DictionaryElementsAccessor::ReconfigureImpl(
1655 object, arguments, entry - length, value, attributes); 1659 object, arguments, entry - length, value, attributes);
1656 } 1660 }
1657 } 1661 }
1658 }; 1662 };
1659 1663
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
1941 #define ACCESSOR_DELETE(Class, Kind, Store) delete elements_accessors_[Kind]; 1945 #define ACCESSOR_DELETE(Class, Kind, Store) delete elements_accessors_[Kind];
1942 ELEMENTS_LIST(ACCESSOR_DELETE) 1946 ELEMENTS_LIST(ACCESSOR_DELETE)
1943 #undef ACCESSOR_DELETE 1947 #undef ACCESSOR_DELETE
1944 elements_accessors_ = NULL; 1948 elements_accessors_ = NULL;
1945 } 1949 }
1946 1950
1947 1951
1948 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; 1952 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL;
1949 } // namespace internal 1953 } // namespace internal
1950 } // namespace v8 1954 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/lookup.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698