Commit 907f079d authored by yangguo@chromium.org's avatar yangguo@chromium.org

Handlify GetPropertyWithFailedAccessCheck.

R=mstarzinger@chromium.org
BUG=

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17146 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 995ea2bd
...@@ -506,57 +506,65 @@ MaybeObject* Object::GetPropertyWithDefinedGetter(Object* receiver, ...@@ -506,57 +506,65 @@ MaybeObject* Object::GetPropertyWithDefinedGetter(Object* receiver,
} }
// TODO(yangguo): this should eventually replace the non-handlified version.
Handle<Object> JSObject::GetPropertyWithCallback(Handle<JSObject> object,
Handle<Object> receiver,
Handle<Object> structure,
Handle<Name> name) {
CALL_HEAP_FUNCTION(object->GetIsolate(),
object->GetPropertyWithCallback(*receiver,
*structure,
*name),
Object);
}
// Only deal with CALLBACKS and INTERCEPTOR // Only deal with CALLBACKS and INTERCEPTOR
MaybeObject* JSObject::GetPropertyWithFailedAccessCheck( Handle<Object> JSObject::GetPropertyWithFailedAccessCheck(
Object* receiver, Handle<JSObject> object,
Handle<Object> receiver,
LookupResult* result, LookupResult* result,
Name* name, Handle<Name> name,
PropertyAttributes* attributes) { PropertyAttributes* attributes) {
Isolate* isolate = name->GetIsolate();
if (result->IsProperty()) { if (result->IsProperty()) {
switch (result->type()) { switch (result->type()) {
case CALLBACKS: { case CALLBACKS: {
// Only allow API accessors. // Only allow API accessors.
Object* obj = result->GetCallbackObject(); Handle<Object> callback_obj(result->GetCallbackObject(), isolate);
if (obj->IsAccessorInfo()) { if (callback_obj->IsAccessorInfo()) {
AccessorInfo* info = AccessorInfo::cast(obj); if (!AccessorInfo::cast(*callback_obj)->all_can_read()) break;
if (info->all_can_read()) { *attributes = result->GetAttributes();
*attributes = result->GetAttributes(); // Fall through to GetPropertyWithCallback.
return result->holder()->GetPropertyWithCallback( } else if (callback_obj->IsAccessorPair()) {
receiver, result->GetCallbackObject(), name); if (!AccessorPair::cast(*callback_obj)->all_can_read()) break;
} // Fall through to GetPropertyWithCallback.
} else if (obj->IsAccessorPair()) { } else {
AccessorPair* pair = AccessorPair::cast(obj); break;
if (pair->all_can_read()) {
return result->holder()->GetPropertyWithCallback(
receiver, result->GetCallbackObject(), name);
}
} }
break; Handle<JSObject> holder(result->holder(), isolate);
return GetPropertyWithCallback(holder, receiver, callback_obj, name);
} }
case NORMAL: case NORMAL:
case FIELD: case FIELD:
case CONSTANT: { case CONSTANT: {
// Search ALL_CAN_READ accessors in prototype chain. // Search ALL_CAN_READ accessors in prototype chain.
LookupResult r(GetIsolate()); LookupResult r(isolate);
result->holder()->LookupRealNamedPropertyInPrototypes(name, &r); result->holder()->LookupRealNamedPropertyInPrototypes(*name, &r);
if (r.IsProperty()) { if (r.IsProperty()) {
return GetPropertyWithFailedAccessCheck(receiver, return GetPropertyWithFailedAccessCheck(
&r, object, receiver, &r, name, attributes);
name,
attributes);
} }
break; break;
} }
case INTERCEPTOR: { case INTERCEPTOR: {
// If the object has an interceptor, try real named properties. // If the object has an interceptor, try real named properties.
// No access check in GetPropertyAttributeWithInterceptor. // No access check in GetPropertyAttributeWithInterceptor.
LookupResult r(GetIsolate()); LookupResult r(isolate);
result->holder()->LookupRealNamedProperty(name, &r); result->holder()->LookupRealNamedProperty(*name, &r);
if (r.IsProperty()) { if (r.IsProperty()) {
return GetPropertyWithFailedAccessCheck(receiver, return GetPropertyWithFailedAccessCheck(
&r, object, receiver, &r, name, attributes);
name,
attributes);
} }
break; break;
} }
...@@ -567,11 +575,9 @@ MaybeObject* JSObject::GetPropertyWithFailedAccessCheck( ...@@ -567,11 +575,9 @@ MaybeObject* JSObject::GetPropertyWithFailedAccessCheck(
// No accessible property found. // No accessible property found.
*attributes = ABSENT; *attributes = ABSENT;
Heap* heap = name->GetHeap(); isolate->ReportFailedAccessCheck(*object, v8::ACCESS_GET);
Isolate* isolate = heap->isolate(); RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object);
isolate->ReportFailedAccessCheck(this, v8::ACCESS_GET); return isolate->factory()->undefined_value();
RETURN_IF_SCHEDULED_EXCEPTION(isolate);
return heap->undefined_value();
} }
...@@ -856,11 +862,16 @@ MaybeObject* Object::GetProperty(Object* receiver, ...@@ -856,11 +862,16 @@ MaybeObject* Object::GetProperty(Object* receiver,
// property from the current object, we still check that we have // property from the current object, we still check that we have
// access to it. // access to it.
JSObject* checked = JSObject::cast(current); JSObject* checked = JSObject::cast(current);
if (!heap->isolate()->MayNamedAccess(checked, name, v8::ACCESS_GET)) { if (!isolate->MayNamedAccess(checked, name, v8::ACCESS_GET)) {
return checked->GetPropertyWithFailedAccessCheck(receiver, HandleScope scope(isolate);
result, Handle<Object> value = JSObject::GetPropertyWithFailedAccessCheck(
name, handle(checked, isolate),
attributes); handle(receiver, isolate),
result,
handle(name, isolate),
attributes);
RETURN_IF_EMPTY_HANDLE(isolate, value);
return *value;
} }
} }
// Stop traversing the chain once we reach the last object in the // Stop traversing the chain once we reach the last object in the
......
...@@ -2118,6 +2118,11 @@ class JSObject: public JSReceiver { ...@@ -2118,6 +2118,11 @@ class JSObject: public JSReceiver {
// a dictionary, and it will stay a dictionary. // a dictionary, and it will stay a dictionary.
MUST_USE_RESULT MaybeObject* PrepareSlowElementsForSort(uint32_t limit); MUST_USE_RESULT MaybeObject* PrepareSlowElementsForSort(uint32_t limit);
static Handle<Object> GetPropertyWithCallback(Handle<JSObject> object,
Handle<Object> receiver,
Handle<Object> structure,
Handle<Name> name);
MUST_USE_RESULT MaybeObject* GetPropertyWithCallback(Object* receiver, MUST_USE_RESULT MaybeObject* GetPropertyWithCallback(Object* receiver,
Object* structure, Object* structure,
Name* name); Name* name);
...@@ -2243,12 +2248,6 @@ class JSObject: public JSReceiver { ...@@ -2243,12 +2248,6 @@ class JSObject: public JSReceiver {
static Handle<Object> SetAccessor(Handle<JSObject> object, static Handle<Object> SetAccessor(Handle<JSObject> object,
Handle<AccessorInfo> info); Handle<AccessorInfo> info);
// Used from Object::GetProperty().
MUST_USE_RESULT MaybeObject* GetPropertyWithFailedAccessCheck(
Object* receiver,
LookupResult* result,
Name* name,
PropertyAttributes* attributes);
static Handle<Object> GetPropertyWithInterceptor( static Handle<Object> GetPropertyWithInterceptor(
Handle<JSObject> object, Handle<JSObject> object,
Handle<Object> receiver, Handle<Object> receiver,
...@@ -2648,6 +2647,15 @@ class JSObject: public JSReceiver { ...@@ -2648,6 +2647,15 @@ class JSObject: public JSReceiver {
private: private:
friend class DictionaryElementsAccessor; friend class DictionaryElementsAccessor;
friend class JSReceiver; friend class JSReceiver;
friend class Object;
// Used from Object::GetProperty().
static Handle<Object> GetPropertyWithFailedAccessCheck(
Handle<JSObject> object,
Handle<Object> receiver,
LookupResult* result,
Handle<Name> name,
PropertyAttributes* attributes);
MUST_USE_RESULT MaybeObject* GetElementWithCallback(Object* receiver, MUST_USE_RESULT MaybeObject* GetElementWithCallback(Object* receiver,
Object* structure, Object* structure,
......
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