Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/objects.cc

Issue 2622873002: Remove API check for interceptors to notify us of modifying the receiver (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 4905 matching lines...) Expand 10 before | Expand all | Expand 10 after
4916 // Check whether it makes sense to reuse the lookup iterator. Here it 4916 // Check whether it makes sense to reuse the lookup iterator. Here it
4917 // might still call into setters up the prototype chain. 4917 // might still call into setters up the prototype chain.
4918 return JSObject::SetPropertyWithFailedAccessCheck(it, value, 4918 return JSObject::SetPropertyWithFailedAccessCheck(it, value,
4919 should_throw); 4919 should_throw);
4920 4920
4921 case LookupIterator::JSPROXY: 4921 case LookupIterator::JSPROXY:
4922 return JSProxy::SetProperty(it->GetHolder<JSProxy>(), it->GetName(), 4922 return JSProxy::SetProperty(it->GetHolder<JSProxy>(), it->GetName(),
4923 value, it->GetReceiver(), language_mode); 4923 value, it->GetReceiver(), language_mode);
4924 4924
4925 case LookupIterator::INTERCEPTOR: { 4925 case LookupIterator::INTERCEPTOR: {
4926 Handle<Map> store_target_map;
4927 if (it->GetReceiver()->IsJSObject()) {
4928 store_target_map = handle(it->GetStoreTarget()->map(), it->isolate());
4929 }
4930 if (it->HolderIsReceiverOrHiddenPrototype()) { 4926 if (it->HolderIsReceiverOrHiddenPrototype()) {
4931 Maybe<bool> result = 4927 Maybe<bool> result =
4932 JSObject::SetPropertyWithInterceptor(it, should_throw, value); 4928 JSObject::SetPropertyWithInterceptor(it, should_throw, value);
4933 if (result.IsNothing() || result.FromJust()) return result; 4929 if (result.IsNothing() || result.FromJust()) return result;
4934 // Interceptor modified the store target but failed to set the
4935 // property.
4936 Utils::ApiCheck(store_target_map.is_null() ||
4937 *store_target_map == it->GetStoreTarget()->map(),
4938 it->IsElement() ? "v8::IndexedPropertySetterCallback"
4939 : "v8::NamedPropertySetterCallback",
4940 "Interceptor silently changed store target.");
4941 } else { 4930 } else {
4942 Maybe<PropertyAttributes> maybe_attributes = 4931 Maybe<PropertyAttributes> maybe_attributes =
4943 JSObject::GetPropertyAttributesWithInterceptor(it); 4932 JSObject::GetPropertyAttributesWithInterceptor(it);
4944 if (!maybe_attributes.IsJust()) return Nothing<bool>(); 4933 if (!maybe_attributes.IsJust()) return Nothing<bool>();
4945 if ((maybe_attributes.FromJust() & READ_ONLY) != 0) { 4934 if ((maybe_attributes.FromJust() & READ_ONLY) != 0) {
4946 return WriteToReadOnlyProperty(it, value, should_throw); 4935 return WriteToReadOnlyProperty(it, value, should_throw);
4947 } 4936 }
4948 // Interceptor modified the store target but failed to set the
4949 // property.
4950 Utils::ApiCheck(store_target_map.is_null() ||
4951 *store_target_map == it->GetStoreTarget()->map(),
4952 it->IsElement() ? "v8::IndexedPropertySetterCallback"
4953 : "v8::NamedPropertySetterCallback",
4954 "Interceptor silently changed store target.");
4955 if (maybe_attributes.FromJust() == ABSENT) break; 4937 if (maybe_attributes.FromJust() == ABSENT) break;
4956 *found = false; 4938 *found = false;
4957 return Nothing<bool>(); 4939 return Nothing<bool>();
4958 } 4940 }
4959 break; 4941 break;
4960 } 4942 }
4961 4943
4962 case LookupIterator::ACCESSOR: { 4944 case LookupIterator::ACCESSOR: {
4963 if (it->IsReadOnly()) { 4945 if (it->IsReadOnly()) {
4964 return WriteToReadOnlyProperty(it, value, should_throw); 4946 return WriteToReadOnlyProperty(it, value, should_throw);
(...skipping 1869 matching lines...) Expand 10 before | Expand all | Expand 10 after
6834 if (!it.HasAccess()) { 6816 if (!it.HasAccess()) {
6835 isolate->ReportFailedAccessCheck(it.GetHolder<JSObject>()); 6817 isolate->ReportFailedAccessCheck(it.GetHolder<JSObject>());
6836 RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Nothing<bool>()); 6818 RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Nothing<bool>());
6837 return Just(true); 6819 return Just(true);
6838 } 6820 }
6839 it.Next(); 6821 it.Next();
6840 } 6822 }
6841 6823
6842 // Handle interceptor 6824 // Handle interceptor
6843 if (it.state() == LookupIterator::INTERCEPTOR) { 6825 if (it.state() == LookupIterator::INTERCEPTOR) {
6844 Handle<Map> store_target_map;
6845 if (it.GetReceiver()->IsJSObject()) {
6846 store_target_map = handle(it.GetStoreTarget()->map(), it.isolate());
6847 }
6848 if (it.HolderIsReceiverOrHiddenPrototype()) { 6826 if (it.HolderIsReceiverOrHiddenPrototype()) {
6849 Maybe<bool> result = DefinePropertyWithInterceptorInternal( 6827 Maybe<bool> result = DefinePropertyWithInterceptorInternal(
6850 &it, it.GetInterceptor(), should_throw, *desc); 6828 &it, it.GetInterceptor(), should_throw, *desc);
6851 if (result.IsNothing() || result.FromJust()) { 6829 if (result.IsNothing() || result.FromJust()) {
6852 return result; 6830 return result;
6853 } 6831 }
6854 // Interceptor modified the store target but failed to set the
6855 // property.
6856 if (!store_target_map.is_null() &&
6857 *store_target_map != it.GetStoreTarget()->map()) {
6858 it.isolate()->PushStackTraceAndDie(
6859 0xabababaa, v8::ToCData<void*>(it.GetInterceptor()->definer()),
6860 nullptr, 0xabababab);
6861 }
6862 Utils::ApiCheck(store_target_map.is_null() ||
6863 *store_target_map == it.GetStoreTarget()->map(),
6864 it.IsElement() ? "v8::IndexedPropertyDefinerCallback"
6865 : "v8::NamedPropertyDefinerCallback",
6866 "Interceptor silently changed store target.");
6867 } 6832 }
6868 } 6833 }
6869 6834
6870 return OrdinaryDefineOwnProperty(&it, desc, should_throw); 6835 return OrdinaryDefineOwnProperty(&it, desc, should_throw);
6871 } 6836 }
6872 6837
6873 6838
6874 // ES6 9.1.6.1 6839 // ES6 9.1.6.1
6875 // static 6840 // static
6876 Maybe<bool> JSReceiver::OrdinaryDefineOwnProperty(LookupIterator* it, 6841 Maybe<bool> JSReceiver::OrdinaryDefineOwnProperty(LookupIterator* it,
(...skipping 13614 matching lines...) Expand 10 before | Expand all | Expand 10 after
20491 // depend on this. 20456 // depend on this.
20492 return DICTIONARY_ELEMENTS; 20457 return DICTIONARY_ELEMENTS;
20493 } 20458 }
20494 DCHECK_LE(kind, LAST_ELEMENTS_KIND); 20459 DCHECK_LE(kind, LAST_ELEMENTS_KIND);
20495 return kind; 20460 return kind;
20496 } 20461 }
20497 } 20462 }
20498 20463
20499 } // namespace internal 20464 } // namespace internal
20500 } // namespace v8 20465 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698