Skip to content
Permalink
Browse files
Bug 54786 - Devirtualize JSCell::classInfo()
Reviewed by Sam Weinig.

Instead of making a virtual function call, add a pointer to the ClassInfo
onto Structure.

This removes a virtual function call, and paves the way towards removing all
the createStructure methods, and StructureFlags/AnonymousSlotCount properties
(these should be able to move onto ClassInfo).

Calls to Structure::create must now pass a pointer to the ClassInfo for the
structure. All objects now have a ClassInfo pointer, non-object cell types
still do not.

Changes are most mechanical, involving three steps:
    * Remove virtual classInfo() methods.
    * Add &s_info parameter to calls to Structure::create.
    * Rename ClassInfo static members on classes from 'info' to 's_info',
      for consistency.

Source/JavaScriptCore:

* API/JSCallbackConstructor.cpp:
* API/JSCallbackConstructor.h:
* API/JSCallbackFunction.cpp:
* API/JSCallbackFunction.h:
* API/JSCallbackObject.cpp:
* API/JSCallbackObject.h:
* API/JSCallbackObjectFunctions.h:
* API/JSObjectRef.cpp:
* API/JSValueRef.cpp:
* API/JSWeakObjectMapRefPrivate.cpp:
* JavaScriptCore.exp:
* debugger/Debugger.cpp:
* debugger/DebuggerActivation.h:
* debugger/DebuggerCallFrame.cpp:
* interpreter/Interpreter.cpp:
* jit/JITCall32_64.cpp:
* jit/JITOpcodes.cpp:
* jit/JITStubs.cpp:
* profiler/Profiler.cpp:
* runtime/Arguments.cpp:
* runtime/Arguments.h:
* runtime/ArrayConstructor.cpp:
* runtime/ArrayPrototype.cpp:
* runtime/ArrayPrototype.h:
* runtime/BooleanObject.cpp:
* runtime/BooleanObject.h:
* runtime/BooleanPrototype.cpp:
* runtime/DateConstructor.cpp:
* runtime/DateInstance.cpp:
* runtime/DateInstance.h:
* runtime/DatePrototype.cpp:
* runtime/DatePrototype.h:
* runtime/ErrorInstance.cpp:
* runtime/ErrorInstance.h:
* runtime/ErrorPrototype.cpp:
* runtime/FunctionPrototype.cpp:
* runtime/FunctionPrototype.h:
* runtime/GetterSetter.h:
* runtime/GlobalEvalFunction.h:
* runtime/InternalFunction.cpp:
* runtime/InternalFunction.h:
* runtime/JSAPIValueWrapper.h:
* runtime/JSActivation.cpp:
* runtime/JSActivation.h:
* runtime/JSArray.cpp:
* runtime/JSArray.h:
* runtime/JSByteArray.cpp:
* runtime/JSByteArray.h:
* runtime/JSCell.cpp:
* runtime/JSCell.h:
* runtime/JSFunction.cpp:
* runtime/JSFunction.h:
* runtime/JSGlobalData.cpp:
* runtime/JSGlobalObject.cpp:
* runtime/JSGlobalObject.h:
* runtime/JSNotAnObject.h:
* runtime/JSONObject.cpp:
* runtime/JSONObject.h:
* runtime/JSObject.cpp:
* runtime/JSObject.h:
* runtime/JSObjectWithGlobalObject.h:
* runtime/JSPropertyNameIterator.h:
* runtime/JSStaticScopeObject.h:
* runtime/JSString.h:
* runtime/JSVariableObject.h:
* runtime/JSWrapperObject.h:
* runtime/JSZombie.cpp:
* runtime/JSZombie.h:
* runtime/Lookup.cpp:
* runtime/MathObject.cpp:
* runtime/MathObject.h:
* runtime/NativeErrorConstructor.cpp:
* runtime/NativeErrorConstructor.h:
* runtime/NumberConstructor.cpp:
* runtime/NumberConstructor.h:
* runtime/NumberObject.cpp:
* runtime/NumberObject.h:
* runtime/NumberPrototype.cpp:
* runtime/ObjectConstructor.cpp:
* runtime/ObjectPrototype.cpp:
* runtime/RegExpConstructor.cpp:
* runtime/RegExpConstructor.h:
* runtime/RegExpObject.cpp:
* runtime/RegExpObject.h:
* runtime/RegExpPrototype.cpp:
* runtime/ScopeChain.cpp:
* runtime/StringConstructor.cpp:
* runtime/StringObject.cpp:
* runtime/StringObject.h:
* runtime/StringObjectThatMasqueradesAsUndefined.h:
* runtime/StringPrototype.cpp:
* runtime/StringPrototype.h:
* runtime/Structure.cpp:
* runtime/Structure.h:

