OLD | NEW |
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 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
949 | 949 |
950 static void AddImpl(Handle<JSObject> object, uint32_t index, | 950 static void AddImpl(Handle<JSObject> object, uint32_t index, |
951 Handle<Object> value, PropertyAttributes attributes, | 951 Handle<Object> value, PropertyAttributes attributes, |
952 uint32_t new_capacity) { | 952 uint32_t new_capacity) { |
953 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell); | 953 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell); |
954 Handle<SeededNumberDictionary> dictionary = | 954 Handle<SeededNumberDictionary> dictionary = |
955 object->HasFastElements() | 955 object->HasFastElements() |
956 ? JSObject::NormalizeElements(object) | 956 ? JSObject::NormalizeElements(object) |
957 : handle(SeededNumberDictionary::cast(object->elements())); | 957 : handle(SeededNumberDictionary::cast(object->elements())); |
958 Handle<SeededNumberDictionary> new_dictionary = | 958 Handle<SeededNumberDictionary> new_dictionary = |
959 SeededNumberDictionary::AddNumberEntry(dictionary, index, value, | 959 SeededNumberDictionary::AddNumberEntry( |
960 details); | 960 dictionary, index, value, details, |
| 961 object->map()->is_prototype_map()); |
961 if (attributes != NONE) object->RequireSlowElements(*new_dictionary); | 962 if (attributes != NONE) object->RequireSlowElements(*new_dictionary); |
962 if (dictionary.is_identical_to(new_dictionary)) return; | 963 if (dictionary.is_identical_to(new_dictionary)) return; |
963 object->set_elements(*new_dictionary); | 964 object->set_elements(*new_dictionary); |
964 } | 965 } |
965 | 966 |
966 static bool HasEntryImpl(FixedArrayBase* store, uint32_t entry) { | 967 static bool HasEntryImpl(FixedArrayBase* store, uint32_t entry) { |
967 DisallowHeapAllocation no_gc; | 968 DisallowHeapAllocation no_gc; |
968 SeededNumberDictionary* dict = SeededNumberDictionary::cast(store); | 969 SeededNumberDictionary* dict = SeededNumberDictionary::cast(store); |
969 Object* index = dict->KeyAt(entry); | 970 Object* index = dict->KeyAt(entry); |
970 return !index->IsTheHole(); | 971 return !index->IsTheHole(); |
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1632 uint32_t new_capacity) { | 1633 uint32_t new_capacity) { |
1633 Handle<FixedArray> parameter_map(FixedArray::cast(object->elements())); | 1634 Handle<FixedArray> parameter_map(FixedArray::cast(object->elements())); |
1634 Handle<FixedArrayBase> old_elements( | 1635 Handle<FixedArrayBase> old_elements( |
1635 FixedArrayBase::cast(parameter_map->get(1))); | 1636 FixedArrayBase::cast(parameter_map->get(1))); |
1636 Handle<SeededNumberDictionary> dictionary = | 1637 Handle<SeededNumberDictionary> dictionary = |
1637 old_elements->IsSeededNumberDictionary() | 1638 old_elements->IsSeededNumberDictionary() |
1638 ? Handle<SeededNumberDictionary>::cast(old_elements) | 1639 ? Handle<SeededNumberDictionary>::cast(old_elements) |
1639 : JSObject::NormalizeElements(object); | 1640 : JSObject::NormalizeElements(object); |
1640 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell); | 1641 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell); |
1641 Handle<SeededNumberDictionary> new_dictionary = | 1642 Handle<SeededNumberDictionary> new_dictionary = |
1642 SeededNumberDictionary::AddNumberEntry(dictionary, index, value, | 1643 SeededNumberDictionary::AddNumberEntry( |
1643 details); | 1644 dictionary, index, value, details, |
| 1645 object->map()->is_prototype_map()); |
1644 if (attributes != NONE) object->RequireSlowElements(*new_dictionary); | 1646 if (attributes != NONE) object->RequireSlowElements(*new_dictionary); |
1645 if (*dictionary != *new_dictionary) { | 1647 if (*dictionary != *new_dictionary) { |
1646 FixedArray::cast(object->elements())->set(1, *new_dictionary); | 1648 FixedArray::cast(object->elements())->set(1, *new_dictionary); |
1647 } | 1649 } |
1648 } | 1650 } |
1649 | 1651 |
1650 static void ReconfigureImpl(Handle<JSObject> object, | 1652 static void ReconfigureImpl(Handle<JSObject> object, |
1651 Handle<FixedArrayBase> store, uint32_t entry, | 1653 Handle<FixedArrayBase> store, uint32_t entry, |
1652 Handle<Object> value, | 1654 Handle<Object> value, |
1653 PropertyAttributes attributes) { | 1655 PropertyAttributes attributes) { |
(...skipping 11 matching lines...) Expand all Loading... |
1665 parameter_map->set_the_hole(entry + 2); | 1667 parameter_map->set_the_hole(entry + 2); |
1666 // For elements that are still writable we re-establish slow aliasing. | 1668 // For elements that are still writable we re-establish slow aliasing. |
1667 if ((attributes & READ_ONLY) == 0) { | 1669 if ((attributes & READ_ONLY) == 0) { |
1668 Isolate* isolate = store->GetIsolate(); | 1670 Isolate* isolate = store->GetIsolate(); |
1669 value = isolate->factory()->NewAliasedArgumentsEntry(context_entry); | 1671 value = isolate->factory()->NewAliasedArgumentsEntry(context_entry); |
1670 } | 1672 } |
1671 | 1673 |
1672 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell); | 1674 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell); |
1673 Handle<SeededNumberDictionary> arguments( | 1675 Handle<SeededNumberDictionary> arguments( |
1674 SeededNumberDictionary::cast(parameter_map->get(1))); | 1676 SeededNumberDictionary::cast(parameter_map->get(1))); |
1675 arguments = SeededNumberDictionary::AddNumberEntry(arguments, entry, | 1677 arguments = SeededNumberDictionary::AddNumberEntry( |
1676 value, details); | 1678 arguments, entry, value, details, object->map()->is_prototype_map()); |
1677 // If the attributes were NONE, we would have called set rather than | 1679 // If the attributes were NONE, we would have called set rather than |
1678 // reconfigure. | 1680 // reconfigure. |
1679 DCHECK_NE(NONE, attributes); | 1681 DCHECK_NE(NONE, attributes); |
1680 object->RequireSlowElements(*arguments); | 1682 object->RequireSlowElements(*arguments); |
1681 parameter_map->set(1, *arguments); | 1683 parameter_map->set(1, *arguments); |
1682 } else { | 1684 } else { |
1683 Handle<FixedArrayBase> arguments( | 1685 Handle<FixedArrayBase> arguments( |
1684 FixedArrayBase::cast(parameter_map->get(1))); | 1686 FixedArrayBase::cast(parameter_map->get(1))); |
1685 DictionaryElementsAccessor::ReconfigureImpl( | 1687 DictionaryElementsAccessor::ReconfigureImpl( |
1686 object, arguments, entry - length, value, attributes); | 1688 object, arguments, entry - length, value, attributes); |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1972 #define ACCESSOR_DELETE(Class, Kind, Store) delete elements_accessors_[Kind]; | 1974 #define ACCESSOR_DELETE(Class, Kind, Store) delete elements_accessors_[Kind]; |
1973 ELEMENTS_LIST(ACCESSOR_DELETE) | 1975 ELEMENTS_LIST(ACCESSOR_DELETE) |
1974 #undef ACCESSOR_DELETE | 1976 #undef ACCESSOR_DELETE |
1975 elements_accessors_ = NULL; | 1977 elements_accessors_ = NULL; |
1976 } | 1978 } |
1977 | 1979 |
1978 | 1980 |
1979 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; | 1981 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; |
1980 } // namespace internal | 1982 } // namespace internal |
1981 } // namespace v8 | 1983 } // namespace v8 |
OLD | NEW |