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

Side by Side Diff: src/objects.cc

Issue 1002703002: remove DeletedField from PropertyDetails (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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 | « src/objects.h ('k') | src/objects-inl.h » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 <iomanip> 5 #include <iomanip>
6 #include <sstream> 6 #include <sstream>
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/accessors.h" 10 #include "src/accessors.h"
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 store_value = object->GetIsolate()->factory()->NewPropertyCell(value); 547 store_value = object->GetIsolate()->factory()->NewPropertyCell(value);
548 } 548 }
549 549
550 property_dictionary = NameDictionary::Add( 550 property_dictionary = NameDictionary::Add(
551 property_dictionary, name, store_value, details); 551 property_dictionary, name, store_value, details);
552 object->set_properties(*property_dictionary); 552 object->set_properties(*property_dictionary);
553 return; 553 return;
554 } 554 }
555 555
556 PropertyDetails original_details = property_dictionary->DetailsAt(entry); 556 PropertyDetails original_details = property_dictionary->DetailsAt(entry);
557 int enumeration_index; 557 int enumeration_index = original_details.dictionary_index();
558
559 if (!object->IsGlobalObject()) {
560 DCHECK(enumeration_index > 0);
561 details = PropertyDetails(details.attributes(), details.type(),
562 enumeration_index);
563 property_dictionary->SetEntry(entry, name, value, details);
564 return;
565 }
566
567 Handle<PropertyCell> cell(
568 PropertyCell::cast(property_dictionary->ValueAt(entry)));
558 // Preserve the enumeration index unless the property was deleted. 569 // Preserve the enumeration index unless the property was deleted.
559 if (original_details.IsDeleted()) { 570 if (cell->value()->IsTheHole()) {
560 enumeration_index = property_dictionary->NextEnumerationIndex(); 571 enumeration_index = property_dictionary->NextEnumerationIndex();
561 property_dictionary->SetNextEnumerationIndex(enumeration_index + 1); 572 property_dictionary->SetNextEnumerationIndex(enumeration_index + 1);
562 } else {
563 enumeration_index = original_details.dictionary_index();
564 DCHECK(enumeration_index > 0);
565 } 573 }
566 574 DCHECK(enumeration_index > 0);
567 details = PropertyDetails( 575 details = PropertyDetails(
568 details.attributes(), details.type(), enumeration_index); 576 details.attributes(), details.type(), enumeration_index);
569 577 PropertyCell::SetValueInferType(cell, value);
570 if (object->IsGlobalObject()) { 578 // Please note we have to update the property details.
571 Handle<PropertyCell> cell( 579 property_dictionary->DetailsAtPut(entry, details);
572 PropertyCell::cast(property_dictionary->ValueAt(entry)));
573 PropertyCell::SetValueInferType(cell, value);
574 // Please note we have to update the property details.
575 property_dictionary->DetailsAtPut(entry, details);
576 } else {
577 property_dictionary->SetEntry(entry, name, value, details);
578 }
579 } 580 }
580 581
581 582
582 static MaybeHandle<JSObject> FindIndexedAllCanReadHolder( 583 static MaybeHandle<JSObject> FindIndexedAllCanReadHolder(
583 Isolate* isolate, Handle<JSObject> js_object, 584 Isolate* isolate, Handle<JSObject> js_object,
584 PrototypeIterator::WhereToStart where_to_start) { 585 PrototypeIterator::WhereToStart where_to_start) {
585 for (PrototypeIterator iter(isolate, js_object, where_to_start); 586 for (PrototypeIterator iter(isolate, js_object, where_to_start);
586 !iter.IsAtEnd(); iter.Advance()) { 587 !iter.IsAtEnd(); iter.Advance()) {
587 auto curr = PrototypeIterator::GetCurrent(iter); 588 auto curr = PrototypeIterator::GetCurrent(iter);
588 if (!curr->IsJSObject()) break; 589 if (!curr->IsJSObject()) break;
(...skipping 4757 matching lines...) Expand 10 before | Expand all | Expand 10 after
5346 void JSObject::DeleteNormalizedProperty(Handle<JSObject> object, 5347 void JSObject::DeleteNormalizedProperty(Handle<JSObject> object,
5347 Handle<Name> name) { 5348 Handle<Name> name) {
5348 DCHECK(!object->HasFastProperties()); 5349 DCHECK(!object->HasFastProperties());
5349 Isolate* isolate = object->GetIsolate(); 5350 Isolate* isolate = object->GetIsolate();
5350 Handle<NameDictionary> dictionary(object->property_dictionary()); 5351 Handle<NameDictionary> dictionary(object->property_dictionary());
5351 int entry = dictionary->FindEntry(name); 5352 int entry = dictionary->FindEntry(name);
5352 DCHECK_NE(NameDictionary::kNotFound, entry); 5353 DCHECK_NE(NameDictionary::kNotFound, entry);
5353 5354
5354 // If we have a global object set the cell to the hole. 5355 // If we have a global object set the cell to the hole.
5355 if (object->IsGlobalObject()) { 5356 if (object->IsGlobalObject()) {
5356 PropertyDetails details = dictionary->DetailsAt(entry); 5357 DCHECK(dictionary->DetailsAt(entry).IsConfigurable());
5357 DCHECK(details.IsConfigurable());
5358 Handle<PropertyCell> cell(PropertyCell::cast(dictionary->ValueAt(entry))); 5358 Handle<PropertyCell> cell(PropertyCell::cast(dictionary->ValueAt(entry)));
5359 Handle<Object> value = isolate->factory()->the_hole_value(); 5359 Handle<Object> value = isolate->factory()->the_hole_value();
5360 PropertyCell::SetValueInferType(cell, value); 5360 PropertyCell::SetValueInferType(cell, value);
5361 dictionary->DetailsAtPut(entry, details.AsDeleted());
5362 return; 5361 return;
5363 } 5362 }
5364 5363
5365 NameDictionary::DeleteProperty(dictionary, entry); 5364 NameDictionary::DeleteProperty(dictionary, entry);
5366 Handle<NameDictionary> new_properties = 5365 Handle<NameDictionary> new_properties =
5367 NameDictionary::Shrink(dictionary, name); 5366 NameDictionary::Shrink(dictionary, name);
5368 object->set_properties(*new_properties); 5367 object->set_properties(*new_properties);
5369 } 5368 }
5370 5369
5371 5370
(...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after
6288 desc->SetEnumCache(*bridge_storage, 6287 desc->SetEnumCache(*bridge_storage,
6289 *storage, 6288 *storage,
6290 indices.is_null() ? Object::cast(Smi::FromInt(0)) 6289 indices.is_null() ? Object::cast(Smi::FromInt(0))
6291 : Object::cast(*indices)); 6290 : Object::cast(*indices));
6292 if (cache_result) { 6291 if (cache_result) {
6293 object->map()->SetEnumLength(own_property_count); 6292 object->map()->SetEnumLength(own_property_count);
6294 } 6293 }
6295 return storage; 6294 return storage;
6296 } else { 6295 } else {
6297 Handle<NameDictionary> dictionary(object->property_dictionary()); 6296 Handle<NameDictionary> dictionary(object->property_dictionary());
6298 int length = dictionary->NumberOfEnumElements(); 6297 int length = dictionary->NumberOfEnumElements(*object);
6299 if (length == 0) { 6298 if (length == 0) {
6300 return Handle<FixedArray>(isolate->heap()->empty_fixed_array()); 6299 return Handle<FixedArray>(isolate->heap()->empty_fixed_array());
6301 } 6300 }
6302 Handle<FixedArray> storage = isolate->factory()->NewFixedArray(length); 6301 Handle<FixedArray> storage = isolate->factory()->NewFixedArray(length);
6303 dictionary->CopyEnumKeysTo(*storage); 6302 dictionary->CopyEnumKeysTo(*object, *storage);
6304 return storage; 6303 return storage;
6305 } 6304 }
6306 } 6305 }
6307 6306
6308 6307
6309 MaybeHandle<FixedArray> JSReceiver::GetKeys(Handle<JSReceiver> object, 6308 MaybeHandle<FixedArray> JSReceiver::GetKeys(Handle<JSReceiver> object,
6310 KeyCollectionType type) { 6309 KeyCollectionType type) {
6311 USE(ContainsOnlyValidKeys); 6310 USE(ContainsOnlyValidKeys);
6312 Isolate* isolate = object->GetIsolate(); 6311 Isolate* isolate = object->GetIsolate();
6313 Handle<FixedArray> content = isolate->factory()->empty_fixed_array(); 6312 Handle<FixedArray> content = isolate->factory()->empty_fixed_array();
(...skipping 7625 matching lines...) Expand 10 before | Expand all | Expand 10 after
13939 int JSObject::NumberOfOwnProperties(PropertyAttributes filter) { 13938 int JSObject::NumberOfOwnProperties(PropertyAttributes filter) {
13940 if (HasFastProperties()) { 13939 if (HasFastProperties()) {
13941 Map* map = this->map(); 13940 Map* map = this->map();
13942 if (filter == NONE) return map->NumberOfOwnDescriptors(); 13941 if (filter == NONE) return map->NumberOfOwnDescriptors();
13943 if (filter & DONT_ENUM) { 13942 if (filter & DONT_ENUM) {
13944 int result = map->EnumLength(); 13943 int result = map->EnumLength();
13945 if (result != kInvalidEnumCacheSentinel) return result; 13944 if (result != kInvalidEnumCacheSentinel) return result;
13946 } 13945 }
13947 return map->NumberOfDescribedProperties(OWN_DESCRIPTORS, filter); 13946 return map->NumberOfDescribedProperties(OWN_DESCRIPTORS, filter);
13948 } 13947 }
13949 return property_dictionary()->NumberOfElementsFilterAttributes(filter); 13948 return property_dictionary()->NumberOfElementsFilterAttributes(this, filter);
13950 } 13949 }
13951 13950
13952 13951
13953 void FixedArray::SwapPairs(FixedArray* numbers, int i, int j) { 13952 void FixedArray::SwapPairs(FixedArray* numbers, int i, int j) {
13954 Object* temp = get(i); 13953 Object* temp = get(i);
13955 set(i, get(j)); 13954 set(i, get(j));
13956 set(j, temp); 13955 set(j, temp);
13957 if (this != numbers) { 13956 if (this != numbers) {
13958 temp = numbers->get(i); 13957 temp = numbers->get(i);
13959 numbers->set(i, Smi::cast(numbers->get(j))); 13958 numbers->set(i, Smi::cast(numbers->get(j)));
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
14072 if (HasFastProperties()) { 14071 if (HasFastProperties()) {
14073 int real_size = map()->NumberOfOwnDescriptors(); 14072 int real_size = map()->NumberOfOwnDescriptors();
14074 DescriptorArray* descs = map()->instance_descriptors(); 14073 DescriptorArray* descs = map()->instance_descriptors();
14075 for (int i = 0; i < real_size; i++) { 14074 for (int i = 0; i < real_size; i++) {
14076 if ((descs->GetDetails(i).attributes() & filter) == 0 && 14075 if ((descs->GetDetails(i).attributes() & filter) == 0 &&
14077 !FilterKey(descs->GetKey(i), filter)) { 14076 !FilterKey(descs->GetKey(i), filter)) {
14078 storage->set(index++, descs->GetKey(i)); 14077 storage->set(index++, descs->GetKey(i));
14079 } 14078 }
14080 } 14079 }
14081 } else { 14080 } else {
14082 property_dictionary()->CopyKeysTo(storage, 14081 property_dictionary()->CopyKeysTo(this, storage, index, filter,
14083 index,
14084 filter,
14085 NameDictionary::UNSORTED); 14082 NameDictionary::UNSORTED);
14086 } 14083 }
14087 } 14084 }
14088 14085
14089 14086
14090 int JSObject::NumberOfOwnElements(PropertyAttributes filter) { 14087 int JSObject::NumberOfOwnElements(PropertyAttributes filter) {
14091 return GetOwnElementKeys(NULL, filter); 14088 return GetOwnElementKeys(NULL, filter);
14092 } 14089 }
14093 14090
14094 14091
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
14158 storage->set(counter, Smi::FromInt(counter)); 14155 storage->set(counter, Smi::FromInt(counter));
14159 } 14156 }
14160 counter++; 14157 counter++;
14161 } 14158 }
14162 DCHECK(!storage || storage->length() >= counter); 14159 DCHECK(!storage || storage->length() >= counter);
14163 break; 14160 break;
14164 } 14161 }
14165 14162
14166 case DICTIONARY_ELEMENTS: { 14163 case DICTIONARY_ELEMENTS: {
14167 if (storage != NULL) { 14164 if (storage != NULL) {
14168 element_dictionary()->CopyKeysTo(storage, 14165 element_dictionary()->CopyKeysTo<DictionaryEntryType::kObjects>(
14169 filter, 14166 storage, filter, SeededNumberDictionary::SORTED);
14170 SeededNumberDictionary::SORTED);
14171 } 14167 }
14172 counter += element_dictionary()->NumberOfElementsFilterAttributes(filter); 14168 counter +=
14169 element_dictionary()
14170 ->NumberOfElementsFilterAttributes<DictionaryEntryType::kObjects>(
14171 filter);
14173 break; 14172 break;
14174 } 14173 }
14175 case SLOPPY_ARGUMENTS_ELEMENTS: { 14174 case SLOPPY_ARGUMENTS_ELEMENTS: {
14176 FixedArray* parameter_map = FixedArray::cast(elements()); 14175 FixedArray* parameter_map = FixedArray::cast(elements());
14177 int mapped_length = parameter_map->length() - 2; 14176 int mapped_length = parameter_map->length() - 2;
14178 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); 14177 FixedArray* arguments = FixedArray::cast(parameter_map->get(1));
14179 if (arguments->IsDictionary()) { 14178 if (arguments->IsDictionary()) {
14180 // Copy the keys from arguments first, because Dictionary::CopyKeysTo 14179 // Copy the keys from arguments first, because Dictionary::CopyKeysTo
14181 // will insert in storage starting at index 0. 14180 // will insert in storage starting at index 0.
14182 SeededNumberDictionary* dictionary = 14181 SeededNumberDictionary* dictionary =
14183 SeededNumberDictionary::cast(arguments); 14182 SeededNumberDictionary::cast(arguments);
14184 if (storage != NULL) { 14183 if (storage != NULL) {
14185 dictionary->CopyKeysTo( 14184 dictionary->CopyKeysTo<DictionaryEntryType::kObjects>(
14186 storage, filter, SeededNumberDictionary::UNSORTED); 14185 storage, filter, SeededNumberDictionary::UNSORTED);
14187 } 14186 }
14188 counter += dictionary->NumberOfElementsFilterAttributes(filter); 14187 counter += dictionary->NumberOfElementsFilterAttributes<
14188 DictionaryEntryType::kObjects>(filter);
14189 for (int i = 0; i < mapped_length; ++i) { 14189 for (int i = 0; i < mapped_length; ++i) {
14190 if (!parameter_map->get(i + 2)->IsTheHole()) { 14190 if (!parameter_map->get(i + 2)->IsTheHole()) {
14191 if (storage != NULL) storage->set(counter, Smi::FromInt(i)); 14191 if (storage != NULL) storage->set(counter, Smi::FromInt(i));
14192 ++counter; 14192 ++counter;
14193 } 14193 }
14194 } 14194 }
14195 if (storage != NULL) storage->SortPairs(storage, counter); 14195 if (storage != NULL) storage->SortPairs(storage, counter);
14196 14196
14197 } else { 14197 } else {
14198 int backing_length = arguments->length(); 14198 int backing_length = arguments->length();
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
14769 AtPut(Handle<UnseededNumberDictionary>, uint32_t, Handle<Object>); 14769 AtPut(Handle<UnseededNumberDictionary>, uint32_t, Handle<Object>);
14770 14770
14771 template Object* 14771 template Object*
14772 Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>:: 14772 Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>::
14773 SlowReverseLookup(Object* value); 14773 SlowReverseLookup(Object* value);
14774 14774
14775 template Object* 14775 template Object*
14776 Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >:: 14776 Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::
14777 SlowReverseLookup(Object* value); 14777 SlowReverseLookup(Object* value);
14778 14778
14779 template void
14780 Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>::
14781 CopyKeysTo(
14782 FixedArray*,
14783 PropertyAttributes,
14784 Dictionary<SeededNumberDictionary,
14785 SeededNumberDictionaryShape,
14786 uint32_t>::SortMode);
14787
14788 template Handle<Object> 14779 template Handle<Object>
14789 Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::DeleteProperty( 14780 Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::DeleteProperty(
14790 Handle<NameDictionary>, int); 14781 Handle<NameDictionary>, int);
14791 14782
14792 template Handle<Object> 14783 template Handle<Object>
14793 Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, 14784 Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape,
14794 uint32_t>::DeleteProperty(Handle<SeededNumberDictionary>, int); 14785 uint32_t>::DeleteProperty(Handle<SeededNumberDictionary>, int);
14795 14786
14796 template Handle<NameDictionary> 14787 template Handle<NameDictionary>
14797 HashTable<NameDictionary, NameDictionaryShape, Handle<Name> >:: 14788 HashTable<NameDictionary, NameDictionaryShape, Handle<Name> >::
14798 New(Isolate*, int, MinimumCapacity, PretenureFlag); 14789 New(Isolate*, int, MinimumCapacity, PretenureFlag);
14799 14790
14800 template Handle<NameDictionary> 14791 template Handle<NameDictionary>
14801 HashTable<NameDictionary, NameDictionaryShape, Handle<Name> >:: 14792 HashTable<NameDictionary, NameDictionaryShape, Handle<Name> >::
14802 Shrink(Handle<NameDictionary>, Handle<Name>); 14793 Shrink(Handle<NameDictionary>, Handle<Name>);
14803 14794
14804 template Handle<SeededNumberDictionary> 14795 template Handle<SeededNumberDictionary>
14805 HashTable<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>:: 14796 HashTable<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>::
14806 Shrink(Handle<SeededNumberDictionary>, uint32_t); 14797 Shrink(Handle<SeededNumberDictionary>, uint32_t);
14807 14798
14808 template void Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::
14809 CopyKeysTo(
14810 FixedArray*,
14811 int,
14812 PropertyAttributes,
14813 Dictionary<
14814 NameDictionary, NameDictionaryShape, Handle<Name> >::SortMode);
14815
14816 template int
14817 Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::
14818 NumberOfElementsFilterAttributes(PropertyAttributes);
14819
14820 template Handle<NameDictionary> 14799 template Handle<NameDictionary>
14821 Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::Add( 14800 Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::Add(
14822 Handle<NameDictionary>, Handle<Name>, Handle<Object>, PropertyDetails); 14801 Handle<NameDictionary>, Handle<Name>, Handle<Object>, PropertyDetails);
14823 14802
14824 template Handle<FixedArray> Dictionary< 14803 template Handle<FixedArray> Dictionary<
14825 NameDictionary, NameDictionaryShape, 14804 NameDictionary, NameDictionaryShape,
14826 Handle<Name> >::BuildIterationIndicesArray(Handle<NameDictionary>); 14805 Handle<Name> >::BuildIterationIndicesArray(Handle<NameDictionary>);
14827 14806
14828 template Handle<FixedArray> Dictionary< 14807 template Handle<FixedArray> Dictionary<
14829 NameDictionary, NameDictionaryShape, 14808 NameDictionary, NameDictionaryShape,
14830 Handle<Name> >::GenerateNewEnumerationIndices(Handle<NameDictionary>); 14809 Handle<Name> >::GenerateNewEnumerationIndices(Handle<NameDictionary>);
14831 14810
14832 template int
14833 Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>::
14834 NumberOfElementsFilterAttributes(PropertyAttributes);
14835
14836 template Handle<SeededNumberDictionary> 14811 template Handle<SeededNumberDictionary>
14837 Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>:: 14812 Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>::
14838 Add(Handle<SeededNumberDictionary>, 14813 Add(Handle<SeededNumberDictionary>,
14839 uint32_t, 14814 uint32_t,
14840 Handle<Object>, 14815 Handle<Object>,
14841 PropertyDetails); 14816 PropertyDetails);
14842 14817
14843 template Handle<UnseededNumberDictionary> 14818 template Handle<UnseededNumberDictionary>
14844 Dictionary<UnseededNumberDictionary, UnseededNumberDictionaryShape, uint32_t>:: 14819 Dictionary<UnseededNumberDictionary, UnseededNumberDictionaryShape, uint32_t>::
14845 Add(Handle<UnseededNumberDictionary>, 14820 Add(Handle<UnseededNumberDictionary>,
14846 uint32_t, 14821 uint32_t,
14847 Handle<Object>, 14822 Handle<Object>,
14848 PropertyDetails); 14823 PropertyDetails);
14849 14824
14850 template Handle<SeededNumberDictionary> 14825 template Handle<SeededNumberDictionary>
14851 Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>:: 14826 Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>::
14852 EnsureCapacity(Handle<SeededNumberDictionary>, int, uint32_t); 14827 EnsureCapacity(Handle<SeededNumberDictionary>, int, uint32_t);
14853 14828
14854 template Handle<UnseededNumberDictionary> 14829 template Handle<UnseededNumberDictionary>
14855 Dictionary<UnseededNumberDictionary, UnseededNumberDictionaryShape, uint32_t>:: 14830 Dictionary<UnseededNumberDictionary, UnseededNumberDictionaryShape, uint32_t>::
14856 EnsureCapacity(Handle<UnseededNumberDictionary>, int, uint32_t); 14831 EnsureCapacity(Handle<UnseededNumberDictionary>, int, uint32_t);
14857 14832
14858 template Handle<NameDictionary> 14833 template Handle<NameDictionary>
14859 Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >:: 14834 Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::
14860 EnsureCapacity(Handle<NameDictionary>, int, Handle<Name>); 14835 EnsureCapacity(Handle<NameDictionary>, int, Handle<Name>);
14861 14836
14862 template 14837 template bool
14863 int Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>:: 14838 Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape,
14864 NumberOfEnumElements(); 14839 uint32_t>::HasComplexElements<DictionaryEntryType::kCells>();
14865 14840
14866 template 14841 template bool
14867 int Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >:: 14842 Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape,
14868 NumberOfEnumElements(); 14843 uint32_t>::HasComplexElements<DictionaryEntryType::kObjects>();
14869
14870 template bool Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape,
14871 uint32_t>::HasComplexElements();
14872 14844
14873 template int HashTable<SeededNumberDictionary, SeededNumberDictionaryShape, 14845 template int HashTable<SeededNumberDictionary, SeededNumberDictionaryShape,
14874 uint32_t>::FindEntry(uint32_t); 14846 uint32_t>::FindEntry(uint32_t);
14875 14847
14876 14848
14877 Handle<Object> JSObject::PrepareSlowElementsForSort( 14849 Handle<Object> JSObject::PrepareSlowElementsForSort(
14878 Handle<JSObject> object, uint32_t limit) { 14850 Handle<JSObject> object, uint32_t limit) {
14879 DCHECK(object->HasDictionaryElements()); 14851 DCHECK(object->HasDictionaryElements());
14880 Isolate* isolate = object->GetIsolate(); 14852 Isolate* isolate = object->GetIsolate();
14881 // Must stay in dictionary mode, either because of requires_slow_elements, 14853 // Must stay in dictionary mode, either because of requires_slow_elements,
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
15323 15295
15324 15296
15325 Handle<PropertyCell> GlobalObject::EnsurePropertyCell( 15297 Handle<PropertyCell> GlobalObject::EnsurePropertyCell(
15326 Handle<GlobalObject> global, Handle<Name> name) { 15298 Handle<GlobalObject> global, Handle<Name> name) {
15327 DCHECK(!global->HasFastProperties()); 15299 DCHECK(!global->HasFastProperties());
15328 int entry = global->property_dictionary()->FindEntry(name); 15300 int entry = global->property_dictionary()->FindEntry(name);
15329 if (entry == NameDictionary::kNotFound) { 15301 if (entry == NameDictionary::kNotFound) {
15330 Isolate* isolate = global->GetIsolate(); 15302 Isolate* isolate = global->GetIsolate();
15331 Handle<PropertyCell> cell = isolate->factory()->NewPropertyCellWithHole(); 15303 Handle<PropertyCell> cell = isolate->factory()->NewPropertyCellWithHole();
15332 PropertyDetails details(NONE, DATA, 0); 15304 PropertyDetails details(NONE, DATA, 0);
15333 details = details.AsDeleted();
15334 Handle<NameDictionary> dictionary = NameDictionary::Add( 15305 Handle<NameDictionary> dictionary = NameDictionary::Add(
15335 handle(global->property_dictionary()), name, cell, details); 15306 handle(global->property_dictionary()), name, cell, details);
15336 global->set_properties(*dictionary); 15307 global->set_properties(*dictionary);
15337 return cell; 15308 return cell;
15338 } else { 15309 } else {
15339 Object* value = global->property_dictionary()->ValueAt(entry); 15310 Object* value = global->property_dictionary()->ValueAt(entry);
15340 DCHECK(value->IsPropertyCell()); 15311 DCHECK(value->IsPropertyCell());
15341 return handle(PropertyCell::cast(value)); 15312 return handle(PropertyCell::cast(value));
15342 } 15313 }
15343 } 15314 }
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
15832 Handle<Derived> dictionary, 15803 Handle<Derived> dictionary,
15833 Key key, 15804 Key key,
15834 Handle<Object> value, 15805 Handle<Object> value,
15835 PropertyDetails details, 15806 PropertyDetails details,
15836 uint32_t hash) { 15807 uint32_t hash) {
15837 // Compute the key object. 15808 // Compute the key object.
15838 Handle<Object> k = Shape::AsHandle(dictionary->GetIsolate(), key); 15809 Handle<Object> k = Shape::AsHandle(dictionary->GetIsolate(), key);
15839 15810
15840 uint32_t entry = dictionary->FindInsertionEntry(hash); 15811 uint32_t entry = dictionary->FindInsertionEntry(hash);
15841 // Insert element at empty or deleted entry 15812 // Insert element at empty or deleted entry
15842 if (!details.IsDeleted() && 15813 if (details.dictionary_index() == 0 && Shape::kIsEnumerable) {
15843 details.dictionary_index() == 0 &&
15844 Shape::kIsEnumerable) {
15845 // Assign an enumeration index to the property and update 15814 // Assign an enumeration index to the property and update
15846 // SetNextEnumerationIndex. 15815 // SetNextEnumerationIndex.
15847 int index = dictionary->NextEnumerationIndex(); 15816 int index = dictionary->NextEnumerationIndex();
15848 details = PropertyDetails(details.attributes(), details.type(), index); 15817 details = PropertyDetails(details.attributes(), details.type(), index);
15849 dictionary->SetNextEnumerationIndex(index + 1); 15818 dictionary->SetNextEnumerationIndex(index + 1);
15850 } 15819 }
15851 dictionary->SetEntry(entry, k, value, details); 15820 dictionary->SetEntry(entry, k, value, details);
15852 DCHECK((dictionary->KeyAt(entry)->IsNumber() || 15821 DCHECK((dictionary->KeyAt(entry)->IsNumber() ||
15853 dictionary->KeyAt(entry)->IsName())); 15822 dictionary->KeyAt(entry)->IsName()));
15854 dictionary->ElementAdded(); 15823 dictionary->ElementAdded();
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
15938 Handle<Object> value) { 15907 Handle<Object> value) {
15939 int entry = dictionary->FindEntry(key); 15908 int entry = dictionary->FindEntry(key);
15940 if (entry == kNotFound) return AddNumberEntry(dictionary, key, value); 15909 if (entry == kNotFound) return AddNumberEntry(dictionary, key, value);
15941 Handle<Object> object_key = 15910 Handle<Object> object_key =
15942 UnseededNumberDictionaryShape::AsHandle(dictionary->GetIsolate(), key); 15911 UnseededNumberDictionaryShape::AsHandle(dictionary->GetIsolate(), key);
15943 dictionary->SetEntry(entry, object_key, value); 15912 dictionary->SetEntry(entry, object_key, value);
15944 return dictionary; 15913 return dictionary;
15945 } 15914 }
15946 15915
15947 15916
15917 template <DictionaryEntryType type, typename D>
15918 static inline bool IsDeleted(D d, int i) {
15919 switch (type) {
15920 case DictionaryEntryType::kObjects:
15921 return false;
15922 case DictionaryEntryType::kCells:
15923 return PropertyCell::cast(d->ValueAt(i))->value()->IsTheHole();
15924 }
15925 UNREACHABLE();
15926 return false;
15927 }
15948 15928
15949 template<typename Derived, typename Shape, typename Key> 15929
15930 template <typename Derived, typename Shape, typename Key>
15931 template <DictionaryEntryType type>
15950 int Dictionary<Derived, Shape, Key>::NumberOfElementsFilterAttributes( 15932 int Dictionary<Derived, Shape, Key>::NumberOfElementsFilterAttributes(
15951 PropertyAttributes filter) { 15933 PropertyAttributes filter) {
15952 int capacity = DerivedHashTable::Capacity(); 15934 int capacity = DerivedHashTable::Capacity();
15953 int result = 0; 15935 int result = 0;
15954 for (int i = 0; i < capacity; i++) { 15936 for (int i = 0; i < capacity; i++) {
15955 Object* k = DerivedHashTable::KeyAt(i); 15937 Object* k = DerivedHashTable::KeyAt(i);
15956 if (DerivedHashTable::IsKey(k) && !FilterKey(k, filter)) { 15938 if (DerivedHashTable::IsKey(k) && !FilterKey(k, filter)) {
15939 if (IsDeleted<type>(this, i)) continue;
15957 PropertyDetails details = DetailsAt(i); 15940 PropertyDetails details = DetailsAt(i);
15958 if (details.IsDeleted()) continue;
15959 PropertyAttributes attr = details.attributes(); 15941 PropertyAttributes attr = details.attributes();
15960 if ((attr & filter) == 0) result++; 15942 if ((attr & filter) == 0) result++;
15961 } 15943 }
15962 } 15944 }
15963 return result; 15945 return result;
15964 } 15946 }
15965 15947
15966 15948
15967 template<typename Derived, typename Shape, typename Key>
15968 int Dictionary<Derived, Shape, Key>::NumberOfEnumElements() {
15969 return NumberOfElementsFilterAttributes(
15970 static_cast<PropertyAttributes>(DONT_ENUM | SYMBOLIC));
15971 }
15972
15973
15974 template <typename Derived, typename Shape, typename Key> 15949 template <typename Derived, typename Shape, typename Key>
15950 template <DictionaryEntryType type>
15975 bool Dictionary<Derived, Shape, Key>::HasComplexElements() { 15951 bool Dictionary<Derived, Shape, Key>::HasComplexElements() {
15976 int capacity = DerivedHashTable::Capacity(); 15952 int capacity = DerivedHashTable::Capacity();
15977 for (int i = 0; i < capacity; i++) { 15953 for (int i = 0; i < capacity; i++) {
15978 Object* k = DerivedHashTable::KeyAt(i); 15954 Object* k = DerivedHashTable::KeyAt(i);
15979 if (DerivedHashTable::IsKey(k) && !FilterKey(k, NONE)) { 15955 if (DerivedHashTable::IsKey(k) && !FilterKey(k, NONE)) {
15956 if (IsDeleted<type>(this, i)) continue;
15980 PropertyDetails details = DetailsAt(i); 15957 PropertyDetails details = DetailsAt(i);
15981 if (details.IsDeleted()) continue;
15982 if (details.type() == ACCESSOR_CONSTANT) return true; 15958 if (details.type() == ACCESSOR_CONSTANT) return true;
15983 PropertyAttributes attr = details.attributes(); 15959 PropertyAttributes attr = details.attributes();
15984 if (attr & (READ_ONLY | DONT_DELETE | DONT_ENUM)) return true; 15960 if (attr & (READ_ONLY | DONT_DELETE | DONT_ENUM)) return true;
15985 } 15961 }
15986 } 15962 }
15987 return false; 15963 return false;
15988 } 15964 }
15989 15965
15990 15966
15991 template <typename Derived, typename Shape, typename Key> 15967 template <typename Derived, typename Shape, typename Key>
15968 template <DictionaryEntryType type>
15992 void Dictionary<Derived, Shape, Key>::CopyKeysTo( 15969 void Dictionary<Derived, Shape, Key>::CopyKeysTo(
15993 FixedArray* storage, PropertyAttributes filter, 15970 FixedArray* storage, PropertyAttributes filter,
15994 typename Dictionary<Derived, Shape, Key>::SortMode sort_mode) { 15971 typename Dictionary<Derived, Shape, Key>::SortMode sort_mode) {
15995 DCHECK(storage->length() >= NumberOfElementsFilterAttributes(filter)); 15972 DCHECK(storage->length() >= NumberOfElementsFilterAttributes<type>(filter));
15996 int capacity = DerivedHashTable::Capacity(); 15973 int capacity = DerivedHashTable::Capacity();
15997 int index = 0; 15974 int index = 0;
15998 for (int i = 0; i < capacity; i++) { 15975 for (int i = 0; i < capacity; i++) {
15999 Object* k = DerivedHashTable::KeyAt(i); 15976 Object* k = DerivedHashTable::KeyAt(i);
16000 if (DerivedHashTable::IsKey(k) && !FilterKey(k, filter)) { 15977 if (DerivedHashTable::IsKey(k) && !FilterKey(k, filter)) {
15978 if (IsDeleted<type>(this, i)) continue;
16001 PropertyDetails details = DetailsAt(i); 15979 PropertyDetails details = DetailsAt(i);
16002 if (details.IsDeleted()) continue;
16003 PropertyAttributes attr = details.attributes(); 15980 PropertyAttributes attr = details.attributes();
16004 if ((attr & filter) == 0) storage->set(index++, k); 15981 if ((attr & filter) == 0) storage->set(index++, k);
16005 } 15982 }
16006 } 15983 }
16007 if (sort_mode == Dictionary::SORTED) { 15984 if (sort_mode == Dictionary::SORTED) {
16008 storage->SortPairs(storage, index); 15985 storage->SortPairs(storage, index);
16009 } 15986 }
16010 DCHECK(storage->length() >= index); 15987 DCHECK(storage->length() >= index);
16011 } 15988 }
16012 15989
16013 15990
16014 struct EnumIndexComparator { 15991 struct EnumIndexComparator {
16015 explicit EnumIndexComparator(NameDictionary* dict) : dict(dict) { } 15992 explicit EnumIndexComparator(NameDictionary* dict) : dict(dict) { }
16016 bool operator() (Smi* a, Smi* b) { 15993 bool operator() (Smi* a, Smi* b) {
16017 PropertyDetails da(dict->DetailsAt(a->value())); 15994 PropertyDetails da(dict->DetailsAt(a->value()));
16018 PropertyDetails db(dict->DetailsAt(b->value())); 15995 PropertyDetails db(dict->DetailsAt(b->value()));
16019 return da.dictionary_index() < db.dictionary_index(); 15996 return da.dictionary_index() < db.dictionary_index();
16020 } 15997 }
16021 NameDictionary* dict; 15998 NameDictionary* dict;
16022 }; 15999 };
16023 16000
16024 16001
16002 template <DictionaryEntryType type>
16025 void NameDictionary::CopyEnumKeysTo(FixedArray* storage) { 16003 void NameDictionary::CopyEnumKeysTo(FixedArray* storage) {
16026 int length = storage->length(); 16004 int length = storage->length();
16027 int capacity = Capacity(); 16005 int capacity = Capacity();
16028 int properties = 0; 16006 int properties = 0;
16029 for (int i = 0; i < capacity; i++) { 16007 for (int i = 0; i < capacity; i++) {
16030 Object* k = KeyAt(i); 16008 Object* k = KeyAt(i);
16031 if (IsKey(k) && !k->IsSymbol()) { 16009 if (IsKey(k) && !k->IsSymbol()) {
16032 PropertyDetails details = DetailsAt(i); 16010 PropertyDetails details = DetailsAt(i);
16033 if (details.IsDeleted() || details.IsDontEnum()) continue; 16011 if (details.IsDontEnum() || IsDeleted<type>(this, i)) continue;
16034 storage->set(properties, Smi::FromInt(i)); 16012 storage->set(properties, Smi::FromInt(i));
16035 properties++; 16013 properties++;
16036 if (properties == length) break; 16014 if (properties == length) break;
16037 } 16015 }
16038 } 16016 }
16039 CHECK_EQ(length, properties); 16017 CHECK_EQ(length, properties);
16040 EnumIndexComparator cmp(this); 16018 EnumIndexComparator cmp(this);
16041 Smi** start = reinterpret_cast<Smi**>(storage->GetFirstElementAddress()); 16019 Smi** start = reinterpret_cast<Smi**>(storage->GetFirstElementAddress());
16042 std::sort(start, start + length, cmp); 16020 std::sort(start, start + length, cmp);
16043 for (int i = 0; i < length; i++) { 16021 for (int i = 0; i < length; i++) {
16044 int index = Smi::cast(storage->get(i))->value(); 16022 int index = Smi::cast(storage->get(i))->value();
16045 storage->set(i, KeyAt(index)); 16023 storage->set(i, KeyAt(index));
16046 } 16024 }
16047 } 16025 }
16048 16026
16049 16027
16050 template<typename Derived, typename Shape, typename Key> 16028 template <typename Derived, typename Shape, typename Key>
16029 template <DictionaryEntryType type>
16051 void Dictionary<Derived, Shape, Key>::CopyKeysTo( 16030 void Dictionary<Derived, Shape, Key>::CopyKeysTo(
16052 FixedArray* storage, 16031 FixedArray* storage, int index, PropertyAttributes filter,
16053 int index,
16054 PropertyAttributes filter,
16055 typename Dictionary<Derived, Shape, Key>::SortMode sort_mode) { 16032 typename Dictionary<Derived, Shape, Key>::SortMode sort_mode) {
16056 DCHECK(storage->length() >= NumberOfElementsFilterAttributes(filter)); 16033 DCHECK(storage->length() >= NumberOfElementsFilterAttributes<type>(filter));
16057 int capacity = DerivedHashTable::Capacity(); 16034 int capacity = DerivedHashTable::Capacity();
16058 for (int i = 0; i < capacity; i++) { 16035 for (int i = 0; i < capacity; i++) {
16059 Object* k = DerivedHashTable::KeyAt(i); 16036 Object* k = DerivedHashTable::KeyAt(i);
16060 if (DerivedHashTable::IsKey(k) && !FilterKey(k, filter)) { 16037 if (DerivedHashTable::IsKey(k) && !FilterKey(k, filter)) {
16038 if (IsDeleted<type>(this, i)) continue;
16061 PropertyDetails details = DetailsAt(i); 16039 PropertyDetails details = DetailsAt(i);
16062 if (details.IsDeleted()) continue;
16063 PropertyAttributes attr = details.attributes(); 16040 PropertyAttributes attr = details.attributes();
16064 if ((attr & filter) == 0) storage->set(index++, k); 16041 if ((attr & filter) == 0) storage->set(index++, k);
16065 } 16042 }
16066 } 16043 }
16067 if (sort_mode == Dictionary::SORTED) { 16044 if (sort_mode == Dictionary::SORTED) {
16068 storage->SortPairs(storage, index); 16045 storage->SortPairs(storage, index);
16069 } 16046 }
16070 DCHECK(storage->length() >= index); 16047 DCHECK(storage->length() >= index);
16071 } 16048 }
16072 16049
16073 16050
16074 // Backwards lookup (slow). 16051 // Backwards lookup (slow).
16075 template<typename Derived, typename Shape, typename Key> 16052 template<typename Derived, typename Shape, typename Key>
16076 Object* Dictionary<Derived, Shape, Key>::SlowReverseLookup(Object* value) { 16053 Object* Dictionary<Derived, Shape, Key>::SlowReverseLookup(Object* value) {
16077 int capacity = DerivedHashTable::Capacity(); 16054 int capacity = DerivedHashTable::Capacity();
16078 for (int i = 0; i < capacity; i++) { 16055 for (int i = 0; i < capacity; i++) {
16079 Object* k = DerivedHashTable::KeyAt(i); 16056 Object* k = DerivedHashTable::KeyAt(i);
16080 if (Dictionary::IsKey(k)) { 16057 if (Dictionary::IsKey(k)) {
16081 Object* e = ValueAt(i); 16058 Object* e = ValueAt(i);
16059 // TODO(dcarney): this should be templatized.
16082 if (e->IsPropertyCell()) { 16060 if (e->IsPropertyCell()) {
16083 e = PropertyCell::cast(e)->value(); 16061 e = PropertyCell::cast(e)->value();
16084 } 16062 }
16085 if (e == value) return k; 16063 if (e == value) return k;
16086 } 16064 }
16087 } 16065 }
16088 Heap* heap = Dictionary::GetHeap(); 16066 Heap* heap = Dictionary::GetHeap();
16089 return heap->undefined_value(); 16067 return heap->undefined_value();
16090 } 16068 }
16091 16069
(...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after
17151 CompilationInfo* info) { 17129 CompilationInfo* info) {
17152 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo( 17130 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo(
17153 handle(cell->dependent_code(), info->isolate()), 17131 handle(cell->dependent_code(), info->isolate()),
17154 DependentCode::kPropertyCellChangedGroup, info->object_wrapper()); 17132 DependentCode::kPropertyCellChangedGroup, info->object_wrapper());
17155 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); 17133 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes);
17156 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( 17134 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add(
17157 cell, info->zone()); 17135 cell, info->zone());
17158 } 17136 }
17159 17137
17160 } } // namespace v8::internal 17138 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698