OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 "src/objects.h" | 5 #include "src/objects.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <iomanip> | 8 #include <iomanip> |
9 #include <memory> | 9 #include <memory> |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 3736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3747 double old_value = object->RawFastDoublePropertyAt(index); | 3747 double old_value = object->RawFastDoublePropertyAt(index); |
3748 value = isolate->factory()->NewHeapNumber(old_value); | 3748 value = isolate->factory()->NewHeapNumber(old_value); |
3749 } else { | 3749 } else { |
3750 value = handle(object->RawFastPropertyAt(index), isolate); | 3750 value = handle(object->RawFastPropertyAt(index), isolate); |
3751 if (details.representation().IsDouble()) { | 3751 if (details.representation().IsDouble()) { |
3752 DCHECK(value->IsMutableHeapNumber()); | 3752 DCHECK(value->IsMutableHeapNumber()); |
3753 Handle<HeapNumber> old = Handle<HeapNumber>::cast(value); | 3753 Handle<HeapNumber> old = Handle<HeapNumber>::cast(value); |
3754 value = isolate->factory()->NewHeapNumber(old->value()); | 3754 value = isolate->factory()->NewHeapNumber(old->value()); |
3755 } | 3755 } |
3756 } | 3756 } |
3757 PropertyDetails d(details.attributes(), DATA, i + 1, | 3757 PropertyDetails d(kData, details.attributes(), i + 1, |
3758 PropertyCellType::kNoCell); | 3758 PropertyCellType::kNoCell); |
3759 dictionary = NameDictionary::Add(dictionary, key, value, d); | 3759 dictionary = NameDictionary::Add(dictionary, key, value, d); |
3760 | 3760 |
3761 } else { | 3761 } else { |
3762 DCHECK_EQ(kAccessor, details.kind()); | 3762 DCHECK_EQ(kAccessor, details.kind()); |
3763 Handle<Object> value(object->RawFastPropertyAt(index), isolate); | 3763 Handle<Object> value(object->RawFastPropertyAt(index), isolate); |
3764 PropertyDetails d(details.attributes(), ACCESSOR_CONSTANT, i + 1, | 3764 PropertyDetails d(kAccessor, details.attributes(), i + 1, |
3765 PropertyCellType::kNoCell); | 3765 PropertyCellType::kNoCell); |
3766 dictionary = NameDictionary::Add(dictionary, key, value, d); | 3766 dictionary = NameDictionary::Add(dictionary, key, value, d); |
3767 } | 3767 } |
3768 | 3768 |
3769 } else { | 3769 } else { |
3770 DCHECK_EQ(kDescriptor, details.location()); | 3770 DCHECK_EQ(kDescriptor, details.location()); |
3771 if (details.kind() == kData) { | 3771 if (details.kind() == kData) { |
3772 Handle<Object> value(descs->GetConstant(i), isolate); | 3772 Handle<Object> value(descs->GetConstant(i), isolate); |
3773 PropertyDetails d(details.attributes(), DATA, i + 1, | 3773 PropertyDetails d(kData, details.attributes(), i + 1, |
3774 PropertyCellType::kNoCell); | 3774 PropertyCellType::kNoCell); |
3775 dictionary = NameDictionary::Add(dictionary, key, value, d); | 3775 dictionary = NameDictionary::Add(dictionary, key, value, d); |
3776 | 3776 |
3777 } else { | 3777 } else { |
3778 DCHECK_EQ(kAccessor, details.kind()); | 3778 DCHECK_EQ(kAccessor, details.kind()); |
3779 Handle<Object> value(descs->GetCallbacksObject(i), isolate); | 3779 Handle<Object> value(descs->GetCallbacksObject(i), isolate); |
3780 PropertyDetails d(details.attributes(), ACCESSOR_CONSTANT, i + 1, | 3780 PropertyDetails d(kAccessor, details.attributes(), i + 1, |
3781 PropertyCellType::kNoCell); | 3781 PropertyCellType::kNoCell); |
3782 dictionary = NameDictionary::Add(dictionary, key, value, d); | 3782 dictionary = NameDictionary::Add(dictionary, key, value, d); |
3783 } | 3783 } |
3784 } | 3784 } |
3785 } | 3785 } |
3786 | 3786 |
3787 // Copy the next enumeration index from instance descriptor. | 3787 // Copy the next enumeration index from instance descriptor. |
3788 dictionary->SetNextEnumerationIndex(real_size + 1); | 3788 dictionary->SetNextEnumerationIndex(real_size + 1); |
3789 | 3789 |
3790 // From here on we cannot fail and we shouldn't GC anymore. | 3790 // From here on we cannot fail and we shouldn't GC anymore. |
(...skipping 1955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5746 if (value->IsJSFunction()) { | 5746 if (value->IsJSFunction()) { |
5747 d = Descriptor::DataConstant(key, handle(value, isolate), | 5747 d = Descriptor::DataConstant(key, handle(value, isolate), |
5748 details.attributes()); | 5748 details.attributes()); |
5749 } else { | 5749 } else { |
5750 d = Descriptor::DataField( | 5750 d = Descriptor::DataField( |
5751 key, current_offset, details.attributes(), | 5751 key, current_offset, details.attributes(), |
5752 // TODO(verwaest): value->OptimalRepresentation(); | 5752 // TODO(verwaest): value->OptimalRepresentation(); |
5753 Representation::Tagged()); | 5753 Representation::Tagged()); |
5754 } | 5754 } |
5755 } else { | 5755 } else { |
5756 DCHECK_EQ(kDescriptor, details.location()); | 5756 DCHECK_EQ(kAccessor, details.kind()); |
5757 d = Descriptor::AccessorConstant(key, handle(value, isolate), | 5757 d = Descriptor::AccessorConstant(key, handle(value, isolate), |
5758 details.attributes()); | 5758 details.attributes()); |
5759 } | 5759 } |
5760 details = d.GetDetails(); | 5760 details = d.GetDetails(); |
5761 if (details.location() == kField) { | 5761 if (details.location() == kField) { |
5762 if (current_offset < inobject_props) { | 5762 if (current_offset < inobject_props) { |
5763 object->InObjectPropertyAtPut(current_offset, value, | 5763 object->InObjectPropertyAtPut(current_offset, value, |
5764 UPDATE_WRITE_BARRIER); | 5764 UPDATE_WRITE_BARRIER); |
5765 } else { | 5765 } else { |
5766 int offset = current_offset - inobject_props; | 5766 int offset = current_offset - inobject_props; |
(...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6960 LookupIterator it(proxy, private_name, proxy); | 6960 LookupIterator it(proxy, private_name, proxy); |
6961 | 6961 |
6962 if (it.IsFound()) { | 6962 if (it.IsFound()) { |
6963 DCHECK_EQ(LookupIterator::DATA, it.state()); | 6963 DCHECK_EQ(LookupIterator::DATA, it.state()); |
6964 DCHECK_EQ(DONT_ENUM, it.property_attributes()); | 6964 DCHECK_EQ(DONT_ENUM, it.property_attributes()); |
6965 it.WriteDataValue(value); | 6965 it.WriteDataValue(value); |
6966 return Just(true); | 6966 return Just(true); |
6967 } | 6967 } |
6968 | 6968 |
6969 Handle<NameDictionary> dict(proxy->property_dictionary()); | 6969 Handle<NameDictionary> dict(proxy->property_dictionary()); |
6970 PropertyDetails details(DONT_ENUM, DATA, 0, PropertyCellType::kNoCell); | 6970 PropertyDetails details(kData, DONT_ENUM, 0, PropertyCellType::kNoCell); |
6971 Handle<NameDictionary> result = | 6971 Handle<NameDictionary> result = |
6972 NameDictionary::Add(dict, private_name, value, details); | 6972 NameDictionary::Add(dict, private_name, value, details); |
6973 if (!dict.is_identical_to(result)) proxy->set_properties(*result); | 6973 if (!dict.is_identical_to(result)) proxy->set_properties(*result); |
6974 return Just(true); | 6974 return Just(true); |
6975 } | 6975 } |
6976 | 6976 |
6977 | 6977 |
6978 // static | 6978 // static |
6979 Maybe<bool> JSReceiver::GetOwnPropertyDescriptor(Isolate* isolate, | 6979 Maybe<bool> JSReceiver::GetOwnPropertyDescriptor(Isolate* isolate, |
6980 Handle<JSReceiver> object, | 6980 Handle<JSReceiver> object, |
(...skipping 10110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17091 // This call should be idempotent. | 17091 // This call should be idempotent. |
17092 DCHECK(dictionary->ValueAt(entry)->IsPropertyCell()); | 17092 DCHECK(dictionary->ValueAt(entry)->IsPropertyCell()); |
17093 cell = handle(PropertyCell::cast(dictionary->ValueAt(entry))); | 17093 cell = handle(PropertyCell::cast(dictionary->ValueAt(entry))); |
17094 PropertyCellType original_cell_type = cell->property_details().cell_type(); | 17094 PropertyCellType original_cell_type = cell->property_details().cell_type(); |
17095 DCHECK(original_cell_type == PropertyCellType::kInvalidated || | 17095 DCHECK(original_cell_type == PropertyCellType::kInvalidated || |
17096 original_cell_type == PropertyCellType::kUninitialized); | 17096 original_cell_type == PropertyCellType::kUninitialized); |
17097 DCHECK(cell->value()->IsTheHole(isolate)); | 17097 DCHECK(cell->value()->IsTheHole(isolate)); |
17098 if (original_cell_type == PropertyCellType::kInvalidated) { | 17098 if (original_cell_type == PropertyCellType::kInvalidated) { |
17099 cell = PropertyCell::InvalidateEntry(dictionary, entry); | 17099 cell = PropertyCell::InvalidateEntry(dictionary, entry); |
17100 } | 17100 } |
17101 PropertyDetails details(NONE, DATA, 0, cell_type); | 17101 PropertyDetails details(kData, NONE, 0, cell_type); |
17102 cell->set_property_details(details); | 17102 cell->set_property_details(details); |
17103 return cell; | 17103 return cell; |
17104 } | 17104 } |
17105 cell = isolate->factory()->NewPropertyCell(); | 17105 cell = isolate->factory()->NewPropertyCell(); |
17106 PropertyDetails details(NONE, DATA, 0, cell_type); | 17106 PropertyDetails details(kData, NONE, 0, cell_type); |
17107 dictionary = | 17107 dictionary = |
17108 GlobalDictionary::Add(dictionary, name, cell, details, entry_out); | 17108 GlobalDictionary::Add(dictionary, name, cell, details, entry_out); |
17109 // {*entry_out} is initialized inside GlobalDictionary::Add(). | 17109 // {*entry_out} is initialized inside GlobalDictionary::Add(). |
17110 global->set_properties(*dictionary); | 17110 global->set_properties(*dictionary); |
17111 return cell; | 17111 return cell; |
17112 } | 17112 } |
17113 | 17113 |
17114 | 17114 |
17115 // This class is used for looking up two character strings in the string table. | 17115 // This class is used for looking up two character strings in the string table. |
17116 // If we don't have a hit we don't want to waste much time so we unroll the | 17116 // If we don't have a hit we don't want to waste much time so we unroll the |
(...skipping 2776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19893 // depend on this. | 19893 // depend on this. |
19894 return DICTIONARY_ELEMENTS; | 19894 return DICTIONARY_ELEMENTS; |
19895 } | 19895 } |
19896 DCHECK_LE(kind, LAST_ELEMENTS_KIND); | 19896 DCHECK_LE(kind, LAST_ELEMENTS_KIND); |
19897 return kind; | 19897 return kind; |
19898 } | 19898 } |
19899 } | 19899 } |
19900 | 19900 |
19901 } // namespace internal | 19901 } // namespace internal |
19902 } // namespace v8 | 19902 } // namespace v8 |
OLD | NEW |