Commit 028025f0 authored by verwaest's avatar verwaest Committed by Commit bot

Also handle elements in *RealNamed* api methods

Apparently the *RealNamed* API methods only have named variants, but were always used by the embedder to find elements as well. We'd never find them though, since we wouldn't even look
there.

This CL ensures we check whether the name is actually an array index.

I guess for all named API functions we should assume they are used similar to o["name"] where name could also be a number... At least we should make it uniform between embedder and V8. This matches us up with their expectations for now...

BUG=v8:4137
LOG=n

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

Cr-Commit-Position: refs/heads/master@{#29008}
parent a6bc7cd4
...@@ -4223,7 +4223,8 @@ MaybeLocal<Value> v8::Object::GetRealNamedPropertyInPrototypeChain( ...@@ -4223,7 +4223,8 @@ MaybeLocal<Value> v8::Object::GetRealNamedPropertyInPrototypeChain(
i::PrototypeIterator iter(isolate, self); i::PrototypeIterator iter(isolate, self);
if (iter.IsAtEnd()) return MaybeLocal<Value>(); if (iter.IsAtEnd()) return MaybeLocal<Value>();
auto proto = i::PrototypeIterator::GetCurrent(iter); auto proto = i::PrototypeIterator::GetCurrent(iter);
i::LookupIterator it(self, key_obj, i::Handle<i::JSReceiver>::cast(proto), i::LookupIterator it = i::LookupIterator::PropertyOrElement(
isolate, self, key_obj, i::Handle<i::JSReceiver>::cast(proto),
i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
Local<Value> result; Local<Value> result;
has_pending_exception = !ToLocal<Value>(i::Object::GetProperty(&it), &result); has_pending_exception = !ToLocal<Value>(i::Object::GetProperty(&it), &result);
...@@ -4252,7 +4253,8 @@ v8::Object::GetRealNamedPropertyAttributesInPrototypeChain( ...@@ -4252,7 +4253,8 @@ v8::Object::GetRealNamedPropertyAttributesInPrototypeChain(
i::PrototypeIterator iter(isolate, self); i::PrototypeIterator iter(isolate, self);
if (iter.IsAtEnd()) return Nothing<PropertyAttribute>(); if (iter.IsAtEnd()) return Nothing<PropertyAttribute>();
auto proto = i::PrototypeIterator::GetCurrent(iter); auto proto = i::PrototypeIterator::GetCurrent(iter);
i::LookupIterator it(self, key_obj, i::Handle<i::JSReceiver>::cast(proto), i::LookupIterator it = i::LookupIterator::PropertyOrElement(
isolate, self, key_obj, i::Handle<i::JSReceiver>::cast(proto),
i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
auto result = i::JSReceiver::GetPropertyAttributes(&it); auto result = i::JSReceiver::GetPropertyAttributes(&it);
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute); RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute);
...@@ -4277,7 +4279,8 @@ MaybeLocal<Value> v8::Object::GetRealNamedProperty(Local<Context> context, ...@@ -4277,7 +4279,8 @@ MaybeLocal<Value> v8::Object::GetRealNamedProperty(Local<Context> context,
PREPARE_FOR_EXECUTION(context, "v8::Object::GetRealNamedProperty()", Value); PREPARE_FOR_EXECUTION(context, "v8::Object::GetRealNamedProperty()", Value);
auto self = Utils::OpenHandle(this); auto self = Utils::OpenHandle(this);
auto key_obj = Utils::OpenHandle(*key); auto key_obj = Utils::OpenHandle(*key);
i::LookupIterator it(self, key_obj, i::LookupIterator it = i::LookupIterator::PropertyOrElement(
isolate, self, key_obj,
i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
Local<Value> result; Local<Value> result;
has_pending_exception = !ToLocal<Value>(i::Object::GetProperty(&it), &result); has_pending_exception = !ToLocal<Value>(i::Object::GetProperty(&it), &result);
...@@ -4300,7 +4303,8 @@ Maybe<PropertyAttribute> v8::Object::GetRealNamedPropertyAttributes( ...@@ -4300,7 +4303,8 @@ Maybe<PropertyAttribute> v8::Object::GetRealNamedPropertyAttributes(
PropertyAttribute); PropertyAttribute);
auto self = Utils::OpenHandle(this); auto self = Utils::OpenHandle(this);
auto key_obj = Utils::OpenHandle(*key); auto key_obj = Utils::OpenHandle(*key);
i::LookupIterator it(self, key_obj, i::LookupIterator it = i::LookupIterator::PropertyOrElement(
isolate, self, key_obj,
i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
auto result = i::JSReceiver::GetPropertyAttributes(&it); auto result = i::JSReceiver::GetPropertyAttributes(&it);
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute); RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute);
......
...@@ -13403,7 +13403,8 @@ MaybeHandle<JSObject> JSObject::GetKeysForIndexedInterceptor( ...@@ -13403,7 +13403,8 @@ MaybeHandle<JSObject> JSObject::GetKeysForIndexedInterceptor(
Maybe<bool> JSObject::HasRealNamedProperty(Handle<JSObject> object, Maybe<bool> JSObject::HasRealNamedProperty(Handle<JSObject> object,
Handle<Name> name) { Handle<Name> name) {
LookupIterator it(object, name, LookupIterator::OWN_SKIP_INTERCEPTOR); LookupIterator it = LookupIterator::PropertyOrElement(
name->GetIsolate(), object, name, LookupIterator::OWN_SKIP_INTERCEPTOR);
Maybe<PropertyAttributes> maybe_result = GetPropertyAttributes(&it); Maybe<PropertyAttributes> maybe_result = GetPropertyAttributes(&it);
if (!maybe_result.IsJust()) return Nothing<bool>(); if (!maybe_result.IsJust()) return Nothing<bool>();
return Just(it.IsFound()); return Just(it.IsFound());
...@@ -13423,7 +13424,8 @@ Maybe<bool> JSObject::HasRealElementProperty(Handle<JSObject> object, ...@@ -13423,7 +13424,8 @@ Maybe<bool> JSObject::HasRealElementProperty(Handle<JSObject> object,
Maybe<bool> JSObject::HasRealNamedCallbackProperty(Handle<JSObject> object, Maybe<bool> JSObject::HasRealNamedCallbackProperty(Handle<JSObject> object,
Handle<Name> name) { Handle<Name> name) {
LookupIterator it(object, name, LookupIterator::OWN_SKIP_INTERCEPTOR); LookupIterator it = LookupIterator::PropertyOrElement(
name->GetIsolate(), object, name, LookupIterator::OWN_SKIP_INTERCEPTOR);
Maybe<PropertyAttributes> maybe_result = GetPropertyAttributes(&it); Maybe<PropertyAttributes> maybe_result = GetPropertyAttributes(&it);
return maybe_result.IsJust() ? Just(it.state() == LookupIterator::ACCESSOR) return maybe_result.IsJust() ? Just(it.state() == LookupIterator::ACCESSOR)
: Nothing<bool>(); : Nothing<bool>();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment