Add static version of JSCell::getConstructData
authormhahnenberg@apple.com <mhahnenberg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 8 Oct 2011 23:26:41 +0000 (23:26 +0000)
committermhahnenberg@apple.com <mhahnenberg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 8 Oct 2011 23:26:41 +0000 (23:26 +0000)
https://bugs.webkit.org/show_bug.cgi?id=69673

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

Added static version of getConstructData to all classes that
override it and changed the virtual versions to call the static
versions.  This is the first step in de-virtualizing JSCell::getConstructData.

* API/JSCallbackConstructor.cpp:
(JSC::JSCallbackConstructor::getConstructData):
* API/JSCallbackConstructor.h:
* API/JSCallbackObject.h:
* API/JSCallbackObjectFunctions.h:
(JSC::::getConstructData):
* runtime/ArrayConstructor.cpp:
(JSC::ArrayConstructor::getConstructData):
* runtime/ArrayConstructor.h:
* runtime/BooleanConstructor.cpp:
(JSC::BooleanConstructor::getConstructData):
* runtime/BooleanConstructor.h:
* runtime/DateConstructor.cpp:
(JSC::DateConstructor::getConstructData):
* runtime/DateConstructor.h:
* runtime/ErrorConstructor.cpp:
(JSC::ErrorConstructor::getConstructData):
* runtime/ErrorConstructor.h:
* runtime/FunctionConstructor.cpp:
(JSC::FunctionConstructor::getConstructData):
* runtime/FunctionConstructor.h:
* runtime/JSCell.cpp:
(JSC::JSCell::getConstructData):
* runtime/JSCell.h:
* runtime/JSFunction.cpp:
(JSC::JSFunction::getConstructData):
* runtime/JSFunction.h:
* runtime/NativeErrorConstructor.cpp:
(JSC::NativeErrorConstructor::getConstructData):
* runtime/NativeErrorConstructor.h:
* runtime/NumberConstructor.cpp:
(JSC::NumberConstructor::getConstructData):
* runtime/NumberConstructor.h:
* runtime/ObjectConstructor.cpp:
(JSC::ObjectConstructor::getConstructData):
* runtime/ObjectConstructor.h:
* runtime/RegExpConstructor.cpp:
(JSC::RegExpConstructor::getConstructData):
* runtime/RegExpConstructor.h:
* runtime/StringConstructor.cpp:
(JSC::StringConstructor::getConstructData):
* runtime/StringConstructor.h:

Source/WebCore:

No new tests.

Added static version of getConstructData to all classes that
override it and changed the virtual versions to call the static
versions.  This is the first step in de-virtualizing JSCell::getConstructData.

* bindings/js/JSAudioConstructor.cpp:
(WebCore::JSAudioConstructor::getConstructData):
* bindings/js/JSAudioConstructor.h:
* bindings/js/JSImageConstructor.cpp:
(WebCore::JSImageConstructor::getConstructData):
* bindings/js/JSImageConstructor.h:
* bindings/js/JSOptionConstructor.cpp:
(WebCore::JSOptionConstructor::getConstructData):
* bindings/js/JSOptionConstructor.h:
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateConstructorDeclaration):
(GenerateConstructorDefinition):
* bindings/scripts/test/JS/JSTestInterface.cpp:
(WebCore::JSTestInterfaceConstructor::getConstructData):
* bridge/runtime_object.cpp:
(JSC::Bindings::RuntimeObject::getConstructData):
* bridge/runtime_object.h:

Source/WebKit2:

Added static version of getConstructData to all classes that
override it and changed the virtual versions to call the static
versions.  This is the first step in de-virtualizing JSCell::getConstructData.

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

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@97016 268f45cc-cd09-0410-ab3c-d52691b4dbfc

