| 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 4659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4670 // Check whether it makes sense to reuse the lookup iterator. Here it | 4670 // Check whether it makes sense to reuse the lookup iterator. Here it |
| 4671 // might still call into setters up the prototype chain. | 4671 // might still call into setters up the prototype chain. |
| 4672 return JSObject::SetPropertyWithFailedAccessCheck(it, value, | 4672 return JSObject::SetPropertyWithFailedAccessCheck(it, value, |
| 4673 should_throw); | 4673 should_throw); |
| 4674 | 4674 |
| 4675 case LookupIterator::JSPROXY: | 4675 case LookupIterator::JSPROXY: |
| 4676 return JSProxy::SetProperty(it->GetHolder<JSProxy>(), it->GetName(), | 4676 return JSProxy::SetProperty(it->GetHolder<JSProxy>(), it->GetName(), |
| 4677 value, it->GetReceiver(), language_mode); | 4677 value, it->GetReceiver(), language_mode); |
| 4678 | 4678 |
| 4679 case LookupIterator::INTERCEPTOR: { | 4679 case LookupIterator::INTERCEPTOR: { |
| 4680 Handle<Map> store_target_map; | |
| 4681 if (it->GetReceiver()->IsJSObject()) { | |
| 4682 store_target_map = handle(it->GetStoreTarget()->map(), it->isolate()); | |
| 4683 } | |
| 4684 if (it->HolderIsReceiverOrHiddenPrototype()) { | 4680 if (it->HolderIsReceiverOrHiddenPrototype()) { |
| 4685 Maybe<bool> result = | 4681 Maybe<bool> result = |
| 4686 JSObject::SetPropertyWithInterceptor(it, should_throw, value); | 4682 JSObject::SetPropertyWithInterceptor(it, should_throw, value); |
| 4687 if (result.IsNothing() || result.FromJust()) return result; | 4683 if (result.IsNothing() || result.FromJust()) return result; |
| 4688 // Interceptor modified the store target but failed to set the | |
| 4689 // property. | |
| 4690 Utils::ApiCheck(store_target_map.is_null() || | |
| 4691 *store_target_map == it->GetStoreTarget()->map(), | |
| 4692 it->IsElement() ? "v8::IndexedPropertySetterCallback" | |
| 4693 : "v8::NamedPropertySetterCallback", | |
| 4694 "Interceptor silently changed store target."); | |
| 4695 } else { | 4684 } else { |
| 4696 Maybe<PropertyAttributes> maybe_attributes = | 4685 Maybe<PropertyAttributes> maybe_attributes = |
| 4697 JSObject::GetPropertyAttributesWithInterceptor(it); | 4686 JSObject::GetPropertyAttributesWithInterceptor(it); |
| 4698 if (!maybe_attributes.IsJust()) return Nothing<bool>(); | 4687 if (!maybe_attributes.IsJust()) return Nothing<bool>(); |
| 4699 if ((maybe_attributes.FromJust() & READ_ONLY) != 0) { | 4688 if ((maybe_attributes.FromJust() & READ_ONLY) != 0) { |
| 4700 return WriteToReadOnlyProperty(it, value, should_throw); | 4689 return WriteToReadOnlyProperty(it, value, should_throw); |
| 4701 } | 4690 } |
| 4702 // Interceptor modified the store target but failed to set the | |
| 4703 // property. | |
| 4704 Utils::ApiCheck(store_target_map.is_null() || | |
| 4705 *store_target_map == it->GetStoreTarget()->map(), | |
| 4706 it->IsElement() ? "v8::IndexedPropertySetterCallback" | |
| 4707 : "v8::NamedPropertySetterCallback", | |
| 4708 "Interceptor silently changed store target."); | |
| 4709 if (maybe_attributes.FromJust() == ABSENT) break; | 4691 if (maybe_attributes.FromJust() == ABSENT) break; |
| 4710 *found = false; | 4692 *found = false; |
| 4711 return Nothing<bool>(); | 4693 return Nothing<bool>(); |
| 4712 } | 4694 } |
| 4713 break; | 4695 break; |
| 4714 } | 4696 } |
| 4715 | 4697 |
| 4716 case LookupIterator::ACCESSOR: { | 4698 case LookupIterator::ACCESSOR: { |
| 4717 if (it->IsReadOnly()) { | 4699 if (it->IsReadOnly()) { |
| 4718 return WriteToReadOnlyProperty(it, value, should_throw); | 4700 return WriteToReadOnlyProperty(it, value, should_throw); |
| (...skipping 1890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6609 if (!it.HasAccess()) { | 6591 if (!it.HasAccess()) { |
| 6610 isolate->ReportFailedAccessCheck(it.GetHolder<JSObject>()); | 6592 isolate->ReportFailedAccessCheck(it.GetHolder<JSObject>()); |
| 6611 RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Nothing<bool>()); | 6593 RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Nothing<bool>()); |
| 6612 return Just(true); | 6594 return Just(true); |
| 6613 } | 6595 } |
| 6614 it.Next(); | 6596 it.Next(); |
| 6615 } | 6597 } |
| 6616 | 6598 |
| 6617 // Handle interceptor | 6599 // Handle interceptor |
| 6618 if (it.state() == LookupIterator::INTERCEPTOR) { | 6600 if (it.state() == LookupIterator::INTERCEPTOR) { |
| 6619 Handle<Map> store_target_map; | |
| 6620 if (it.GetReceiver()->IsJSObject()) { | |
| 6621 store_target_map = handle(it.GetStoreTarget()->map(), it.isolate()); | |
| 6622 } | |
| 6623 if (it.HolderIsReceiverOrHiddenPrototype()) { | 6601 if (it.HolderIsReceiverOrHiddenPrototype()) { |
| 6624 Maybe<bool> result = DefinePropertyWithInterceptorInternal( | 6602 Maybe<bool> result = DefinePropertyWithInterceptorInternal( |
| 6625 &it, it.GetInterceptor(), should_throw, *desc); | 6603 &it, it.GetInterceptor(), should_throw, *desc); |
| 6626 if (result.IsNothing() || result.FromJust()) { | 6604 if (result.IsNothing() || result.FromJust()) { |
| 6627 return result; | 6605 return result; |
| 6628 } | 6606 } |
| 6629 // Interceptor modified the store target but failed to set the | |
| 6630 // property. | |
| 6631 if (!store_target_map.is_null() && | |
| 6632 *store_target_map != it.GetStoreTarget()->map()) { | |
| 6633 it.isolate()->PushStackTraceAndDie( | |
| 6634 0xabababaa, v8::ToCData<void*>(it.GetInterceptor()->definer()), | |
| 6635 nullptr, 0xabababab); | |
| 6636 } | |
| 6637 Utils::ApiCheck(store_target_map.is_null() || | |
| 6638 *store_target_map == it.GetStoreTarget()->map(), | |
| 6639 it.IsElement() ? "v8::IndexedPropertyDefinerCallback" | |
| 6640 : "v8::NamedPropertyDefinerCallback", | |
| 6641 "Interceptor silently changed store target."); | |
| 6642 } | 6607 } |
| 6643 } | 6608 } |
| 6644 | 6609 |
| 6645 return OrdinaryDefineOwnProperty(&it, desc, should_throw); | 6610 return OrdinaryDefineOwnProperty(&it, desc, should_throw); |
| 6646 } | 6611 } |
| 6647 | 6612 |
| 6648 | 6613 |
| 6649 // ES6 9.1.6.1 | 6614 // ES6 9.1.6.1 |
| 6650 // static | 6615 // static |
| 6651 Maybe<bool> JSReceiver::OrdinaryDefineOwnProperty(LookupIterator* it, | 6616 Maybe<bool> JSReceiver::OrdinaryDefineOwnProperty(LookupIterator* it, |
| (...skipping 13781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20433 // depend on this. | 20398 // depend on this. |
| 20434 return DICTIONARY_ELEMENTS; | 20399 return DICTIONARY_ELEMENTS; |
| 20435 } | 20400 } |
| 20436 DCHECK_LE(kind, LAST_ELEMENTS_KIND); | 20401 DCHECK_LE(kind, LAST_ELEMENTS_KIND); |
| 20437 return kind; | 20402 return kind; |
| 20438 } | 20403 } |
| 20439 } | 20404 } |
| 20440 | 20405 |
| 20441 } // namespace internal | 20406 } // namespace internal |
| 20442 } // namespace v8 | 20407 } // namespace v8 |
| OLD | NEW |