Add static ClassInfo structs to classes that override JSCell::getCallData
authormhahnenberg@apple.com <mhahnenberg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Oct 2011 02:47:42 +0000 (02:47 +0000)
committermhahnenberg@apple.com <mhahnenberg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Oct 2011 02:47:42 +0000 (02:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=69311

Reviewed by Darin Adler.

Source/JavaScriptCore:

Added ClassInfo structs to each class that defined its own getCallData
function but did not already have its own ClassInfo struct.  This is a
necessary addition for when we switch over to looking up getCallData from
the MethodTable in ClassInfo rather than doing the virtual call (which we
are removing).  These new ClassInfo structs are public because we often
use these structs in other areas of the code to uniquely identify JSC classes and
to enforce runtime invariants based on those class identities using ASSERTs.
Also added new createStructure methods to those classes that didn't have
them so that the new ClassInfo structs would be used when creating the Structures
in these classes.

* runtime/BooleanConstructor.cpp:
* runtime/BooleanConstructor.h:
(JSC::BooleanConstructor::createStructure):

getCallData was not marked as static in StrictModeTypeErrorFunction.
* runtime/Error.cpp:
(JSC::StrictModeTypeErrorFunction::getCallDataVirtual):
(JSC::StrictModeTypeErrorFunction::getCallData):
(JSC::StrictModeTypeErrorFunction::createStructure):
* runtime/ErrorConstructor.cpp:
* runtime/ErrorConstructor.h:
(JSC::ErrorConstructor::createStructure):
* runtime/FunctionConstructor.cpp:
* runtime/FunctionConstructor.h:
(JSC::FunctionConstructor::createStructure):
* runtime/FunctionPrototype.cpp:
* runtime/FunctionPrototype.h:

Source/WebCore:

No new tests.

Added ClassInfo structs to each class that defined its own getCallData
function but did not already have its own ClassInfo struct.  This is a
necessary addition for when we switch over to looking up getCallData from
the MethodTable in ClassInfo rather than doing the virtual call (which we
are removing).  These new ClassInfo structs are public because we often
use these structs in other areas of the code to uniquely identify JSC classes and
to enforce runtime invariants based on those class identities using ASSERTs.
Also added new createStructure methods to those classes that didn't have
them so that the new ClassInfo structs would be used when creating the Structures
in these classes.

* bridge/qt/qt_runtime.cpp:
* bridge/qt/qt_runtime.h:

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

13 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/BooleanConstructor.cpp
Source/JavaScriptCore/runtime/BooleanConstructor.h
Source/JavaScriptCore/runtime/Error.cpp
Source/JavaScriptCore/runtime/ErrorConstructor.cpp
Source/JavaScriptCore/runtime/ErrorConstructor.h
Source/JavaScriptCore/runtime/FunctionConstructor.cpp
Source/JavaScriptCore/runtime/FunctionConstructor.h
Source/JavaScriptCore/runtime/FunctionPrototype.cpp
Source/JavaScriptCore/runtime/FunctionPrototype.h
Source/WebCore/ChangeLog
Source/WebCore/bridge/qt/qt_runtime.cpp
Source/WebCore/bridge/qt/qt_runtime.h

index a097a90..54c5a62 100644 (file)
@@ -1,3 +1,39 @@
+2011-10-04  Mark Hahnenberg  <mhahnenberg@apple.com>
+
+        Add static ClassInfo structs to classes that override JSCell::getCallData
+        https://bugs.webkit.org/show_bug.cgi?id=69311
+
+        Reviewed by Darin Adler.
+
+        Added ClassInfo structs to each class that defined its own getCallData 
+        function but did not already have its own ClassInfo struct.  This is a 
+        necessary addition for when we switch over to looking up getCallData from 
+        the MethodTable in ClassInfo rather than doing the virtual call (which we 
+        are removing).  These new ClassInfo structs are public because we often 
+        use these structs in other areas of the code to uniquely identify JSC classes and 
+        to enforce runtime invariants based on those class identities using ASSERTs.
+        Also added new createStructure methods to those classes that didn't have 
+        them so that the new ClassInfo structs would be used when creating the Structures 
+        in these classes.
+
+        * runtime/BooleanConstructor.cpp:
+        * runtime/BooleanConstructor.h:
+        (JSC::BooleanConstructor::createStructure):
+
+        getCallData was not marked as static in StrictModeTypeErrorFunction.  
+        * runtime/Error.cpp:
+        (JSC::StrictModeTypeErrorFunction::getCallDataVirtual):
+        (JSC::StrictModeTypeErrorFunction::getCallData):
+        (JSC::StrictModeTypeErrorFunction::createStructure):
+        * runtime/ErrorConstructor.cpp:
+        * runtime/ErrorConstructor.h:
+        (JSC::ErrorConstructor::createStructure):
+        * runtime/FunctionConstructor.cpp:
+        * runtime/FunctionConstructor.h:
+        (JSC::FunctionConstructor::createStructure):
+        * runtime/FunctionPrototype.cpp:
+        * runtime/FunctionPrototype.h:
+
 2011-10-03  Geoffrey Garen  <ggaren@apple.com>
 
         Some JSValue cleanup
index c98c98e..7cbdeb3 100644 (file)
@@ -28,6 +28,8 @@ namespace JSC {
 
 ASSERT_CLASS_FITS_IN_CELL(BooleanConstructor);
 
+const ClassInfo BooleanConstructor::s_info = { "Function", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(BooleanConstructor) };
+
 BooleanConstructor::BooleanConstructor(JSGlobalObject* globalObject, Structure* structure)
     : InternalFunction(globalObject, structure)
 {
index 0395f82..a989c30 100644 (file)
@@ -38,6 +38,13 @@ namespace JSC {
             return constructor;
         }
 
+        static const ClassInfo s_info;
+
+        static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype) 
+        { 
+            return Structure::create(globalData, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), &s_info); 
+        }
+
     protected:
         void finishCreation(ExecState*, BooleanPrototype*);
 
index 19d9216..0ed7075 100644 (file)
@@ -201,23 +201,32 @@ public:
         return JSValue::encode(jsNull());
     }
 