43 files changed:
Source/JavaScriptCore/API/JSCallbackConstructor.cpp
Source/JavaScriptCore/API/JSCallbackConstructor.h
Source/JavaScriptCore/API/JSCallbackObject.h
Source/JavaScriptCore/API/JSCallbackObjectFunctions.h
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/ArrayConstructor.cpp
Source/JavaScriptCore/runtime/ArrayConstructor.h
Source/JavaScriptCore/runtime/BooleanConstructor.cpp
Source/JavaScriptCore/runtime/BooleanConstructor.h
Source/JavaScriptCore/runtime/DateConstructor.cpp
Source/JavaScriptCore/runtime/DateConstructor.h
Source/JavaScriptCore/runtime/ErrorConstructor.cpp
Source/JavaScriptCore/runtime/ErrorConstructor.h
Source/JavaScriptCore/runtime/FunctionConstructor.cpp
Source/JavaScriptCore/runtime/FunctionConstructor.h
Source/JavaScriptCore/runtime/JSCell.cpp
Source/JavaScriptCore/runtime/JSCell.h
Source/JavaScriptCore/runtime/JSFunction.cpp
Source/JavaScriptCore/runtime/JSFunction.h
Source/JavaScriptCore/runtime/NativeErrorConstructor.cpp
Source/JavaScriptCore/runtime/NativeErrorConstructor.h
Source/JavaScriptCore/runtime/NumberConstructor.cpp
Source/JavaScriptCore/runtime/NumberConstructor.h
Source/JavaScriptCore/runtime/ObjectConstructor.cpp
Source/JavaScriptCore/runtime/ObjectConstructor.h
Source/JavaScriptCore/runtime/RegExpConstructor.cpp
Source/JavaScriptCore/runtime/RegExpConstructor.h
Source/JavaScriptCore/runtime/StringConstructor.cpp
Source/JavaScriptCore/runtime/StringConstructor.h
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSAudioConstructor.cpp
Source/WebCore/bindings/js/JSAudioConstructor.h
Source/WebCore/bindings/js/JSImageConstructor.cpp
Source/WebCore/bindings/js/JSImageConstructor.h
Source/WebCore/bindings/js/JSOptionConstructor.cpp
Source/WebCore/bindings/js/JSOptionConstructor.h
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp
Source/WebCore/bridge/runtime_object.cpp
Source/WebCore/bridge/runtime_object.h
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.cpp
Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.h

index 9d72470..966d34a 100644 (file)
@@ -88,6 +88,11 @@ static EncodedJSValue JSC_HOST_CALL constructJSCallback(ExecState* exec)
 
 ConstructType JSCallbackConstructor::getConstructData(ConstructData& constructData)
 {
+    return getConstructData(this, constructData);
+}
+
+ConstructType JSCallbackConstructor::getConstructData(JSCell*, ConstructData& constructData)
+{
     constructData.native.function = constructJSCallback;
     return ConstructTypeHost;
 }
index 720fdfc..46ea820 100644 (file)
@@ -59,6 +59,7 @@ protected:
 
 private:
     virtual ConstructType getConstructData(ConstructData&);
+    static ConstructType getConstructData(JSCell*, ConstructData&);
 
     JSClassRef m_class;
     JSObjectCallAsConstructorCallback m_callback;
index c6f6182..571337a 100644 (file)
@@ -197,6 +197,7 @@ private:
     virtual UString toString(ExecState*) const;
 
     virtual ConstructType getConstructData(ConstructData&);
+    static ConstructType getConstructData(JSCell*, ConstructData&);
     virtual CallType getCallDataVirtual(CallData&);
     static CallType getCallData(JSCell*, CallData&);
 
