diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog index a097a906b015db3ee916e35f93ea56d1ff8bd41b..54c5a62c13c3c65687c1987417a1fdad39c0cea2 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 c98c98efe100b443b65d64b475b6ede315c18d63..7cbdeb368e6e7fe2677adec0e6cf510ef3261120 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 0395f8267e8653d0a81831d8a043b47d34cb2f4e..a989c307e7f45cdf0d63e86ec98e200f2493cbcf 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 19d9216c61d5c47f28dc4b8b4ded9162e4c3d975..0ed7075893d1624c50e3a4d3e77e2889b5eab422 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 a05cd526d8b4678ef3644eafd00070f0309d81b0..7a002ba1337b02fa9c330331aded034902a8a5e0 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 24fc198b2cfe1e0d7de34f55cbf9922844cc36a8..b7d881b3c2374b291ffdcab937cbe7dd683b7fe4 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 f691300c952c10cc1b280add87bb48aff24cc78c..767822466fa71492d77971891740bb75822e72c0 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 68f057e736fafc90dd8161701198543ce3f063ab..22a6016b7853bd16829e6551767df310a068ee81 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 35f97d60f1f70b65d22caeba02c197957127f19f..c02e675e4fc6574b9208492d2ab3ba7e487e84fb 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 82fff0586cf40203e6e2512768daebeddf7c146a..7c1963222fed002d061b130ab659030f0e75322c 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 dce67d1448e982e00a31d7c532bc3f436af5fec5..f48ce0c4d2c960c22bd2126d66becad91f752d87 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 5557b136825f053e367626045ac36cc8aa88c2d4..d965e94e3d314ef8784c0af9a92a3b59da91f623 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 9a27629e6dfcb5a069358daf289c3ab9015b440c..aec11ca6d815a239eabe078746b1d9bb9bc2d154 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);}