Source/JavaScriptGlue:

* JSUtils.cpp:
(KJSValueToJSObject):
(KJSValueToCFTypeInternal):
* UserObjectImp.cpp:
* UserObjectImp.h:
(UserObjectImp::createStructure):

Source/WebCore:

* WebCore.exp.in:
* bindings/js/JSAudioConstructor.cpp:
* bindings/js/JSAudioConstructor.h:
* bindings/js/JSDOMBinding.cpp:
* bindings/js/JSDOMBinding.h:
* bindings/js/JSDOMGlobalObject.cpp:
* bindings/js/JSDOMGlobalObject.h:
* bindings/js/JSDOMWindowBase.cpp:
* bindings/js/JSDOMWindowBase.h:
* bindings/js/JSDOMWindowShell.cpp:
* bindings/js/JSDOMWindowShell.h:
* bindings/js/JSGeolocationCustom.cpp:
* bindings/js/JSImageConstructor.cpp:
* bindings/js/JSImageConstructor.h:
* bindings/js/JSImageDataCustom.cpp:
* bindings/js/JSOptionConstructor.cpp:
* bindings/js/JSOptionConstructor.h:
* bindings/js/JSWorkerContextBase.cpp:
* bindings/js/JSWorkerContextBase.h:
* bindings/js/SerializedScriptValue.cpp:
* bindings/scripts/CodeGeneratorJS.pm:
* bridge/c/CRuntimeObject.cpp:
* bridge/c/CRuntimeObject.h:
* bridge/c/c_instance.cpp:
* bridge/jni/jsc/JNIUtilityPrivate.cpp:
* bridge/jni/jsc/JavaInstanceJSC.cpp:
* bridge/jni/jsc/JavaRuntimeObject.cpp:
* bridge/jni/jsc/JavaRuntimeObject.h:
* bridge/jsc/BridgeJSC.cpp:
* bridge/objc/ObjCRuntimeObject.h:
* bridge/objc/ObjCRuntimeObject.mm:
* bridge/objc/objc_instance.mm:
* bridge/objc/objc_runtime.h:
* bridge/objc/objc_runtime.mm:
* bridge/runtime_array.cpp:
* bridge/runtime_array.h:
* bridge/runtime_method.cpp:
* bridge/runtime_method.h:
* bridge/runtime_object.cpp:
* bridge/runtime_object.h:

Source/WebKit/mac:

* Plugins/Hosted/ProxyInstance.mm:
(WebKit::ProxyRuntimeMethod::ProxyRuntimeMethod):
(WebKit::ProxyRuntimeMethod::createStructure):
* Plugins/Hosted/ProxyRuntimeObject.h:
(WebKit::ProxyRuntimeObject::createStructure):
* Plugins/Hosted/ProxyRuntimeObject.mm:
(WebKit::ProxyRuntimeObject::ProxyRuntimeObject):
* WebView/WebView.mm:
(aeDescFromJSValue):

Source/WebKit2:

* WebProcess/Plugins/Netscape/JSNPMethod.cpp:
(WebKit::JSNPMethod::JSNPMethod):
* WebProcess/Plugins/Netscape/JSNPMethod.h:
(WebKit::JSNPMethod::createStructure):
* WebProcess/Plugins/Netscape/JSNPObject.cpp:
(WebKit::JSNPObject::JSNPObject):
* WebProcess/Plugins/Netscape/JSNPObject.h:
(WebKit::JSNPObject::createStructure):



