Index: src/objects.cc |
diff --git a/src/objects.cc b/src/objects.cc |
index 2901840af92fbe0b1cd995ba1129a4cb4024befa..6e35c5e4537b397987cf4656c7def68a84912ec9 100644 |
--- a/src/objects.cc |
+++ b/src/objects.cc |
@@ -4483,7 +4483,7 @@ Maybe<bool> Object::SetSuperProperty(LookupIterator* it, Handle<Object> value, |
PropertyDescriptor value_desc; |
value_desc.set_value(value); |
return JSReceiver::DefineOwnProperty(isolate, receiver, it->GetName(), |
- &value_desc, should_throw); |
+ &value_desc, should_throw, false); |
} |
case LookupIterator::NOT_FOUND: |
@@ -6101,7 +6101,8 @@ Maybe<bool> JSReceiver::DeletePropertyOrElement(Handle<JSReceiver> object, |
// static |
Object* JSReceiver::DefineProperty(Isolate* isolate, Handle<Object> object, |
Handle<Object> key, |
- Handle<Object> attributes) { |
+ Handle<Object> attributes, |
+ bool bypass_interceptor) { |
// 1. If Type(O) is not Object, throw a TypeError exception. |
if (!object->IsJSReceiver()) { |
Handle<String> fun_name = |
@@ -6119,8 +6120,9 @@ Object* JSReceiver::DefineProperty(Isolate* isolate, Handle<Object> object, |
return isolate->heap()->exception(); |
} |
// 6. Let success be DefinePropertyOrThrow(O,key, desc). |
- Maybe<bool> success = DefineOwnProperty( |
- isolate, Handle<JSReceiver>::cast(object), key, &desc, THROW_ON_ERROR); |
+ Maybe<bool> success = |
+ DefineOwnProperty(isolate, Handle<JSReceiver>::cast(object), key, &desc, |
+ THROW_ON_ERROR, bypass_interceptor); |
// 7. ReturnIfAbrupt(success). |
MAYBE_RETURN(success, isolate->heap()->exception()); |
CHECK(success.FromJust()); |
@@ -6128,7 +6130,6 @@ Object* JSReceiver::DefineProperty(Isolate* isolate, Handle<Object> object, |
return *object; |
} |
- |
// ES6 19.1.2.3.1 |
// static |
MaybeHandle<Object> JSReceiver::DefineProperties(Isolate* isolate, |
@@ -6212,18 +6213,22 @@ Maybe<bool> JSReceiver::DefineOwnProperty(Isolate* isolate, |
Handle<JSReceiver> object, |
Handle<Object> key, |
PropertyDescriptor* desc, |
- ShouldThrow should_throw) { |
+ ShouldThrow should_throw, |
+ bool bypass_interceptor) { |
if (object->IsJSArray()) { |
return JSArray::DefineOwnProperty(isolate, Handle<JSArray>::cast(object), |
- key, desc, should_throw); |
+ key, desc, should_throw, |
+ bypass_interceptor); |
} |
if (object->IsJSProxy()) { |
return JSProxy::DefineOwnProperty(isolate, Handle<JSProxy>::cast(object), |
- key, desc, should_throw); |
+ key, desc, should_throw, |
+ bypass_interceptor); |
} |
if (object->IsJSTypedArray()) { |
return JSTypedArray::DefineOwnProperty( |
- isolate, Handle<JSTypedArray>::cast(object), key, desc, should_throw); |
+ isolate, Handle<JSTypedArray>::cast(object), key, desc, should_throw, |
+ bypass_interceptor); |
} |
// TODO(neis): Special case for JSModuleNamespace? |
@@ -6231,20 +6236,27 @@ Maybe<bool> JSReceiver::DefineOwnProperty(Isolate* isolate, |
// DefineOwnPropertyIgnoreAttributes, can handle arguments |
// (ES#sec-arguments-exotic-objects-defineownproperty-p-desc). |
return OrdinaryDefineOwnProperty(isolate, Handle<JSObject>::cast(object), key, |
- desc, should_throw); |
+ desc, should_throw, bypass_interceptor); |
} |
- |
// static |
Maybe<bool> JSReceiver::OrdinaryDefineOwnProperty(Isolate* isolate, |
Handle<JSObject> object, |
Handle<Object> key, |
PropertyDescriptor* desc, |
- ShouldThrow should_throw) { |
+ ShouldThrow should_throw, |
+ bool bypass_interceptor) { |
bool success = false; |
DCHECK(key->IsName() || key->IsNumber()); // |key| is a PropertyKey... |
- LookupIterator it = LookupIterator::PropertyOrElement( |
- isolate, object, key, &success, LookupIterator::OWN); |
+ |
+ LookupIterator::Configuration ItBase = LookupIterator::OWN; |
Franzi
2017/05/10 09:17:52
Can we name this iterator_config or config?
|
+ if (bypass_interceptor) { |
+ ItBase = LookupIterator::OWN_SKIP_INTERCEPTOR; |
+ } |
+ |
+ LookupIterator it = |
+ LookupIterator::PropertyOrElement(isolate, object, key, &success, ItBase); |
+ |
DCHECK(success); // ...so creating a LookupIterator can't fail. |
// Deal with access checks first. |
@@ -6257,13 +6269,15 @@ Maybe<bool> JSReceiver::OrdinaryDefineOwnProperty(Isolate* isolate, |
it.Next(); |
} |
Franzi
2017/05/10 09:17:52
I think if OWN_SKIP_INTERCEPTOR was used, the stat
|
- // Handle interceptor |
- if (it.state() == LookupIterator::INTERCEPTOR) { |
- if (it.HolderIsReceiverOrHiddenPrototype()) { |
- Maybe<bool> result = DefinePropertyWithInterceptorInternal( |
- &it, it.GetInterceptor(), should_throw, *desc); |
- if (result.IsNothing() || result.FromJust()) { |
- return result; |
+ if (!bypass_interceptor) { |
+ // Handle interceptor |
+ if (it.state() == LookupIterator::INTERCEPTOR) { |
+ if (it.HolderIsReceiverOrHiddenPrototype()) { |
+ Maybe<bool> result = DefinePropertyWithInterceptorInternal( |
+ &it, it.GetInterceptor(), should_throw, *desc); |
+ if (result.IsNothing() || result.FromJust()) { |
+ return result; |
+ } |
} |
} |
} |
@@ -6587,7 +6601,7 @@ Maybe<bool> JSReceiver::CreateDataProperty(LookupIterator* it, |
new_desc.set_configurable(true); |
return JSReceiver::DefineOwnProperty(isolate, receiver, it->GetName(), |
- &new_desc, should_throw); |
+ &new_desc, should_throw, false); |
Franzi
2017/05/10 09:17:52
Do we need the last parameter? I thought it has a
|
} |
Maybe<bool> JSObject::CreateDataProperty(LookupIterator* it, |
@@ -6641,13 +6655,14 @@ bool PropertyKeyToArrayIndex(Handle<Object> index_obj, uint32_t* output) { |
Maybe<bool> JSArray::DefineOwnProperty(Isolate* isolate, Handle<JSArray> o, |
Handle<Object> name, |
PropertyDescriptor* desc, |
- ShouldThrow should_throw) { |
+ ShouldThrow should_throw, |
+ bool bypass_interceptor) { |
// 1. Assert: IsPropertyKey(P) is true. ("P" is |name|.) |
// 2. If P is "length", then: |
// TODO(jkummerow): Check if we need slow string comparison. |
if (*name == isolate->heap()->length_string()) { |
// 2a. Return ArraySetLength(A, Desc). |
- return ArraySetLength(isolate, o, desc, should_throw); |
+ return ArraySetLength(isolate, o, desc, should_throw, bypass_interceptor); |
} |
// 3. Else if P is an array index, then: |
uint32_t index = 0; |
@@ -6673,8 +6688,8 @@ Maybe<bool> JSArray::DefineOwnProperty(Isolate* isolate, Handle<JSArray> o, |
NewTypeError(MessageTemplate::kDefineDisallowed, name)); |
} |
// 3g. Let succeeded be OrdinaryDefineOwnProperty(A, P, Desc). |
- Maybe<bool> succeeded = |
- OrdinaryDefineOwnProperty(isolate, o, name, desc, should_throw); |
+ Maybe<bool> succeeded = OrdinaryDefineOwnProperty( |
+ isolate, o, name, desc, should_throw, bypass_interceptor); |
// 3h. Assert: succeeded is not an abrupt completion. |
// In our case, if should_throw == THROW_ON_ERROR, it can be! |
// 3i. If succeeded is false, return false. |
@@ -6685,9 +6700,9 @@ Maybe<bool> JSArray::DefineOwnProperty(Isolate* isolate, Handle<JSArray> o, |
old_len_desc.set_value(isolate->factory()->NewNumberFromUint(index + 1)); |
// 3j ii. Let succeeded be |
// OrdinaryDefineOwnProperty(A, "length", oldLenDesc). |
- succeeded = OrdinaryDefineOwnProperty(isolate, o, |
- isolate->factory()->length_string(), |
- &old_len_desc, should_throw); |
+ succeeded = OrdinaryDefineOwnProperty( |
+ isolate, o, isolate->factory()->length_string(), &old_len_desc, |
+ should_throw, bypass_interceptor); |
// 3j iii. Assert: succeeded is true. |
DCHECK(succeeded.FromJust()); |
USE(succeeded); |
@@ -6697,7 +6712,8 @@ Maybe<bool> JSArray::DefineOwnProperty(Isolate* isolate, Handle<JSArray> o, |
} |
// 4. Return OrdinaryDefineOwnProperty(A, P, Desc). |
- return OrdinaryDefineOwnProperty(isolate, o, name, desc, should_throw); |
+ return OrdinaryDefineOwnProperty(isolate, o, name, desc, should_throw, |
+ bypass_interceptor); |
} |
@@ -6742,12 +6758,14 @@ bool JSArray::AnythingToArrayLength(Isolate* isolate, |
// static |
Maybe<bool> JSArray::ArraySetLength(Isolate* isolate, Handle<JSArray> a, |
PropertyDescriptor* desc, |
- ShouldThrow should_throw) { |
+ ShouldThrow should_throw, |
+ bool bypass_interceptor = false) { |
// 1. If the [[Value]] field of Desc is absent, then |
if (!desc->has_value()) { |
// 1a. Return OrdinaryDefineOwnProperty(A, "length", Desc). |
- return OrdinaryDefineOwnProperty( |
- isolate, a, isolate->factory()->length_string(), desc, should_throw); |
+ return OrdinaryDefineOwnProperty(isolate, a, |
+ isolate->factory()->length_string(), desc, |
+ should_throw, bypass_interceptor); |
} |
// 2. Let newLenDesc be a copy of Desc. |
// (Actual copying is not necessary.) |
@@ -6775,9 +6793,9 @@ Maybe<bool> JSArray::ArraySetLength(Isolate* isolate, Handle<JSArray> a, |
// 8. Set newLenDesc.[[Value]] to newLen. |
// 12a. Return OrdinaryDefineOwnProperty(A, "length", newLenDesc). |
new_len_desc->set_value(isolate->factory()->NewNumberFromUint(new_len)); |
- return OrdinaryDefineOwnProperty(isolate, a, |
- isolate->factory()->length_string(), |
- new_len_desc, should_throw); |
+ return OrdinaryDefineOwnProperty( |
+ isolate, a, isolate->factory()->length_string(), new_len_desc, |
+ should_throw, bypass_interceptor); |
} |
// 13. If oldLenDesc.[[Writable]] is false, return false. |
if (!old_len_desc.writable()) { |
@@ -6806,7 +6824,7 @@ Maybe<bool> JSArray::ArraySetLength(Isolate* isolate, Handle<JSArray> a, |
readonly.set_writable(false); |
Maybe<bool> success = OrdinaryDefineOwnProperty( |
isolate, a, isolate->factory()->length_string(), &readonly, |
- should_throw); |
+ should_throw, bypass_interceptor); |
DCHECK(success.FromJust()); |
USE(success); |
} |
@@ -6830,7 +6848,8 @@ Maybe<bool> JSArray::ArraySetLength(Isolate* isolate, Handle<JSArray> a, |
Maybe<bool> JSProxy::DefineOwnProperty(Isolate* isolate, Handle<JSProxy> proxy, |
Handle<Object> key, |
PropertyDescriptor* desc, |
- ShouldThrow should_throw) { |
+ ShouldThrow should_throw, |
+ bool bypass_interceptor) { |
STACK_CHECK(isolate, Nothing<bool>()); |
if (key->IsSymbol() && Handle<Symbol>::cast(key)->IsPrivate()) { |
return SetPrivateProperty(isolate, proxy, Handle<Symbol>::cast(key), desc, |
@@ -6860,7 +6879,7 @@ Maybe<bool> JSProxy::DefineOwnProperty(Isolate* isolate, Handle<JSProxy> proxy, |
if (trap->IsUndefined(isolate)) { |
// 7a. Return target.[[DefineOwnProperty]](P, Desc). |
return JSReceiver::DefineOwnProperty(isolate, target, key, desc, |
- should_throw); |
+ should_throw, bypass_interceptor); |
} |
// 8. Let descObj be FromPropertyDescriptor(Desc). |
Handle<Object> desc_obj = desc->ToObject(isolate); |
@@ -7403,9 +7422,9 @@ Maybe<bool> JSReceiver::SetIntegrityLevel(Handle<JSReceiver> receiver, |
if (level == SEALED) { |
for (int i = 0; i < keys->length(); ++i) { |
Handle<Object> key(keys->get(i), isolate); |
- MAYBE_RETURN( |
- DefineOwnProperty(isolate, receiver, key, &no_conf, THROW_ON_ERROR), |
- Nothing<bool>()); |
+ MAYBE_RETURN(DefineOwnProperty(isolate, receiver, key, &no_conf, |
+ THROW_ON_ERROR, false), |
+ Nothing<bool>()); |
} |
return Just(true); |
} |
@@ -7421,9 +7440,9 @@ Maybe<bool> JSReceiver::SetIntegrityLevel(Handle<JSReceiver> receiver, |
PropertyDescriptor::IsAccessorDescriptor(¤t_desc) |
? no_conf |
: no_conf_no_write; |
- MAYBE_RETURN( |
- DefineOwnProperty(isolate, receiver, key, &desc, THROW_ON_ERROR), |
- Nothing<bool>()); |
+ MAYBE_RETURN(DefineOwnProperty(isolate, receiver, key, &desc, |
+ THROW_ON_ERROR, false), |
+ Nothing<bool>()); |
} |
} |
return Just(true); |
@@ -17163,7 +17182,8 @@ Maybe<bool> JSTypedArray::DefineOwnProperty(Isolate* isolate, |
Handle<JSTypedArray> o, |
Handle<Object> key, |
PropertyDescriptor* desc, |
- ShouldThrow should_throw) { |
+ ShouldThrow should_throw, |
+ bool bypass_interceptor) { |
// 1. Assert: IsPropertyKey(P) is true. |
DCHECK(key->IsName() || key->IsNumber()); |
// 2. Assert: O is an Object that has a [[ViewedArrayBuffer]] internal slot. |
@@ -17224,7 +17244,8 @@ Maybe<bool> JSTypedArray::DefineOwnProperty(Isolate* isolate, |
} |
} |
// 4. Return ! OrdinaryDefineOwnProperty(O, P, Desc). |
- return OrdinaryDefineOwnProperty(isolate, o, key, desc, should_throw); |
+ return OrdinaryDefineOwnProperty(isolate, o, key, desc, should_throw, |
+ bypass_interceptor); |
} |
ExternalArrayType JSTypedArray::type() { |