OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 details = PropertyDetails( | 687 details = PropertyDetails( |
688 details.attributes(), details.type(), enumeration_index); | 688 details.attributes(), details.type(), enumeration_index); |
689 | 689 |
690 if (object->IsGlobalObject()) { | 690 if (object->IsGlobalObject()) { |
691 Handle<PropertyCell> cell( | 691 Handle<PropertyCell> cell( |
692 PropertyCell::cast(property_dictionary->ValueAt(entry))); | 692 PropertyCell::cast(property_dictionary->ValueAt(entry))); |
693 PropertyCell::SetValueInferType(cell, value); | 693 PropertyCell::SetValueInferType(cell, value); |
694 // Please note we have to update the property details. | 694 // Please note we have to update the property details. |
695 property_dictionary->DetailsAtPut(entry, details); | 695 property_dictionary->DetailsAtPut(entry, details); |
696 } else { | 696 } else { |
697 property_dictionary->SetEntry(entry, *name, *value, details); | 697 property_dictionary->SetEntry(entry, name, value, details); |
698 } | 698 } |
699 } | 699 } |
700 | 700 |
701 | 701 |
702 Handle<Object> JSObject::DeleteNormalizedProperty(Handle<JSObject> object, | 702 Handle<Object> JSObject::DeleteNormalizedProperty(Handle<JSObject> object, |
703 Handle<Name> name, | 703 Handle<Name> name, |
704 DeleteMode mode) { | 704 DeleteMode mode) { |
705 ASSERT(!object->HasFastProperties()); | 705 ASSERT(!object->HasFastProperties()); |
706 Isolate* isolate = object->GetIsolate(); | 706 Isolate* isolate = object->GetIsolate(); |
707 Handle<NameDictionary> dictionary(object->property_dictionary()); | 707 Handle<NameDictionary> dictionary(object->property_dictionary()); |
(...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1927 // In case name is an orphaned property reuse the cell. | 1927 // In case name is an orphaned property reuse the cell. |
1928 int entry = dict->FindEntry(name); | 1928 int entry = dict->FindEntry(name); |
1929 if (entry != NameDictionary::kNotFound) { | 1929 if (entry != NameDictionary::kNotFound) { |
1930 Handle<PropertyCell> cell(PropertyCell::cast(dict->ValueAt(entry))); | 1930 Handle<PropertyCell> cell(PropertyCell::cast(dict->ValueAt(entry))); |
1931 PropertyCell::SetValueInferType(cell, value); | 1931 PropertyCell::SetValueInferType(cell, value); |
1932 // Assign an enumeration index to the property and update | 1932 // Assign an enumeration index to the property and update |
1933 // SetNextEnumerationIndex. | 1933 // SetNextEnumerationIndex. |
1934 int index = dict->NextEnumerationIndex(); | 1934 int index = dict->NextEnumerationIndex(); |
1935 PropertyDetails details = PropertyDetails(attributes, NORMAL, index); | 1935 PropertyDetails details = PropertyDetails(attributes, NORMAL, index); |
1936 dict->SetNextEnumerationIndex(index + 1); | 1936 dict->SetNextEnumerationIndex(index + 1); |
1937 dict->SetEntry(entry, *name, *cell, details); | 1937 dict->SetEntry(entry, name, cell, details); |
1938 return; | 1938 return; |
1939 } | 1939 } |
1940 Handle<PropertyCell> cell = isolate->factory()->NewPropertyCell(value); | 1940 Handle<PropertyCell> cell = isolate->factory()->NewPropertyCell(value); |
1941 PropertyCell::SetValueInferType(cell, value); | 1941 PropertyCell::SetValueInferType(cell, value); |
1942 value = cell; | 1942 value = cell; |
1943 } | 1943 } |
1944 PropertyDetails details = PropertyDetails(attributes, NORMAL, 0); | 1944 PropertyDetails details = PropertyDetails(attributes, NORMAL, 0); |
1945 Handle<NameDictionary> result = | 1945 Handle<NameDictionary> result = |
1946 NameDictionary::Add(dict, name, value, details); | 1946 NameDictionary::Add(dict, name, value, details); |
1947 if (*dict != *result) object->set_properties(*result); | 1947 if (*dict != *result) object->set_properties(*result); |
(...skipping 13029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14977 EnsureCapacity(Handle<SeededNumberDictionary>, int, uint32_t); | 14977 EnsureCapacity(Handle<SeededNumberDictionary>, int, uint32_t); |
14978 | 14978 |
14979 template Handle<UnseededNumberDictionary> | 14979 template Handle<UnseededNumberDictionary> |
14980 Dictionary<UnseededNumberDictionary, UnseededNumberDictionaryShape, uint32_t>:: | 14980 Dictionary<UnseededNumberDictionary, UnseededNumberDictionaryShape, uint32_t>:: |
14981 EnsureCapacity(Handle<UnseededNumberDictionary>, int, uint32_t); | 14981 EnsureCapacity(Handle<UnseededNumberDictionary>, int, uint32_t); |
14982 | 14982 |
14983 template Handle<NameDictionary> | 14983 template Handle<NameDictionary> |
14984 Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >:: | 14984 Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >:: |
14985 EnsureCapacity(Handle<NameDictionary>, int, Handle<Name>); | 14985 EnsureCapacity(Handle<NameDictionary>, int, Handle<Name>); |
14986 | 14986 |
14987 template MaybeObject* | |
14988 Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>:: | |
14989 AddEntry(uint32_t, Object*, PropertyDetails, uint32_t); | |
14990 | |
14991 template MaybeObject* | |
14992 Dictionary<UnseededNumberDictionary, UnseededNumberDictionaryShape, uint32_t>:: | |
14993 AddEntry(uint32_t, Object*, PropertyDetails, uint32_t); | |
14994 | |
14995 template MaybeObject* | |
14996 Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::AddEntry( | |
14997 Handle<Name>, Object*, PropertyDetails, uint32_t); | |
14998 | |
14999 template | 14987 template |
15000 int Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>:: | 14988 int Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>:: |
15001 NumberOfEnumElements(); | 14989 NumberOfEnumElements(); |
15002 | 14990 |
15003 template | 14991 template |
15004 int Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >:: | 14992 int Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >:: |
15005 NumberOfEnumElements(); | 14993 NumberOfEnumElements(); |
15006 | 14994 |
15007 template | 14995 template |
15008 int HashTable<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>:: | 14996 int HashTable<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>:: |
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15837 Handle<Object> Dictionary<Derived, Shape, Key>::DeleteProperty( | 15825 Handle<Object> Dictionary<Derived, Shape, Key>::DeleteProperty( |
15838 Handle<Derived> dictionary, | 15826 Handle<Derived> dictionary, |
15839 int entry, | 15827 int entry, |
15840 JSObject::DeleteMode mode) { | 15828 JSObject::DeleteMode mode) { |
15841 Factory* factory = dictionary->GetIsolate()->factory(); | 15829 Factory* factory = dictionary->GetIsolate()->factory(); |
15842 PropertyDetails details = dictionary->DetailsAt(entry); | 15830 PropertyDetails details = dictionary->DetailsAt(entry); |
15843 // Ignore attributes if forcing a deletion. | 15831 // Ignore attributes if forcing a deletion. |
15844 if (details.IsDontDelete() && mode != JSReceiver::FORCE_DELETION) { | 15832 if (details.IsDontDelete() && mode != JSReceiver::FORCE_DELETION) { |
15845 return factory->false_value(); | 15833 return factory->false_value(); |
15846 } | 15834 } |
| 15835 |
15847 dictionary->SetEntry( | 15836 dictionary->SetEntry( |
15848 entry, *factory->the_hole_value(), *factory->the_hole_value()); | 15837 entry, factory->the_hole_value(), factory->the_hole_value()); |
15849 dictionary->ElementRemoved(); | 15838 dictionary->ElementRemoved(); |
15850 return factory->true_value(); | 15839 return factory->true_value(); |
15851 } | 15840 } |
15852 | 15841 |
15853 | 15842 |
15854 template<typename Derived, typename Shape, typename Key> | 15843 template<typename Derived, typename Shape, typename Key> |
15855 Handle<Derived> Dictionary<Derived, Shape, Key>::AtPut( | 15844 Handle<Derived> Dictionary<Derived, Shape, Key>::AtPut( |
15856 Handle<Derived> dictionary, Key key, Handle<Object> value) { | 15845 Handle<Derived> dictionary, Key key, Handle<Object> value) { |
15857 int entry = dictionary->FindEntry(key); | 15846 int entry = dictionary->FindEntry(key); |
15858 | 15847 |
15859 // If the entry is present set the value; | 15848 // If the entry is present set the value; |
15860 if (entry != Dictionary::kNotFound) { | 15849 if (entry != Dictionary::kNotFound) { |
15861 dictionary->ValueAtPut(entry, *value); | 15850 dictionary->ValueAtPut(entry, *value); |
15862 return dictionary; | 15851 return dictionary; |
15863 } | 15852 } |
15864 | 15853 |
15865 // Check whether the dictionary should be extended. | 15854 // Check whether the dictionary should be extended. |
15866 dictionary = EnsureCapacity(dictionary, 1, key); | 15855 dictionary = EnsureCapacity(dictionary, 1, key); |
15867 | 15856 |
15868 Handle<Object> k = Shape::AsHandle(dictionary->GetIsolate(), key); | 15857 Handle<Object> k = Shape::AsHandle(dictionary->GetIsolate(), key); |
15869 // TODO(ishell): Figure out if it is necessary to call AsHandle() here. | 15858 // TODO(ishell): Figure out if it is necessary to call AsHandle() here. |
15870 USE(k); | 15859 USE(k); |
15871 PropertyDetails details = PropertyDetails(NONE, NORMAL, 0); | 15860 PropertyDetails details = PropertyDetails(NONE, NORMAL, 0); |
15872 | 15861 |
15873 return AddEntry(dictionary, key, value, details, dictionary->Hash(key)); | 15862 AddEntry(dictionary, key, value, details, dictionary->Hash(key)); |
| 15863 return dictionary; |
15874 } | 15864 } |
15875 | 15865 |
15876 | 15866 |
15877 template<typename Derived, typename Shape, typename Key> | 15867 template<typename Derived, typename Shape, typename Key> |
15878 Handle<Derived> Dictionary<Derived, Shape, Key>::Add( | 15868 Handle<Derived> Dictionary<Derived, Shape, Key>::Add( |
15879 Handle<Derived> dictionary, | 15869 Handle<Derived> dictionary, |
15880 Key key, | 15870 Key key, |
15881 Handle<Object> value, | 15871 Handle<Object> value, |
15882 PropertyDetails details) { | 15872 PropertyDetails details) { |
15883 // Valdate key is absent. | 15873 // Valdate key is absent. |
15884 SLOW_ASSERT((dictionary->FindEntry(key) == Dictionary::kNotFound)); | 15874 SLOW_ASSERT((dictionary->FindEntry(key) == Dictionary::kNotFound)); |
15885 // Check whether the dictionary should be extended. | 15875 // Check whether the dictionary should be extended. |
15886 dictionary = EnsureCapacity(dictionary, 1, key); | 15876 dictionary = EnsureCapacity(dictionary, 1, key); |
15887 | 15877 |
15888 return AddEntry(dictionary, key, value, details, dictionary->Hash(key)); | 15878 AddEntry(dictionary, key, value, details, dictionary->Hash(key)); |
| 15879 return dictionary; |
15889 } | 15880 } |
15890 | 15881 |
15891 | 15882 |
15892 // Add a key, value pair to the dictionary. | 15883 // Add a key, value pair to the dictionary. |
15893 template<typename Derived, typename Shape, typename Key> | 15884 template<typename Derived, typename Shape, typename Key> |
15894 Handle<Derived> Dictionary<Derived, Shape, Key>::AddEntry( | 15885 void Dictionary<Derived, Shape, Key>::AddEntry( |
15895 Handle<Derived> dictionary, | 15886 Handle<Derived> dictionary, |
15896 Key key, | 15887 Key key, |
15897 Handle<Object> value, | 15888 Handle<Object> value, |
15898 PropertyDetails details, | 15889 PropertyDetails details, |
15899 uint32_t hash) { | 15890 uint32_t hash) { |
15900 CALL_HEAP_FUNCTION( | 15891 // Compute the key object. |
15901 dictionary->GetIsolate(), | 15892 Handle<Object> k = Shape::AsHandle(dictionary->GetIsolate(), key); |
15902 dictionary->AddEntry(key, *value, details, hash), | |
15903 Derived); | |
15904 } | |
15905 | 15893 |
15906 template<typename Derived, typename Shape, typename Key> | 15894 uint32_t entry = dictionary->FindInsertionEntry(hash); |
15907 MaybeObject* Dictionary<Derived, Shape, Key>::AddEntry( | |
15908 Key key, | |
15909 Object* value, | |
15910 PropertyDetails details, | |
15911 uint32_t hash) { | |
15912 // Compute the key object. | |
15913 Object* k; | |
15914 { MaybeObject* maybe_k = Shape::AsObject(this->GetHeap(), key); | |
15915 if (!maybe_k->ToObject(&k)) return maybe_k; | |
15916 } | |
15917 | |
15918 uint32_t entry = Dictionary::FindInsertionEntry(hash); | |
15919 // Insert element at empty or deleted entry | 15895 // Insert element at empty or deleted entry |
15920 if (!details.IsDeleted() && | 15896 if (!details.IsDeleted() && |
15921 details.dictionary_index() == 0 && | 15897 details.dictionary_index() == 0 && |
15922 Shape::kIsEnumerable) { | 15898 Shape::kIsEnumerable) { |
15923 // Assign an enumeration index to the property and update | 15899 // Assign an enumeration index to the property and update |
15924 // SetNextEnumerationIndex. | 15900 // SetNextEnumerationIndex. |
15925 int index = NextEnumerationIndex(); | 15901 int index = dictionary->NextEnumerationIndex(); |
15926 details = PropertyDetails(details.attributes(), details.type(), index); | 15902 details = PropertyDetails(details.attributes(), details.type(), index); |
15927 SetNextEnumerationIndex(index + 1); | 15903 dictionary->SetNextEnumerationIndex(index + 1); |
15928 } | 15904 } |
15929 SetEntry(entry, k, value, details); | 15905 dictionary->SetEntry(entry, k, value, details); |
15930 ASSERT((Dictionary::KeyAt(entry)->IsNumber() || | 15906 ASSERT((dictionary->KeyAt(entry)->IsNumber() || |
15931 Dictionary::KeyAt(entry)->IsName())); | 15907 dictionary->KeyAt(entry)->IsName())); |
15932 DerivedHashTable::ElementAdded(); | 15908 dictionary->ElementAdded(); |
15933 return this; | |
15934 } | 15909 } |
15935 | 15910 |
15936 | 15911 |
15937 void SeededNumberDictionary::UpdateMaxNumberKey(uint32_t key) { | 15912 void SeededNumberDictionary::UpdateMaxNumberKey(uint32_t key) { |
15938 DisallowHeapAllocation no_allocation; | 15913 DisallowHeapAllocation no_allocation; |
15939 // If the dictionary requires slow elements an element has already | 15914 // If the dictionary requires slow elements an element has already |
15940 // been added at a high index. | 15915 // been added at a high index. |
15941 if (requires_slow_elements()) return; | 15916 if (requires_slow_elements()) return; |
15942 // Check if this index is high enough that we should require slow | 15917 // Check if this index is high enough that we should require slow |
15943 // elements. | 15918 // elements. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15999 int entry = dictionary->FindEntry(key); | 15974 int entry = dictionary->FindEntry(key); |
16000 if (entry == kNotFound) { | 15975 if (entry == kNotFound) { |
16001 return AddNumberEntry(dictionary, key, value, details); | 15976 return AddNumberEntry(dictionary, key, value, details); |
16002 } | 15977 } |
16003 // Preserve enumeration index. | 15978 // Preserve enumeration index. |
16004 details = PropertyDetails(details.attributes(), | 15979 details = PropertyDetails(details.attributes(), |
16005 details.type(), | 15980 details.type(), |
16006 dictionary->DetailsAt(entry).dictionary_index()); | 15981 dictionary->DetailsAt(entry).dictionary_index()); |
16007 Handle<Object> object_key = | 15982 Handle<Object> object_key = |
16008 SeededNumberDictionaryShape::AsHandle(dictionary->GetIsolate(), key); | 15983 SeededNumberDictionaryShape::AsHandle(dictionary->GetIsolate(), key); |
16009 dictionary->SetEntry(entry, *object_key, *value, details); | 15984 dictionary->SetEntry(entry, object_key, value, details); |
16010 return dictionary; | 15985 return dictionary; |
16011 } | 15986 } |
16012 | 15987 |
16013 | 15988 |
16014 Handle<UnseededNumberDictionary> UnseededNumberDictionary::Set( | 15989 Handle<UnseededNumberDictionary> UnseededNumberDictionary::Set( |
16015 Handle<UnseededNumberDictionary> dictionary, | 15990 Handle<UnseededNumberDictionary> dictionary, |
16016 uint32_t key, | 15991 uint32_t key, |
16017 Handle<Object> value) { | 15992 Handle<Object> value) { |
16018 int entry = dictionary->FindEntry(key); | 15993 int entry = dictionary->FindEntry(key); |
16019 if (entry == kNotFound) return AddNumberEntry(dictionary, key, value); | 15994 if (entry == kNotFound) return AddNumberEntry(dictionary, key, value); |
16020 Handle<Object> object_key = | 15995 Handle<Object> object_key = |
16021 UnseededNumberDictionaryShape::AsHandle(dictionary->GetIsolate(), key); | 15996 UnseededNumberDictionaryShape::AsHandle(dictionary->GetIsolate(), key); |
16022 dictionary->SetEntry(entry, *object_key, *value); | 15997 dictionary->SetEntry(entry, object_key, value); |
16023 return dictionary; | 15998 return dictionary; |
16024 } | 15999 } |
16025 | 16000 |
16026 | 16001 |
16027 | 16002 |
16028 template<typename Derived, typename Shape, typename Key> | 16003 template<typename Derived, typename Shape, typename Key> |
16029 int Dictionary<Derived, Shape, Key>::NumberOfElementsFilterAttributes( | 16004 int Dictionary<Derived, Shape, Key>::NumberOfElementsFilterAttributes( |
16030 PropertyAttributes filter) { | 16005 PropertyAttributes filter) { |
16031 int capacity = DerivedHashTable::Capacity(); | 16006 int capacity = DerivedHashTable::Capacity(); |
16032 int result = 0; | 16007 int result = 0; |
(...skipping 1298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17331 #define ERROR_MESSAGES_TEXTS(C, T) T, | 17306 #define ERROR_MESSAGES_TEXTS(C, T) T, |
17332 static const char* error_messages_[] = { | 17307 static const char* error_messages_[] = { |
17333 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 17308 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
17334 }; | 17309 }; |
17335 #undef ERROR_MESSAGES_TEXTS | 17310 #undef ERROR_MESSAGES_TEXTS |
17336 return error_messages_[reason]; | 17311 return error_messages_[reason]; |
17337 } | 17312 } |
17338 | 17313 |
17339 | 17314 |
17340 } } // namespace v8::internal | 17315 } } // namespace v8::internal |
OLD | NEW |