Restore ExecutableAccessorInfoHandling for now

BUG=v8:4137
LOG=n
R=ishell@chromium.org

Review URL: https://codereview.chromium.org/1173283004.

Cr-Commit-Position: refs/heads/master@{#28965}
This commit is contained in:
Toon Verwaest 2015-06-11 22:14:46 +02:00
parent 32f4bd659d
commit 91de375868
6 changed files with 43 additions and 27 deletions

View File

@ -3535,8 +3535,9 @@ Maybe<bool> v8::Object::CreateDataProperty(v8::Local<v8::Context> context,
if (it.IsFound() && !it.IsConfigurable()) return Just(false);
has_pending_exception = i::Runtime::DefineObjectProperty(
self, key_obj, value_obj, NONE).is_null();
has_pending_exception =
i::Runtime::DefineObjectProperty(self, key_obj, value_obj, NONE,
i::JSObject::DONT_FORCE_FIELD).is_null();
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
return Just(true);
}
@ -3573,9 +3574,10 @@ Maybe<bool> v8::Object::CreateDataProperty(v8::Local<v8::Context> context,
return Just(false);
}
has_pending_exception = i::Runtime::DefineObjectProperty(
self, isolate->factory()->Uint32ToString(index),
value_obj, NONE).is_null();
has_pending_exception =
i::Runtime::DefineObjectProperty(
self, isolate->factory()->Uint32ToString(index), value_obj, NONE,
i::JSObject::DONT_FORCE_FIELD).is_null();
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
return Just(true);
}

View File

