| Index: src/objects.cc
|
| diff --git a/src/objects.cc b/src/objects.cc
|
| index 6cb5e212026de06051e8d83d9000964d4e3a7ba5..8a95b980a19ce5a5db6d589160cf6aae4027d0ca 100644
|
| --- a/src/objects.cc
|
| +++ b/src/objects.cc
|
| @@ -203,6 +203,31 @@ bool Object::ToUint32(uint32_t* value) {
|
| }
|
|
|
|
|
| +bool FunctionTemplateInfo::IsTemplateFor(Object* object) {
|
| + if (!object->IsHeapObject()) return false;
|
| + return IsTemplateFor(HeapObject::cast(object)->map());
|
| +}
|
| +
|
| +
|
| +bool FunctionTemplateInfo::IsTemplateFor(Map* map) {
|
| + // There is a constraint on the object; check.
|
| + if (!map->IsJSObjectMap()) return false;
|
| + // Fetch the constructor function of the object.
|
| + Object* cons_obj = 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 == this) return true;
|
| + }
|
| + // Didn't find the required type in the inheritance chain.
|
| + return false;
|
| +}
|
| +
|
| +
|
| template<typename To>
|
| static inline To* CheckedCast(void *from) {
|
| uintptr_t temp = reinterpret_cast<uintptr_t>(from);
|
|
|