Canonical link: https://commits.webkit.org/69070@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@79132 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Gavin Barraclough committed Feb 19, 2011
1 parent 93dca5f commit 67bc1a700a17e04546619145bf0db0bfe4669d88
Showing with 824 additions and 476 deletions.
  1. +1 −1 Source/JavaScriptCore/API/JSCallbackConstructor.cpp
  2. +4 −5 Source/JavaScriptCore/API/JSCallbackConstructor.h
  3. +1 −1 Source/JavaScriptCore/API/JSCallbackFunction.cpp
  4. +2 −3 Source/JavaScriptCore/API/JSCallbackFunction.h
  5. +2 −2 Source/JavaScriptCore/API/JSCallbackObject.cpp
  6. +2 −3 Source/JavaScriptCore/API/JSCallbackObject.h
  7. +1 −1 Source/JavaScriptCore/API/JSCallbackObjectFunctions.h
  8. +11 −10 Source/JavaScriptCore/API/JSObjectRef.cpp
  9. +2 −2 Source/JavaScriptCore/API/JSValueRef.cpp
  10. +1 −1 Source/JavaScriptCore/API/JSWeakObjectMapRefPrivate.cpp
  11. +118 −0 Source/JavaScriptCore/ChangeLog
  12. +13 −12 Source/JavaScriptCore/JavaScriptCore.exp
  13. +0 −5 Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
  14. +1 −1 Source/JavaScriptCore/debugger/Debugger.cpp
  15. +1 −1 Source/JavaScriptCore/debugger/DebuggerActivation.h
  16. +2 −2 Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp
  17. +3 −3 Source/JavaScriptCore/interpreter/Interpreter.cpp
  18. +2 −2 Source/JavaScriptCore/jit/JITStubs.cpp
  19. +3 −3 Source/JavaScriptCore/profiler/Profiler.cpp
  20. +1 −1 Source/JavaScriptCore/runtime/Arguments.cpp
  21. +3 −6 Source/JavaScriptCore/runtime/Arguments.h
  22. +1 −2 Source/JavaScriptCore/runtime/ArrayConstructor.cpp
  23. +5 −5 Source/JavaScriptCore/runtime/ArrayPrototype.cpp
  24. +2 −3 Source/JavaScriptCore/runtime/ArrayPrototype.h
  25. +1 −1 Source/JavaScriptCore/runtime/BooleanObject.cpp
  26. +3 −4 Source/JavaScriptCore/runtime/BooleanObject.h
  27. +2 −3 Source/JavaScriptCore/runtime/BooleanPrototype.cpp
  28. +6 −7 Source/JavaScriptCore/runtime/DateConstructor.cpp
  29. +1 −1 Source/JavaScriptCore/runtime/DateInstance.cpp
  30. +3 −4 Source/JavaScriptCore/runtime/DateInstance.h
  31. +33 −33 Source/JavaScriptCore/runtime/DatePrototype.cpp
  32. +2 −3 Source/JavaScriptCore/runtime/DatePrototype.h
  33. +1 −1 Source/JavaScriptCore/runtime/ErrorInstance.cpp
  34. +5 −2 Source/JavaScriptCore/runtime/ErrorInstance.h
  35. +0 −1 Source/JavaScriptCore/runtime/ErrorPrototype.cpp
  36. +4 −5 Source/JavaScriptCore/runtime/FunctionPrototype.cpp
  37. +1 −1 Source/JavaScriptCore/runtime/FunctionPrototype.h
  38. +1 −1 Source/JavaScriptCore/runtime/GetterSetter.h
  39. +1 −1 Source/JavaScriptCore/runtime/GlobalEvalFunction.h
  40. +4 −6 Source/JavaScriptCore/runtime/InternalFunction.cpp
  41. +5 −4 Source/JavaScriptCore/runtime/InternalFunction.h
  42. +1 −1 Source/JavaScriptCore/runtime/JSAPIValueWrapper.h
  43. +2 −2 Source/JavaScriptCore/runtime/JSActivation.cpp
  44. +3 −4 Source/JavaScriptCore/runtime/JSActivation.h
  45. +1 −1 Source/JavaScriptCore/runtime/JSArray.cpp
  46. +3 −5 Source/JavaScriptCore/runtime/JSArray.h
  47. +4 −6 Source/JavaScriptCore/runtime/JSByteArray.cpp
  48. +4 −5 Source/JavaScriptCore/runtime/JSByteArray.h
  49. +0 −5 Source/JavaScriptCore/runtime/JSCell.cpp
  50. +2 −2 Source/JavaScriptCore/runtime/JSCell.h
  51. +1 −1 Source/JavaScriptCore/runtime/JSFunction.cpp
  52. +3 −5 Source/JavaScriptCore/runtime/JSFunction.h
  53. +1 −1 Source/JavaScriptCore/runtime/JSGlobalData.cpp
  54. +1 −2 Source/JavaScriptCore/runtime/JSGlobalObject.cpp
  55. +1 −2 Source/JavaScriptCore/runtime/JSGlobalObject.h
  56. +1 −1 Source/JavaScriptCore/runtime/JSNotAnObject.h
  57. +12 −12 Source/JavaScriptCore/runtime/JSONObject.cpp
  58. +2 −3 Source/JavaScriptCore/runtime/JSONObject.h
  59. +4 −3 Source/JavaScriptCore/runtime/JSObject.cpp
  60. +14 −6 Source/JavaScriptCore/runtime/JSObject.h
  61. +1 −1 Source/JavaScriptCore/runtime/JSObjectWithGlobalObject.h
  62. +1 −1 Source/JavaScriptCore/runtime/JSPropertyNameIterator.h
  63. +1 −1 Source/JavaScriptCore/runtime/JSStaticScopeObject.h
  64. +1 −1 Source/JavaScriptCore/runtime/JSString.h
  65. +1 −1 Source/JavaScriptCore/runtime/JSVariableObject.h
  66. +1 −1 Source/JavaScriptCore/runtime/JSWrapperObject.h
  67. +1 −1 Source/JavaScriptCore/runtime/JSZombie.cpp
  68. +6 −1 Source/JavaScriptCore/runtime/JSZombie.h
  69. +0 −1 Source/JavaScriptCore/runtime/Lookup.cpp
  70. +1 −1 Source/JavaScriptCore/runtime/MathObject.cpp
  71. +2 −3 Source/JavaScriptCore/runtime/MathObject.h
  72. +1 −1 Source/JavaScriptCore/runtime/NativeErrorConstructor.cpp
  73. +6 −3 Source/JavaScriptCore/runtime/NativeErrorConstructor.h
  74. +2 −2 Source/JavaScriptCore/runtime/NumberConstructor.cpp
  75. +2 −4 Source/JavaScriptCore/runtime/NumberConstructor.h
  76. +1 −1 Source/JavaScriptCore/runtime/NumberObject.cpp
  77. +2 −4 Source/JavaScriptCore/runtime/NumberObject.h
  78. +0 −1 Source/JavaScriptCore/runtime/NumberPrototype.cpp
  79. +1 −2 Source/JavaScriptCore/runtime/ObjectConstructor.cpp
  80. +0 −1 Source/JavaScriptCore/runtime/ObjectPrototype.cpp
  81. +2 −2 Source/JavaScriptCore/runtime/RegExpConstructor.cpp
  82. +3 −5 Source/JavaScriptCore/runtime/RegExpConstructor.h
  83. +1 −1 Source/JavaScriptCore/runtime/RegExpObject.cpp
  84. +3 −4 Source/JavaScriptCore/runtime/RegExpObject.h
  85. +6 −7 Source/JavaScriptCore/runtime/RegExpPrototype.cpp
  86. +1 −1 Source/JavaScriptCore/runtime/ScopeChain.cpp
  87. +0 −1 Source/JavaScriptCore/runtime/StringConstructor.cpp
  88. +1 −1 Source/JavaScriptCore/runtime/StringObject.cpp
  89. +3 −4 Source/JavaScriptCore/runtime/StringObject.h
  90. +1 −1 Source/JavaScriptCore/runtime/StringObjectThatMasqueradesAsUndefined.h
  91. +6 −6 Source/JavaScriptCore/runtime/StringPrototype.cpp
  92. +6 −2 Source/JavaScriptCore/runtime/StringPrototype.h
  93. +48 −28 Source/JavaScriptCore/runtime/Structure.cpp
  94. +15 −4 Source/JavaScriptCore/runtime/Structure.h
  95. +30 −0 Source/JavaScriptGlue/ChangeLog
  96. +3 −3 Source/JavaScriptGlue/JSUtils.cpp
  97. +1 −6 Source/JavaScriptGlue/UserObjectImp.cpp
  98. +2 −3 Source/JavaScriptGlue/UserObjectImp.h
  99. +64 −0 Source/WebCore/ChangeLog
  100. +4 −2 Source/WebCore/WebCore.exp.in
  101. +2 −1 Source/WebCore/bindings/js/JSAudioConstructor.cpp
  102. +6 −2 Source/WebCore/bindings/js/JSAudioConstructor.h
  103. +1 −1 Source/WebCore/bindings/js/JSDOMBinding.cpp
  104. +2 −2 Source/WebCore/bindings/js/JSDOMBinding.h
  105. +2 −1 Source/WebCore/bindings/js/JSDOMGlobalObject.cpp
  106. +5 −1 Source/WebCore/bindings/js/JSDOMGlobalObject.h
  107. +2 −0 Source/WebCore/bindings/js/JSDOMWindowBase.cpp
  108. +5 −1 Source/WebCore/bindings/js/JSDOMWindowBase.h
  109. +2 −1 Source/WebCore/bindings/js/JSDOMWindowShell.cpp
  110. +1 −2 Source/WebCore/bindings/js/JSDOMWindowShell.h
  111. +2 −2 Source/WebCore/bindings/js/JSGeolocationCustom.cpp
  112. +2 −1 Source/WebCore/bindings/js/JSImageConstructor.cpp
  113. +6 −1 Source/WebCore/bindings/js/JSImageConstructor.h
  114. +3 −3 Source/WebCore/bindings/js/JSImageDataCustom.cpp
  115. +2 −1 Source/WebCore/bindings/js/JSOptionConstructor.cpp
  116. +6 −1 Source/WebCore/bindings/js/JSOptionConstructor.h
  117. +1 −0 Source/WebCore/bindings/js/JSWorkerContextBase.cpp
  118. +5 −1 Source/WebCore/bindings/js/JSWorkerContextBase.h
  119. +3 −3 Source/WebCore/bindings/js/SerializedScriptValue.cpp
  120. +9 −10 Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
  121. +1 −2 Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp
  122. +2 −4 Source/WebCore/bindings/scripts/test/JS/JSTestInterface.h
  123. +1 −2 Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp
  124. +2 −4 Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.h
  125. +1 −2 Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
  126. +2 −4 Source/WebCore/bindings/scripts/test/JS/JSTestObj.h
  127. +7 −2 Source/WebCore/bridge/c/CRuntimeObject.cpp
  128. +4 −2 Source/WebCore/bridge/c/CRuntimeObject.h
  129. +10 −2 Source/WebCore/bridge/c/c_instance.cpp
  130. +1 −1 Source/WebCore/bridge/jni/jsc/JNIUtilityPrivate.cpp
  131. +10 −2 Source/WebCore/bridge/jni/jsc/JavaInstanceJSC.cpp
  132. +7 −2 Source/WebCore/bridge/jni/jsc/JavaRuntimeObject.cpp
  133. +4 −2 Source/WebCore/bridge/jni/jsc/JavaRuntimeObject.h
  134. +6 −3 Source/WebCore/bridge/jsc/BridgeJSC.cpp
  135. +4 −2 Source/WebCore/bridge/objc/ObjCRuntimeObject.h
  136. +6 −1 Source/WebCore/bridge/objc/ObjCRuntimeObject.mm
  137. +10 −2 Source/WebCore/bridge/objc/objc_instance.mm
  138. +1 −3 Source/WebCore/bridge/objc/objc_runtime.h
  139. +2 −1 Source/WebCore/bridge/objc/objc_runtime.mm
  140. +1 −4 Source/WebCore/bridge/qt/qt_instance.cpp
  141. +1 −4 Source/WebCore/bridge/qt/qt_pixmapruntime.cpp
  142. +8 −8 Source/WebCore/bridge/qt/qt_runtime.cpp
  143. +1 −1 Source/WebCore/bridge/qt/qt_runtime.h
  144. +2 −1 Source/WebCore/bridge/runtime_array.cpp
  145. +8 −3 Source/WebCore/bridge/runtime_array.h
  146. +4 −5 Source/WebCore/bridge/runtime_method.cpp
  147. +5 −8 Source/WebCore/bridge/runtime_method.h
  148. +2 −9 Source/WebCore/bridge/runtime_object.cpp
  149. +3 −6 Source/WebCore/bridge/runtime_object.h
  150. +33 −0 Source/WebKit/mac/ChangeLog
  151. +9 −2 Source/WebKit/mac/Plugins/Hosted/ProxyInstance.mm
  152. +5 −3 Source/WebKit/mac/Plugins/Hosted/ProxyRuntimeObject.h
  153. +6 −1 Source/WebKit/mac/Plugins/Hosted/ProxyRuntimeObject.mm
  154. +2 −2 Source/WebKit/mac/WebView/WebView.mm
  155. +32 −0 Source/WebKit2/ChangeLog
  156. +2 −1 Source/WebKit2/WebProcess/Plugins/Netscape/JSNPMethod.cpp
  157. +1 −2 Source/WebKit2/WebProcess/Plugins/Netscape/JSNPMethod.h
  158. +3 −1 Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.cpp
  159. +2 −4 Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.h
