Bug 1288817, part 2 - Remove marking methods from XPCNativeScriptableShared and XPCNativeScriptableFlags. r=billm
Nothing depends on the value of the mark bit now.
MozReview-Commit-ID: 9k06XdtR9KB
--- a/js/xpconnect/src/xpcprivate.h
+++ b/js/xpconnect/src/xpcprivate.h
@@ -1421,50 +1421,43 @@ class XPCNativeSet final
uint16_t mInterfaceCount : 15;
uint16_t mMarked : 1;
XPCNativeInterface* mInterfaces[1]; // always last - object sized for array
};
/***************************************************************************/
// XPCNativeScriptableFlags is a wrapper class that holds the flags returned
// from calls to nsIXPCScriptable::GetScriptableFlags(). It has convenience
-// methods to check for particular bitflags. Since we also use this class as
-// a member of the gc'd class XPCNativeScriptableShared, this class holds the
-// bit and exposes the inlined methods to support marking.
-
-#define XPC_WN_SJSFLAGS_MARK_FLAG JS_BIT(31) // only high bit of 32 is set
+// methods to check for particular bitflags.
class XPCNativeScriptableFlags final
{
-private:
- uint32_t mFlags;
-
public:
-
explicit XPCNativeScriptableFlags(uint32_t flags = 0) : mFlags(flags) {}
- uint32_t GetFlags() const {return mFlags & ~XPC_WN_SJSFLAGS_MARK_FLAG;}
- void SetFlags(uint32_t flags) {mFlags = flags;}
-
- operator uint32_t() const {return GetFlags();}
+ uint32_t GetFlags() const { return mFlags; }
+ void SetFlags(uint32_t flags) { mFlags = flags; }
+
+ operator uint32_t() const { return GetFlags(); }
XPCNativeScriptableFlags(const XPCNativeScriptableFlags& r)
- {mFlags = r.GetFlags();}
+ {
+ mFlags = r.GetFlags();
+ }
XPCNativeScriptableFlags& operator= (const XPCNativeScriptableFlags& r)
- {mFlags = r.GetFlags(); return *this;}
-
- void Mark() {mFlags |= XPC_WN_SJSFLAGS_MARK_FLAG;}
- void Unmark() {mFlags &= ~XPC_WN_SJSFLAGS_MARK_FLAG;}
- bool IsMarked() const {return 0 != (mFlags & XPC_WN_SJSFLAGS_MARK_FLAG);}
+ {
+ mFlags = r.GetFlags();
+ return *this;
+ }
#ifdef GET_IT
#undef GET_IT
#endif
-#define GET_IT(f_) const {return 0 != (mFlags & nsIXPCScriptable:: f_ );}
+#define GET_IT(f_) const { return 0 != (mFlags & nsIXPCScriptable:: f_ ); }
bool WantPreCreate() GET_IT(WANT_PRECREATE)
bool WantAddProperty() GET_IT(WANT_ADDPROPERTY)
bool WantGetProperty() GET_IT(WANT_GETPROPERTY)
bool WantSetProperty() GET_IT(WANT_SETPROPERTY)
bool WantEnumerate() GET_IT(WANT_ENUMERATE)
bool WantNewEnumerate() GET_IT(WANT_NEWENUMERATE)
bool WantResolve() GET_IT(WANT_RESOLVE)
@@ -1479,16 +1472,19 @@ public:
bool DontAskInstanceForScriptable() GET_IT(DONT_ASK_INSTANCE_FOR_SCRIPTABLE)
bool ClassInfoInterfacesOnly() GET_IT(CLASSINFO_INTERFACES_ONLY)
bool AllowPropModsDuringResolve() GET_IT(ALLOW_PROP_MODS_DURING_RESOLVE)
bool AllowPropModsToPrototype() GET_IT(ALLOW_PROP_MODS_TO_PROTOTYPE)
bool IsGlobalObject() GET_IT(IS_GLOBAL_OBJECT)
bool DontReflectInterfaceNames() GET_IT(DONT_REFLECT_INTERFACE_NAMES)
#undef GET_IT
+
+private:
+ uint32_t mFlags;
};
/***************************************************************************/
// XPCNativeScriptableShared is used to hold the JSClass and the
// associated scriptable flags for XPCWrappedNatives. These are shared across
// the runtime and are garbage collected by xpconnect. We *used* to just store
// this inside the XPCNativeScriptableInfo (usually owned by instances of
@@ -1508,20 +1504,16 @@ public:
XPCNativeScriptableShared(uint32_t aFlags, char* aName, bool aPopulate);
char* TransferNameOwnership() {
char* name = (char*)mJSClass.name;
mJSClass.name = nullptr;
return name;
}
- void Mark() { mFlags.Mark(); }
- void Unmark() { mFlags.Unmark(); }
- bool IsMarked() const { return mFlags.IsMarked(); }
-
private:
~XPCNativeScriptableShared();
XPCNativeScriptableFlags mFlags;
// This is an unusual js::Class instance: its name and cOps members are
// heap-allocated, unlike all other instances for which they are statically
// allocated. So we must free them in the destructor.
@@ -1545,22 +1537,17 @@ public:
GetFlags() const { return mShared->GetFlags(); }
const JSClass*
GetJSClass() { return mShared->GetJSClass(); }
void
SetScriptableShared(already_AddRefed<XPCNativeScriptableShared>&& shared) { mShared = shared; }
- void Mark()
- {
- if (mShared)
- mShared->Mark();
- }
-
+ void Mark() {}
void TraceJS(JSTracer* trc) {}
void AutoTrace(JSTracer* trc) {}
protected:
explicit XPCNativeScriptableInfo(nsIXPCScriptable* scriptable)
: mCallback(scriptable)
{
MOZ_COUNT_CTOR(XPCNativeScriptableInfo);