Changeset 36766 in webkit
- Timestamp:
- Sep 22, 2008 8:03:52 AM (16 years ago)
- Location:
- trunk
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/API/JSCallbackConstructor.cpp
r36726 r36766 52 52 } 53 53 54 bool JSCallbackConstructor::implementsHasInstance() const55 {56 return true;57 }58 59 54 static JSObject* constructJSCallback(ExecState* exec, JSObject* constructor, const ArgList& args) 60 55 { -
trunk/JavaScriptCore/API/JSCallbackConstructor.h
r36726 r36766 40 40 static const ClassInfo info; 41 41 42 static PassRefPtr<StructureID> createStructureID(JSValue* proto) 43 { 44 return StructureID::create(proto, TypeInfo(ObjectType, ImplementsHasInstance)); 45 } 46 42 47 private: 43 virtual bool implementsHasInstance() const;44 48 virtual ConstructType getConstructData(ConstructData&); 45 49 virtual const ClassInfo* classInfo() const { return &info; } -
trunk/JavaScriptCore/API/JSCallbackFunction.cpp
r36726 r36766 47 47 } 48 48 49 // InternalFunction mish-mashes constructor and function behavior -- we should50 // refactor the code so this override isn't necessary51 bool JSCallbackFunction::implementsHasInstance() const52 {53 return false;54 }55 56 49 JSValue* JSCallbackFunction::call(ExecState* exec, JSObject* functionObject, JSValue* thisValue, const ArgList& args) 57 50 { -
trunk/JavaScriptCore/API/JSCallbackFunction.h
r36263 r36766 38 38 static const ClassInfo info; 39 39 40 // InternalFunction mish-mashes constructor and function behavior -- we should 41 // refactor the code so this override isn't necessary 42 static PassRefPtr<StructureID> createStructureID(JSValue* proto) 43 { 44 return StructureID::create(proto, TypeInfo(ObjectType)); 45 } 46 40 47 private: 41 virtual bool implementsHasInstance() const;42 48 virtual CallType getCallData(CallData&); 43 49 virtual const ClassInfo* classInfo() const { return &info; } -
trunk/JavaScriptCore/API/JSCallbackObject.h
r36726 r36766 49 49 bool inherits(JSClassRef) const; 50 50 51 static PassRefPtr<StructureID> createStructureID(JSValue* proto) 52 { 53 return StructureID::create(proto, TypeInfo(ObjectType, ImplementsHasInstance)); 54 } 55 51 56 private: 52 57 virtual UString className() const; … … 60 65 virtual bool deleteProperty(ExecState*, unsigned); 61 66 62 virtual bool implementsHasInstance() const;63 67 virtual bool hasInstance(ExecState* exec, JSValue* value, JSValue* proto); 64 68 -
trunk/JavaScriptCore/API/JSCallbackObjectFunctions.h
r36726 r36766 274 274 275 275 template <class Base> 276 bool JSCallbackObject<Base>::implementsHasInstance() const 277 { 278 for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) 279 if (jsClass->hasInstance) 280 return true; 281 276 bool JSCallbackObject<Base>::hasInstance(ExecState* exec, JSValue* value, JSValue*) 277 { 278 JSContextRef execRef = toRef(exec); 279 JSObjectRef thisRef = toRef(this); 280 281 for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) { 282 if (JSObjectHasInstanceCallback hasInstance = jsClass->hasInstance) { 283 JSLock::DropAllLocks dropAllLocks(exec); 284 return hasInstance(execRef, thisRef, toRef(value), toRef(exec->exceptionSlot())); 285 } 286 } 282 287 return false; 283 }284 285 template <class Base>286 bool JSCallbackObject<Base>::hasInstance(ExecState* exec, JSValue* value, JSValue*)287 {288 JSContextRef execRef = toRef(exec);289 JSObjectRef thisRef = toRef(this);290 291 for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) {292 if (JSObjectHasInstanceCallback hasInstance = jsClass->hasInstance) {293 JSLock::DropAllLocks dropAllLocks(exec);294 return hasInstance(execRef, thisRef, toRef(value), toRef(exec->exceptionSlot()));295 }296 }297 ASSERT_NOT_REACHED(); // implementsHasInstance should prevent us from reaching here298 return 0;299 288 } 300 289 -
trunk/JavaScriptCore/API/JSValueRef.cpp
r36417 r36766 145 145 JSValue* jsValue = toJS(value); 146 146 JSObject* jsConstructor = toJS(constructor); 147 if (!jsConstructor-> implementsHasInstance())147 if (!jsConstructor->structureID()->typeInfo().implementsHasInstance()) 148 148 return false; 149 149 bool result = jsConstructor->hasInstance(exec, jsValue, jsConstructor->get(exec, exec->propertyNames().prototype)); // false if an exception is thrown -
trunk/JavaScriptCore/ChangeLog
r36764 r36766 1 2008-09-22 Maciej Stachowiak <mjs@apple.com> 2 3 Reviewed by Cameron Zwarich. 4 5 - speed up instanceof operator by replacing implementsHasInstance method with a TypeInfo flag 6 7 Partial work towards <https://bugs.webkit.org/show_bug.cgi?id=20818> 8 9 2.2% speedup on EarleyBoyer benchmark. 10 11 * API/JSCallbackConstructor.cpp: 12 * API/JSCallbackConstructor.h: 13 (JSC::JSCallbackConstructor::createStructureID): 14 * API/JSCallbackFunction.cpp: 15 * API/JSCallbackFunction.h: 16 (JSC::JSCallbackFunction::createStructureID): 17 * API/JSCallbackObject.h: 18 (JSC::JSCallbackObject::createStructureID): 19 * API/JSCallbackObjectFunctions.h: 20 (JSC::::hasInstance): 21 * API/JSValueRef.cpp: 22 (JSValueIsInstanceOfConstructor): 23 * JavaScriptCore.exp: 24 * VM/Machine.cpp: 25 (JSC::Machine::privateExecute): 26 (JSC::Machine::cti_op_instanceof): 27 * kjs/InternalFunction.cpp: 28 * kjs/InternalFunction.h: 29 (JSC::InternalFunction::createStructureID): 30 * kjs/JSObject.cpp: 31 * kjs/JSObject.h: 32 * kjs/TypeInfo.h: 33 (JSC::TypeInfo::implementsHasInstance): 34 1 35 2008-09-22 Maciej Stachowiak <mjs@apple.com> 2 36 -
trunk/JavaScriptCore/JavaScriptCore.exp
r36755 r36766 292 292 __ZNK3JSC14JSGlobalObject14isDynamicScopeEv 293 293 __ZNK3JSC14JSGlobalObject14toGlobalObjectEPNS_9ExecStateE 294 __ZNK3JSC16InternalFunction21implementsHasInstanceEv295 294 __ZNK3JSC16JSVariableObject16isVariableObjectEv 296 295 __ZNK3JSC16JSVariableObject21getPropertyAttributesEPNS_9ExecStateERKNS_10IdentifierERj … … 329 328 __ZNK3JSC8JSObject14toGlobalObjectEPNS_9ExecStateE 330 329 __ZNK3JSC8JSObject21getPropertyAttributesEPNS_9ExecStateERKNS_10IdentifierERj 331 __ZNK3JSC8JSObject21implementsHasInstanceEv332 330 __ZNK3JSC8JSObject8toNumberEPNS_9ExecStateE 333 331 __ZNK3JSC8JSObject8toObjectEPNS_9ExecStateE -
trunk/JavaScriptCore/VM/Machine.cpp
r36764 r36766 2124 2124 2125 2125 JSObject* baseObj = static_cast<JSObject*>(baseVal); 2126 r[dst] = jsBoolean(baseObj-> implementsHasInstance() ? baseObj->hasInstance(exec, r[value].jsValue(exec), r[baseProto].jsValue(exec)) : false);2126 r[dst] = jsBoolean(baseObj->structureID()->typeInfo().implementsHasInstance() ? baseObj->hasInstance(exec, r[value].jsValue(exec), r[baseProto].jsValue(exec)) : false); 2127 2127 2128 2128 ++vPC; … … 4305 4305 JSObject* baseObj = static_cast<JSObject*>(baseVal); 4306 4306 JSValue* basePrototype = ARG_src3; 4307 JSValue* result = jsBoolean(baseObj-> implementsHasInstance() ? baseObj->hasInstance(exec, ARG_src1, basePrototype) : false);4307 JSValue* result = jsBoolean(baseObj->structureID()->typeInfo().implementsHasInstance() ? baseObj->hasInstance(exec, ARG_src1, basePrototype) : false); 4308 4308 VM_CHECK_EXCEPTION_AT_END(); 4309 4309 return result; -
trunk/JavaScriptCore/kjs/InternalFunction.cpp
r36726 r36766 52 52 } 53 53 54 bool InternalFunction::implementsHasInstance() const55 {56 return true;57 }58 59 54 } // namespace JSC -
trunk/JavaScriptCore/kjs/InternalFunction.h
r36726 r36766 39 39 const UString& name(ExecState*); 40 40 41 static PassRefPtr<StructureID> createStructureID(JSValue* proto) 42 { 43 return StructureID::create(proto, TypeInfo(ObjectType, ImplementsHasInstance)); 44 } 45 41 46 protected: 42 47 InternalFunction(PassRefPtr<StructureID> structure) : JSObject(structure) { } … … 46 51 private: 47 52 virtual CallType getCallData(CallData&) = 0; 48 virtual bool implementsHasInstance() const;49 53 }; 50 54 -
trunk/JavaScriptCore/kjs/JSObject.cpp
r36755 r36766 385 385 } 386 386 387 bool JSObject::implementsHasInstance() const388 {389 return false;390 }391 392 387 bool JSObject::hasInstance(ExecState* exec, JSValue* value, JSValue* proto) 393 388 { -
trunk/JavaScriptCore/kjs/JSObject.h
r36755 r36766 104 104 virtual JSValue* defaultValue(ExecState*, PreferredPrimitiveType) const; 105 105 106 virtual bool implementsHasInstance() const;107 106 virtual bool hasInstance(ExecState*, JSValue*, JSValue* prototypeProperty); 108 107 -
trunk/JavaScriptCore/kjs/TypeInfo.h
r36764 r36766 34 34 // WebCore uses this to make document.all and style.filter undetectable. 35 35 static const unsigned MasqueradesAsUndefined = 0x1; 36 static const unsigned ImplementsHasInstance = 0x2; 36 37 37 38 class TypeInfo { … … 43 44 44 45 bool masqueradesAsUndefined() const { return m_flags & MasqueradesAsUndefined; } 46 bool implementsHasInstance() const { return m_flags & ImplementsHasInstance; } 45 47 46 48 private: -
trunk/WebCore/ChangeLog
r36765 r36766 1 2008-09-22 Maciej Stachowiak <mjs@apple.com> 2 3 Reviewed by Cameron Zwarich. 4 5 - speed up instanceof operator by replacing implementsHasInstance method with a TypeInfo flag 6 7 Partial work towards <https://bugs.webkit.org/show_bug.cgi?id=20818> 8 9 2.2% speedup on EarleyBoyer benchmark. 10 11 * bindings/js/JSQuarantinedObjectWrapper.cpp: 12 * bindings/js/JSQuarantinedObjectWrapper.h: 13 (WebCore::JSQuarantinedObjectWrapper::createStructureID): 14 * bindings/scripts/CodeGeneratorJS.pm: 15 1 16 2008-09-22 Adam Roben <aroben@apple.com> 2 17 -
trunk/WebCore/bindings/js/JSQuarantinedObjectWrapper.cpp
r36675 r36766 220 220 } 221 221 222 bool JSQuarantinedObjectWrapper::implementsHasInstance() const223 {224 return m_unwrappedObject->implementsHasInstance();225 }226 227 222 bool JSQuarantinedObjectWrapper::hasInstance(ExecState* exec, JSValue* value, JSValue* proto) 228 223 { -
trunk/WebCore/bindings/js/JSQuarantinedObjectWrapper.h
r36675 r36766 45 45 static const JSC::ClassInfo s_info; 46 46 47 static PassRefPtr<JSC::StructureID> createStructureID(JSC::JSValue* proto) 48 { 49 return JSC::StructureID::create(proto, JSC::TypeInfo(JSC::ObjectType, JSC::ImplementsHasInstance)); 50 } 51 47 52 protected: 48 53 JSQuarantinedObjectWrapper(JSC::ExecState* unwrappedExec, JSC::JSObject* unwrappedObject, PassRefPtr<JSC::StructureID>); … … 63 68 virtual JSC::ConstructType getConstructData(JSC::ConstructData&); 64 69 65 virtual bool implementsHasInstance() const;66 70 virtual bool hasInstance(JSC::ExecState*, JSC::JSValue*, JSC::JSValue* proto); 67 71 -
trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm
r36755 r36766 1821 1821 static const ClassInfo s_info; 1822 1822 1823 virtual bool implementsHasInstance() const { return true; } 1823 static PassRefPtr<StructureID> createStructureID(JSValue* proto) 1824 { 1825 return StructureID::create(proto, TypeInfo(ObjectType, ImplementsHasInstance)); 1826 } 1824 1827 EOF 1825 1828
Note: See TracChangeset
for help on using the changeset viewer.