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 "src/objects.h" | 5 #include "src/objects.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <iomanip> | 8 #include <iomanip> |
9 #include <sstream> | 9 #include <sstream> |
10 | 10 |
(...skipping 3669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3680 } | 3680 } |
3681 case LookupIterator::INTEGER_INDEXED_EXOTIC: | 3681 case LookupIterator::INTEGER_INDEXED_EXOTIC: |
3682 // TODO(verwaest): We should throw an exception. | 3682 // TODO(verwaest): We should throw an exception. |
3683 return Just(true); | 3683 return Just(true); |
3684 | 3684 |
3685 case LookupIterator::DATA: | 3685 case LookupIterator::DATA: |
3686 if (it->IsReadOnly()) { | 3686 if (it->IsReadOnly()) { |
3687 return WriteToReadOnlyProperty(it, value, should_throw); | 3687 return WriteToReadOnlyProperty(it, value, should_throw); |
3688 } | 3688 } |
3689 if (it->HolderIsReceiverOrHiddenPrototype()) { | 3689 if (it->HolderIsReceiverOrHiddenPrototype()) { |
3690 return SetDataProperty(it, value, should_throw); | 3690 return SetDataProperty(it, value); |
3691 } | 3691 } |
3692 done = true; | 3692 done = true; |
3693 break; | 3693 break; |
3694 | 3694 |
3695 case LookupIterator::TRANSITION: | 3695 case LookupIterator::TRANSITION: |
3696 done = true; | 3696 done = true; |
3697 break; | 3697 break; |
3698 } | 3698 } |
3699 | 3699 |
3700 if (done) break; | 3700 if (done) break; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3759 should_throw); | 3759 should_throw); |
3760 } | 3760 } |
3761 break; | 3761 break; |
3762 | 3762 |
3763 case LookupIterator::INTEGER_INDEXED_EXOTIC: | 3763 case LookupIterator::INTEGER_INDEXED_EXOTIC: |
3764 return RedefineIncompatibleProperty(it->isolate(), it->GetName(), value, | 3764 return RedefineIncompatibleProperty(it->isolate(), it->GetName(), value, |
3765 should_throw); | 3765 should_throw); |
3766 | 3766 |
3767 case LookupIterator::DATA: { | 3767 case LookupIterator::DATA: { |
3768 PropertyDetails details = own_lookup.property_details(); | 3768 PropertyDetails details = own_lookup.property_details(); |
3769 if (details.IsConfigurable() || !details.IsReadOnly()) { | 3769 if (details.IsReadOnly()) { |
3770 return JSObject::DefineOwnPropertyIgnoreAttributes( | 3770 return WriteToReadOnlyProperty(&own_lookup, value, should_throw); |
3771 &own_lookup, value, details.attributes(), should_throw); | |
3772 } | 3771 } |
3773 return WriteToReadOnlyProperty(&own_lookup, value, should_throw); | 3772 return SetDataProperty(&own_lookup, value); |
3774 } | 3773 } |
3775 | 3774 |
3776 case LookupIterator::ACCESSOR: { | 3775 case LookupIterator::ACCESSOR: { |
3777 return RedefineIncompatibleProperty(it->isolate(), it->GetName(), value, | 3776 return RedefineIncompatibleProperty(it->isolate(), it->GetName(), value, |
3778 should_throw); | 3777 should_throw); |
3779 } | 3778 } |
3780 | 3779 |
3781 case LookupIterator::INTERCEPTOR: | 3780 case LookupIterator::INTERCEPTOR: |
3782 case LookupIterator::JSPROXY: { | 3781 case LookupIterator::JSPROXY: { |
3783 bool found = false; | 3782 bool found = false; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3856 | 3855 |
3857 Maybe<bool> Object::RedefineIncompatibleProperty(Isolate* isolate, | 3856 Maybe<bool> Object::RedefineIncompatibleProperty(Isolate* isolate, |
3858 Handle<Object> name, | 3857 Handle<Object> name, |
3859 Handle<Object> value, | 3858 Handle<Object> value, |
3860 ShouldThrow should_throw) { | 3859 ShouldThrow should_throw) { |
3861 RETURN_FAILURE(isolate, should_throw, | 3860 RETURN_FAILURE(isolate, should_throw, |
3862 NewTypeError(MessageTemplate::kRedefineDisallowed, name)); | 3861 NewTypeError(MessageTemplate::kRedefineDisallowed, name)); |
3863 } | 3862 } |
3864 | 3863 |
3865 | 3864 |
3866 Maybe<bool> Object::SetDataProperty(LookupIterator* it, Handle<Object> value, | 3865 Maybe<bool> Object::SetDataProperty(LookupIterator* it, Handle<Object> value) { |
3867 ShouldThrow should_throw) { | |
3868 // Proxies are handled on the WithHandler path. Other non-JSObjects cannot | 3866 // Proxies are handled on the WithHandler path. Other non-JSObjects cannot |
3869 // have own properties. | 3867 // have own properties. |
3870 Handle<JSObject> receiver = Handle<JSObject>::cast(it->GetReceiver()); | 3868 Handle<JSObject> receiver = Handle<JSObject>::cast(it->GetReceiver()); |
3871 | 3869 |
3872 // Store on the holder which may be hidden behind the receiver. | 3870 // Store on the holder which may be hidden behind the receiver. |
3873 DCHECK(it->HolderIsReceiverOrHiddenPrototype()); | 3871 DCHECK(it->HolderIsReceiverOrHiddenPrototype()); |
3874 | 3872 |
3875 // Old value for the observation change record. | 3873 // Old value for the observation change record. |
3876 // Fetch before transforming the object since the encoding may become | 3874 // Fetch before transforming the object since the encoding may become |
3877 // incompatible with what's cached in |it|. | 3875 // incompatible with what's cached in |it|. |
(...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4848 } | 4846 } |
4849 case LookupIterator::INTEGER_INDEXED_EXOTIC: | 4847 case LookupIterator::INTEGER_INDEXED_EXOTIC: |
4850 return RedefineIncompatibleProperty(it->isolate(), it->GetName(), value, | 4848 return RedefineIncompatibleProperty(it->isolate(), it->GetName(), value, |
4851 should_throw); | 4849 should_throw); |
4852 | 4850 |
4853 case LookupIterator::DATA: { | 4851 case LookupIterator::DATA: { |
4854 PropertyDetails details = it->property_details(); | 4852 PropertyDetails details = it->property_details(); |
4855 Handle<Object> old_value = it->factory()->the_hole_value(); | 4853 Handle<Object> old_value = it->factory()->the_hole_value(); |
4856 // Regular property update if the attributes match. | 4854 // Regular property update if the attributes match. |
4857 if (details.attributes() == attributes) { | 4855 if (details.attributes() == attributes) { |
4858 return SetDataProperty(it, value, should_throw); | 4856 return SetDataProperty(it, value); |
4859 } | 4857 } |
4860 | 4858 |
4861 // Special case: properties of typed arrays cannot be reconfigured to | 4859 // Special case: properties of typed arrays cannot be reconfigured to |
4862 // non-writable nor to non-enumerable. | 4860 // non-writable nor to non-enumerable. |
4863 if (it->IsElement() && object->HasFixedTypedArrayElements()) { | 4861 if (it->IsElement() && object->HasFixedTypedArrayElements()) { |
4864 return RedefineIncompatibleProperty(it->isolate(), it->GetName(), | 4862 return RedefineIncompatibleProperty(it->isolate(), it->GetName(), |
4865 value, should_throw); | 4863 value, should_throw); |
4866 } | 4864 } |
4867 | 4865 |
4868 // Reconfigure the data property if the attributes mismatch. | 4866 // Reconfigure the data property if the attributes mismatch. |
(...skipping 13140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18009 if (cell->value() != *new_value) { | 18007 if (cell->value() != *new_value) { |
18010 cell->set_value(*new_value); | 18008 cell->set_value(*new_value); |
18011 Isolate* isolate = cell->GetIsolate(); | 18009 Isolate* isolate = cell->GetIsolate(); |
18012 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 18010 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
18013 isolate, DependentCode::kPropertyCellChangedGroup); | 18011 isolate, DependentCode::kPropertyCellChangedGroup); |
18014 } | 18012 } |
18015 } | 18013 } |
18016 | 18014 |
18017 } // namespace internal | 18015 } // namespace internal |
18018 } // namespace v8 | 18016 } // namespace v8 |
OLD | NEW |