Merge r2636 to trunk.
Review URL: http://codereview.chromium.org/164146
git-svn-id: http://v8.googlecode.com/svn/trunk@2649 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
diff --git a/src/objects-inl.h b/src/objects-inl.h
index c7f791c..a3bd3ce 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -100,6 +100,25 @@
}
+bool Object::IsInstanceOf(FunctionTemplateInfo* expected) {
+ // There is a constraint on the object; check.
+ if (!this->IsJSObject()) return false;
+ // Fetch the constructor function of the object.
+ Object* cons_obj = JSObject::cast(this)->map()->constructor();
+ if (!cons_obj->IsJSFunction()) return false;
+ JSFunction* fun = JSFunction::cast(cons_obj);
+ // Iterate through the chain of inheriting function templates to
+ // see if the required one occurs.
+ for (Object* type = fun->shared()->function_data();
+ type->IsFunctionTemplateInfo();
+ type = FunctionTemplateInfo::cast(type)->parent_template()) {
+ if (type == expected) return true;
+ }
+ // Didn't find the required type in the inheritance chain.
+ return false;
+}
+
+
bool Object::IsSmi() {
return HAS_SMI_TAG(this);
}