Commit fd80653a authored by verwaest@chromium.org's avatar verwaest@chromium.org

Rewrite GetPropertyAttribute to use the LookupIterator

BUG=
R=ishell@chromium.org

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21814 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 6a8d820f
......@@ -3128,7 +3128,7 @@ Local<Value> v8::Object::GetPrivate(v8::Handle<Private> key) {
PropertyAttribute v8::Object::GetPropertyAttributes(v8::Handle<Value> key) {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
ON_BAILOUT(isolate, "v8::Object::GetPropertyAttribute()",
ON_BAILOUT(isolate, "v8::Object::GetPropertyAttributes()",
return static_cast<PropertyAttribute>(NONE));
ENTER_V8(isolate);
i::HandleScope scope(isolate);
......@@ -3142,7 +3142,7 @@ PropertyAttribute v8::Object::GetPropertyAttributes(v8::Handle<Value> key) {
}
i::Handle<i::Name> key_name = i::Handle<i::Name>::cast(key_obj);
PropertyAttributes result =
i::JSReceiver::GetPropertyAttribute(self, key_name);
i::JSReceiver::GetPropertyAttributes(self, key_name);
if (result == ABSENT) return static_cast<PropertyAttribute>(NONE);
return static_cast<PropertyAttribute>(result);
}
......
......@@ -108,9 +108,9 @@ Handle<Object> Context::Lookup(Handle<String> name,
// to only do a local lookup for context extension objects.
if ((flags & FOLLOW_PROTOTYPE_CHAIN) == 0 ||
object->IsJSContextExtensionObject()) {
*attributes = JSReceiver::GetOwnPropertyAttribute(object, name);
*attributes = JSReceiver::GetOwnPropertyAttributes(object, name);
} else {
*attributes = JSReceiver::GetPropertyAttribute(object, name);
*attributes = JSReceiver::GetPropertyAttributes(object, name);
}
if (isolate->has_pending_exception()) return Handle<Object>();
......
......@@ -53,11 +53,12 @@ bool LookupIterator::NextHolder() {
Handle<JSReceiver> next(JSReceiver::cast(holder_map_->prototype()));
if (!check_derived() &&
// TODO(verwaest): Check if this is actually necessary currently. If it
// is, this should be handled by setting is_hidden_prototype on the
// global object behind the proxy.
!holder_map_->IsJSGlobalProxyMap() &&
!next->map()->is_hidden_prototype()) {
!(check_hidden() &&
// TODO(verwaest): Check if this is actually necessary currently. If it
// is, this should be handled by setting is_hidden_prototype on the
// global object behind the proxy.
(holder_map_->IsJSGlobalProxyMap() ||
next->map()->is_hidden_prototype()))) {
return false;
}
......@@ -189,8 +190,6 @@ Handle<Object> LookupIterator::GetDataValue() const {
ASSERT_EQ(DATA, property_kind_);
Handle<Object> value = FetchValue();
if (value->IsTheHole()) {
ASSERT_EQ(DICTIONARY, property_encoding_);
ASSERT(GetHolder()->IsGlobalObject());
ASSERT(property_details_.IsReadOnly());
return factory()->undefined_value();
}
......
......@@ -15,12 +15,15 @@ namespace internal {
class LookupIterator V8_FINAL BASE_EMBEDDED {
public:
enum Configuration {
CHECK_DERIVED = 1 << 0,
CHECK_INTERCEPTOR = 1 << 1,
CHECK_ACCESS_CHECK = 1 << 2,
CHECK_OWN_REAL = 0,
CHECK_ALL = CHECK_DERIVED | CHECK_INTERCEPTOR | CHECK_ACCESS_CHECK,
SKIP_INTERCEPTOR = CHECK_ALL ^ CHECK_INTERCEPTOR
CHECK_HIDDEN = 1 << 0,
CHECK_DERIVED = 1 << 1,
CHECK_INTERCEPTOR = 1 << 2,
CHECK_ACCESS_CHECK = 1 << 3,
CHECK_ALL = CHECK_HIDDEN | CHECK_DERIVED |
CHECK_INTERCEPTOR | CHECK_ACCESS_CHECK,
SKIP_INTERCEPTOR = CHECK_ALL ^ CHECK_INTERCEPTOR,
CHECK_OWN = CHECK_ALL ^ CHECK_DERIVED
};
enum State {
......@@ -53,9 +56,9 @@ class LookupIterator V8_FINAL BASE_EMBEDDED {
name_(name),
maybe_receiver_(receiver),
number_(DescriptorArray::kNotFound) {
Handle<JSReceiver> origin = GetRoot();
holder_map_ = handle(origin->map());
maybe_holder_ = origin;
Handle<JSReceiver> root = GetRoot();
holder_map_ = handle(root->map());
maybe_holder_ = root;
Next();
}
......@@ -95,6 +98,16 @@ class LookupIterator V8_FINAL BASE_EMBEDDED {
}
Handle<JSReceiver> GetRoot() const;
/* Dynamically reduce the trapped types. */
void skip_interceptor() {
configuration_ = static_cast<Configuration>(
configuration_ & ~CHECK_INTERCEPTOR);
}
void skip_access_check() {
configuration_ = static_cast<Configuration>(
configuration_ & ~CHECK_ACCESS_CHECK);
}
/* ACCESS_CHECK */
bool HasAccess(v8::AccessType access_type) const;
......@@ -142,6 +155,9 @@ class LookupIterator V8_FINAL BASE_EMBEDDED {
bool check_derived() const {
return (configuration_ & CHECK_DERIVED) != 0;
}
bool check_hidden() const {
return (configuration_ & CHECK_HIDDEN) != 0;
}
bool check_access_check() const {
return (configuration_ & CHECK_ACCESS_CHECK) != 0;
}
......
......@@ -6418,7 +6418,7 @@ bool JSReceiver::HasProperty(Handle<JSReceiver> object,
Handle<JSProxy> proxy = Handle<JSProxy>::cast(object);
return JSProxy::HasPropertyWithHandler(proxy, name);
}
return GetPropertyAttribute(object, name) != ABSENT;
return GetPropertyAttributes(object, name) != ABSENT;
}
......@@ -6427,17 +6427,18 @@ bool JSReceiver::HasOwnProperty(Handle<JSReceiver> object, Handle<Name> name) {
Handle<JSProxy> proxy = Handle<JSProxy>::cast(object);
return JSProxy::HasPropertyWithHandler(proxy, name);
}
return GetOwnPropertyAttribute(object, name) != ABSENT;
return GetOwnPropertyAttributes(object, name) != ABSENT;
}
PropertyAttributes JSReceiver::GetPropertyAttribute(Handle<JSReceiver> object,
Handle<Name> key) {
PropertyAttributes JSReceiver::GetPropertyAttributes(Handle<JSReceiver> object,
Handle<Name> key) {
uint32_t index;
if (object->IsJSObject() && key->AsArrayIndex(&index)) {
return GetElementAttribute(object, index);
}
return GetPropertyAttributeWithReceiver(object, object, key);
LookupIterator it(object, key);
return GetPropertyAttributes(&it);
}
......
This diff is collapsed.
......@@ -1954,14 +1954,11 @@ class JSReceiver: public HeapObject {
// function that was used to instantiate the object).
String* constructor_name();
static inline PropertyAttributes GetPropertyAttribute(
static inline PropertyAttributes GetPropertyAttributes(
Handle<JSReceiver> object,
Handle<Name> name);
static PropertyAttributes GetPropertyAttributeWithReceiver(
Handle<JSReceiver> object,
Handle<JSReceiver> receiver,
Handle<Name> name);
static PropertyAttributes GetOwnPropertyAttribute(
static PropertyAttributes GetPropertyAttributes(LookupIterator* it);
static PropertyAttributes GetOwnPropertyAttributes(
Handle<JSReceiver> object,
Handle<Name> name);
......@@ -2002,13 +1999,6 @@ class JSReceiver: public HeapObject {
KeyCollectionType type);
private:
static PropertyAttributes GetPropertyAttributeForResult(
Handle<JSReceiver> object,
Handle<JSReceiver> receiver,
LookupResult* result,
Handle<Name> name,
bool continue_search);
MUST_USE_RESULT static MaybeHandle<Object> SetProperty(
Handle<JSReceiver> receiver,
LookupResult* result,
......@@ -2209,21 +2199,12 @@ class JSObject: public JSReceiver {
InterceptorInfo* GetIndexedInterceptor();
// Used from JSReceiver.
static PropertyAttributes GetPropertyAttributePostInterceptor(
Handle<JSObject> object,
Handle<JSObject> receiver,
Handle<Name> name,
bool check_prototype);
static PropertyAttributes GetPropertyAttributeWithInterceptor(
Handle<JSObject> object,
Handle<JSObject> receiver,
Handle<Name> name,
bool check_prototype);
static PropertyAttributes GetPropertyAttributeWithFailedAccessCheck(
Handle<JSObject> object,
LookupResult* result,
Handle<Name> name,
bool check_prototype);
static Maybe<PropertyAttributes> GetPropertyAttributesWithInterceptor(
Handle<JSObject> holder,
Handle<Object> receiver,
Handle<Name> name);
static PropertyAttributes GetPropertyAttributesWithFailedAccessCheck(
LookupIterator* it);
static PropertyAttributes GetElementAttributeWithReceiver(
Handle<JSObject> object,
Handle<JSReceiver> receiver,
......@@ -9998,9 +9979,9 @@ class JSProxy: public JSReceiver {
StrictMode strict_mode,
bool* done);
static PropertyAttributes GetPropertyAttributeWithHandler(
static PropertyAttributes GetPropertyAttributesWithHandler(
Handle<JSProxy> proxy,
Handle<JSReceiver> receiver,
Handle<Object> receiver,
Handle<Name> name);
static PropertyAttributes GetElementAttributeWithHandler(
Handle<JSProxy> proxy,
......
......@@ -2022,7 +2022,7 @@ MUST_USE_RESULT static MaybeHandle<Object> GetOwnProperty(Isolate* isolate,
case ACCESS_ABSENT: return factory->undefined_value();
}
PropertyAttributes attrs = JSReceiver::GetOwnPropertyAttribute(obj, name);
PropertyAttributes attrs = JSReceiver::GetOwnPropertyAttributes(obj, name);
if (attrs == ABSENT) {
RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object);
return factory->undefined_value();
......@@ -2279,7 +2279,7 @@ RUNTIME_FUNCTION(RuntimeHidden_DeclareGlobals) {
// We found an existing property. Unless it was an interceptor
// that claims the property is absent, skip this declaration.
if (!lookup.IsInterceptor()) continue;
if (JSReceiver::GetPropertyAttribute(global, name) != ABSENT) continue;
if (JSReceiver::GetPropertyAttributes(global, name) != ABSENT) continue;
// Fall-through and introduce the absent property by using
// SetProperty.
}
......@@ -2470,7 +2470,7 @@ RUNTIME_FUNCTION(Runtime_InitializeVarGlobal) {
if (lookup.IsInterceptor()) {
Handle<JSObject> holder(lookup.holder());
PropertyAttributes intercepted =
JSReceiver::GetPropertyAttribute(holder, name);
JSReceiver::GetPropertyAttributes(holder, name);
if (intercepted != ABSENT && (intercepted & READ_ONLY) == 0) {
// Found an interceptor that's not read only.
if (assign) {
......@@ -5767,7 +5767,7 @@ RUNTIME_FUNCTION(Runtime_IsPropertyEnumerable) {
CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
CONVERT_ARG_HANDLE_CHECKED(Name, key, 1);
PropertyAttributes att = JSReceiver::GetOwnPropertyAttribute(object, key);
PropertyAttributes att = JSReceiver::GetOwnPropertyAttributes(object, key);
if (att == ABSENT || (att & DONT_ENUM) != 0) {
RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate);
return isolate->heap()->false_value();
......@@ -9454,7 +9454,7 @@ RUNTIME_FUNCTION(RuntimeHidden_StoreContextSlot) {
// Set the property if it's not read only or doesn't yet exist.
if ((attributes & READ_ONLY) == 0 ||
(JSReceiver::GetOwnPropertyAttribute(object, name) == ABSENT)) {
(JSReceiver::GetOwnPropertyAttributes(object, name) == ABSENT)) {
RETURN_FAILURE_ON_EXCEPTION(
isolate,
JSReceiver::SetProperty(object, name, value, NONE, strict_mode));
......
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