From 77d198e8f73c017ebb569fecf6be6993ebac9712 Mon Sep 17 00:00:00 2001 From: "mhahnenberg@apple.com" Date: Wed, 5 Oct 2011 02:47:42 +0000 Subject: [PATCH] Add static ClassInfo structs to classes that override JSCell::getCallData 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: http://svn.webkit.org/repository/webkit/trunk@96674 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/JavaScriptCore/ChangeLog | 36 +++++++++++++++++++ .../runtime/BooleanConstructor.cpp | 2 ++ .../runtime/BooleanConstructor.h | 7 ++++ Source/JavaScriptCore/runtime/Error.cpp | 13 +++++-- .../runtime/ErrorConstructor.cpp | 2 ++ .../JavaScriptCore/runtime/ErrorConstructor.h | 7 ++++ .../runtime/FunctionConstructor.cpp | 2 ++ .../runtime/FunctionConstructor.h | 7 ++++ .../runtime/FunctionPrototype.cpp | 2 ++ .../runtime/FunctionPrototype.h | 2 ++ Source/WebCore/ChangeLog | 23 ++++++++++++ Source/WebCore/bridge/qt/qt_runtime.cpp | 4 +++ Source/WebCore/bridge/qt/qt_runtime.h | 4 +++ 13 files changed, 109 insertions(+), 2 deletions(-) diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog index a097a906b01..54c5a62c13c 100644 --- a/Source/JavaScriptCore/ChangeLog +++ b/Source/JavaScriptCore/ChangeLog @@ -1,3 +1,39 @@ +2011-10-04 Mark Hahnenberg + + 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 Some JSValue cleanup diff --git a/Source/JavaScriptCore/runtime/BooleanConstructor.cpp b/Source/JavaScriptCore/runtime/BooleanConstructor.cpp index c98c98efe10..7cbdeb368e6 100644 --- a/Source/JavaScriptCore/runtime/BooleanConstructor.cpp +++ b/Source/JavaScriptCore/runtime/BooleanConstructor.cpp @@ -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) { diff --git a/Source/JavaScriptCore/runtime/BooleanConstructor.h b/Source/JavaScriptCore/runtime/BooleanConstructor.h index 0395f8267e8..a989c307e7f 100644 --- a/Source/JavaScriptCore/runtime/BooleanConstructor.h +++ b/Source/JavaScriptCore/runtime/BooleanConstructor.h @@ -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*); diff --git a/Source/JavaScriptCore/runtime/Error.cpp b/Source/JavaScriptCore/runtime/Error.cpp index 19d9216c61d..0ed7075893d 100644 --- a/Source/JavaScriptCore/runtime/Error.cpp +++ b/Source/JavaScriptCore/runtime/Error.cpp @@ -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); diff --git a/Source/JavaScriptCore/runtime/ErrorConstructor.cpp b/Source/JavaScriptCore/runtime/ErrorConstructor.cpp index a05cd526d8b..7a002ba1337 100644 --- a/Source/JavaScriptCore/runtime/ErrorConstructor.cpp +++ b/Source/JavaScriptCore/runtime/ErrorConstructor.cpp @@ -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) { diff --git a/Source/JavaScriptCore/runtime/ErrorConstructor.h b/Source/JavaScriptCore/runtime/ErrorConstructor.h index 24fc198b2cf..b7d881b3c23 100644 --- a/Source/JavaScriptCore/runtime/ErrorConstructor.h +++ b/Source/JavaScriptCore/runtime/ErrorConstructor.h @@ -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*); diff --git a/Source/JavaScriptCore/runtime/FunctionConstructor.cpp b/Source/JavaScriptCore/runtime/FunctionConstructor.cpp index f691300c952..767822466fa 100644 --- a/Source/JavaScriptCore/runtime/FunctionConstructor.cpp +++ b/Source/JavaScriptCore/runtime/FunctionConstructor.cpp @@ -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) { diff --git a/Source/JavaScriptCore/runtime/FunctionConstructor.h b/Source/JavaScriptCore/runtime/FunctionConstructor.h index 68f057e736f..22a6016b785 100644 --- a/Source/JavaScriptCore/runtime/FunctionConstructor.h +++ b/Source/JavaScriptCore/runtime/FunctionConstructor.h @@ -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*); diff --git a/Source/JavaScriptCore/runtime/FunctionPrototype.cpp b/Source/JavaScriptCore/runtime/FunctionPrototype.cpp index 35f97d60f1f..c02e675e4fc 100644 --- a/Source/JavaScriptCore/runtime/FunctionPrototype.cpp +++ b/Source/JavaScriptCore/runtime/FunctionPrototype.cpp @@ -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) { diff --git a/Source/JavaScriptCore/runtime/FunctionPrototype.h b/Source/JavaScriptCore/runtime/FunctionPrototype.h index 82fff0586cf..7c1963222fe 100644 --- a/Source/JavaScriptCore/runtime/FunctionPrototype.h +++ b/Source/JavaScriptCore/runtime/FunctionPrototype.h @@ -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); diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index dce67d1448e..f48ce0c4d2c 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,26 @@ +2011-10-04 Mark Hahnenberg + + 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 Some JSValue cleanup diff --git a/Source/WebCore/bridge/qt/qt_runtime.cpp b/Source/WebCore/bridge/qt/qt_runtime.cpp index 5557b136825..d965e94e3d3 100644 --- a/Source/WebCore/bridge/qt/qt_runtime.cpp +++ b/Source/WebCore/bridge/qt/qt_runtime.cpp @@ -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 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) { diff --git a/Source/WebCore/bridge/qt/qt_runtime.h b/Source/WebCore/bridge/qt/qt_runtime.h index 9a27629e6df..aec11ca6d81 100644 --- a/Source/WebCore/bridge/qt/qt_runtime.h +++ b/Source/WebCore/bridge/qt/qt_runtime.h @@ -170,6 +170,8 @@ public: static void visitChildren(JSCell*, SlotVisitor&); + static const ClassInfo s_info; + protected: QtRuntimeMetaMethodData* d_func() const {return reinterpret_cast(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(d_ptr);} -- GitLab