2008-09-22 Maciej Stachowiak <mjs@apple.com>
Reviewed by Cameron Zwarich.
- speed up instanceof operator by replacing implementsHasInstance method with a TypeInfo flag
Partial work towards <https://bugs.webkit.org/show_bug.cgi?id=20818>
2.2% speedup on EarleyBoyer benchmark.
* API/JSCallbackConstructor.cpp:
* API/JSCallbackConstructor.h:
(JSC::JSCallbackConstructor::createStructureID):
* API/JSCallbackFunction.cpp:
* API/JSCallbackFunction.h:
(JSC::JSCallbackFunction::createStructureID):
* API/JSCallbackObject.h:
(JSC::JSCallbackObject::createStructureID):
* API/JSCallbackObjectFunctions.h:
(JSC::::hasInstance):
* API/JSValueRef.cpp:
(JSValueIsInstanceOfConstructor):
* JavaScriptCore.exp:
* VM/Machine.cpp:
(JSC::Machine::privateExecute):
(JSC::Machine::cti_op_instanceof):
* kjs/InternalFunction.cpp:
* kjs/InternalFunction.h:
(JSC::InternalFunction::createStructureID):
* kjs/JSObject.cpp:
* kjs/JSObject.h:
* kjs/TypeInfo.h:
(JSC::TypeInfo::implementsHasInstance):
WebCore:
2008-09-22 Maciej Stachowiak <mjs@apple.com>
Reviewed by Cameron Zwarich.
- speed up instanceof operator by replacing implementsHasInstance method with a TypeInfo flag
Partial work towards <https://bugs.webkit.org/show_bug.cgi?id=20818>
2.2% speedup on EarleyBoyer benchmark.
* bindings/js/JSQuarantinedObjectWrapper.cpp:
* bindings/js/JSQuarantinedObjectWrapper.h:
(WebCore::JSQuarantinedObjectWrapper::createStructureID):
* bindings/scripts/CodeGeneratorJS.pm:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@36766
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
JSClassRelease(m_class);
}
-bool JSCallbackConstructor::implementsHasInstance() const
-{
- return true;
-}
-
static JSObject* constructJSCallback(ExecState* exec, JSObject* constructor, const ArgList& args)
{
JSContextRef ctx = toRef(exec);
JSObjectCallAsConstructorCallback callback() const { return m_callback; }
static const ClassInfo info;
+ static PassRefPtr<StructureID> createStructureID(JSValue* proto)
+ {
+ return StructureID::create(proto, TypeInfo(ObjectType, ImplementsHasInstance));
+ }
+
private:
- virtual bool implementsHasInstance() const;
virtual ConstructType getConstructData(ConstructData&);
virtual const ClassInfo* classInfo() const { return &info; }
{
}
-// InternalFunction mish-mashes constructor and function behavior -- we should
-// refactor the code so this override isn't necessary
-bool JSCallbackFunction::implementsHasInstance() const
-{
- return false;
-}
-
JSValue* JSCallbackFunction::call(ExecState* exec, JSObject* functionObject, JSValue* thisValue, const ArgList& args)
{
JSContextRef execRef = toRef(exec);
static const ClassInfo info;
+ // InternalFunction mish-mashes constructor and function behavior -- we should
+ // refactor the code so this override isn't necessary
+ static PassRefPtr<StructureID> createStructureID(JSValue* proto)
+ {
+ return StructureID::create(proto, TypeInfo(ObjectType));
+ }
+
private:
- virtual bool implementsHasInstance() const;
virtual CallType getCallData(CallData&);
virtual const ClassInfo* classInfo() const { return &info; }
JSClassRef classRef() const { return m_callbackObjectData->jsClass; }
bool inherits(JSClassRef) const;
+ static PassRefPtr<StructureID> createStructureID(JSValue* proto)
+ {
+ return StructureID::create(proto, TypeInfo(ObjectType, ImplementsHasInstance));
+ }
+
private:
virtual UString className() const;
virtual bool deleteProperty(ExecState*, const Identifier&);
virtual bool deleteProperty(ExecState*, unsigned);
- virtual bool implementsHasInstance() const;
virtual bool hasInstance(ExecState* exec, JSValue* value, JSValue* proto);
virtual void getPropertyNames(ExecState*, PropertyNameArray&);
return 0;
}
-template <class Base>
-bool JSCallbackObject<Base>::implementsHasInstance() const
-{
- for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass)
- if (jsClass->hasInstance)
- return true;
-
- return false;
-}
-
template <class Base>
bool JSCallbackObject<Base>::hasInstance(ExecState* exec, JSValue* value, JSValue*)
{
return hasInstance(execRef, thisRef, toRef(value), toRef(exec->exceptionSlot()));
}
}
- ASSERT_NOT_REACHED(); // implementsHasInstance should prevent us from reaching here
- return 0;
+ return false;
}
template <class Base>
JSValue* jsValue = toJS(value);
JSObject* jsConstructor = toJS(constructor);
- if (!jsConstructor->implementsHasInstance())
+ if (!jsConstructor->structureID()->typeInfo().implementsHasInstance())
return false;
bool result = jsConstructor->hasInstance(exec, jsValue, jsConstructor->get(exec, exec->propertyNames().prototype)); // false if an exception is thrown
if (exec->hadException()) {
+2008-09-22 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by Cameron Zwarich.
+
+ - speed up instanceof operator by replacing implementsHasInstance method with a TypeInfo flag
+
+ Partial work towards <https://bugs.webkit.org/show_bug.cgi?id=20818>
+
+ 2.2% speedup on EarleyBoyer benchmark.
+
+ * API/JSCallbackConstructor.cpp:
+ * API/JSCallbackConstructor.h:
+ (JSC::JSCallbackConstructor::createStructureID):
+ * API/JSCallbackFunction.cpp:
+ * API/JSCallbackFunction.h:
+ (JSC::JSCallbackFunction::createStructureID):
+ * API/JSCallbackObject.h:
+ (JSC::JSCallbackObject::createStructureID):
+ * API/JSCallbackObjectFunctions.h:
+ (JSC::::hasInstance):
+ * API/JSValueRef.cpp:
+ (JSValueIsInstanceOfConstructor):
+ * JavaScriptCore.exp:
+ * VM/Machine.cpp:
+ (JSC::Machine::privateExecute):
+ (JSC::Machine::cti_op_instanceof):
+ * kjs/InternalFunction.cpp:
+ * kjs/InternalFunction.h:
+ (JSC::InternalFunction::createStructureID):
+ * kjs/JSObject.cpp:
+ * kjs/JSObject.h:
+ * kjs/TypeInfo.h:
+ (JSC::TypeInfo::implementsHasInstance):
+
2008-09-22 Maciej Stachowiak <mjs@apple.com>
Reviewed by Dave Hyatt.
__ZNK3JSC12StringObject8toStringEPNS_9ExecStateE
__ZNK3JSC14JSGlobalObject14isDynamicScopeEv
__ZNK3JSC14JSGlobalObject14toGlobalObjectEPNS_9ExecStateE
-__ZNK3JSC16InternalFunction21implementsHasInstanceEv
__ZNK3JSC16JSVariableObject16isVariableObjectEv
__ZNK3JSC16JSVariableObject21getPropertyAttributesEPNS_9ExecStateERKNS_10IdentifierERj
__ZNK3JSC17DebuggerCallFrame10thisObjectEv
__ZNK3JSC8JSObject12toThisObjectEPNS_9ExecStateE
__ZNK3JSC8JSObject14toGlobalObjectEPNS_9ExecStateE
__ZNK3JSC8JSObject21getPropertyAttributesEPNS_9ExecStateERKNS_10IdentifierERj
-__ZNK3JSC8JSObject21implementsHasInstanceEv
__ZNK3JSC8JSObject8toNumberEPNS_9ExecStateE
__ZNK3JSC8JSObject8toObjectEPNS_9ExecStateE
__ZNK3JSC8JSObject8toStringEPNS_9ExecStateE
goto vm_throw;
JSObject* baseObj = static_cast<JSObject*>(baseVal);
- r[dst] = jsBoolean(baseObj->implementsHasInstance() ? baseObj->hasInstance(exec, r[value].jsValue(exec), r[baseProto].jsValue(exec)) : false);
+ r[dst] = jsBoolean(baseObj->structureID()->typeInfo().implementsHasInstance() ? baseObj->hasInstance(exec, r[value].jsValue(exec), r[baseProto].jsValue(exec)) : false);
++vPC;
NEXT_OPCODE;
JSObject* baseObj = static_cast<JSObject*>(baseVal);
JSValue* basePrototype = ARG_src3;
- JSValue* result = jsBoolean(baseObj->implementsHasInstance() ? baseObj->hasInstance(exec, ARG_src1, basePrototype) : false);
+ JSValue* result = jsBoolean(baseObj->structureID()->typeInfo().implementsHasInstance() ? baseObj->hasInstance(exec, ARG_src1, basePrototype) : false);
VM_CHECK_EXCEPTION_AT_END();
return result;
}
return static_cast<JSString*>(v)->value();
}
-bool InternalFunction::implementsHasInstance() const
-{
- return true;
-}
-
} // namespace JSC
const UString& name(ExecState*);
+ static PassRefPtr<StructureID> createStructureID(JSValue* proto)
+ {
+ return StructureID::create(proto, TypeInfo(ObjectType, ImplementsHasInstance));
+ }
+
protected:
InternalFunction(PassRefPtr<StructureID> structure) : JSObject(structure) { }
InternalFunction(ExecState*);
private:
virtual CallType getCallData(CallData&) = 0;
- virtual bool implementsHasInstance() const;
};
} // namespace JSC
}
}
-bool JSObject::implementsHasInstance() const
-{
- return false;
-}
-
bool JSObject::hasInstance(ExecState* exec, JSValue* value, JSValue* proto)
{
if (!proto->isObject()) {
virtual JSValue* defaultValue(ExecState*, PreferredPrimitiveType) const;
- virtual bool implementsHasInstance() const;
virtual bool hasInstance(ExecState*, JSValue*, JSValue* prototypeProperty);
virtual void getPropertyNames(ExecState*, PropertyNameArray&);
// WebCore uses this to make document.all and style.filter undetectable.
static const unsigned MasqueradesAsUndefined = 0x1;
+ static const unsigned ImplementsHasInstance = 0x2;
class TypeInfo {
friend class CTI;
JSType type() const { return m_type; }
bool masqueradesAsUndefined() const { return m_flags & MasqueradesAsUndefined; }
+ bool implementsHasInstance() const { return m_flags & ImplementsHasInstance; }
private:
JSType m_type;
+2008-09-22 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by Cameron Zwarich.
+
+ - speed up instanceof operator by replacing implementsHasInstance method with a TypeInfo flag
+
+ Partial work towards <https://bugs.webkit.org/show_bug.cgi?id=20818>
+
+ 2.2% speedup on EarleyBoyer benchmark.
+
+ * bindings/js/JSQuarantinedObjectWrapper.cpp:
+ * bindings/js/JSQuarantinedObjectWrapper.h:
+ (WebCore::JSQuarantinedObjectWrapper::createStructureID):
+ * bindings/scripts/CodeGeneratorJS.pm:
+
2008-09-22 Adam Roben <aroben@apple.com>
Windows build fix
return ConstructTypeHost;
}
-bool JSQuarantinedObjectWrapper::implementsHasInstance() const
-{
- return m_unwrappedObject->implementsHasInstance();
-}
-
bool JSQuarantinedObjectWrapper::hasInstance(ExecState* exec, JSValue* value, JSValue* proto)
{
if (!allowsHasInstance())
static const JSC::ClassInfo s_info;
+ static PassRefPtr<JSC::StructureID> createStructureID(JSC::JSValue* proto)
+ {
+ return JSC::StructureID::create(proto, JSC::TypeInfo(JSC::ObjectType, JSC::ImplementsHasInstance));
+ }
+
protected:
JSQuarantinedObjectWrapper(JSC::ExecState* unwrappedExec, JSC::JSObject* unwrappedObject, PassRefPtr<JSC::StructureID>);
virtual JSC::CallType getCallData(JSC::CallData&);
virtual JSC::ConstructType getConstructData(JSC::ConstructData&);
- virtual bool implementsHasInstance() const;
virtual bool hasInstance(JSC::ExecState*, JSC::JSValue*, JSC::JSValue* proto);
virtual void getPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&);
virtual const ClassInfo* classInfo() const { return &s_info; }
static const ClassInfo s_info;
- virtual bool implementsHasInstance() const { return true; }
+ static PassRefPtr<StructureID> createStructureID(JSValue* proto)
+ {
+ return StructureID::create(proto, TypeInfo(ObjectType, ImplementsHasInstance));
+ }
EOF
if ($canConstruct) {