Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index df66ea23861d5727b50ef937de90044bf57aadf2..f0af90945291801eaa7534a261d0598e855bc462 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -3186,14 +3186,17 @@ Local<Object> v8::Object::FindInstanceInPrototypeChain( |
"v8::Object::FindInstanceInPrototypeChain()", |
return Local<v8::Object>()); |
ENTER_V8(isolate); |
- i::JSObject* object = *Utils::OpenHandle(this); |
+ i::PrototypeIterator iter(isolate, *Utils::OpenHandle(this), |
+ i::PrototypeIterator::START_AT_RECEIVER); |
i::FunctionTemplateInfo* tmpl_info = *Utils::OpenHandle(*tmpl); |
- while (!tmpl_info->IsTemplateFor(object)) { |
- i::Object* prototype = object->GetPrototype(); |
- if (!prototype->IsJSObject()) return Local<Object>(); |
- object = i::JSObject::cast(prototype); |
+ while (!tmpl_info->IsTemplateFor(iter.GetCurrent())) { |
+ iter.Advance(); |
+ if (iter.IsAtEnd()) { |
+ return Local<Object>(); |
+ } |
} |
- return Utils::ToLocal(i::Handle<i::JSObject>(object)); |
+ return Utils::ToLocal( |
+ i::handle(i::JSObject::cast(iter.GetCurrent()), isolate)); |
} |