Fix casting error for receiver of interceptors.

This fixes a casting error that occured when the receiver of a missed
or uninitialized CallIC is a Smi and there is an interceptor installed
on the prototype chain.

R=yangguo@chromium.org
BUG=chromium:149912
TEST=cctest/test-api/Regress149912

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12531 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 783d1019
...@@ -651,11 +651,9 @@ MaybeObject* Object::GetProperty(Object* receiver, ...@@ -651,11 +651,9 @@ MaybeObject* Object::GetProperty(Object* receiver,
receiver, result->GetCallbackObject(), name); receiver, result->GetCallbackObject(), name);
case HANDLER: case HANDLER:
return result->proxy()->GetPropertyWithHandler(receiver, name); return result->proxy()->GetPropertyWithHandler(receiver, name);
case INTERCEPTOR: { case INTERCEPTOR:
JSObject* recvr = JSObject::cast(receiver);
return result->holder()->GetPropertyWithInterceptor( return result->holder()->GetPropertyWithInterceptor(
recvr, name, attributes); receiver, name, attributes);
}
case TRANSITION: case TRANSITION:
case NONEXISTENT: case NONEXISTENT:
UNREACHABLE(); UNREACHABLE();
...@@ -10483,7 +10481,7 @@ InterceptorInfo* JSObject::GetIndexedInterceptor() { ...@@ -10483,7 +10481,7 @@ InterceptorInfo* JSObject::GetIndexedInterceptor() {
MaybeObject* JSObject::GetPropertyPostInterceptor( MaybeObject* JSObject::GetPropertyPostInterceptor(
JSReceiver* receiver, Object* receiver,
String* name, String* name,
PropertyAttributes* attributes) { PropertyAttributes* attributes) {
// Check local property in holder, ignore interceptor. // Check local property in holder, ignore interceptor.
...@@ -10501,7 +10499,7 @@ MaybeObject* JSObject::GetPropertyPostInterceptor( ...@@ -10501,7 +10499,7 @@ MaybeObject* JSObject::GetPropertyPostInterceptor(
MaybeObject* JSObject::GetLocalPropertyPostInterceptor( MaybeObject* JSObject::GetLocalPropertyPostInterceptor(
JSReceiver* receiver, Object* receiver,
String* name, String* name,
PropertyAttributes* attributes) { PropertyAttributes* attributes) {
// Check local property in holder, ignore interceptor. // Check local property in holder, ignore interceptor.
...@@ -10515,13 +10513,13 @@ MaybeObject* JSObject::GetLocalPropertyPostInterceptor( ...@@ -10515,13 +10513,13 @@ MaybeObject* JSObject::GetLocalPropertyPostInterceptor(
MaybeObject* JSObject::GetPropertyWithInterceptor( MaybeObject* JSObject::GetPropertyWithInterceptor(
JSReceiver* receiver, Object* receiver,
String* name, String* name,
PropertyAttributes* attributes) { PropertyAttributes* attributes) {
Isolate* isolate = GetIsolate(); Isolate* isolate = GetIsolate();
InterceptorInfo* interceptor = GetNamedInterceptor(); InterceptorInfo* interceptor = GetNamedInterceptor();
HandleScope scope(isolate); HandleScope scope(isolate);
Handle<JSReceiver> receiver_handle(receiver); Handle<Object> receiver_handle(receiver);
Handle<JSObject> holder_handle(this); Handle<JSObject> holder_handle(this);
Handle<String> name_handle(name); Handle<String> name_handle(name);
......
...@@ -1687,15 +1687,15 @@ class JSObject: public JSReceiver { ...@@ -1687,15 +1687,15 @@ class JSObject: public JSReceiver {
String* name, String* name,
PropertyAttributes* attributes); PropertyAttributes* attributes);
MUST_USE_RESULT MaybeObject* GetPropertyWithInterceptor( MUST_USE_RESULT MaybeObject* GetPropertyWithInterceptor(
JSReceiver* receiver, Object* receiver,
String* name, String* name,
PropertyAttributes* attributes); PropertyAttributes* attributes);
MUST_USE_RESULT MaybeObject* GetPropertyPostInterceptor( MUST_USE_RESULT MaybeObject* GetPropertyPostInterceptor(
JSReceiver* receiver, Object* receiver,
String* name, String* name,
PropertyAttributes* attributes); PropertyAttributes* attributes);
MUST_USE_RESULT MaybeObject* GetLocalPropertyPostInterceptor( MUST_USE_RESULT MaybeObject* GetLocalPropertyPostInterceptor(
JSReceiver* receiver, Object* receiver,
String* name, String* name,
PropertyAttributes* attributes); PropertyAttributes* attributes);
......
...@@ -17469,6 +17469,16 @@ THREADED_TEST(Regress137496) { ...@@ -17469,6 +17469,16 @@ THREADED_TEST(Regress137496) {
} }
THREADED_TEST(Regress149912) {
v8::HandleScope scope;
LocalContext context;
Handle<FunctionTemplate> templ = FunctionTemplate::New();
AddInterceptor(templ, EmptyInterceptorGetter, EmptyInterceptorSetter);
context->Global()->Set(v8_str("Bug"), templ->GetFunction());
CompileRun("Number.prototype.__proto__ = new Bug; var x = 0; x.foo();");
}
#ifndef WIN32 #ifndef WIN32
class ThreadInterruptTest { class ThreadInterruptTest {
public: public:
......
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