@@ -36,7 +36,7 @@

namespace JSC {

const ClassInfo JSCallbackConstructor::info = { "CallbackConstructor", 0, 0, 0 };
const ClassInfo JSCallbackConstructor::s_info = { "CallbackConstructor", &JSObjectWithGlobalObject::s_info, 0, 0 };

JSCallbackConstructor::JSCallbackConstructor(JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, JSClassRef jsClass, JSObjectCallAsConstructorCallback callback)
: JSObjectWithGlobalObject(globalObject, structure)
@@ -37,19 +37,18 @@ class JSCallbackConstructor : public JSObjectWithGlobalObject {
virtual ~JSCallbackConstructor();
JSClassRef classRef() const { return m_class; }
JSObjectCallAsConstructorCallback callback() const { return m_callback; }
static const ClassInfo info;
static const ClassInfo s_info;

static PassRefPtr<Structure> createStructure(JSValue proto)
{
return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
{
return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
}

protected:
static const unsigned StructureFlags = ImplementsHasInstance | JSObject::StructureFlags;

private:
virtual ConstructType getConstructData(ConstructData&);
virtual const ClassInfo* classInfo() const { return &info; }

JSClassRef m_class;
JSObjectCallAsConstructorCallback m_callback;
@@ -40,7 +40,7 @@ namespace JSC {

ASSERT_CLASS_FITS_IN_CELL(JSCallbackFunction);

const ClassInfo JSCallbackFunction::info = { "CallbackFunction", &InternalFunction::info, 0, 0 };
const ClassInfo JSCallbackFunction::s_info = { "CallbackFunction", &InternalFunction::s_info, 0, 0 };

JSCallbackFunction::JSCallbackFunction(ExecState* exec, JSGlobalObject* globalObject, JSObjectCallAsFunctionCallback callback, const Identifier& name)
: InternalFunction(&exec->globalData(), globalObject, globalObject->callbackFunctionStructure(), name)
@@ -35,18 +35,17 @@ class JSCallbackFunction : public InternalFunction {
public:
JSCallbackFunction(ExecState*, JSGlobalObject*, JSObjectCallAsFunctionCallback, const Identifier& name);

static const ClassInfo info;
static const ClassInfo s_info;

// InternalFunction mish-mashes constructor and function behavior -- we should
// refactor the code so this override isn't necessary
static PassRefPtr<Structure> createStructure(JSValue proto)
{
return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
}

private:
virtual CallType getCallData(CallData&);
virtual const ClassInfo* classInfo() const { return &info; }

static EncodedJSValue JSC_HOST_CALL call(ExecState*);

@@ -36,7 +36,7 @@ ASSERT_CLASS_FITS_IN_CELL(JSCallbackObject<JSObjectWithGlobalObject>);
ASSERT_CLASS_FITS_IN_CELL(JSCallbackObject<JSGlobalObject>);

// Define the two types of JSCallbackObjects we support.
template <> const ClassInfo JSCallbackObject<JSObjectWithGlobalObject>::info = { "CallbackObject", 0, 0, 0 };
template <> const ClassInfo JSCallbackObject<JSGlobalObject>::info = { "CallbackGlobalObject", 0, 0, 0 };
template <> const ClassInfo JSCallbackObject<JSObjectWithGlobalObject>::s_info = { "CallbackObject", &JSObjectWithGlobalObject::s_info, 0, 0 };
template <> const ClassInfo JSCallbackObject<JSGlobalObject>::s_info = { "CallbackGlobalObject", &JSGlobalObject::s_info, 0, 0 };

} // namespace JSC
@@ -123,14 +123,14 @@ class JSCallbackObject : public Base {
void setPrivate(void* data);
void* getPrivate();

static const ClassInfo info;
static const ClassInfo s_info;

JSClassRef classRef() const { return m_callbackObjectData->jsClass; }
bool inherits(JSClassRef) const;

static PassRefPtr<Structure> createStructure(JSValue proto)
{
return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), Base::AnonymousSlotCount);
return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), Base::AnonymousSlotCount, &s_info);
}

JSValue getPrivateProperty(const Identifier& propertyName) const
@@ -171,7 +171,6 @@ class JSCallbackObject : public Base {

virtual ConstructType getConstructData(ConstructData&);
virtual CallType getCallData(CallData&);
virtual const ClassInfo* classInfo() const { return &info; }

virtual void markChildren(MarkStack& markStack)
{
@@ -45,7 +45,7 @@ namespace JSC {
template <class Base>
inline JSCallbackObject<Base>* JSCallbackObject<Base>::asCallbackObject(JSValue value)
{
ASSERT(asObject(value)->inherits(&info));
ASSERT(asObject(value)->inherits(&s_info));
return static_cast<JSCallbackObject*>(asObject(value));
}

@@ -340,9 +340,9 @@ void* JSObjectGetPrivate(JSObjectRef object)
{
JSObject* jsObject = toJS(object);

if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::info))
if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::s_info))
return static_cast<JSCallbackObject<JSGlobalObject>*>(jsObject)->getPrivate();
else if (jsObject->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::info))
if (jsObject->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::s_info))
return static_cast<JSCallbackObject<JSObjectWithGlobalObject>*>(jsObject)->getPrivate();

