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 15183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15194 DCHECK(!global->HasFastProperties()); | 15194 DCHECK(!global->HasFastProperties()); |
15195 auto dictionary = handle(global->property_dictionary()); | 15195 auto dictionary = handle(global->property_dictionary()); |
15196 int entry = dictionary->FindEntry(name); | 15196 int entry = dictionary->FindEntry(name); |
15197 Handle<PropertyCell> cell; | 15197 Handle<PropertyCell> cell; |
15198 if (entry != NameDictionary::kNotFound) { | 15198 if (entry != NameDictionary::kNotFound) { |
15199 // This call should be idempotent. | 15199 // This call should be idempotent. |
15200 DCHECK(dictionary->DetailsAt(entry).cell_type() == | 15200 DCHECK(dictionary->DetailsAt(entry).cell_type() == |
15201 PropertyCellType::kUninitialized || | 15201 PropertyCellType::kUninitialized || |
15202 dictionary->DetailsAt(entry).cell_type() == | 15202 dictionary->DetailsAt(entry).cell_type() == |
15203 PropertyCellType::kDeleted); | 15203 PropertyCellType::kDeleted); |
| 15204 DCHECK(dictionary->ValueAt(entry)->IsPropertyCell()); |
15204 cell = handle(PropertyCell::cast(dictionary->ValueAt(entry))); | 15205 cell = handle(PropertyCell::cast(dictionary->ValueAt(entry))); |
15205 DCHECK(cell->value()->IsTheHole()); | 15206 DCHECK(cell->value()->IsTheHole()); |
15206 return cell; | 15207 return cell; |
15207 } | 15208 } |
15208 Isolate* isolate = global->GetIsolate(); | 15209 Isolate* isolate = global->GetIsolate(); |
15209 cell = isolate->factory()->NewPropertyCell(); | 15210 cell = isolate->factory()->NewPropertyCell(); |
15210 PropertyDetails details(NONE, DATA, 0, PropertyCellType::kUninitialized); | 15211 PropertyDetails details(NONE, DATA, 0, PropertyCellType::kUninitialized); |
15211 dictionary = NameDictionary::Add(dictionary, name, cell, details); | 15212 dictionary = NameDictionary::Add(dictionary, name, cell, details); |
15212 global->set_properties(*dictionary); | 15213 global->set_properties(*dictionary); |
15213 return cell; | 15214 return cell; |
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15810 return dictionary; | 15811 return dictionary; |
15811 } | 15812 } |
15812 | 15813 |
15813 | 15814 |
15814 template <DictionaryEntryType type, typename D> | 15815 template <DictionaryEntryType type, typename D> |
15815 static inline bool IsDeleted(D d, int i) { | 15816 static inline bool IsDeleted(D d, int i) { |
15816 switch (type) { | 15817 switch (type) { |
15817 case DictionaryEntryType::kObjects: | 15818 case DictionaryEntryType::kObjects: |
15818 return false; | 15819 return false; |
15819 case DictionaryEntryType::kCells: | 15820 case DictionaryEntryType::kCells: |
| 15821 DCHECK(d->ValueAt(i)->IsPropertyCell()); |
15820 return PropertyCell::cast(d->ValueAt(i))->value()->IsTheHole(); | 15822 return PropertyCell::cast(d->ValueAt(i))->value()->IsTheHole(); |
15821 } | 15823 } |
15822 UNREACHABLE(); | 15824 UNREACHABLE(); |
15823 return false; | 15825 return false; |
15824 } | 15826 } |
15825 | 15827 |
15826 | 15828 |
15827 template <typename Derived, typename Shape, typename Key> | 15829 template <typename Derived, typename Shape, typename Key> |
15828 template <DictionaryEntryType type> | 15830 template <DictionaryEntryType type> |
15829 int Dictionary<Derived, Shape, Key>::NumberOfElementsFilterAttributes( | 15831 int Dictionary<Derived, Shape, Key>::NumberOfElementsFilterAttributes( |
(...skipping 1135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16965 } | 16967 } |
16966 Handle<JSTypedArray> self(this); | 16968 Handle<JSTypedArray> self(this); |
16967 return MaterializeArrayBuffer(self); | 16969 return MaterializeArrayBuffer(self); |
16968 } | 16970 } |
16969 | 16971 |
16970 | 16972 |
16971 Handle<PropertyCell> PropertyCell::InvalidateEntry( | 16973 Handle<PropertyCell> PropertyCell::InvalidateEntry( |
16972 Handle<NameDictionary> dictionary, int entry) { | 16974 Handle<NameDictionary> dictionary, int entry) { |
16973 Isolate* isolate = dictionary->GetIsolate(); | 16975 Isolate* isolate = dictionary->GetIsolate(); |
16974 // Swap with a copy. | 16976 // Swap with a copy. |
| 16977 DCHECK(dictionary->ValueAt(entry)->IsPropertyCell()); |
16975 Handle<PropertyCell> cell(PropertyCell::cast(dictionary->ValueAt(entry))); | 16978 Handle<PropertyCell> cell(PropertyCell::cast(dictionary->ValueAt(entry))); |
16976 auto new_cell = isolate->factory()->NewPropertyCell(); | 16979 auto new_cell = isolate->factory()->NewPropertyCell(); |
16977 new_cell->set_value(cell->value()); | 16980 new_cell->set_value(cell->value()); |
16978 dictionary->ValueAtPut(entry, *new_cell); | 16981 dictionary->ValueAtPut(entry, *new_cell); |
16979 bool is_the_hole = cell->value()->IsTheHole(); | 16982 bool is_the_hole = cell->value()->IsTheHole(); |
16980 // Cell is officially mutable henceforth. | 16983 // Cell is officially mutable henceforth. |
16981 auto details = dictionary->DetailsAt(entry); | 16984 auto details = dictionary->DetailsAt(entry); |
16982 details = details.set_cell_type(is_the_hole ? PropertyCellType::kDeleted | 16985 details = details.set_cell_type(is_the_hole ? PropertyCellType::kDeleted |
16983 : PropertyCellType::kMutable); | 16986 : PropertyCellType::kMutable); |
16984 dictionary->DetailsAtPut(entry, details); | 16987 dictionary->DetailsAtPut(entry, details); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17018 } | 17021 } |
17019 UNREACHABLE(); | 17022 UNREACHABLE(); |
17020 return PropertyCellType::kMutable; | 17023 return PropertyCellType::kMutable; |
17021 } | 17024 } |
17022 | 17025 |
17023 | 17026 |
17024 Handle<Object> PropertyCell::UpdateCell(Handle<NameDictionary> dictionary, | 17027 Handle<Object> PropertyCell::UpdateCell(Handle<NameDictionary> dictionary, |
17025 int entry, Handle<Object> value, | 17028 int entry, Handle<Object> value, |
17026 PropertyDetails details) { | 17029 PropertyDetails details) { |
17027 DCHECK(!value->IsTheHole()); | 17030 DCHECK(!value->IsTheHole()); |
| 17031 DCHECK(dictionary->ValueAt(entry)->IsPropertyCell()); |
17028 Handle<PropertyCell> cell(PropertyCell::cast(dictionary->ValueAt(entry))); | 17032 Handle<PropertyCell> cell(PropertyCell::cast(dictionary->ValueAt(entry))); |
17029 const PropertyDetails original_details = dictionary->DetailsAt(entry); | 17033 const PropertyDetails original_details = dictionary->DetailsAt(entry); |
17030 // Data accesses could be cached in ics or optimized code. | 17034 // Data accesses could be cached in ics or optimized code. |
17031 bool invalidate = | 17035 bool invalidate = |
17032 original_details.kind() == kData && details.kind() == kAccessor; | 17036 original_details.kind() == kData && details.kind() == kAccessor; |
17033 int index = original_details.dictionary_index(); | 17037 int index = original_details.dictionary_index(); |
17034 auto old_type = original_details.cell_type(); | 17038 auto old_type = original_details.cell_type(); |
17035 // Preserve the enumeration index unless the property was deleted or never | 17039 // Preserve the enumeration index unless the property was deleted or never |
17036 // initialized. | 17040 // initialized. |
17037 if (cell->value()->IsTheHole()) { | 17041 if (cell->value()->IsTheHole()) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17079 CompilationInfo* info) { | 17083 CompilationInfo* info) { |
17080 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo( | 17084 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo( |
17081 handle(cell->dependent_code(), info->isolate()), | 17085 handle(cell->dependent_code(), info->isolate()), |
17082 DependentCode::kPropertyCellChangedGroup, info->object_wrapper()); | 17086 DependentCode::kPropertyCellChangedGroup, info->object_wrapper()); |
17083 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); | 17087 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); |
17084 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( | 17088 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( |
17085 cell, info->zone()); | 17089 cell, info->zone()); |
17086 } | 17090 } |
17087 | 17091 |
17088 } } // namespace v8::internal | 17092 } } // namespace v8::internal |
OLD | NEW |