OLD | NEW |
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 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(it->isolate(), Object); | 548 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(it->isolate(), Object); |
549 return value; | 549 return value; |
550 } | 550 } |
551 | 551 |
552 | 552 |
553 void JSObject::SetNormalizedProperty(Handle<JSObject> object, | 553 void JSObject::SetNormalizedProperty(Handle<JSObject> object, |
554 Handle<Name> name, | 554 Handle<Name> name, |
555 Handle<Object> value, | 555 Handle<Object> value, |
556 PropertyDetails details) { | 556 PropertyDetails details) { |
557 DCHECK(!object->HasFastProperties()); | 557 DCHECK(!object->HasFastProperties()); |
558 Handle<NameDictionary> property_dictionary(object->property_dictionary()); | |
559 | |
560 if (!name->IsUniqueName()) { | 558 if (!name->IsUniqueName()) { |
561 name = object->GetIsolate()->factory()->InternalizeString( | 559 name = object->GetIsolate()->factory()->InternalizeString( |
562 Handle<String>::cast(name)); | 560 Handle<String>::cast(name)); |
563 } | 561 } |
564 | 562 |
565 int entry = property_dictionary->FindEntry(name); | 563 if (object->IsGlobalObject()) { |
566 if (entry == NameDictionary::kNotFound) { | 564 Handle<GlobalDictionary> property_dictionary(object->global_dictionary()); |
567 if (object->IsGlobalObject()) { | 565 |
| 566 int entry = property_dictionary->FindEntry(name); |
| 567 if (entry == GlobalDictionary::kNotFound) { |
568 auto cell = object->GetIsolate()->factory()->NewPropertyCell(); | 568 auto cell = object->GetIsolate()->factory()->NewPropertyCell(); |
569 cell->set_value(*value); | 569 cell->set_value(*value); |
570 auto cell_type = value->IsUndefined() ? PropertyCellType::kUndefined | 570 auto cell_type = value->IsUndefined() ? PropertyCellType::kUndefined |
571 : PropertyCellType::kConstant; | 571 : PropertyCellType::kConstant; |
572 details = details.set_cell_type(cell_type); | 572 details = details.set_cell_type(cell_type); |
573 value = cell; | 573 value = cell; |
| 574 property_dictionary = |
| 575 GlobalDictionary::Add(property_dictionary, name, value, details); |
| 576 object->set_properties(*property_dictionary); |
| 577 } else { |
| 578 PropertyCell::UpdateCell(property_dictionary, entry, value, details); |
574 } | 579 } |
575 property_dictionary = | 580 } else { |
576 NameDictionary::Add(property_dictionary, name, value, details); | 581 Handle<NameDictionary> property_dictionary(object->property_dictionary()); |
577 object->set_properties(*property_dictionary); | 582 |
578 return; | 583 int entry = property_dictionary->FindEntry(name); |
| 584 if (entry == NameDictionary::kNotFound) { |
| 585 property_dictionary = |
| 586 NameDictionary::Add(property_dictionary, name, value, details); |
| 587 object->set_properties(*property_dictionary); |
| 588 } else { |
| 589 PropertyDetails original_details = property_dictionary->DetailsAt(entry); |
| 590 int enumeration_index = original_details.dictionary_index(); |
| 591 DCHECK(enumeration_index > 0); |
| 592 details = details.set_index(enumeration_index); |
| 593 property_dictionary->SetEntry(entry, name, value, details); |
| 594 } |
579 } | 595 } |
580 | |
581 if (object->IsGlobalObject()) { | |
582 PropertyCell::UpdateCell(property_dictionary, entry, value, details); | |
583 return; | |
584 } | |
585 | |
586 PropertyDetails original_details = property_dictionary->DetailsAt(entry); | |
587 int enumeration_index = original_details.dictionary_index(); | |
588 DCHECK(enumeration_index > 0); | |
589 details = details.set_index(enumeration_index); | |
590 property_dictionary->SetEntry(entry, name, value, details); | |
591 } | 596 } |
592 | 597 |
593 | 598 |
594 static MaybeHandle<JSObject> FindIndexedAllCanReadHolder( | 599 static MaybeHandle<JSObject> FindIndexedAllCanReadHolder( |
595 Isolate* isolate, Handle<JSObject> js_object, | 600 Isolate* isolate, Handle<JSObject> js_object, |
596 PrototypeIterator::WhereToStart where_to_start) { | 601 PrototypeIterator::WhereToStart where_to_start) { |
597 for (PrototypeIterator iter(isolate, js_object, where_to_start); | 602 for (PrototypeIterator iter(isolate, js_object, where_to_start); |
598 !iter.IsAtEnd(); iter.Advance()) { | 603 !iter.IsAtEnd(); iter.Advance()) { |
599 auto curr = PrototypeIterator::GetCurrent(iter); | 604 auto curr = PrototypeIterator::GetCurrent(iter); |
600 if (!curr->IsJSObject()) break; | 605 if (!curr->IsJSObject()) break; |
(...skipping 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1797 return Map::CopyAddDescriptor(map, &new_constant_desc, flag); | 1802 return Map::CopyAddDescriptor(map, &new_constant_desc, flag); |
1798 } | 1803 } |
1799 | 1804 |
1800 | 1805 |
1801 void JSObject::AddSlowProperty(Handle<JSObject> object, | 1806 void JSObject::AddSlowProperty(Handle<JSObject> object, |
1802 Handle<Name> name, | 1807 Handle<Name> name, |
1803 Handle<Object> value, | 1808 Handle<Object> value, |
1804 PropertyAttributes attributes) { | 1809 PropertyAttributes attributes) { |
1805 DCHECK(!object->HasFastProperties()); | 1810 DCHECK(!object->HasFastProperties()); |
1806 Isolate* isolate = object->GetIsolate(); | 1811 Isolate* isolate = object->GetIsolate(); |
1807 Handle<NameDictionary> dict(object->property_dictionary()); | |
1808 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell); | |
1809 if (object->IsGlobalObject()) { | 1812 if (object->IsGlobalObject()) { |
| 1813 Handle<GlobalDictionary> dict(object->global_dictionary()); |
| 1814 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell); |
1810 int entry = dict->FindEntry(name); | 1815 int entry = dict->FindEntry(name); |
1811 // If there's a cell there, just invalidate and set the property. | 1816 // If there's a cell there, just invalidate and set the property. |
1812 if (entry != NameDictionary::kNotFound) { | 1817 if (entry != GlobalDictionary::kNotFound) { |
1813 PropertyCell::UpdateCell(dict, entry, value, details); | 1818 PropertyCell::UpdateCell(dict, entry, value, details); |
1814 // TODO(dcarney): move this to UpdateCell. | 1819 // TODO(dcarney): move this to UpdateCell. |
1815 // Need to adjust the details. | 1820 // Need to adjust the details. |
1816 int index = dict->NextEnumerationIndex(); | 1821 int index = dict->NextEnumerationIndex(); |
1817 dict->SetNextEnumerationIndex(index + 1); | 1822 dict->SetNextEnumerationIndex(index + 1); |
1818 details = dict->DetailsAt(entry).set_index(index); | 1823 details = dict->DetailsAt(entry).set_index(index); |
1819 dict->DetailsAtPut(entry, details); | 1824 dict->DetailsAtPut(entry, details); |
1820 return; | 1825 |
| 1826 } else { |
| 1827 auto cell = isolate->factory()->NewPropertyCell(); |
| 1828 cell->set_value(*value); |
| 1829 auto cell_type = value->IsUndefined() ? PropertyCellType::kUndefined |
| 1830 : PropertyCellType::kConstant; |
| 1831 details = details.set_cell_type(cell_type); |
| 1832 value = cell; |
| 1833 |
| 1834 Handle<GlobalDictionary> result = |
| 1835 GlobalDictionary::Add(dict, name, value, details); |
| 1836 if (*dict != *result) object->set_properties(*result); |
1821 } | 1837 } |
1822 auto cell = isolate->factory()->NewPropertyCell(); | 1838 } else { |
1823 cell->set_value(*value); | 1839 Handle<NameDictionary> dict(object->property_dictionary()); |
1824 auto cell_type = value->IsUndefined() ? PropertyCellType::kUndefined | 1840 PropertyDetails details(attributes, DATA, 0, PropertyCellType::kNoCell); |
1825 : PropertyCellType::kConstant; | 1841 Handle<NameDictionary> result = |
1826 details = details.set_cell_type(cell_type); | 1842 NameDictionary::Add(dict, name, value, details); |
1827 value = cell; | 1843 if (*dict != *result) object->set_properties(*result); |
1828 } | 1844 } |
1829 Handle<NameDictionary> result = | |
1830 NameDictionary::Add(dict, name, value, details); | |
1831 if (*dict != *result) object->set_properties(*result); | |
1832 } | 1845 } |
1833 | 1846 |
1834 | 1847 |
1835 Context* JSObject::GetCreationContext() { | 1848 Context* JSObject::GetCreationContext() { |
1836 Object* constructor = this->map()->GetConstructor(); | 1849 Object* constructor = this->map()->GetConstructor(); |
1837 JSFunction* function; | 1850 JSFunction* function; |
1838 if (!constructor->IsJSFunction()) { | 1851 if (!constructor->IsJSFunction()) { |
1839 // Functions have null as a constructor, | 1852 // Functions have null as a constructor, |
1840 // but any JSFunction knows its context immediately. | 1853 // but any JSFunction knows its context immediately. |
1841 function = JSFunction::cast(this); | 1854 function = JSFunction::cast(this); |
(...skipping 3551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5393 } | 5406 } |
5394 | 5407 |
5395 return result; | 5408 return result; |
5396 } | 5409 } |
5397 | 5410 |
5398 | 5411 |
5399 void JSObject::DeleteNormalizedProperty(Handle<JSObject> object, | 5412 void JSObject::DeleteNormalizedProperty(Handle<JSObject> object, |
5400 Handle<Name> name) { | 5413 Handle<Name> name) { |
5401 DCHECK(!object->HasFastProperties()); | 5414 DCHECK(!object->HasFastProperties()); |
5402 Isolate* isolate = object->GetIsolate(); | 5415 Isolate* isolate = object->GetIsolate(); |
5403 Handle<NameDictionary> dictionary(object->property_dictionary()); | |
5404 int entry = dictionary->FindEntry(name); | |
5405 DCHECK_NE(NameDictionary::kNotFound, entry); | |
5406 | 5416 |
5407 // If we have a global object, invalidate the cell and swap in a new one. | |
5408 if (object->IsGlobalObject()) { | 5417 if (object->IsGlobalObject()) { |
| 5418 // If we have a global object, invalidate the cell and swap in a new one. |
| 5419 Handle<GlobalDictionary> dictionary(object->global_dictionary()); |
| 5420 int entry = dictionary->FindEntry(name); |
| 5421 DCHECK_NE(GlobalDictionary::kNotFound, entry); |
| 5422 |
5409 auto cell = PropertyCell::InvalidateEntry(dictionary, entry); | 5423 auto cell = PropertyCell::InvalidateEntry(dictionary, entry); |
5410 cell->set_value(isolate->heap()->the_hole_value()); | 5424 cell->set_value(isolate->heap()->the_hole_value()); |
5411 // TODO(dcarney): InvalidateForDelete | 5425 // TODO(dcarney): InvalidateForDelete |
5412 dictionary->DetailsAtPut(entry, dictionary->DetailsAt(entry).set_cell_type( | 5426 dictionary->DetailsAtPut(entry, dictionary->DetailsAt(entry).set_cell_type( |
5413 PropertyCellType::kInvalidated)); | 5427 PropertyCellType::kInvalidated)); |
5414 return; | 5428 } else { |
| 5429 Handle<NameDictionary> dictionary(object->property_dictionary()); |
| 5430 int entry = dictionary->FindEntry(name); |
| 5431 DCHECK_NE(NameDictionary::kNotFound, entry); |
| 5432 |
| 5433 NameDictionary::DeleteProperty(dictionary, entry); |
| 5434 Handle<NameDictionary> new_properties = |
| 5435 NameDictionary::Shrink(dictionary, name); |
| 5436 object->set_properties(*new_properties); |
5415 } | 5437 } |
5416 | |
5417 NameDictionary::DeleteProperty(dictionary, entry); | |
5418 Handle<NameDictionary> new_properties = | |
5419 NameDictionary::Shrink(dictionary, name); | |
5420 object->set_properties(*new_properties); | |
5421 } | 5438 } |
5422 | 5439 |
5423 | 5440 |
5424 MaybeHandle<Object> JSObject::DeleteProperty(Handle<JSObject> object, | 5441 MaybeHandle<Object> JSObject::DeleteProperty(Handle<JSObject> object, |
5425 Handle<Name> name, | 5442 Handle<Name> name, |
5426 LanguageMode language_mode) { | 5443 LanguageMode language_mode) { |
5427 // ECMA-262, 3rd, 8.6.2.5 | 5444 // ECMA-262, 3rd, 8.6.2.5 |
5428 DCHECK(name->IsName()); | 5445 DCHECK(name->IsName()); |
5429 | 5446 |
5430 uint32_t index = 0; | 5447 uint32_t index = 0; |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5844 | 5861 |
5845 // Create a new map, since other objects with this map may be extensible. | 5862 // Create a new map, since other objects with this map may be extensible. |
5846 // TODO(adamk): Extend the NormalizedMapCache to handle non-extensible maps. | 5863 // TODO(adamk): Extend the NormalizedMapCache to handle non-extensible maps. |
5847 Handle<Map> new_map = | 5864 Handle<Map> new_map = |
5848 Map::Copy(handle(object->map()), "SlowCopyForPreventExtensions"); | 5865 Map::Copy(handle(object->map()), "SlowCopyForPreventExtensions"); |
5849 new_map->set_is_extensible(false); | 5866 new_map->set_is_extensible(false); |
5850 new_map->set_elements_kind(DICTIONARY_ELEMENTS); | 5867 new_map->set_elements_kind(DICTIONARY_ELEMENTS); |
5851 JSObject::MigrateToMap(object, new_map); | 5868 JSObject::MigrateToMap(object, new_map); |
5852 | 5869 |
5853 if (attrs != NONE) { | 5870 if (attrs != NONE) { |
5854 ApplyAttributesToDictionary(object->property_dictionary(), attrs); | 5871 if (object->IsGlobalObject()) { |
| 5872 ApplyAttributesToDictionary(object->global_dictionary(), attrs); |
| 5873 } else { |
| 5874 ApplyAttributesToDictionary(object->property_dictionary(), attrs); |
| 5875 } |
5855 } | 5876 } |
5856 } | 5877 } |
5857 | 5878 |
5858 DCHECK(object->map()->has_dictionary_elements()); | 5879 DCHECK(object->map()->has_dictionary_elements()); |
5859 if (!new_element_dictionary.is_null()) { | 5880 if (!new_element_dictionary.is_null()) { |
5860 object->set_elements(*new_element_dictionary); | 5881 object->set_elements(*new_element_dictionary); |
5861 } | 5882 } |
5862 | 5883 |
5863 if (object->elements() != isolate->heap()->empty_slow_element_dictionary()) { | 5884 if (object->elements() != isolate->heap()->empty_slow_element_dictionary()) { |
5864 SeededNumberDictionary* dictionary = object->element_dictionary(); | 5885 SeededNumberDictionary* dictionary = object->element_dictionary(); |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6336 DescriptorArray::kEnumCacheBridgeLength); | 6357 DescriptorArray::kEnumCacheBridgeLength); |
6337 DescriptorArray* desc = object->map()->instance_descriptors(); | 6358 DescriptorArray* desc = object->map()->instance_descriptors(); |
6338 desc->SetEnumCache(*bridge_storage, | 6359 desc->SetEnumCache(*bridge_storage, |
6339 *storage, | 6360 *storage, |
6340 indices.is_null() ? Object::cast(Smi::FromInt(0)) | 6361 indices.is_null() ? Object::cast(Smi::FromInt(0)) |
6341 : Object::cast(*indices)); | 6362 : Object::cast(*indices)); |
6342 if (cache_result) { | 6363 if (cache_result) { |
6343 object->map()->SetEnumLength(own_property_count); | 6364 object->map()->SetEnumLength(own_property_count); |
6344 } | 6365 } |
6345 return storage; | 6366 return storage; |
| 6367 } else if (object->IsGlobalObject()) { |
| 6368 Handle<GlobalDictionary> dictionary(object->global_dictionary()); |
| 6369 int length = dictionary->NumberOfEnumElements(*object); |
| 6370 if (length == 0) { |
| 6371 return Handle<FixedArray>(isolate->heap()->empty_fixed_array()); |
| 6372 } |
| 6373 Handle<FixedArray> storage = isolate->factory()->NewFixedArray(length); |
| 6374 dictionary->CopyEnumKeysTo(*object, *storage); |
| 6375 return storage; |
6346 } else { | 6376 } else { |
6347 Handle<NameDictionary> dictionary(object->property_dictionary()); | 6377 Handle<NameDictionary> dictionary(object->property_dictionary()); |
6348 int length = dictionary->NumberOfEnumElements(*object); | 6378 int length = dictionary->NumberOfEnumElements(*object); |
6349 if (length == 0) { | 6379 if (length == 0) { |
6350 return Handle<FixedArray>(isolate->heap()->empty_fixed_array()); | 6380 return Handle<FixedArray>(isolate->heap()->empty_fixed_array()); |
6351 } | 6381 } |
6352 Handle<FixedArray> storage = isolate->factory()->NewFixedArray(length); | 6382 Handle<FixedArray> storage = isolate->factory()->NewFixedArray(length); |
6353 dictionary->CopyEnumKeysTo(*object, *storage); | 6383 dictionary->CopyEnumKeysTo(*object, *storage); |
6354 return storage; | 6384 return storage; |
6355 } | 6385 } |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6915 return descs->GetKey(i); | 6945 return descs->GetKey(i); |
6916 } | 6946 } |
6917 } | 6947 } |
6918 } else if (descs->GetType(i) == DATA_CONSTANT) { | 6948 } else if (descs->GetType(i) == DATA_CONSTANT) { |
6919 if (descs->GetConstant(i) == value) { | 6949 if (descs->GetConstant(i) == value) { |
6920 return descs->GetKey(i); | 6950 return descs->GetKey(i); |
6921 } | 6951 } |
6922 } | 6952 } |
6923 } | 6953 } |
6924 return GetHeap()->undefined_value(); | 6954 return GetHeap()->undefined_value(); |
| 6955 } else if (IsGlobalObject()) { |
| 6956 return global_dictionary()->SlowReverseLookup(value); |
6925 } else { | 6957 } else { |
6926 return property_dictionary()->SlowReverseLookup(value); | 6958 return property_dictionary()->SlowReverseLookup(value); |
6927 } | 6959 } |
6928 } | 6960 } |
6929 | 6961 |
6930 | 6962 |
6931 Handle<Map> Map::RawCopy(Handle<Map> map, int instance_size) { | 6963 Handle<Map> Map::RawCopy(Handle<Map> map, int instance_size) { |
6932 Isolate* isolate = map->GetIsolate(); | 6964 Isolate* isolate = map->GetIsolate(); |
6933 Handle<Map> result = | 6965 Handle<Map> result = |
6934 isolate->factory()->NewMap(map->instance_type(), instance_size); | 6966 isolate->factory()->NewMap(map->instance_type(), instance_size); |
(...skipping 7234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14169 | 14201 |
14170 int JSObject::NumberOfOwnProperties(PropertyAttributes filter) { | 14202 int JSObject::NumberOfOwnProperties(PropertyAttributes filter) { |
14171 if (HasFastProperties()) { | 14203 if (HasFastProperties()) { |
14172 Map* map = this->map(); | 14204 Map* map = this->map(); |
14173 if (filter == NONE) return map->NumberOfOwnDescriptors(); | 14205 if (filter == NONE) return map->NumberOfOwnDescriptors(); |
14174 if (filter & DONT_ENUM) { | 14206 if (filter & DONT_ENUM) { |
14175 int result = map->EnumLength(); | 14207 int result = map->EnumLength(); |
14176 if (result != kInvalidEnumCacheSentinel) return result; | 14208 if (result != kInvalidEnumCacheSentinel) return result; |
14177 } | 14209 } |
14178 return map->NumberOfDescribedProperties(OWN_DESCRIPTORS, filter); | 14210 return map->NumberOfDescribedProperties(OWN_DESCRIPTORS, filter); |
| 14211 } else if (IsGlobalObject()) { |
| 14212 return global_dictionary()->NumberOfElementsFilterAttributes(this, filter); |
| 14213 } else { |
| 14214 return property_dictionary()->NumberOfElementsFilterAttributes(this, |
| 14215 filter); |
14179 } | 14216 } |
14180 return property_dictionary()->NumberOfElementsFilterAttributes(this, filter); | |
14181 } | 14217 } |
14182 | 14218 |
14183 | 14219 |
14184 void FixedArray::SwapPairs(FixedArray* numbers, int i, int j) { | 14220 void FixedArray::SwapPairs(FixedArray* numbers, int i, int j) { |
14185 Object* temp = get(i); | 14221 Object* temp = get(i); |
14186 set(i, get(j)); | 14222 set(i, get(j)); |
14187 set(j, temp); | 14223 set(j, temp); |
14188 if (this != numbers) { | 14224 if (this != numbers) { |
14189 temp = numbers->get(i); | 14225 temp = numbers->get(i); |
14190 numbers->set(i, Smi::cast(numbers->get(j))); | 14226 numbers->set(i, Smi::cast(numbers->get(j))); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14302 DCHECK(storage->length() >= (NumberOfOwnProperties(filter) - index)); | 14338 DCHECK(storage->length() >= (NumberOfOwnProperties(filter) - index)); |
14303 if (HasFastProperties()) { | 14339 if (HasFastProperties()) { |
14304 int real_size = map()->NumberOfOwnDescriptors(); | 14340 int real_size = map()->NumberOfOwnDescriptors(); |
14305 DescriptorArray* descs = map()->instance_descriptors(); | 14341 DescriptorArray* descs = map()->instance_descriptors(); |
14306 for (int i = 0; i < real_size; i++) { | 14342 for (int i = 0; i < real_size; i++) { |
14307 if ((descs->GetDetails(i).attributes() & filter) == 0 && | 14343 if ((descs->GetDetails(i).attributes() & filter) == 0 && |
14308 !FilterKey(descs->GetKey(i), filter)) { | 14344 !FilterKey(descs->GetKey(i), filter)) { |
14309 storage->set(index++, descs->GetKey(i)); | 14345 storage->set(index++, descs->GetKey(i)); |
14310 } | 14346 } |
14311 } | 14347 } |
| 14348 } else if (IsGlobalObject()) { |
| 14349 global_dictionary()->CopyKeysTo(this, storage, index, filter, |
| 14350 GlobalDictionary::UNSORTED); |
14312 } else { | 14351 } else { |
14313 property_dictionary()->CopyKeysTo(this, storage, index, filter, | 14352 property_dictionary()->CopyKeysTo(this, storage, index, filter, |
14314 NameDictionary::UNSORTED); | 14353 NameDictionary::UNSORTED); |
14315 } | 14354 } |
14316 } | 14355 } |
14317 | 14356 |
14318 | 14357 |
14319 int JSObject::NumberOfOwnElements(PropertyAttributes filter) { | 14358 int JSObject::NumberOfOwnElements(PropertyAttributes filter) { |
14320 return GetOwnElementKeys(NULL, filter); | 14359 return GetOwnElementKeys(NULL, filter); |
14321 } | 14360 } |
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14969 HashTableKey*>; | 15008 HashTableKey*>; |
14970 | 15009 |
14971 template class HashTable<ObjectHashTable, | 15010 template class HashTable<ObjectHashTable, |
14972 ObjectHashTableShape, | 15011 ObjectHashTableShape, |
14973 Handle<Object> >; | 15012 Handle<Object> >; |
14974 | 15013 |
14975 template class HashTable<WeakHashTable, WeakHashTableShape<2>, Handle<Object> >; | 15014 template class HashTable<WeakHashTable, WeakHashTableShape<2>, Handle<Object> >; |
14976 | 15015 |
14977 template class Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >; | 15016 template class Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >; |
14978 | 15017 |
| 15018 template class Dictionary<GlobalDictionary, GlobalDictionaryShape, |
| 15019 Handle<Name> >; |
| 15020 |
14979 template class Dictionary<SeededNumberDictionary, | 15021 template class Dictionary<SeededNumberDictionary, |
14980 SeededNumberDictionaryShape, | 15022 SeededNumberDictionaryShape, |
14981 uint32_t>; | 15023 uint32_t>; |
14982 | 15024 |
14983 template class Dictionary<UnseededNumberDictionary, | 15025 template class Dictionary<UnseededNumberDictionary, |
14984 UnseededNumberDictionaryShape, | 15026 UnseededNumberDictionaryShape, |
14985 uint32_t>; | 15027 uint32_t>; |
14986 | 15028 |
14987 template Handle<SeededNumberDictionary> | 15029 template Handle<SeededNumberDictionary> |
14988 Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>:: | 15030 Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>:: |
14989 New(Isolate*, int at_least_space_for, PretenureFlag pretenure); | 15031 New(Isolate*, int at_least_space_for, PretenureFlag pretenure); |
14990 | 15032 |
14991 template Handle<UnseededNumberDictionary> | 15033 template Handle<UnseededNumberDictionary> |
14992 Dictionary<UnseededNumberDictionary, UnseededNumberDictionaryShape, uint32_t>:: | 15034 Dictionary<UnseededNumberDictionary, UnseededNumberDictionaryShape, uint32_t>:: |
14993 New(Isolate*, int at_least_space_for, PretenureFlag pretenure); | 15035 New(Isolate*, int at_least_space_for, PretenureFlag pretenure); |
14994 | 15036 |
14995 template Handle<NameDictionary> | 15037 template Handle<NameDictionary> |
14996 Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >:: | 15038 Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >:: |
14997 New(Isolate*, int n, PretenureFlag pretenure); | 15039 New(Isolate*, int n, PretenureFlag pretenure); |
14998 | 15040 |
| 15041 template Handle<GlobalDictionary> |
| 15042 Dictionary<GlobalDictionary, GlobalDictionaryShape, Handle<Name> >::New( |
| 15043 Isolate*, int n, PretenureFlag pretenure); |
| 15044 |
14999 template Handle<SeededNumberDictionary> | 15045 template Handle<SeededNumberDictionary> |
15000 Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>:: | 15046 Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>:: |
15001 AtPut(Handle<SeededNumberDictionary>, uint32_t, Handle<Object>); | 15047 AtPut(Handle<SeededNumberDictionary>, uint32_t, Handle<Object>); |
15002 | 15048 |
15003 template Handle<UnseededNumberDictionary> | 15049 template Handle<UnseededNumberDictionary> |
15004 Dictionary<UnseededNumberDictionary, UnseededNumberDictionaryShape, uint32_t>:: | 15050 Dictionary<UnseededNumberDictionary, UnseededNumberDictionaryShape, uint32_t>:: |
15005 AtPut(Handle<UnseededNumberDictionary>, uint32_t, Handle<Object>); | 15051 AtPut(Handle<UnseededNumberDictionary>, uint32_t, Handle<Object>); |
15006 | 15052 |
15007 template Object* | 15053 template Object* |
15008 Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>:: | 15054 Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>:: |
(...skipping 20 matching lines...) Expand all Loading... |
15029 Shrink(Handle<NameDictionary>, Handle<Name>); | 15075 Shrink(Handle<NameDictionary>, Handle<Name>); |
15030 | 15076 |
15031 template Handle<SeededNumberDictionary> | 15077 template Handle<SeededNumberDictionary> |
15032 HashTable<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>:: | 15078 HashTable<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>:: |
15033 Shrink(Handle<SeededNumberDictionary>, uint32_t); | 15079 Shrink(Handle<SeededNumberDictionary>, uint32_t); |
15034 | 15080 |
15035 template Handle<NameDictionary> | 15081 template Handle<NameDictionary> |
15036 Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::Add( | 15082 Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::Add( |
15037 Handle<NameDictionary>, Handle<Name>, Handle<Object>, PropertyDetails); | 15083 Handle<NameDictionary>, Handle<Name>, Handle<Object>, PropertyDetails); |
15038 | 15084 |
| 15085 template Handle<GlobalDictionary> |
| 15086 Dictionary<GlobalDictionary, GlobalDictionaryShape, Handle<Name> >::Add( |
| 15087 Handle<GlobalDictionary>, Handle<Name>, Handle<Object>, |
| 15088 PropertyDetails); |
| 15089 |
15039 template Handle<FixedArray> Dictionary< | 15090 template Handle<FixedArray> Dictionary< |
15040 NameDictionary, NameDictionaryShape, | 15091 NameDictionary, NameDictionaryShape, |
15041 Handle<Name> >::BuildIterationIndicesArray(Handle<NameDictionary>); | 15092 Handle<Name> >::BuildIterationIndicesArray(Handle<NameDictionary>); |
15042 | 15093 |
15043 template Handle<FixedArray> Dictionary< | 15094 template Handle<FixedArray> Dictionary< |
15044 NameDictionary, NameDictionaryShape, | 15095 NameDictionary, NameDictionaryShape, |
15045 Handle<Name> >::GenerateNewEnumerationIndices(Handle<NameDictionary>); | 15096 Handle<Name> >::GenerateNewEnumerationIndices(Handle<NameDictionary>); |
15046 | 15097 |
15047 template Handle<SeededNumberDictionary> | 15098 template Handle<SeededNumberDictionary> |
15048 Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>:: | 15099 Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>:: |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15518 array->set(index, double_value); | 15569 array->set(index, double_value); |
15519 } | 15570 } |
15520 } | 15571 } |
15521 return array->GetIsolate()->factory()->NewNumber(double_value); | 15572 return array->GetIsolate()->factory()->NewNumber(double_value); |
15522 } | 15573 } |
15523 | 15574 |
15524 | 15575 |
15525 void GlobalObject::InvalidatePropertyCell(Handle<GlobalObject> global, | 15576 void GlobalObject::InvalidatePropertyCell(Handle<GlobalObject> global, |
15526 Handle<Name> name) { | 15577 Handle<Name> name) { |
15527 DCHECK(!global->HasFastProperties()); | 15578 DCHECK(!global->HasFastProperties()); |
15528 auto dictionary = handle(global->property_dictionary()); | 15579 auto dictionary = handle(global->global_dictionary()); |
15529 int entry = dictionary->FindEntry(name); | 15580 int entry = dictionary->FindEntry(name); |
15530 if (entry == NameDictionary::kNotFound) return; | 15581 if (entry == GlobalDictionary::kNotFound) return; |
15531 PropertyCell::InvalidateEntry(dictionary, entry); | 15582 PropertyCell::InvalidateEntry(dictionary, entry); |
15532 } | 15583 } |
15533 | 15584 |
15534 | 15585 |
15535 // TODO(dcarney): rename to EnsureEmptyPropertyCell or something. | 15586 // TODO(dcarney): rename to EnsureEmptyPropertyCell or something. |
15536 Handle<PropertyCell> GlobalObject::EnsurePropertyCell( | 15587 Handle<PropertyCell> GlobalObject::EnsurePropertyCell( |
15537 Handle<GlobalObject> global, Handle<Name> name) { | 15588 Handle<GlobalObject> global, Handle<Name> name) { |
15538 DCHECK(!global->HasFastProperties()); | 15589 DCHECK(!global->HasFastProperties()); |
15539 auto dictionary = handle(global->property_dictionary()); | 15590 auto dictionary = handle(global->global_dictionary()); |
15540 int entry = dictionary->FindEntry(name); | 15591 int entry = dictionary->FindEntry(name); |
15541 Handle<PropertyCell> cell; | 15592 Handle<PropertyCell> cell; |
15542 if (entry != NameDictionary::kNotFound) { | 15593 if (entry != GlobalDictionary::kNotFound) { |
15543 // This call should be idempotent. | 15594 // This call should be idempotent. |
15544 DCHECK(dictionary->DetailsAt(entry).cell_type() == | 15595 DCHECK(dictionary->DetailsAt(entry).cell_type() == |
15545 PropertyCellType::kUninitialized || | 15596 PropertyCellType::kUninitialized || |
15546 dictionary->DetailsAt(entry).cell_type() == | 15597 dictionary->DetailsAt(entry).cell_type() == |
15547 PropertyCellType::kInvalidated); | 15598 PropertyCellType::kInvalidated); |
15548 DCHECK(dictionary->ValueAt(entry)->IsPropertyCell()); | 15599 DCHECK(dictionary->ValueAt(entry)->IsPropertyCell()); |
15549 cell = handle(PropertyCell::cast(dictionary->ValueAt(entry))); | 15600 cell = handle(PropertyCell::cast(dictionary->ValueAt(entry))); |
15550 DCHECK(cell->value()->IsTheHole()); | 15601 DCHECK(cell->value()->IsTheHole()); |
15551 return cell; | 15602 return cell; |
15552 } | 15603 } |
15553 Isolate* isolate = global->GetIsolate(); | 15604 Isolate* isolate = global->GetIsolate(); |
15554 cell = isolate->factory()->NewPropertyCell(); | 15605 cell = isolate->factory()->NewPropertyCell(); |
15555 PropertyDetails details(NONE, DATA, 0, PropertyCellType::kUninitialized); | 15606 PropertyDetails details(NONE, DATA, 0, PropertyCellType::kUninitialized); |
15556 dictionary = NameDictionary::Add(dictionary, name, cell, details); | 15607 dictionary = GlobalDictionary::Add(dictionary, name, cell, details); |
15557 global->set_properties(*dictionary); | 15608 global->set_properties(*dictionary); |
15558 return cell; | 15609 return cell; |
15559 } | 15610 } |
15560 | 15611 |
15561 | 15612 |
15562 // This class is used for looking up two character strings in the string table. | 15613 // This class is used for looking up two character strings in the string table. |
15563 // If we don't have a hit we don't want to waste much time so we unroll the | 15614 // If we don't have a hit we don't want to waste much time so we unroll the |
15564 // string hash calculation loop here for speed. Doesn't work if the two | 15615 // string hash calculation loop here for speed. Doesn't work if the two |
15565 // characters form a decimal integer, since such strings have a different hash | 15616 // characters form a decimal integer, since such strings have a different hash |
15566 // algorithm. | 15617 // algorithm. |
(...skipping 1653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17220 if (IsExternalArrayElementsKind(map()->elements_kind())) { | 17271 if (IsExternalArrayElementsKind(map()->elements_kind())) { |
17221 Handle<Object> result(buffer(), GetIsolate()); | 17272 Handle<Object> result(buffer(), GetIsolate()); |
17222 return Handle<JSArrayBuffer>::cast(result); | 17273 return Handle<JSArrayBuffer>::cast(result); |
17223 } | 17274 } |
17224 Handle<JSTypedArray> self(this); | 17275 Handle<JSTypedArray> self(this); |
17225 return MaterializeArrayBuffer(self); | 17276 return MaterializeArrayBuffer(self); |
17226 } | 17277 } |
17227 | 17278 |
17228 | 17279 |
17229 Handle<PropertyCell> PropertyCell::InvalidateEntry( | 17280 Handle<PropertyCell> PropertyCell::InvalidateEntry( |
17230 Handle<NameDictionary> dictionary, int entry) { | 17281 Handle<GlobalDictionary> dictionary, int entry) { |
17231 Isolate* isolate = dictionary->GetIsolate(); | 17282 Isolate* isolate = dictionary->GetIsolate(); |
17232 // Swap with a copy. | 17283 // Swap with a copy. |
17233 DCHECK(dictionary->ValueAt(entry)->IsPropertyCell()); | 17284 DCHECK(dictionary->ValueAt(entry)->IsPropertyCell()); |
17234 Handle<PropertyCell> cell(PropertyCell::cast(dictionary->ValueAt(entry))); | 17285 Handle<PropertyCell> cell(PropertyCell::cast(dictionary->ValueAt(entry))); |
17235 auto new_cell = isolate->factory()->NewPropertyCell(); | 17286 auto new_cell = isolate->factory()->NewPropertyCell(); |
17236 new_cell->set_value(cell->value()); | 17287 new_cell->set_value(cell->value()); |
17237 dictionary->ValueAtPut(entry, *new_cell); | 17288 dictionary->ValueAtPut(entry, *new_cell); |
17238 bool is_the_hole = cell->value()->IsTheHole(); | 17289 bool is_the_hole = cell->value()->IsTheHole(); |
17239 // Cell is officially mutable henceforth. | 17290 // Cell is officially mutable henceforth. |
17240 auto details = dictionary->DetailsAt(entry); | 17291 auto details = dictionary->DetailsAt(entry); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17303 } | 17354 } |
17304 // Fall through. | 17355 // Fall through. |
17305 case PropertyCellType::kMutable: | 17356 case PropertyCellType::kMutable: |
17306 return PropertyCellType::kMutable; | 17357 return PropertyCellType::kMutable; |
17307 } | 17358 } |
17308 UNREACHABLE(); | 17359 UNREACHABLE(); |
17309 return PropertyCellType::kMutable; | 17360 return PropertyCellType::kMutable; |
17310 } | 17361 } |
17311 | 17362 |
17312 | 17363 |
17313 void PropertyCell::UpdateCell(Handle<NameDictionary> dictionary, int entry, | 17364 void PropertyCell::UpdateCell(Handle<GlobalDictionary> dictionary, int entry, |
17314 Handle<Object> value, PropertyDetails details) { | 17365 Handle<Object> value, PropertyDetails details) { |
17315 DCHECK(!value->IsTheHole()); | 17366 DCHECK(!value->IsTheHole()); |
17316 DCHECK(dictionary->ValueAt(entry)->IsPropertyCell()); | 17367 DCHECK(dictionary->ValueAt(entry)->IsPropertyCell()); |
17317 Handle<PropertyCell> cell(PropertyCell::cast(dictionary->ValueAt(entry))); | 17368 Handle<PropertyCell> cell(PropertyCell::cast(dictionary->ValueAt(entry))); |
17318 const PropertyDetails original_details = dictionary->DetailsAt(entry); | 17369 const PropertyDetails original_details = dictionary->DetailsAt(entry); |
17319 // Data accesses could be cached in ics or optimized code. | 17370 // Data accesses could be cached in ics or optimized code. |
17320 bool invalidate = | 17371 bool invalidate = |
17321 original_details.kind() == kData && details.kind() == kAccessor; | 17372 original_details.kind() == kData && details.kind() == kAccessor; |
17322 int index = original_details.dictionary_index(); | 17373 int index = original_details.dictionary_index(); |
17323 auto old_type = original_details.cell_type(); | 17374 auto old_type = original_details.cell_type(); |
(...skipping 29 matching lines...) Expand all Loading... |
17353 void PropertyCell::SetValueWithInvalidation(Handle<PropertyCell> cell, | 17404 void PropertyCell::SetValueWithInvalidation(Handle<PropertyCell> cell, |
17354 Handle<Object> new_value) { | 17405 Handle<Object> new_value) { |
17355 if (cell->value() != *new_value) { | 17406 if (cell->value() != *new_value) { |
17356 cell->set_value(*new_value); | 17407 cell->set_value(*new_value); |
17357 Isolate* isolate = cell->GetIsolate(); | 17408 Isolate* isolate = cell->GetIsolate(); |
17358 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 17409 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
17359 isolate, DependentCode::kPropertyCellChangedGroup); | 17410 isolate, DependentCode::kPropertyCellChangedGroup); |
17360 } | 17411 } |
17361 } | 17412 } |
17362 } } // namespace v8::internal | 17413 } } // namespace v8::internal |
OLD | NEW |