return 0;
@@ -352,10 +352,11 @@ bool JSObjectSetPrivate(JSObjectRef object, void* data)
{
JSObject* jsObject = toJS(object);

if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::info)) {
if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::s_info)) {
static_cast<JSCallbackObject<JSGlobalObject>*>(jsObject)->setPrivate(data);
return true;
} else if (jsObject->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::info)) {
}
if (jsObject->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::s_info)) {
static_cast<JSCallbackObject<JSObjectWithGlobalObject>*>(jsObject)->setPrivate(data);
return true;
}
@@ -370,9 +371,9 @@ JSValueRef JSObjectGetPrivateProperty(JSContextRef ctx, JSObjectRef object, JSSt
JSObject* jsObject = toJS(object);
JSValue result;
Identifier name(propertyName->identifier(&exec->globalData()));
if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::info))
if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::s_info))
result = static_cast<JSCallbackObject<JSGlobalObject>*>(jsObject)->getPrivateProperty(name);
else if (jsObject->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::info))
else if (jsObject->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::s_info))
result = static_cast<JSCallbackObject<JSObjectWithGlobalObject>*>(jsObject)->getPrivateProperty(name);
return toRef(exec, result);
}
@@ -384,11 +385,11 @@ bool JSObjectSetPrivateProperty(JSContextRef ctx, JSObjectRef object, JSStringRe
JSObject* jsObject = toJS(object);
JSValue jsValue = value ? toJS(exec, value) : JSValue();
Identifier name(propertyName->identifier(&exec->globalData()));
if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::info)) {
if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::s_info)) {
static_cast<JSCallbackObject<JSGlobalObject>*>(jsObject)->setPrivateProperty(exec->globalData(), name, jsValue);
return true;
}
if (jsObject->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::info)) {
if (jsObject->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::s_info)) {
static_cast<JSCallbackObject<JSObjectWithGlobalObject>*>(jsObject)->setPrivateProperty(exec->globalData(), name, jsValue);
return true;
}
@@ -401,11 +402,11 @@ bool JSObjectDeletePrivateProperty(JSContextRef ctx, JSObjectRef object, JSStrin
APIEntryShim entryShim(exec);
JSObject* jsObject = toJS(object);
Identifier name(propertyName->identifier(&exec->globalData()));
if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::info)) {
if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::s_info)) {
static_cast<JSCallbackObject<JSGlobalObject>*>(jsObject)->deletePrivateProperty(name);
return true;
}
if (jsObject->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::info)) {
if (jsObject->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::s_info)) {
static_cast<JSCallbackObject<JSObjectWithGlobalObject>*>(jsObject)->deletePrivateProperty(name);
return true;
}
@@ -129,9 +129,9 @@ bool JSValueIsObjectOfClass(JSContextRef ctx, JSValueRef value, JSClassRef jsCla
JSValue jsValue = toJS(exec, value);

if (JSObject* o = jsValue.getObject()) {
if (o->inherits(&JSCallbackObject<JSGlobalObject>::info))
if (o->inherits(&JSCallbackObject<JSGlobalObject>::s_info))
return static_cast<JSCallbackObject<JSGlobalObject>*>(o)->inherits(jsClass);
else if (o->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::info))
if (o->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::s_info))
return static_cast<JSCallbackObject<JSObjectWithGlobalObject>*>(o)->inherits(jsClass);
}
return false;
@@ -57,7 +57,7 @@ void JSWeakObjectMapSet(JSContextRef ctx, JSWeakObjectMapRef map, void* key, JSO
JSObject* obj = toJS(object);
if (!obj)
return;
ASSERT(obj->inherits(&JSCallbackObject<JSGlobalObject>::info) || obj->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::info));
ASSERT(obj->inherits(&JSCallbackObject<JSGlobalObject>::s_info) || obj->inherits(&JSCallbackObject<JSObjectWithGlobalObject>::s_info));
map->map().set(key, obj);
}