index b74beb7..23d1a8c 100644 (file)
@@ -330,7 +330,14 @@ bool JSCallbackObject<Parent>::deleteProperty(JSCell* cell, ExecState* exec, uns
 template <class Parent>
 ConstructType JSCallbackObject<Parent>::getConstructData(ConstructData& constructData)
 {
-    for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) {
+    return getConstructData(this, constructData);
+}
+
+template <class Parent>
+ConstructType JSCallbackObject<Parent>::getConstructData(JSCell* cell, ConstructData& constructData)
+{
+    JSCallbackObject* thisObject = static_cast<JSCallbackObject*>(cell);
+    for (JSClassRef jsClass = thisObject->classRef(); jsClass; jsClass = jsClass->parentClass) {
         if (jsClass->callAsConstructor) {
             constructData.native.function = construct;
             return ConstructTypeHost;
index ebc1398..c3d0e90 100644 (file)
@@ -1,5 +1,59 @@
 2011-10-08  Mark Hahnenberg  <mhahnenberg@apple.com>
 
+        Add static version of JSCell::getConstructData
+        https://bugs.webkit.org/show_bug.cgi?id=69673
+
+        Reviewed by Geoffrey Garen.
+
+        Added static version of getConstructData to all classes that 
+        override it and changed the virtual versions to call the static 
+        versions.  This is the first step in de-virtualizing JSCell::getConstructData.
+
+        * API/JSCallbackConstructor.cpp:
+        (JSC::JSCallbackConstructor::getConstructData):
+        * API/JSCallbackConstructor.h:
+        * API/JSCallbackObject.h:
+        * API/JSCallbackObjectFunctions.h:
+        (JSC::::getConstructData):
+        * runtime/ArrayConstructor.cpp:
+        (JSC::ArrayConstructor::getConstructData):
+        * runtime/ArrayConstructor.h:
+        * runtime/BooleanConstructor.cpp:
+        (JSC::BooleanConstructor::getConstructData):
+        * runtime/BooleanConstructor.h:
+        * runtime/DateConstructor.cpp:
+        (JSC::DateConstructor::getConstructData):
+        * runtime/DateConstructor.h:
+        * runtime/ErrorConstructor.cpp:
+        (JSC::ErrorConstructor::getConstructData):
+        * runtime/ErrorConstructor.h:
+        * runtime/FunctionConstructor.cpp:
+        (JSC::FunctionConstructor::getConstructData):
+        * runtime/FunctionConstructor.h:
+        * runtime/JSCell.cpp:
+        (JSC::JSCell::getConstructData):
+        * runtime/JSCell.h:
+        * runtime/JSFunction.cpp:
+        (JSC::JSFunction::getConstructData):
+        * runtime/JSFunction.h:
+        * runtime/NativeErrorConstructor.cpp:
+        (JSC::NativeErrorConstructor::getConstructData):
+        * runtime/NativeErrorConstructor.h:
+        * runtime/NumberConstructor.cpp:
+        (JSC::NumberConstructor::getConstructData):
+        * runtime/NumberConstructor.h:
+        * runtime/ObjectConstructor.cpp:
+        (JSC::ObjectConstructor::getConstructData):
+        * runtime/ObjectConstructor.h:
+        * runtime/RegExpConstructor.cpp:
+        (JSC::RegExpConstructor::getConstructData):
+        * runtime/RegExpConstructor.h:
+        * runtime/StringConstructor.cpp:
+        (JSC::StringConstructor::getConstructData):
+        * runtime/StringConstructor.h:
+
+2011-10-08  Mark Hahnenberg  <mhahnenberg@apple.com>
+
         Add static version of JSCell::getOwnPropertySlot
         https://bugs.webkit.org/show_bug.cgi?id=69593
 
index 4538cb8..b566229 100644 (file)
@@ -99,6 +99,11 @@ static EncodedJSValue JSC_HOST_CALL constructWithArrayConstructor(ExecState* exe
 
 ConstructType ArrayConstructor::getConstructData(ConstructData& constructData)
 {
+    return getConstructData(this, constructData);
+}
+
+ConstructType ArrayConstructor::getConstructData(JSCell*, ConstructData& constructData)
+{
     constructData.native.function = constructWithArrayConstructor;
     return ConstructTypeHost;
 }
index 29e8be0..2899098 100644 (file)
@@ -57,6 +57,7 @@ namespace JSC {
         virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
 
         virtual ConstructType getConstructData(ConstructData&);
+        static ConstructType getConstructData(JSCell*, ConstructData&);
         virtual CallType getCallDataVirtual(CallData&);
         static CallType getCallData(JSCell*, CallData&);
     };
index 7cbdeb3..e3d0242 100644 (file)
@@ -60,6 +60,11 @@ static EncodedJSValue JSC_HOST_CALL constructWithBooleanConstructor(ExecState* e
 
 ConstructType BooleanConstructor::getConstructData(ConstructData& constructData)
 {
+    return getConstructData(this, constructData);
+}
+
+ConstructType BooleanConstructor::getConstructData(JSCell*, ConstructData& constructData)
+{
     constructData.native.function = constructWithBooleanConstructor;
     return ConstructTypeHost;
 }
index a989c30..b360502 100644 (file)
@@ -51,6 +51,7 @@ namespace JSC {
     private:
         BooleanConstructor(JSGlobalObject*, Structure*);
         virtual ConstructType getConstructData(ConstructData&);
+        static ConstructType getConstructData(JSCell*, ConstructData&);
         virtual CallType getCallDataVirtual(CallData&);
         static CallType getCallData(JSCell*, CallData&);
     };
index ca64425..f89aba4 100644 (file)
@@ -163,6 +163,11 @@ static EncodedJSValue JSC_HOST_CALL constructWithDateConstructor(ExecState* exec
 
 ConstructType DateConstructor::getConstructData(ConstructData& constructData)
 {
+    return getConstructData(this, constructData);
+}
+
+ConstructType DateConstructor::getConstructData(JSCell*, ConstructData& constructData)
+{
     constructData.native.function = constructWithDateConstructor;
     return ConstructTypeHost;
 }
index 28e4170..0ac25d0 100644 (file)
@@ -52,6 +52,7 @@ namespace JSC {
     private:
         DateConstructor(JSGlobalObject*, Structure*);
         virtual ConstructType getConstructData(ConstructData&);
+        static ConstructType getConstructData(JSCell*, ConstructData&);
         virtual CallType getCallDataVirtual(CallData&);
         static CallType getCallData(JSCell*, CallData&);
 
index 7a002ba..7bd278e 100644 (file)
@@ -55,6 +55,11 @@ static EncodedJSValue JSC_HOST_CALL constructWithErrorConstructor(ExecState* exe
 
 ConstructType ErrorConstructor::getConstructData(ConstructData& constructData)
 {
+    return getConstructData(this, constructData);
+}
+
+ConstructType ErrorConstructor::getConstructData(JSCell*, ConstructData& constructData)
+{
     constructData.native.function = constructWithErrorConstructor;
     return ConstructTypeHost;
 }
index b7d881b..bdaf31d 100644 (file)
@@ -52,6 +52,7 @@ namespace JSC {
     private:
         ErrorConstructor(JSGlobalObject*, Structure*);
         virtual ConstructType getConstructData(ConstructData&);
+        static ConstructType getConstructData(JSCell*, ConstructData&);
         virtual CallType getCallDataVirtual(CallData&);
         static CallType getCallData(JSCell*, CallData&);
     };
index 7678224..96e38dd 100644 (file)
@@ -61,6 +61,11 @@ static EncodedJSValue JSC_HOST_CALL constructWithFunctionConstructor(ExecState*
 
 ConstructType FunctionConstructor::getConstructData(ConstructData& constructData)
 {
+    return getConstructData(this, constructData);
+}
+
+ConstructType FunctionConstructor::getConstructData(JSCell*, ConstructData& constructData)
+{
     constructData.native.function = constructWithFunctionConstructor;
     return ConstructTypeHost;
 }
index 22a6016..be4ab6a 100644 (file)
@@ -49,6 +49,7 @@ namespace JSC {
         FunctionConstructor(JSGlobalObject*, Structure*);
         void finishCreation(ExecState*, FunctionPrototype*);
         virtual ConstructType getConstructData(ConstructData&);
+        static ConstructType getConstructData(JSCell*, ConstructData&);
         virtual CallType getCallDataVirtual(CallData&);
         static CallType getCallData(JSCell*, CallData&);
     };
index c757a03..3d627e1 100644 (file)
@@ -69,6 +69,11 @@ ConstructType JSCell::getConstructData(ConstructData&)
     return ConstructTypeNone;
 }
 
+ConstructType JSCell::getConstructData(JSCell*, ConstructData&)
+{
+    return ConstructTypeNone;
+}
+
 bool JSCell::getOwnPropertySlot(ExecState* exec, const Identifier& identifier, PropertySlot& slot)
 {
     return getOwnPropertySlot(this, exec, identifier, slot);
index 5bdffb6..72f55a1 100644 (file)
@@ -76,6 +76,7 @@ namespace JSC {
         virtual CallType getCallDataVirtual(CallData&);
         static CallType getCallData(JSCell*, CallData&);
         virtual ConstructType getConstructData(ConstructData&);
+        static ConstructType getConstructData(JSCell*, ConstructData&);
 
         // Basic conversions.
         JSValue toPrimitive(ExecState*, PreferredPrimitiveType) const;
index 07dcc07..62fdf4f 100644 (file)
@@ -353,15 +353,21 @@ bool JSFunction::deleteProperty(JSCell* cell, ExecState* exec, const Identifier&
     return Base::deleteProperty(thisObject, exec, propertyName);
 }
 
-// ECMA 13.2.2 [[Construct]]
 ConstructType JSFunction::getConstructData(ConstructData& constructData)
 {
-    if (isHostFunction()) {
-        constructData.native.function = nativeConstructor();
+    return getConstructData(this, constructData);
+}
+
+// ECMA 13.2.2 [[Construct]]
+ConstructType JSFunction::getConstructData(JSCell* cell, ConstructData& constructData)
+{
+    JSFunction* thisObject = static_cast<JSFunction*>(cell);
+    if (thisObject->isHostFunction()) {
+        constructData.native.function = thisObject->nativeConstructor();
         return ConstructTypeHost;
     }
-    constructData.js.functionExecutable = jsExecutable();
-    constructData.js.scopeChain = scope();
+    constructData.js.functionExecutable = thisObject->jsExecutable();
+    constructData.js.scopeChain = thisObject->scope();
     return ConstructTypeJS;
 }
 
index 17fa348..2409d4e 100644 (file)
@@ -109,6 +109,7 @@ namespace JSC {
         NativeFunction nativeConstructor();
 
         virtual ConstructType getConstructData(ConstructData&);
+        static ConstructType getConstructData(JSCell*, ConstructData&);
         virtual CallType getCallDataVirtual(CallData&);
         static CallType getCallData(JSCell*, CallData&);
 
index f2e6bcc..d43cc18 100644 (file)
@@ -58,6 +58,11 @@ static EncodedJSValue JSC_HOST_CALL constructWithNativeErrorConstructor(ExecStat
 
 ConstructType NativeErrorConstructor::getConstructData(ConstructData& constructData)
 {
+    return getConstructData(this, constructData);
+}
+
+ConstructType NativeErrorConstructor::getConstructData(JSCell*, ConstructData& constructData)
+{
     constructData.native.function = constructWithNativeErrorConstructor;
     return ConstructTypeHost;
 }
index 67f528d..f301caa 100644 (file)
@@ -69,6 +69,7 @@ namespace JSC {
         NativeErrorConstructor(JSGlobalObject*, Structure*);
         static const unsigned StructureFlags = OverridesVisitChildren | InternalFunction::StructureFlags;
         virtual ConstructType getConstructData(ConstructData&);
+        static ConstructType getConstructData(JSCell*, ConstructData&);
         virtual CallType getCallDataVirtual(CallData&);
         static CallType getCallData(JSCell*, CallData&);
         static void visitChildren(JSCell*, SlotVisitor&);
index 66a43fd..91309a4 100644 (file)
@@ -122,6 +122,11 @@ static EncodedJSValue JSC_HOST_CALL constructWithNumberConstructor(ExecState* ex
 
 ConstructType NumberConstructor::getConstructData(ConstructData& constructData)
 {
+    return getConstructData(this, constructData);
+}
+
+ConstructType NumberConstructor::getConstructData(JSCell*, ConstructData& constructData)
+{
     constructData.native.function = constructWithNumberConstructor;
     return ConstructTypeHost;
 }
index 50fef39..457b1d2 100644 (file)
@@ -59,6 +59,7 @@ namespace JSC {
     private:
         NumberConstructor(JSGlobalObject*, Structure*);
         virtual ConstructType getConstructData(ConstructData&);
+        static ConstructType getConstructData(JSCell*, ConstructData&);
         virtual CallType getCallDataVirtual(CallData&);
         static CallType getCallData(JSCell*, CallData&);
     };
index d2aadf1..2d218a9 100644 (file)
@@ -121,6 +121,11 @@ static EncodedJSValue JSC_HOST_CALL constructWithObjectConstructor(ExecState* ex
 
 ConstructType ObjectConstructor::getConstructData(ConstructData& constructData)
 {
+    return getConstructData(this, constructData);
+}
+
+ConstructType ObjectConstructor::getConstructData(JSCell*, ConstructData& constructData)
+{
     constructData.native.function = constructWithObjectConstructor;
     return ConstructTypeHost;
 }
index f1b6fcd..03bb513 100644 (file)
@@ -56,6 +56,7 @@ namespace JSC {
     private:
         ObjectConstructor(JSGlobalObject*, Structure*);
         virtual ConstructType getConstructData(ConstructData&);
+        static ConstructType getConstructData(JSCell*, ConstructData&);
         virtual CallType getCallDataVirtual(CallData&);
         static CallType getCallData(JSCell*, CallData&);
     };
index 72ab282..5867694 100644 (file)
@@ -356,6 +356,11 @@ static EncodedJSValue JSC_HOST_CALL constructWithRegExpConstructor(ExecState* ex
 
 ConstructType RegExpConstructor::getConstructData(ConstructData& constructData)
 {
+    return getConstructData(this, constructData);
+}
+
+ConstructType RegExpConstructor::getConstructData(JSCell*, ConstructData& constructData)
+{
     constructData.native.function = constructWithRegExpConstructor;
     return ConstructTypeHost;
 }
index 937490a..d9fdfce 100644 (file)
@@ -101,6 +101,7 @@ namespace JSC {
     private:
         RegExpConstructor(JSGlobalObject*, Structure*);
         virtual ConstructType getConstructData(ConstructData&);
+        static ConstructType getConstructData(JSCell*, ConstructData&);
         virtual CallType getCallDataVirtual(CallData&);
         static CallType getCallData(JSCell*, CallData&);
 
index 37b902a..3ee20fa 100644 (file)
@@ -103,6 +103,11 @@ static EncodedJSValue JSC_HOST_CALL constructWithStringConstructor(ExecState* ex
 
 ConstructType StringConstructor::getConstructData(ConstructData& constructData)
 {
+    return getConstructData(this, constructData);
+}
+
+ConstructType StringConstructor::getConstructData(JSCell*, ConstructData& constructData)
+{
     constructData.native.function = constructWithStringConstructor;
     return ConstructTypeHost;
 }
index 4b16968..0eb0f61 100644 (file)
@@ -52,6 +52,7 @@ namespace JSC {
         StringConstructor(JSGlobalObject*, Structure*);
         void finishCreation(ExecState*, StringPrototype*);
         virtual ConstructType getConstructData(ConstructData&);
+        static ConstructType getConstructData(JSCell*, ConstructData&);
         virtual CallType getCallDataVirtual(CallData&);
         static CallType getCallData(JSCell*, CallData&);
 
index 1ddc5a9..390f762 100644 (file)
@@ -1,5 +1,36 @@
 2011-10-08  Mark Hahnenberg  <mhahnenberg@apple.com>
 
+        Add static version of JSCell::getConstructData
+        https://bugs.webkit.org/show_bug.cgi?id=69673
+
+        Reviewed by Geoffrey Garen.
+
+        No new tests.
+
+        Added static version of getConstructData to all classes that 
+        override it and changed the virtual versions to call the static 
+        versions.  This is the first step in de-virtualizing JSCell::getConstructData.
+
+        * bindings/js/JSAudioConstructor.cpp:
+        (WebCore::JSAudioConstructor::getConstructData):
+        * bindings/js/JSAudioConstructor.h:
+        * bindings/js/JSImageConstructor.cpp:
+        (WebCore::JSImageConstructor::getConstructData):
+        * bindings/js/JSImageConstructor.h:
+        * bindings/js/JSOptionConstructor.cpp:
+        (WebCore::JSOptionConstructor::getConstructData):
+        * bindings/js/JSOptionConstructor.h:
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateConstructorDeclaration):
+        (GenerateConstructorDefinition):
+        * bindings/scripts/test/JS/JSTestInterface.cpp:
+        (WebCore::JSTestInterfaceConstructor::getConstructData):
+        * bridge/runtime_object.cpp:
+        (JSC::Bindings::RuntimeObject::getConstructData):
+        * bridge/runtime_object.h:
+
+2011-10-08  Mark Hahnenberg  <mhahnenberg@apple.com>
+
         Add static version of JSCell::getOwnPropertySlot
         https://bugs.webkit.org/show_bug.cgi?id=69593
 
index 564d4d7..3acc0bb 100644 (file)
@@ -77,6 +77,11 @@ static EncodedJSValue JSC_HOST_CALL constructAudio(ExecState* exec)
 
 ConstructType JSAudioConstructor::getConstructData(ConstructData& constructData)
 {
+    return getConstructData(this, constructData);
+}
+
+ConstructType JSAudioConstructor::getConstructData(JSCell*, ConstructData& constructData)
+{
     constructData.native.function = constructAudio;
     return ConstructTypeHost;
 }
index 35c4805..3be45e3 100644 (file)
@@ -56,6 +56,7 @@ namespace WebCore {
         JSAudioConstructor(JSC::Structure*, JSDOMGlobalObject*);
         void finishCreation(JSC::ExecState*, JSDOMGlobalObject*);
         virtual JSC::ConstructType getConstructData(JSC::ConstructData&);
+        static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&);
     };
 
 } // namespace WebCore
index cc7d5c7..1914786 100644 (file)
@@ -76,6 +76,11 @@ static EncodedJSValue JSC_HOST_CALL constructImage(ExecState* exec)
 
 ConstructType JSImageConstructor::getConstructData(ConstructData& constructData)
 {
+    return getConstructData(this, constructData);
+}
+
+ConstructType JSImageConstructor::getConstructData(JSCell*, ConstructData& constructData)
+{
     constructData.native.function = constructImage;
     return ConstructTypeHost;
 }
index d454b42..ab3fd31 100644 (file)
@@ -47,6 +47,7 @@ namespace WebCore {
         JSImageConstructor(JSC::Structure*, JSDOMGlobalObject*);
         void finishCreation(JSC::ExecState*, JSDOMGlobalObject*);
         virtual JSC::ConstructType getConstructData(JSC::ConstructData&);
+        static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&);
     };
 
 } // namespace WebCore
index 449b292..022a3cd 100644 (file)
@@ -77,6 +77,11 @@ static EncodedJSValue JSC_HOST_CALL constructHTMLOptionElement(ExecState* exec)
 
 ConstructType JSOptionConstructor::getConstructData(ConstructData& constructData)
 {
+    return getConstructData(this, constructData);
+}
+
+ConstructType JSOptionConstructor::getConstructData(JSCell*, ConstructData& constructData)
+{
     constructData.native.function = constructHTMLOptionElement;
     return ConstructTypeHost;
 }
index 2d935ca..01b8ecb 100644 (file)
@@ -48,6 +48,7 @@ namespace WebCore {
         JSOptionConstructor(JSC::Structure*, JSDOMGlobalObject*);
         void finishCreation(JSC::ExecState*, JSDOMGlobalObject*);
         virtual JSC::ConstructType getConstructData(JSC::ConstructData&);
+        static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&);
     };
 
 } // namespace WebCore
index a9a3602..9dfd12c 100644 (file)
@@ -3172,6 +3172,7 @@ sub GenerateConstructorDeclaration
     if ($canConstruct) {
         push(@$outputArray, "    static JSC::EncodedJSValue JSC_HOST_CALL construct${className}(JSC::ExecState*);\n");
         push(@$outputArray, "    virtual JSC::ConstructType getConstructData(JSC::ConstructData&);\n");
+        push(@$outputArray, "    static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&);\n");
     }
     push(@$outputArray, "};\n\n");
 }
@@ -3238,6 +3239,11 @@ sub GenerateConstructorDefinition
 
         push(@$outputArray, "ConstructType ${constructorClassName}::getConstructData(ConstructData& constructData)\n");
         push(@$outputArray, "{\n");
+        push(@$outputArray, "    return getConstructData(this, constructData);\n");
+        push(@$outputArray, "}\n\n");
+
+        push(@$outputArray, "ConstructType ${constructorClassName}::getConstructData(JSCell*, ConstructData& constructData)\n");
+        push(@$outputArray, "{\n");
         push(@$outputArray, "    constructData.native.function = construct${className};\n");
         push(@$outputArray, "    return ConstructTypeHost;\n");
         push(@$outputArray, "}\n\n");
index 9b7838f..da9911e 100644 (file)
@@ -97,6 +97,7 @@ protected:
     static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags;
     static JSC::EncodedJSValue JSC_HOST_CALL constructJSTestInterface(JSC::ExecState*);
     virtual JSC::ConstructType getConstructData(JSC::ConstructData&);
+    static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&);
 };
 
 const ClassInfo JSTestInterfaceConstructor::s_info = { "TestInterfaceConstructor", &DOMConstructorObject::s_info, &JSTestInterfaceConstructorTable, 0, CREATE_METHOD_TABLE(JSTestInterfaceConstructor) };
@@ -133,6 +134,11 @@ EncodedJSValue JSC_HOST_CALL JSTestInterfaceConstructor::constructJSTestInterfac
 
 ConstructType JSTestInterfaceConstructor::getConstructData(ConstructData& constructData)
 {
+    return getConstructData(this, constructData);
+}
+
+ConstructType JSTestInterfaceConstructor::getConstructData(JSCell*, ConstructData& constructData)
+{
     constructData.native.function = constructJSTestInterface;
     return ConstructTypeHost;
 }
index ed42a55..a85f9a9 100644 (file)
@@ -311,10 +311,16 @@ static EncodedJSValue JSC_HOST_CALL callRuntimeConstructor(ExecState* exec)
 
 ConstructType RuntimeObject::getConstructData(ConstructData& constructData)
 {
-    if (!m_instance)
+    return getConstructData(this, constructData);
+}
+
+ConstructType RuntimeObject::getConstructData(JSCell* cell, ConstructData& constructData)
+{
+    RuntimeObject* thisObject = static_cast<RuntimeObject*>(cell);
+    if (!thisObject->m_instance)
         return ConstructTypeNone;
     
-    RefPtr<Instance> instance = m_instance;
+    RefPtr<Instance> instance = thisObject->m_instance;
     if (!instance->supportsConstruct())
         return ConstructTypeNone;
     
index b449c9b..f73304f 100644 (file)
@@ -56,6 +56,7 @@ public:
     virtual CallType getCallDataVirtual(CallData&);
     static CallType getCallData(JSCell*, CallData&);
     virtual ConstructType getConstructData(ConstructData&);
+    static ConstructType getConstructData(JSCell*, ConstructData&);
 
     virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
 
index e150689..5ce961b 100644 (file)
@@ -1,5 +1,20 @@
 2011-10-08  Mark Hahnenberg  <mhahnenberg@apple.com>
 
+        Add static version of JSCell::getConstructData
+        https://bugs.webkit.org/show_bug.cgi?id=69673
+
+        Reviewed by Geoffrey Garen.
+
+        Added static version of getConstructData to all classes that 
+        override it and changed the virtual versions to call the static 
+        versions.  This is the first step in de-virtualizing JSCell::getConstructData.
+
+        * WebProcess/Plugins/Netscape/JSNPObject.cpp:
+        (WebKit::JSNPObject::getConstructData):
+        * WebProcess/Plugins/Netscape/JSNPObject.h:
+
+2011-10-08  Mark Hahnenberg  <mhahnenberg@apple.com>
+
         Add static version of JSCell::getOwnPropertySlot
         https://bugs.webkit.org/show_bug.cgi?id=69593
 
index 2603701..ec13e1c 100644 (file)
@@ -243,8 +243,14 @@ static EncodedJSValue JSC_HOST_CALL constructWithConstructor(ExecState* exec)
 
 ConstructType JSNPObject::getConstructData(ConstructData& constructData)
 {
-    ASSERT_GC_OBJECT_INHERITS(this, &s_info);
-    if (!m_npObject || !m_npObject->_class->construct)
+    return getConstructData(this, constructData);
+}
+
+ConstructType JSNPObject::getConstructData(JSCell* cell, ConstructData& constructData)
+{
+    JSNPObject* thisObject = static_cast<JSNPObject*>(cell);
+    ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
+    if (!thisObject->m_npObject || !thisObject->m_npObject->_class->construct)
         return ConstructTypeNone;
 
     constructData.native.function = constructWithConstructor;
index 2939db9..f3c2843 100644 (file)
@@ -82,6 +82,7 @@ private:
     virtual JSC::CallType getCallDataVirtual(JSC::CallData&);
     static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&);
     virtual JSC::ConstructType getConstructData(JSC::ConstructData&);
+    static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&);
 
     virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&);
     static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&);