mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 891966 - 2 - Comment calls to Handle::fromMarkedLocation r=bz
This commit is contained in:
parent
b216cf9603
commit
7345e3e7f2
@ -237,6 +237,8 @@ nsresult
|
||||
nsXBLProtoImplMethod::Read(nsIScriptContext* aContext,
|
||||
nsIObjectInputStream* aStream)
|
||||
{
|
||||
MOZ_ASSERT(!IsCompiled() && !GetUncompiledMethod());
|
||||
|
||||
JS::Rooted<JSObject*> methodObject(aContext->GetNativeContext());
|
||||
nsresult rv = XBL_DeserializeFunction(aContext, aStream, &methodObject);
|
||||
if (NS_FAILED(rv)) {
|
||||
@ -261,6 +263,9 @@ nsXBLProtoImplMethod::Write(nsIScriptContext* aContext,
|
||||
rv = aStream->WriteWStringZ(mName);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Calling fromMarkedLocation() is safe because mMethod is traced by the
|
||||
// Trace() method above, and because its value is never changed after it has
|
||||
// been set to a compiled method.
|
||||
JS::Handle<JSObject*> method =
|
||||
JS::Handle<JSObject*>::fromMarkedLocation(mMethod.AsHeapObject().address());
|
||||
return XBL_SerializeFunction(aContext, aStream, method);
|
||||
@ -273,7 +278,7 @@ nsresult
|
||||
nsXBLProtoImplAnonymousMethod::Execute(nsIContent* aBoundElement)
|
||||
{
|
||||
NS_PRECONDITION(IsCompiled(), "Can't execute uncompiled method");
|
||||
|
||||
|
||||
if (!GetCompiledMethod()) {
|
||||
// Nothing to do here
|
||||
return NS_OK;
|
||||
@ -366,6 +371,9 @@ nsXBLProtoImplAnonymousMethod::Write(nsIScriptContext* aContext,
|
||||
nsresult rv = aStream->Write8(aType);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Calling fromMarkedLocation() is safe because mMethod is traced by the
|
||||
// Trace() method above, and because its value is never changed after it has
|
||||
// been set to a compiled method.
|
||||
JS::Handle<JSObject*> method =
|
||||
JS::Handle<JSObject*>::fromMarkedLocation(mMethod.AsHeapObject().address());
|
||||
rv = XBL_SerializeFunction(aContext, aStream, method);
|
||||
|
@ -357,6 +357,11 @@ nsXBLProtoImplProperty::Write(nsIScriptContext* aContext,
|
||||
rv = aStream->WriteWStringZ(mName);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// The calls to fromMarkedLocation() below are safe because mSetter and
|
||||
// mGetter are traced by the Trace() method above, and because their values
|
||||
// are never changed after they have been set to a compiled function.
|
||||
MOZ_ASSERT_IF(mJSAttributes & (JSPROP_GETTER | JSPROP_SETTER), mIsCompiled);
|
||||
|
||||
if (mJSAttributes & JSPROP_GETTER) {
|
||||
JS::Handle<JSObject*> function =
|
||||
JS::Handle<JSObject*>::fromMarkedLocation(mGetter.AsHeapObject().address());
|
||||
|
@ -2380,7 +2380,12 @@ nsXULPrototypeScript::Serialize(nsIObjectOutputStream* aStream,
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = aStream->Write32(mLangVersion);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
// And delegate the writing to the nsIScriptContext
|
||||
|
||||
// And delegate the writing to the nsIScriptContext.
|
||||
//
|
||||
// Calling fromMarkedLocation() is safe because we trace mScriptObject in
|
||||
// TraceScriptObject() and because its value is never changed after it has
|
||||
// been set.
|
||||
JS::Handle<JSScript*> script =
|
||||
JS::Handle<JSScript*>::fromMarkedLocation(mScriptObject.address());
|
||||
rv = context->Serialize(aStream, script);
|
||||
|
@ -243,6 +243,9 @@ public:
|
||||
// &mScriptObject pointer can't go stale.
|
||||
JS::Handle<JSScript*> GetScriptObject()
|
||||
{
|
||||
// Calling fromMarkedLocation() is safe because we trace mScriptObject in
|
||||
// TraceScriptObject() and because its value is never changed after it has
|
||||
// been set.
|
||||
return JS::Handle<JSScript*>::fromMarkedLocation(mScriptObject.address());
|
||||
}
|
||||
|
||||
|
@ -71,11 +71,11 @@ public:
|
||||
* This should only be called if you are certain that the return value won't
|
||||
* be passed into a JS API function and that it won't be stored without being
|
||||
* rooted (or otherwise signaling the stored value to the CC).
|
||||
*
|
||||
* This can return a handle because we trace our mCallback.
|
||||
*/
|
||||
JS::Handle<JSObject*> CallbackPreserveColor() const
|
||||
{
|
||||
// Calling fromMarkedLocation() is safe because we trace our mCallback, and
|
||||
// because the value of mCallback cannot change after if has been set.
|
||||
return JS::Handle<JSObject*>::fromMarkedLocation(mCallback.address());
|
||||
}
|
||||
|
||||
@ -93,6 +93,7 @@ protected:
|
||||
private:
|
||||
inline void Init(JSObject* aCallback)
|
||||
{
|
||||
MOZ_ASSERT(aCallback && !mCallback);
|
||||
// Set mCallback before we hold, on the off chance that a GC could somehow
|
||||
// happen in there... (which would be pretty odd, granted).
|
||||
mCallback = aCallback;
|
||||
|
@ -1892,7 +1892,13 @@ class CGGetPerInterfaceObject(CGAbstractMethod):
|
||||
CreateInterfaceObjects(aCx, aGlobal, protoAndIfaceArray);
|
||||
}
|
||||
|
||||
/* The object might _still_ be null, but that's OK */
|
||||
/*
|
||||
* The object might _still_ be null, but that's OK.
|
||||
*
|
||||
* Calling fromMarkedLocation() is safe because protoAndIfaceArray is
|
||||
* traced by TraceProtoAndIfaceCache() and its contents are never
|
||||
* changed after they have been set.
|
||||
*/
|
||||
return JS::Handle<JSObject*>::fromMarkedLocation(protoAndIfaceArray[%s].address());""" %
|
||||
(self.id, self.id))
|
||||
|
||||
|
@ -409,11 +409,19 @@ class MOZ_NONHEAP_CLASS Handle : public js::HandleBase<T>
|
||||
}
|
||||
|
||||
/*
|
||||
* This may be called only if the location of the T is guaranteed
|
||||
* to be marked (for some reason other than being a Rooted),
|
||||
* e.g., if it is guaranteed to be reachable from an implicit root.
|
||||
* Take care when calling this method!
|
||||
*
|
||||
* Create a Handle from a raw location of a T.
|
||||
* This creates a Handle from the raw location of a T.
|
||||
*
|
||||
* It should be called only if the following conditions hold:
|
||||
*
|
||||
* 1) the location of the T is guaranteed to be marked (for some reason
|
||||
* other than being a Rooted), e.g., if it is guaranteed to be reachable
|
||||
* from an implicit root.
|
||||
*
|
||||
* 2) the contents of the location are immutable, or at least cannot change
|
||||
* for the lifetime of the handle, as its users may not expect its value
|
||||
* to change underneath them.
|
||||
*/
|
||||
static Handle fromMarkedLocation(const T *p) {
|
||||
Handle h;
|
||||
|
Loading…
Reference in New Issue
Block a user