@@ -1,3 +1,121 @@
2011-02-18 Gavin Barraclough <barraclough@apple.com>

Reviewed by Sam Weinig.

Bug 54786 - Devirtualize JSCell::classInfo()

Instead of making a virtual function call, add a pointer to the ClassInfo
onto Structure.

This removes a virtual function call, and paves the way towards removing all
the createStructure methods, and StructureFlags/AnonymousSlotCount properties
(these should be able to move onto ClassInfo).

Calls to Structure::create must now pass a pointer to the ClassInfo for the
structure. All objects now have a ClassInfo pointer, non-object cell types
still do not.

Changes are most mechanical, involving three steps:
* Remove virtual classInfo() methods.
* Add &s_info parameter to calls to Structure::create.
* Rename ClassInfo static members on classes from 'info' to 's_info',
for consistency.

* API/JSCallbackConstructor.cpp:
* API/JSCallbackConstructor.h:
* API/JSCallbackFunction.cpp:
* API/JSCallbackFunction.h:
* API/JSCallbackObject.cpp:
* API/JSCallbackObject.h:
* API/JSCallbackObjectFunctions.h:
* API/JSObjectRef.cpp:
* API/JSValueRef.cpp:
* API/JSWeakObjectMapRefPrivate.cpp:
* JavaScriptCore.exp:
* debugger/Debugger.cpp:
* debugger/DebuggerActivation.h:
* debugger/DebuggerCallFrame.cpp:
* interpreter/Interpreter.cpp:
* jit/JITCall32_64.cpp:
* jit/JITOpcodes.cpp:
* jit/JITStubs.cpp:
* profiler/Profiler.cpp:
* runtime/Arguments.cpp:
* runtime/Arguments.h:
* runtime/ArrayConstructor.cpp:
* runtime/ArrayPrototype.cpp:
* runtime/ArrayPrototype.h:
* runtime/BooleanObject.cpp:
* runtime/BooleanObject.h:
* runtime/BooleanPrototype.cpp:
* runtime/DateConstructor.cpp:
* runtime/DateInstance.cpp:
* runtime/DateInstance.h:
* runtime/DatePrototype.cpp:
* runtime/DatePrototype.h:
* runtime/ErrorInstance.cpp:
* runtime/ErrorInstance.h:
* runtime/ErrorPrototype.cpp:
* runtime/FunctionPrototype.cpp:
* runtime/FunctionPrototype.h:
* runtime/GetterSetter.h:
* runtime/GlobalEvalFunction.h:
* runtime/InternalFunction.cpp:
* runtime/InternalFunction.h:
* runtime/JSAPIValueWrapper.h:
* runtime/JSActivation.cpp:
* runtime/JSActivation.h:
* runtime/JSArray.cpp:
* runtime/JSArray.h:
* runtime/JSByteArray.cpp:
* runtime/JSByteArray.h:
* runtime/JSCell.cpp:
* runtime/JSCell.h:
* runtime/JSFunction.cpp:
* runtime/JSFunction.h:
* runtime/JSGlobalData.cpp:
* runtime/JSGlobalObject.cpp:
* runtime/JSGlobalObject.h:
* runtime/JSNotAnObject.h:
* runtime/JSONObject.cpp:
* runtime/JSONObject.h:
* runtime/JSObject.cpp:
* runtime/JSObject.h:
* runtime/JSObjectWithGlobalObject.h:
* runtime/JSPropertyNameIterator.h:
* runtime/JSStaticScopeObject.h:
* runtime/JSString.h:
* runtime/JSVariableObject.h:
* runtime/JSWrapperObject.h:
* runtime/JSZombie.cpp:
* runtime/JSZombie.h:
* runtime/Lookup.cpp:
* runtime/MathObject.cpp:
* runtime/MathObject.h:
* runtime/NativeErrorConstructor.cpp:
* runtime/NativeErrorConstructor.h:
* runtime/NumberConstructor.cpp:
* runtime/NumberConstructor.h:
* runtime/NumberObject.cpp:
* runtime/NumberObject.h:
* runtime/NumberPrototype.cpp:
* runtime/ObjectConstructor.cpp:
* runtime/ObjectPrototype.cpp:
* runtime/RegExpConstructor.cpp:
* runtime/RegExpConstructor.h:
* runtime/RegExpObject.cpp:
* runtime/RegExpObject.h:
* runtime/RegExpPrototype.cpp:
* runtime/ScopeChain.cpp:
* runtime/StringConstructor.cpp:
* runtime/StringObject.cpp:
* runtime/StringObject.h:
* runtime/StringObjectThatMasqueradesAsUndefined.h:
* runtime/StringPrototype.cpp:
* runtime/StringPrototype.h:
* runtime/Structure.cpp:
* runtime/Structure.h:

2011-02-19 David Kilzer <ddkilzer@apple.com>

<http://webkit.org/b/54808> Change jsc target to build directly into JavaScriptCore.framework/Resources/jsc

0 comments on commit 67bc1a7

Please sign in to comment.