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 <sstream> | 9 #include <sstream> |
10 | 10 |
(...skipping 6689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6700 | 6700 |
6701 // static | 6701 // static |
6702 Maybe<bool> JSReceiver::CreateDataProperty(LookupIterator* it, | 6702 Maybe<bool> JSReceiver::CreateDataProperty(LookupIterator* it, |
6703 Handle<Object> value, | 6703 Handle<Object> value, |
6704 ShouldThrow should_throw) { | 6704 ShouldThrow should_throw) { |
6705 DCHECK(!it->check_prototype_chain()); | 6705 DCHECK(!it->check_prototype_chain()); |
6706 Handle<JSReceiver> receiver = Handle<JSReceiver>::cast(it->GetReceiver()); | 6706 Handle<JSReceiver> receiver = Handle<JSReceiver>::cast(it->GetReceiver()); |
6707 Isolate* isolate = receiver->GetIsolate(); | 6707 Isolate* isolate = receiver->GetIsolate(); |
6708 | 6708 |
6709 if (receiver->IsJSObject()) { | 6709 if (receiver->IsJSObject()) { |
6710 return JSObject::CreateDataProperty(it, value); // Shortcut. | 6710 return JSObject::CreateDataProperty(it, value, should_throw); // Shortcut. |
6711 } | 6711 } |
6712 | 6712 |
6713 PropertyDescriptor new_desc; | 6713 PropertyDescriptor new_desc; |
6714 new_desc.set_value(value); | 6714 new_desc.set_value(value); |
6715 new_desc.set_writable(true); | 6715 new_desc.set_writable(true); |
6716 new_desc.set_enumerable(true); | 6716 new_desc.set_enumerable(true); |
6717 new_desc.set_configurable(true); | 6717 new_desc.set_configurable(true); |
6718 | 6718 |
6719 return JSReceiver::DefineOwnProperty(isolate, receiver, it->GetName(), | 6719 return JSReceiver::DefineOwnProperty(isolate, receiver, it->GetName(), |
6720 &new_desc, should_throw); | 6720 &new_desc, should_throw); |
6721 } | 6721 } |
6722 | 6722 |
6723 | |
6724 Maybe<bool> JSObject::CreateDataProperty(LookupIterator* it, | 6723 Maybe<bool> JSObject::CreateDataProperty(LookupIterator* it, |
6725 Handle<Object> value) { | 6724 Handle<Object> value, |
| 6725 ShouldThrow should_throw) { |
6726 DCHECK(it->GetReceiver()->IsJSObject()); | 6726 DCHECK(it->GetReceiver()->IsJSObject()); |
6727 MAYBE_RETURN(JSReceiver::GetPropertyAttributes(it), Nothing<bool>()); | 6727 MAYBE_RETURN(JSReceiver::GetPropertyAttributes(it), Nothing<bool>()); |
| 6728 Handle<JSReceiver> receiver = Handle<JSReceiver>::cast(it->GetReceiver()); |
| 6729 Isolate* isolate = receiver->GetIsolate(); |
6728 | 6730 |
6729 if (it->IsFound()) { | 6731 if (it->IsFound()) { |
6730 if (!it->IsConfigurable()) return Just(false); | 6732 if (!it->IsConfigurable()) { |
| 6733 RETURN_FAILURE( |
| 6734 isolate, should_throw, |
| 6735 NewTypeError(MessageTemplate::kRedefineDisallowed, it->GetName())); |
| 6736 } |
6731 } else { | 6737 } else { |
6732 if (!JSObject::IsExtensible(Handle<JSObject>::cast(it->GetReceiver()))) | 6738 if (!JSObject::IsExtensible(Handle<JSObject>::cast(it->GetReceiver()))) { |
6733 return Just(false); | 6739 RETURN_FAILURE( |
| 6740 isolate, should_throw, |
| 6741 NewTypeError(MessageTemplate::kDefineDisallowed, it->GetName())); |
| 6742 } |
6734 } | 6743 } |
6735 | 6744 |
6736 RETURN_ON_EXCEPTION_VALUE(it->isolate(), | 6745 RETURN_ON_EXCEPTION_VALUE(it->isolate(), |
6737 DefineOwnPropertyIgnoreAttributes(it, value, NONE), | 6746 DefineOwnPropertyIgnoreAttributes(it, value, NONE), |
6738 Nothing<bool>()); | 6747 Nothing<bool>()); |
6739 | 6748 |
6740 return Just(true); | 6749 return Just(true); |
6741 } | 6750 } |
6742 | 6751 |
6743 | 6752 |
(...skipping 13027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19771 if (cell->value() != *new_value) { | 19780 if (cell->value() != *new_value) { |
19772 cell->set_value(*new_value); | 19781 cell->set_value(*new_value); |
19773 Isolate* isolate = cell->GetIsolate(); | 19782 Isolate* isolate = cell->GetIsolate(); |
19774 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 19783 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
19775 isolate, DependentCode::kPropertyCellChangedGroup); | 19784 isolate, DependentCode::kPropertyCellChangedGroup); |
19776 } | 19785 } |
19777 } | 19786 } |
19778 | 19787 |
19779 } // namespace internal | 19788 } // namespace internal |
19780 } // namespace v8 | 19789 } // namespace v8 |
OLD | NEW |