Revision: 17876
Author: [email protected]
Date: Tue Nov 19 13:38:15 2013 UTC
Log: Move template instance check from Object to
FunctionTemplateInfo::IsTemplateFor
BUG=
[email protected]
Review URL: https://chromiumcodereview.appspot.com/67613005
http://code.google.com/p/v8/source/detail?r=17876
Modified:
/branches/bleeding_edge/src/api.cc
/branches/bleeding_edge/src/bootstrapper.cc
/branches/bleeding_edge/src/builtins.cc
/branches/bleeding_edge/src/objects-inl.h
/branches/bleeding_edge/src/objects.cc
/branches/bleeding_edge/src/objects.h
/branches/bleeding_edge/src/stub-cache.cc
/branches/bleeding_edge/src/stub-cache.h
=======================================
--- /branches/bleeding_edge/src/api.cc Tue Nov 19 13:08:37 2013 UTC
+++ /branches/bleeding_edge/src/api.cc Tue Nov 19 13:38:15 2013 UTC
@@ -1274,7 +1274,7 @@
i::Handle<i::TypeSwitchInfo> info = Utils::OpenHandle(this);
i::FixedArray* types = i::FixedArray::cast(info->types());
for (int i = 0; i < types->length(); i++) {
- if (obj->IsInstanceOf(i::FunctionTemplateInfo::cast(types->get(i))))
+ if (i::FunctionTemplateInfo::cast(types->get(i))->IsTemplateFor(*obj))
return i + 1;
}
return 0;
@@ -3356,7 +3356,7 @@
ENTER_V8(isolate);
i::JSObject* object = *Utils::OpenHandle(this);
i::FunctionTemplateInfo* tmpl_info = *Utils::OpenHandle(*tmpl);
- while (!object->IsInstanceOf(tmpl_info)) {
+ while (!tmpl_info->IsTemplateFor(object)) {
i::Object* prototype = object->GetPrototype();
if (!prototype->IsJSObject()) return Local<Object>();
object = i::JSObject::cast(prototype);
@@ -5437,7 +5437,7 @@
ON_BAILOUT(i::Isolate::Current(), "v8::FunctionTemplate::HasInstanceOf()",
return false);
i::Object* obj = *Utils::OpenHandle(*value);
- return obj->IsInstanceOf(*Utils::OpenHandle(this));
+ return Utils::OpenHandle(this)->IsTemplateFor(obj);
}
=======================================
--- /branches/bleeding_edge/src/bootstrapper.cc Mon Oct 21 09:16:31 2013 UTC
+++ /branches/bleeding_edge/src/bootstrapper.cc Tue Nov 19 13:38:15 2013 UTC
@@ -2426,8 +2426,8 @@
bool Genesis::ConfigureApiObject(Handle<JSObject> object,
Handle<ObjectTemplateInfo> object_template) {
ASSERT(!object_template.is_null());
- ASSERT(object->IsInstanceOf(
- FunctionTemplateInfo::cast(object_template->constructor())));
+ ASSERT(FunctionTemplateInfo::cast(object_template->constructor())
+ ->IsTemplateFor(object->map()));;
bool pending_exception = false;
Handle<JSObject> obj =
=======================================
--- /branches/bleeding_edge/src/builtins.cc Mon Nov 18 13:07:44 2013 UTC
+++ /branches/bleeding_edge/src/builtins.cc Tue Nov 19 13:38:15 2013 UTC
@@ -1104,7 +1104,7 @@
static inline Object* FindHidden(Heap* heap,
Object* object,
FunctionTemplateInfo* type) {
- if (object->IsInstanceOf(type)) return object;
+ if (type->IsTemplateFor(object)) return object;
Object* proto = object->GetPrototype(heap->isolate());
if (proto->IsJSObject() &&
JSObject::cast(proto)->map()->is_hidden_prototype()) {
=======================================
--- /branches/bleeding_edge/src/objects-inl.h Fri Nov 15 10:52:05 2013 UTC
+++ /branches/bleeding_edge/src/objects-inl.h Tue Nov 19 13:38:15 2013 UTC
@@ -148,25 +148,6 @@
bool Object::IsAccessorInfo() {
return IsExecutableAccessorInfo() || IsDeclaredAccessorInfo();
}
-
-
-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() {
@@ -5957,7 +5938,7 @@
bool AccessorInfo::IsCompatibleReceiver(Object* receiver) {
Object* function_template = expected_receiver_type();
if (!function_template->IsFunctionTemplateInfo()) return true;
- return
receiver->IsInstanceOf(FunctionTemplateInfo::cast(function_template));
+ return
FunctionTemplateInfo::cast(function_template)->IsTemplateFor(receiver);
}
=======================================
--- /branches/bleeding_edge/src/objects.cc Tue Nov 19 12:04:54 2013 UTC
+++ /branches/bleeding_edge/src/objects.cc Tue Nov 19 13:38:15 2013 UTC
@@ -201,6 +201,31 @@
}
return false;
}
+
+
+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>
=======================================
--- /branches/bleeding_edge/src/objects.h Tue Nov 19 12:04:54 2013 UTC
+++ /branches/bleeding_edge/src/objects.h Tue Nov 19 13:38:15 2013 UTC
@@ -1351,10 +1351,6 @@
inline bool IsExternal();
inline bool IsAccessorInfo();
- // Returns true if this object is an instance of the specified
- // function template.
- inline bool IsInstanceOf(FunctionTemplateInfo* type);
-
inline bool IsStruct();
#define DECLARE_STRUCT_PREDICATE(NAME, Name, name) inline bool Is##Name();
STRUCT_LIST(DECLARE_STRUCT_PREDICATE)
@@ -10267,6 +10263,10 @@
static const int kLengthOffset = kFlagOffset + kPointerSize;
static const int kSize = kLengthOffset + kPointerSize;
+ // Returns true if |object| is an instance of this function template.
+ bool IsTemplateFor(Object* object);
+ bool IsTemplateFor(Map* map);
+
private:
// Bit position in the flag, from least significant bit position.
static const int kHiddenPrototypeBit = 0;
=======================================
--- /branches/bleeding_edge/src/stub-cache.cc Tue Nov 19 12:04:54 2013 UTC
+++ /branches/bleeding_edge/src/stub-cache.cc Tue Nov 19 13:38:15 2013 UTC
@@ -1785,12 +1785,12 @@
if (expected_receiver_type_.is_null()) return 0;
int depth = 0;
while (!object.is_identical_to(holder)) {
- if (object->IsInstanceOf(*expected_receiver_type_)) return depth;
+ if (expected_receiver_type_->IsTemplateFor(object->map())) return
depth;
object = Handle<JSObject>(JSObject::cast(object->GetPrototype()));
if (!object->map()->is_hidden_prototype()) return kInvalidProtoDepth;
++depth;
}
- if (holder->IsInstanceOf(*expected_receiver_type_)) return depth;
+ if (expected_receiver_type_->IsTemplateFor(holder->map())) return depth;
return kInvalidProtoDepth;
}
=======================================
--- /branches/bleeding_edge/src/stub-cache.h Mon Nov 18 17:18:14 2013 UTC
+++ /branches/bleeding_edge/src/stub-cache.h Tue Nov 19 13:38:15 2013 UTC
@@ -1037,7 +1037,7 @@
bool IsCompatibleReceiver(Object* receiver) {
ASSERT(is_simple_api_call());
if (expected_receiver_type_.is_null()) return true;
- return receiver->IsInstanceOf(*expected_receiver_type_);
+ return expected_receiver_type_->IsTemplateFor(receiver);
}
private:
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.