-    CallType getCallDataVirtual(CallData& callData)
+    virtual CallType getCallDataVirtual(CallData& callData)
     {
         return getCallData(this, callData);
     }
 
-    CallType getCallData(JSCell*, CallData& callData)
+    static CallType getCallData(JSCell*, CallData& callData)
     {
         callData.native.function = callThrowTypeError;
         return CallTypeHost;
     }
 
+    static const ClassInfo s_info;
+
+    static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype) 
+    { 
+        return Structure::create(globalData, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), &s_info); 
+    }
+
 private:
     UString m_message;
 };
 
 ASSERT_CLASS_FITS_IN_CELL(StrictModeTypeErrorFunction);
 
+const ClassInfo StrictModeTypeErrorFunction::s_info = { "Function", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(StrictModeTypeErrorFunction) };
+
 JSValue createTypeErrorFunction(ExecState* exec, const UString& message)
 {
     return StrictModeTypeErrorFunction::create(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->internalFunctionStructure(), message);
index a05cd52..7a002ba 100644 (file)
@@ -29,6 +29,8 @@ namespace JSC {
 
 ASSERT_CLASS_FITS_IN_CELL(ErrorConstructor);
 
+const ClassInfo ErrorConstructor::s_info = { "Function", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(ErrorConstructor) };
+
 ErrorConstructor::ErrorConstructor(JSGlobalObject* globalObject, Structure* structure)
     : InternalFunction(globalObject, structure)
 {
index 24fc198..b7d881b 100644 (file)
@@ -39,6 +39,13 @@ namespace JSC {
             return constructor;
         }
 
+        static const ClassInfo s_info;
+
+        static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype) 
+        { 
+            return Structure::create(globalData, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), &s_info); 
+        }
+
     protected:
         void finishCreation(ExecState*, ErrorPrototype*);
         
index f691300..7678224 100644 (file)
@@ -37,6 +37,8 @@ namespace JSC {
 
 ASSERT_CLASS_FITS_IN_CELL(FunctionConstructor);
 
+const ClassInfo FunctionConstructor::s_info = { "Function", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(FunctionConstructor) };
+
 FunctionConstructor::FunctionConstructor(JSGlobalObject* globalObject, Structure* structure)
     : InternalFunction(globalObject, structure)
 {
index 68f057e..22a6016 100644 (file)
@@ -38,6 +38,13 @@ namespace JSC {
             return constructor;
         }
 
+        static const ClassInfo s_info;
+
+        static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype) 
+        { 
+            return Structure::create(globalData, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), &s_info); 
+        }
+
     private:
         FunctionConstructor(JSGlobalObject*, Structure*);
         void finishCreation(ExecState*, FunctionPrototype*);
index 35f97d6..c02e675 100644 (file)
@@ -39,6 +39,8 @@ static EncodedJSValue JSC_HOST_CALL functionProtoFuncApply(ExecState*);
 static EncodedJSValue JSC_HOST_CALL functionProtoFuncCall(ExecState*);
 static EncodedJSValue JSC_HOST_CALL functionProtoFuncBind(ExecState*);
 
+const ClassInfo FunctionPrototype::s_info = { "Function", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(FunctionPrototype) };
+
 FunctionPrototype::FunctionPrototype(JSGlobalObject* globalObject, Structure* structure)
     : InternalFunction(globalObject, structure)
 {
index 82fff05..7c19632 100644 (file)
@@ -43,6 +43,8 @@ namespace JSC {
             return Structure::create(globalData, globalObject, proto, TypeInfo(ObjectType, StructureFlags), &s_info);
         }
 
+        static const ClassInfo s_info;
+
     protected:
         void finishCreation(ExecState*, const Identifier& name);
 
index dce67d1..f48ce0c 100644 (file)
@@ -1,3 +1,26 @@
+2011-10-04  Mark Hahnenberg  <mhahnenberg@apple.com>
+
+        Add static ClassInfo structs to classes that override JSCell::getCallData
+        https://bugs.webkit.org/show_bug.cgi?id=69311
+
+        Reviewed by Darin Adler.
+
+        No new tests.
+
+        Added ClassInfo structs to each class that defined its own getCallData 
+        function but did not already have its own ClassInfo struct.  This is a 
+        necessary addition for when we switch over to looking up getCallData from 
+        the MethodTable in ClassInfo rather than doing the virtual call (which we 
+        are removing).  These new ClassInfo structs are public because we often 
+        use these structs in other areas of the code to uniquely identify JSC classes and 
+        to enforce runtime invariants based on those class identities using ASSERTs.
+        Also added new createStructure methods to those classes that didn't have 
+        them so that the new ClassInfo structs would be used when creating the Structures 
+        in these classes.
+
+        * bridge/qt/qt_runtime.cpp:
+        * bridge/qt/qt_runtime.h:
+
 2011-10-03  Geoffrey Garen  <ggaren@apple.com>
 
         Some JSValue cleanup
index 5557b13..d965e94 100644 (file)
@@ -1425,6 +1425,8 @@ static int findSignalIndex(const QMetaObject* meta, int initialIndex, QByteArray
     return index;
 }
 
+const ClassInfo QtRuntimeMetaMethod::s_info = { "QtRuntimeMethod", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(QtRuntimeMetaMethod) };
+
 QtRuntimeMetaMethod::QtRuntimeMetaMethod(ExecState* exec, Structure* structure, const Identifier& identifier)
     : QtRuntimeMethod (new QtRuntimeMetaMethodData(), exec, structure, identifier)
 {
@@ -1580,6 +1582,8 @@ JSValue QtRuntimeMetaMethod::disconnectGetter(ExecState* exec, JSValue slotBase,
 
 QMultiMap<QObject*, QtConnectionObject*> QtRuntimeConnectionMethod::connections;
 
+const ClassInfo QtRuntimeConnectionMethod::s_info = { "QtRuntimeMethod", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(QtRuntimeConnectionMethod) };
+
 QtRuntimeConnectionMethod::QtRuntimeConnectionMethod(ExecState* exec, Structure* structure, const Identifier& identifier)
     : QtRuntimeMethod (new QtRuntimeConnectionMethodData(), exec, structure, identifier)
 {
index 9a27629..aec11ca 100644 (file)
@@ -170,6 +170,8 @@ public:
 
     static void visitChildren(JSCell*, SlotVisitor&);
 
+    static const ClassInfo s_info;
+
 protected:
     QtRuntimeMetaMethodData* d_func() const {return reinterpret_cast<QtRuntimeMetaMethodData*>(d_ptr);}
 
@@ -201,6 +203,8 @@ public:
     virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
     virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
     virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
+    static const ClassInfo s_info;
 
 protected:
     QtRuntimeConnectionMethodData* d_func() const {return reinterpret_cast<QtRuntimeConnectionMethodData*>(d_ptr);}