@ -4133,7 +4133,8 @@ void ExecutableAccessorInfo::ClearSetter(Handle<ExecutableAccessorInfo> info) {
MaybeHandle<Object> JSObject::ReconfigureAsDataProperty(
LookupIterator* it, Handle<Object> value, PropertyAttributes attributes) {
LookupIterator* it, Handle<Object> value, PropertyAttributes attributes,
ExecutableAccessorInfoHandling handling) {
Handle<JSObject> object = Handle<JSObject>::cast(it->GetReceiver());
bool is_observed = object->map()->is_observed() &&
(it->IsElement() ||
@ -4159,7 +4160,8 @@ MaybeHandle<Object> JSObject::ReconfigureAsDataProperty(
// Special handling for ExecutableAccessorInfo, which behaves like a
// data property.
if (accessors->IsExecutableAccessorInfo()) {
if (accessors->IsExecutableAccessorInfo() &&
handling == DONT_FORCE_FIELD) {
Handle<Object> result;
ASSIGN_RETURN_ON_EXCEPTION(
it->isolate(), result,
@ -4252,7 +4254,7 @@ MaybeHandle<Object> JSObject::ReconfigureAsDataProperty(
// reconfigurable.
MaybeHandle<Object> JSObject::SetOwnPropertyIgnoreAttributes(
Handle<JSObject> object, Handle<Name> name, Handle<Object> value,
PropertyAttributes attributes) {
PropertyAttributes attributes, ExecutableAccessorInfoHandling handling) {
DCHECK(!value->IsTheHole());
LookupIterator it(object, name, LookupIterator::OWN_SKIP_INTERCEPTOR);
if (it.state() == LookupIterator::ACCESS_CHECK) {
@ -4263,7 +4265,7 @@ MaybeHandle<Object> JSObject::SetOwnPropertyIgnoreAttributes(
}
if (it.IsFound()) {
return ReconfigureAsDataProperty(&it, value, attributes);
return ReconfigureAsDataProperty(&it, value, attributes, handling);
}
return AddDataProperty(&it, value, attributes, STRICT,
@ -4273,7 +4275,7 @@ MaybeHandle<Object> JSObject::SetOwnPropertyIgnoreAttributes(
MaybeHandle<Object> JSObject::SetOwnElementIgnoreAttributes(
Handle<JSObject> object, uint32_t index, Handle<Object> value,
PropertyAttributes attributes) {
PropertyAttributes attributes, ExecutableAccessorInfoHandling handling) {
DCHECK(!object->HasExternalArrayElements());
Isolate* isolate = object->GetIsolate();
LookupIterator it(isolate, object, index,
@ -4286,7 +4288,7 @@ MaybeHandle<Object> JSObject::SetOwnElementIgnoreAttributes(
}
if (it.IsFound()) {
return ReconfigureAsDataProperty(&it, value, attributes);
return ReconfigureAsDataProperty(&it, value, attributes, handling);
}
return AddDataProperty(&it, value, attributes, STRICT,

View File

@ -1841,16 +1841,23 @@ class JSObject: public JSReceiver {
MUST_USE_RESULT static MaybeHandle<Object> SetPropertyWithInterceptor(
LookupIterator* it, Handle<Object> value);
// SetLocalPropertyIgnoreAttributes converts callbacks to fields. We need to
// grant an exemption to ExecutableAccessor callbacks in some cases.
enum ExecutableAccessorInfoHandling { DEFAULT_HANDLING, DONT_FORCE_FIELD };
MUST_USE_RESULT static MaybeHandle<Object> SetOwnPropertyIgnoreAttributes(
Handle<JSObject> object, Handle<Name> name, Handle<Object> value,
PropertyAttributes attributes);
PropertyAttributes attributes,
ExecutableAccessorInfoHandling handling = DEFAULT_HANDLING);
MUST_USE_RESULT static MaybeHandle<Object> SetOwnElementIgnoreAttributes(
Handle<JSObject> object, uint32_t index, Handle<Object> value,
PropertyAttributes attributes);
PropertyAttributes attributes,
ExecutableAccessorInfoHandling handling = DEFAULT_HANDLING);
MUST_USE_RESULT static MaybeHandle<Object> ReconfigureAsDataProperty(
LookupIterator* it, Handle<Object> value, PropertyAttributes attributes);
LookupIterator* it, Handle<Object> value, PropertyAttributes attributes,
ExecutableAccessorInfoHandling handling = DEFAULT_HANDLING);
static void AddProperty(Handle<JSObject> object, Handle<Name> name,
Handle<Object> value, PropertyAttributes attributes);

View File

@ -174,16 +174,16 @@ MaybeHandle<Object> Runtime::SetObjectProperty(Isolate* isolate,
}
MaybeHandle<Object> Runtime::DefineObjectProperty(Handle<JSObject> js_object,
Handle<Object> key,
Handle<Object> value,
PropertyAttributes attrs) {
MaybeHandle<Object> Runtime::DefineObjectProperty(
Handle<JSObject> js_object, Handle<Object> key, Handle<Object> value,
PropertyAttributes attrs,
JSObject::ExecutableAccessorInfoHandling handling) {
Isolate* isolate = js_object->GetIsolate();
// Check if the given key is an array index.
uint32_t index = 0;
if (key->ToArrayIndex(&index)) {
return JSObject::SetOwnElementIgnoreAttributes(js_object, index, value,
attrs);
attrs, handling);
}
Handle<Name> name;
@ -199,11 +199,11 @@ MaybeHandle<Object> Runtime::DefineObjectProperty(Handle<JSObject> js_object,
if (name->AsArrayIndex(&index)) {
return JSObject::SetOwnElementIgnoreAttributes(js_object, index, value,
attrs);
attrs, handling);
} else {
if (name->IsString()) name = String::Flatten(Handle<String>::cast(name));
return JSObject::SetOwnPropertyIgnoreAttributes(js_object, name, value,
attrs);
attrs, handling);
}
}
@ -1371,7 +1371,8 @@ RUNTIME_FUNCTION(Runtime_DefineDataPropertyUnchecked) {
Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
Runtime::DefineObjectProperty(js_object, name, obj_value, attrs));
Runtime::DefineObjectProperty(js_object, name, obj_value, attrs,
JSObject::DONT_FORCE_FIELD));
return *result;
}

View File

@ -824,7 +824,9 @@ class Runtime : public AllStatic {
MUST_USE_RESULT static MaybeHandle<Object> DefineObjectProperty(
Handle<JSObject> object, Handle<Object> key, Handle<Object> value,
PropertyAttributes attr);
PropertyAttributes attr,
JSObject::ExecutableAccessorInfoHandling handling =
JSObject::DEFAULT_HANDLING);
MUST_USE_RESULT static MaybeHandle<Object> GetObjectProperty(
Isolate* isolate, Handle<Object> object, Handle<Object> key);

View File

@ -13266,11 +13266,13 @@ TEST(ForceSet) {
CHECK_EQ(3, global->Get(access_property)->Int32Value());
CHECK_EQ(1, force_set_set_count);
CHECK_EQ(2, force_set_get_count);
// ForceSet does not remove the accessors, but rather calls the setter.
// ForceSet doesn't call the accessors for now.
// TODO(verwaest): Update once blink doesn't rely on ForceSet to delete api
// accessors.
global->ForceSet(access_property, v8::Int32::New(isolate, 8));
CHECK_EQ(3, global->Get(access_property)->Int32Value());
CHECK_EQ(2, force_set_set_count);
CHECK_EQ(3, force_set_get_count);
CHECK_EQ(8, global->Get(access_property)->Int32Value());
CHECK_EQ(1, force_set_set_count);
CHECK_EQ(2, force_set_get_count);
}