| 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 15798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15809 PropertyDetails details = cell->property_details(); | 15809 PropertyDetails details = cell->property_details(); |
| 15810 details = details.set_cell_type(is_the_hole ? PropertyCellType::kInvalidated | 15810 details = details.set_cell_type(is_the_hole ? PropertyCellType::kInvalidated |
| 15811 : PropertyCellType::kMutable); | 15811 : PropertyCellType::kMutable); |
| 15812 new_cell->set_property_details(details); | 15812 new_cell->set_property_details(details); |
| 15813 // Old cell is ready for invalidation. | 15813 // Old cell is ready for invalidation. |
| 15814 if (is_the_hole) { | 15814 if (is_the_hole) { |
| 15815 cell->set_value(isolate->heap()->undefined_value()); | 15815 cell->set_value(isolate->heap()->undefined_value()); |
| 15816 } else { | 15816 } else { |
| 15817 cell->set_value(isolate->heap()->the_hole_value()); | 15817 cell->set_value(isolate->heap()->the_hole_value()); |
| 15818 } | 15818 } |
| 15819 details = details.set_cell_type(PropertyCellType::kInvalidated); |
| 15820 cell->set_property_details(details); |
| 15819 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 15821 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
| 15820 isolate, DependentCode::kPropertyCellChangedGroup); | 15822 isolate, DependentCode::kPropertyCellChangedGroup); |
| 15821 return new_cell; | 15823 return new_cell; |
| 15822 } | 15824 } |
| 15823 | 15825 |
| 15824 | 15826 |
| 15825 PropertyCellConstantType PropertyCell::GetConstantType() { | 15827 PropertyCellConstantType PropertyCell::GetConstantType() { |
| 15826 if (value()->IsSmi()) return PropertyCellConstantType::kSmi; | 15828 if (value()->IsSmi()) return PropertyCellConstantType::kSmi; |
| 15827 return PropertyCellConstantType::kStableMap; | 15829 return PropertyCellConstantType::kStableMap; |
| 15828 } | 15830 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15880 | 15882 |
| 15881 | 15883 |
| 15882 void PropertyCell::UpdateCell(Handle<GlobalDictionary> dictionary, int entry, | 15884 void PropertyCell::UpdateCell(Handle<GlobalDictionary> dictionary, int entry, |
| 15883 Handle<Object> value, PropertyDetails details) { | 15885 Handle<Object> value, PropertyDetails details) { |
| 15884 DCHECK(!value->IsTheHole()); | 15886 DCHECK(!value->IsTheHole()); |
| 15885 DCHECK(dictionary->ValueAt(entry)->IsPropertyCell()); | 15887 DCHECK(dictionary->ValueAt(entry)->IsPropertyCell()); |
| 15886 Handle<PropertyCell> cell(PropertyCell::cast(dictionary->ValueAt(entry))); | 15888 Handle<PropertyCell> cell(PropertyCell::cast(dictionary->ValueAt(entry))); |
| 15887 const PropertyDetails original_details = cell->property_details(); | 15889 const PropertyDetails original_details = cell->property_details(); |
| 15888 // Data accesses could be cached in ics or optimized code. | 15890 // Data accesses could be cached in ics or optimized code. |
| 15889 bool invalidate = | 15891 bool invalidate = |
| 15890 (original_details.kind() == kData && details.kind() == kAccessor) || | 15892 original_details.kind() == kData && details.kind() == kAccessor; |
| 15891 ((original_details.attributes() & READ_ONLY) != | |
| 15892 (details.attributes() & READ_ONLY)); | |
| 15893 int index = original_details.dictionary_index(); | 15893 int index = original_details.dictionary_index(); |
| 15894 PropertyCellType old_type = original_details.cell_type(); | 15894 PropertyCellType old_type = original_details.cell_type(); |
| 15895 // Preserve the enumeration index unless the property was deleted or never | 15895 // Preserve the enumeration index unless the property was deleted or never |
| 15896 // initialized. | 15896 // initialized. |
| 15897 if (cell->value()->IsTheHole()) { | 15897 if (cell->value()->IsTheHole()) { |
| 15898 index = dictionary->NextEnumerationIndex(); | 15898 index = dictionary->NextEnumerationIndex(); |
| 15899 dictionary->SetNextEnumerationIndex(index + 1); | 15899 dictionary->SetNextEnumerationIndex(index + 1); |
| 15900 // Negative lookup cells must be invalidated. | 15900 // Negative lookup cells must be invalidated. |
| 15901 invalidate = true; | 15901 invalidate = true; |
| 15902 } | 15902 } |
| 15903 DCHECK(index > 0); | 15903 DCHECK(index > 0); |
| 15904 details = details.set_index(index); | 15904 details = details.set_index(index); |
| 15905 | 15905 |
| 15906 PropertyCellType new_type = UpdatedType(cell, value, original_details); | 15906 PropertyCellType new_type = UpdatedType(cell, value, original_details); |
| 15907 if (invalidate) cell = PropertyCell::InvalidateEntry(dictionary, entry); | 15907 if (invalidate) cell = PropertyCell::InvalidateEntry(dictionary, entry); |
| 15908 | 15908 |
| 15909 // Install new property details and cell value. | 15909 // Install new property details and cell value. |
| 15910 details = details.set_cell_type(new_type); | 15910 details = details.set_cell_type(new_type); |
| 15911 cell->set_property_details(details); | 15911 cell->set_property_details(details); |
| 15912 cell->set_value(*value); | 15912 cell->set_value(*value); |
| 15913 | 15913 |
| 15914 // Deopt when transitioning from a constant type. | 15914 // Deopt when transitioning from a constant type. |
| 15915 if (!invalidate && (old_type != new_type)) { | 15915 if (!invalidate && (old_type != new_type || |
| 15916 auto isolate = dictionary->GetIsolate(); | 15916 original_details.IsReadOnly() != details.IsReadOnly())) { |
| 15917 Isolate* isolate = dictionary->GetIsolate(); |
| 15917 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 15918 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
| 15918 isolate, DependentCode::kPropertyCellChangedGroup); | 15919 isolate, DependentCode::kPropertyCellChangedGroup); |
| 15919 } | 15920 } |
| 15920 } | 15921 } |
| 15921 | 15922 |
| 15922 | 15923 |
| 15923 // static | 15924 // static |
| 15924 void PropertyCell::SetValueWithInvalidation(Handle<PropertyCell> cell, | 15925 void PropertyCell::SetValueWithInvalidation(Handle<PropertyCell> cell, |
| 15925 Handle<Object> new_value) { | 15926 Handle<Object> new_value) { |
| 15926 if (cell->value() != *new_value) { | 15927 if (cell->value() != *new_value) { |
| 15927 cell->set_value(*new_value); | 15928 cell->set_value(*new_value); |
| 15928 Isolate* isolate = cell->GetIsolate(); | 15929 Isolate* isolate = cell->GetIsolate(); |
| 15929 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 15930 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
| 15930 isolate, DependentCode::kPropertyCellChangedGroup); | 15931 isolate, DependentCode::kPropertyCellChangedGroup); |
| 15931 } | 15932 } |
| 15932 } | 15933 } |
| 15934 |
| 15933 } // namespace internal | 15935 } // namespace internal |
| 15934 } // namespace v8 | 15936 } // namespace v8 |
| OLD | NEW |