X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/f9bf01c6616d5ddcf65b13b33cedf9e387ff7a63..217a6308cd6a1dc049a0bb69263bd4c91f91c4d0:/API/JSClassRef.h?ds=sidebyside diff --git a/API/JSClassRef.h b/API/JSClassRef.h index ae60aad..7bf18e7 100644 --- a/API/JSClassRef.h +++ b/API/JSClassRef.h @@ -26,16 +26,16 @@ #ifndef JSClassRef_h #define JSClassRef_h -#include "JSObjectRef.h" +#include -#include -#include -#include -#include +#include "Weak.h" +#include "Protect.h" #include -#include +#include -struct StaticValueEntry : FastAllocBase { +struct StaticValueEntry { + WTF_MAKE_FAST_ALLOCATED; +public: StaticValueEntry(JSObjectGetPropertyCallback _getProperty, JSObjectSetPropertyCallback _setProperty, JSPropertyAttributes _attributes) : getProperty(_getProperty), setProperty(_setProperty), attributes(_attributes) { @@ -46,7 +46,9 @@ struct StaticValueEntry : FastAllocBase { JSPropertyAttributes attributes; }; -struct StaticFunctionEntry : FastAllocBase { +struct StaticFunctionEntry { + WTF_MAKE_FAST_ALLOCATED; +public: StaticFunctionEntry(JSObjectCallAsFunctionCallback _callAsFunction, JSPropertyAttributes _attributes) : callAsFunction(_callAsFunction), attributes(_attributes) { @@ -56,36 +58,37 @@ struct StaticFunctionEntry : FastAllocBase { JSPropertyAttributes attributes; }; -typedef HashMap, StaticValueEntry*> OpaqueJSClassStaticValuesTable; -typedef HashMap, StaticFunctionEntry*> OpaqueJSClassStaticFunctionsTable; +typedef HashMap, OwnPtr > OpaqueJSClassStaticValuesTable; +typedef HashMap, OwnPtr > OpaqueJSClassStaticFunctionsTable; struct OpaqueJSClass; // An OpaqueJSClass (JSClass) is created without a context, so it can be used with any context, even across context groups. // This structure holds data members that vary across context groups. -struct OpaqueJSClassContextData : Noncopyable { - OpaqueJSClassContextData(OpaqueJSClass*); - ~OpaqueJSClassContextData(); +struct OpaqueJSClassContextData { + WTF_MAKE_NONCOPYABLE(OpaqueJSClassContextData); WTF_MAKE_FAST_ALLOCATED; +public: + OpaqueJSClassContextData(JSC::VM&, OpaqueJSClass*); // It is necessary to keep OpaqueJSClass alive because of the following rare scenario: - // 1. A class is created and used, so its context data is stored in JSGlobalData hash map. + // 1. A class is created and used, so its context data is stored in VM hash map. // 2. The class is released, and when all JS objects that use it are collected, OpaqueJSClass // is deleted (that's the part prevented by this RefPtr). // 3. Another class is created at the same address. - // 4. When it is used, the old context data is found in JSGlobalData and used. + // 4. When it is used, the old context data is found in VM and used. RefPtr m_class; - OpaqueJSClassStaticValuesTable* staticValues; - OpaqueJSClassStaticFunctionsTable* staticFunctions; - JSC::WeakGCPtr cachedPrototype; + OwnPtr staticValues; + OwnPtr staticFunctions; + JSC::Weak cachedPrototype; }; -struct OpaqueJSClass : public ThreadSafeShared { +struct OpaqueJSClass : public ThreadSafeRefCounted { static PassRefPtr create(const JSClassDefinition*); static PassRefPtr createNoAutomaticPrototype(const JSClassDefinition*); - ~OpaqueJSClass(); + JS_EXPORT_PRIVATE ~OpaqueJSClass(); - JSC::UString className(); + String className(); OpaqueJSClassStaticValuesTable* staticValues(JSC::ExecState*); OpaqueJSClassStaticFunctionsTable* staticFunctions(JSC::ExecState*); JSC::JSObject* prototype(JSC::ExecState*); @@ -114,10 +117,10 @@ private: OpaqueJSClassContextData& contextData(JSC::ExecState*); - // UStrings in these data members should not be put into any IdentifierTable. - JSC::UString m_className; - OpaqueJSClassStaticValuesTable* m_staticValues; - OpaqueJSClassStaticFunctionsTable* m_staticFunctions; + // Strings in these data members should not be put into any IdentifierTable. + String m_className; + OwnPtr m_staticValues; + OwnPtr m_staticFunctions; }; #endif // JSClassRef_h