Commit 6f6356a2 authored by yangguo@chromium.org's avatar yangguo@chromium.org

Handlify PropertyAttribute lookups.

R=ishell@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19891 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent c64b78f6
......@@ -3120,7 +3120,8 @@ PropertyAttribute v8::Object::GetPropertyAttributes(v8::Handle<Value> key) {
EXCEPTION_BAILOUT_CHECK(isolate, static_cast<PropertyAttribute>(NONE));
}
i::Handle<i::Name> key_name = i::Handle<i::Name>::cast(key_obj);
PropertyAttributes result = self->GetPropertyAttribute(*key_name);
PropertyAttributes result =
i::JSReceiver::GetPropertyAttribute(self, key_name);
if (result == ABSENT) return static_cast<PropertyAttribute>(NONE);
return static_cast<PropertyAttribute>(result);
}
......
......@@ -131,9 +131,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 = object->GetLocalPropertyAttribute(*name);
*attributes = JSReceiver::GetLocalPropertyAttribute(object, name);
} else {
*attributes = object->GetPropertyAttribute(*name);
*attributes = JSReceiver::GetPropertyAttribute(object, name);
}
if (isolate->has_pending_exception()) return Handle<Object>();
......
......@@ -6177,7 +6177,7 @@ bool JSReceiver::HasProperty(Handle<JSReceiver> object,
Handle<JSProxy> proxy = Handle<JSProxy>::cast(object);
return JSProxy::HasPropertyWithHandler(proxy, name);
}
return object->GetPropertyAttribute(*name) != ABSENT;
return GetPropertyAttribute(object, name) != ABSENT;
}
......@@ -6187,25 +6187,28 @@ bool JSReceiver::HasLocalProperty(Handle<JSReceiver> object,
Handle<JSProxy> proxy = Handle<JSProxy>::cast(object);
return JSProxy::HasPropertyWithHandler(proxy, name);
}
return object->GetLocalPropertyAttribute(*name) != ABSENT;
return GetLocalPropertyAttribute(object, name) != ABSENT;
}
PropertyAttributes JSReceiver::GetPropertyAttribute(Name* key) {
PropertyAttributes JSReceiver::GetPropertyAttribute(Handle<JSReceiver> object,
Handle<Name> key) {
uint32_t index;
if (IsJSObject() && key->AsArrayIndex(&index)) {
return GetElementAttribute(index);
if (object->IsJSObject() && key->AsArrayIndex(&index)) {
return GetElementAttribute(object, index);
}
return GetPropertyAttributeWithReceiver(this, key);
return GetPropertyAttributeWithReceiver(object, object, key);
}
PropertyAttributes JSReceiver::GetElementAttribute(uint32_t index) {
if (IsJSProxy()) {
return JSProxy::cast(this)->GetElementAttributeWithHandler(this, index);
PropertyAttributes JSReceiver::GetElementAttribute(Handle<JSReceiver> object,
uint32_t index) {
if (object->IsJSProxy()) {
return JSProxy::GetElementAttributeWithHandler(
Handle<JSProxy>::cast(object), object, index);
}
return JSObject::cast(this)->GetElementAttributeWithReceiver(
this, index, true);
return JSObject::GetElementAttributeWithReceiver(
Handle<JSObject>::cast(object), object, index, true);
}
......@@ -6238,8 +6241,8 @@ bool JSReceiver::HasElement(Handle<JSReceiver> object, uint32_t index) {
Handle<JSProxy> proxy = Handle<JSProxy>::cast(object);
return JSProxy::HasElementWithHandler(proxy, index);
}
return Handle<JSObject>::cast(object)->GetElementAttributeWithReceiver(
*object, index, true) != ABSENT;
return JSObject::GetElementAttributeWithReceiver(
Handle<JSObject>::cast(object), object, index, true) != ABSENT;
}
......@@ -6248,17 +6251,19 @@ bool JSReceiver::HasLocalElement(Handle<JSReceiver> object, uint32_t index) {
Handle<JSProxy> proxy = Handle<JSProxy>::cast(object);
return JSProxy::HasElementWithHandler(proxy, index);
}
return Handle<JSObject>::cast(object)->GetElementAttributeWithReceiver(
*object, index, false) != ABSENT;
return JSObject::GetElementAttributeWithReceiver(
Handle<JSObject>::cast(object), object, index, false) != ABSENT;
}
PropertyAttributes JSReceiver::GetLocalElementAttribute(uint32_t index) {
if (IsJSProxy()) {
return JSProxy::cast(this)->GetElementAttributeWithHandler(this, index);
PropertyAttributes JSReceiver::GetLocalElementAttribute(
Handle<JSReceiver> object, uint32_t index) {
if (object->IsJSProxy()) {
return JSProxy::GetElementAttributeWithHandler(
Handle<JSProxy>::cast(object), object, index);
}
return JSObject::cast(this)->GetElementAttributeWithReceiver(
this, index, false);
return JSObject::GetElementAttributeWithReceiver(
Handle<JSObject>::cast(object), object, index, false);
}
......
This diff is collapsed.
......@@ -2076,13 +2076,23 @@ class JSReceiver: public HeapObject {
// function that was used to instantiate the object).
String* constructor_name();
inline PropertyAttributes GetPropertyAttribute(Name* name);
PropertyAttributes GetPropertyAttributeWithReceiver(JSReceiver* receiver,
Name* name);
PropertyAttributes GetLocalPropertyAttribute(Name* name);
static inline PropertyAttributes GetPropertyAttribute(
Handle<JSReceiver> object,
Handle<Name> name);
static PropertyAttributes GetPropertyAttributeWithReceiver(
Handle<JSReceiver> object,
Handle<JSReceiver> receiver,
Handle<Name> name);
static PropertyAttributes GetLocalPropertyAttribute(
Handle<JSReceiver> object,
Handle<Name> name);
inline PropertyAttributes GetElementAttribute(uint32_t index);
inline PropertyAttributes GetLocalElementAttribute(uint32_t index);
static inline PropertyAttributes GetElementAttribute(
Handle<JSReceiver> object,
uint32_t index);
static inline PropertyAttributes GetLocalElementAttribute(
Handle<JSReceiver> object,
uint32_t index);
// Return the object's prototype (might be Heap::null_value()).
inline Object* GetPrototype();
......@@ -2113,10 +2123,12 @@ class JSReceiver: public HeapObject {
Handle<Object> value);
private:
PropertyAttributes GetPropertyAttributeForResult(JSReceiver* receiver,
LookupResult* result,
Name* name,
bool continue_search);
static PropertyAttributes GetPropertyAttributeForResult(
Handle<JSReceiver> object,
Handle<JSReceiver> receiver,
LookupResult* result,
Handle<Name> name,
bool continue_search);
static Handle<Object> SetProperty(Handle<JSReceiver> receiver,
LookupResult* result,
......@@ -2307,20 +2319,26 @@ class JSObject: public JSReceiver {
InterceptorInfo* GetIndexedInterceptor();
// Used from JSReceiver.
PropertyAttributes GetPropertyAttributePostInterceptor(JSObject* receiver,
Name* name,
bool continue_search);
PropertyAttributes GetPropertyAttributeWithInterceptor(JSObject* receiver,
Name* name,
bool continue_search);
PropertyAttributes GetPropertyAttributeWithFailedAccessCheck(
Object* receiver,
static PropertyAttributes GetPropertyAttributePostInterceptor(
Handle<JSObject> object,
Handle<JSObject> receiver,
Handle<Name> name,
bool continue_search);
static PropertyAttributes GetPropertyAttributeWithInterceptor(
Handle<JSObject> object,
Handle<JSObject> receiver,
Handle<Name> name,
bool continue_search);
static PropertyAttributes GetPropertyAttributeWithFailedAccessCheck(
Handle<JSObject> object,
LookupResult* result,
Name* name,
Handle<Name> name,
bool continue_search);
static PropertyAttributes GetElementAttributeWithReceiver(
Handle<JSObject> object,
Handle<JSReceiver> receiver,
uint32_t index,
bool continue_search);
PropertyAttributes GetElementAttributeWithReceiver(JSReceiver* receiver,
uint32_t index,
bool continue_search);
// Retrieves an AccessorPair property from the given object. Might return
// undefined if the property doesn't exist or is of a different kind.
......@@ -2384,7 +2402,7 @@ class JSObject: public JSReceiver {
static void DeleteHiddenProperty(Handle<JSObject> object,
Handle<Name> key);
// Returns true if the object has a property with the hidden string as name.
bool HasHiddenProperties();
static bool HasHiddenProperties(Handle<JSObject> object);
static void SetIdentityHash(Handle<JSObject> object, Handle<Smi> hash);
......@@ -2757,12 +2775,14 @@ class JSObject: public JSReceiver {
Object* structure,
uint32_t index,
Object* holder);
MUST_USE_RESULT PropertyAttributes GetElementAttributeWithInterceptor(
JSReceiver* receiver,
static PropertyAttributes GetElementAttributeWithInterceptor(
Handle<JSObject> object,
Handle<JSReceiver> receiver,
uint32_t index,
bool continue_search);
MUST_USE_RESULT PropertyAttributes GetElementAttributeWithoutInterceptor(
JSReceiver* receiver,
static PropertyAttributes GetElementAttributeWithoutInterceptor(
Handle<JSObject> object,
Handle<JSReceiver> receiver,
uint32_t index,
bool continue_search);
static Handle<Object> SetElementWithCallback(
......@@ -9598,11 +9618,13 @@ class JSProxy: public JSReceiver {
StrictMode strict_mode,
bool* done);
MUST_USE_RESULT PropertyAttributes GetPropertyAttributeWithHandler(
JSReceiver* receiver,
Name* name);
MUST_USE_RESULT PropertyAttributes GetElementAttributeWithHandler(
JSReceiver* receiver,
static PropertyAttributes GetPropertyAttributeWithHandler(
Handle<JSProxy> proxy,
Handle<JSReceiver> receiver,
Handle<Name> name);
static PropertyAttributes GetElementAttributeWithHandler(
Handle<JSProxy> proxy,
Handle<JSReceiver> receiver,
uint32_t index);
// Turn the proxy into an (empty) JSObject.
......
......@@ -1813,7 +1813,7 @@ static Handle<Object> GetOwnProperty(Isolate* isolate,
case ACCESS_ABSENT: return factory->undefined_value();
}
PropertyAttributes attrs = obj->GetLocalPropertyAttribute(*name);
PropertyAttributes attrs = JSReceiver::GetLocalPropertyAttribute(obj, name);
if (attrs == ABSENT) {
RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object);
return factory->undefined_value();
......@@ -2061,8 +2061,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareGlobals) {
// We found an existing property. Unless it was an interceptor
// that claims the property is absent, skip this declaration.
if (!lookup.IsInterceptor()) continue;
PropertyAttributes attributes = global->GetPropertyAttribute(*name);
if (attributes != ABSENT) continue;
if (JSReceiver::GetPropertyAttribute(global, name) != ABSENT) continue;
// Fall-through and introduce the absent property by using
// SetProperty.
}
......@@ -2252,15 +2251,15 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeVarGlobal) {
LookupResult lookup(isolate);
isolate->context()->global_object()->LocalLookup(*name, &lookup, true);
if (lookup.IsInterceptor()) {
Handle<JSObject> holder(lookup.holder());
PropertyAttributes intercepted =
lookup.holder()->GetPropertyAttribute(*name);
JSReceiver::GetPropertyAttribute(holder, name);
if (intercepted != ABSENT && (intercepted & READ_ONLY) == 0) {
// Found an interceptor that's not read only.
if (assign) {
CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
Handle<Object> result = JSObject::SetPropertyForResult(
handle(lookup.holder()), &lookup, name, value, attributes,
strict_mode);
holder, &lookup, name, value, attributes, strict_mode);
RETURN_IF_EMPTY_HANDLE(isolate, result);
return *result;
} else {
......@@ -5644,13 +5643,13 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_HasElement) {
RUNTIME_FUNCTION(MaybeObject*, Runtime_IsPropertyEnumerable) {
SealHandleScope shs(isolate);
HandleScope scope(isolate);
ASSERT(args.length() == 2);
CONVERT_ARG_CHECKED(JSObject, object, 0);
CONVERT_ARG_CHECKED(Name, key, 1);
CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
CONVERT_ARG_HANDLE_CHECKED(Name, key, 1);
PropertyAttributes att = object->GetLocalPropertyAttribute(key);
PropertyAttributes att = JSReceiver::GetLocalPropertyAttribute(object, key);
if (att == ABSENT || (att & DONT_ENUM) != 0) {
RETURN_IF_SCHEDULED_EXCEPTION(isolate);
return isolate->heap()->false_value();
......@@ -5800,7 +5799,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLocalPropertyNames) {
next_copy_index += local_property_count[i];
// Hidden properties only show up if the filter does not skip strings.
if ((filter & STRING) == 0 && jsproto->HasHiddenProperties()) {
if ((filter & STRING) == 0 && JSObject::HasHiddenProperties(jsproto)) {
hidden_strings++;
}
if (i < length - 1) {
......@@ -9339,7 +9338,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreContextSlot) {
// Set the property if it's not read only or doesn't yet exist.
if ((attributes & READ_ONLY) == 0 ||
(object->GetLocalPropertyAttribute(*name) == ABSENT)) {
(JSReceiver::GetLocalPropertyAttribute(object, name) == ABSENT)) {
RETURN_IF_EMPTY_HANDLE(
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