зеркало из https://github.com/mozilla/gecko-dev.git
Bug 811206, Fix JSHolder drop handling, part 3 (fixes), r=mccr8,khuey
--HG-- extra : rebase_source : 7b2726d2aa7f5764a3c4cb750e5a735728069687
This commit is contained in:
Родитель
2e7f4ef4ba
Коммит
c806b877ae
|
@ -2239,8 +2239,6 @@ private:
|
|||
static nsILineBreaker* sLineBreaker;
|
||||
static nsIWordBreaker* sWordBreaker;
|
||||
|
||||
static uint32_t sJSGCThingRootCount;
|
||||
|
||||
#ifdef IBMBIDI
|
||||
static nsIBidiKeyboard* sBidiKeyboard;
|
||||
#endif
|
||||
|
|
|
@ -208,7 +208,6 @@ nsIContentPolicy *nsContentUtils::sContentPolicyService;
|
|||
bool nsContentUtils::sTriedToGetContentPolicy = false;
|
||||
nsILineBreaker *nsContentUtils::sLineBreaker;
|
||||
nsIWordBreaker *nsContentUtils::sWordBreaker;
|
||||
uint32_t nsContentUtils::sJSGCThingRootCount;
|
||||
#ifdef IBMBIDI
|
||||
nsIBidiKeyboard *nsContentUtils::sBidiKeyboard = nullptr;
|
||||
#endif
|
||||
|
@ -4526,6 +4525,10 @@ nsContentUtils::HoldJSObjects(void* aScriptObjectHolder,
|
|||
nsresult
|
||||
nsContentUtils::DropJSObjects(void* aScriptObjectHolder)
|
||||
{
|
||||
if (!sXPConnect) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return sXPConnect->RemoveJSHolder(aScriptObjectHolder);
|
||||
}
|
||||
|
||||
|
@ -6863,9 +6866,8 @@ nsContentUtils::ReleaseWrapper(void* aScriptObjectHolder,
|
|||
if (aCache->IsDOMBinding() && obj) {
|
||||
xpc::GetObjectScope(obj)->RemoveDOMExpandoObject(obj);
|
||||
}
|
||||
DropJSObjects(aScriptObjectHolder);
|
||||
|
||||
aCache->SetPreservingWrapper(false);
|
||||
DropJSObjects(aScriptObjectHolder);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,8 +46,8 @@ void
|
|||
ImageData::DropData()
|
||||
{
|
||||
if (mData) {
|
||||
NS_DROP_JS_OBJECTS(this, ImageData);
|
||||
mData = NULL;
|
||||
NS_DROP_JS_OBJECTS(this, ImageData);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -62,9 +62,9 @@ void
|
|||
nsDOMMessageEvent::UnrootData()
|
||||
{
|
||||
NS_ASSERTION(mDataRooted, "...");
|
||||
NS_DROP_JS_OBJECTS(this, nsDOMMessageEvent);
|
||||
mDataRooted = false;
|
||||
mData = JSVAL_VOID;
|
||||
NS_DROP_JS_OBJECTS(this, nsDOMMessageEvent);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -38,8 +38,8 @@ NS_IMPL_RELEASE_INHERITED(nsDOMNotifyAudioAvailableEvent, nsDOMEvent)
|
|||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMNotifyAudioAvailableEvent, nsDOMEvent)
|
||||
if (tmp->mCachedArray) {
|
||||
NS_DROP_JS_OBJECTS(tmp, nsDOMNotifyAudioAvailableEvent);
|
||||
tmp->mCachedArray = nullptr;
|
||||
NS_DROP_JS_OBJECTS(tmp, nsDOMNotifyAudioAvailableEvent);
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
|
@ -60,8 +60,8 @@ nsDOMNotifyAudioAvailableEvent::~nsDOMNotifyAudioAvailableEvent()
|
|||
{
|
||||
MOZ_COUNT_DTOR(nsDOMNotifyAudioAvailableEvent);
|
||||
if (mCachedArray) {
|
||||
NS_DROP_JS_OBJECTS(this, nsDOMNotifyAudioAvailableEvent);
|
||||
mCachedArray = nullptr;
|
||||
NS_DROP_JS_OBJECTS(this, nsDOMNotifyAudioAvailableEvent);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@ AudioBuffer::AudioBuffer(AudioContext* aContext, uint32_t aLength,
|
|||
|
||||
AudioBuffer::~AudioBuffer()
|
||||
{
|
||||
mChannels.Clear();
|
||||
NS_DROP_JS_OBJECTS(this, AudioBuffer);
|
||||
}
|
||||
|
||||
|
|
|
@ -522,8 +522,9 @@ nsXBLDocumentInfo::~nsXBLDocumentInfo()
|
|||
mGlobalObject->ClearGlobalObjectOwner(); // just in case
|
||||
}
|
||||
if (mBindingTable) {
|
||||
NS_DROP_JS_OBJECTS(this, nsXBLDocumentInfo);
|
||||
delete mBindingTable;
|
||||
mBindingTable = nullptr;
|
||||
NS_DROP_JS_OBJECTS(this, nsXBLDocumentInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2491,8 +2491,8 @@ void
|
|||
nsXULPrototypeScript::UnlinkJSObjects()
|
||||
{
|
||||
if (mScriptObject.mObject) {
|
||||
nsContentUtils::DropJSObjects(this);
|
||||
mScriptObject.mObject = nullptr;
|
||||
nsContentUtils::DropJSObjects(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(DOMRequest,
|
||||
nsDOMEventTargetHelper)
|
||||
if (tmp->mRooted) {
|
||||
tmp->mResult = JSVAL_VOID;
|
||||
tmp->UnrootResultVal();
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mError)
|
||||
|
@ -187,6 +186,7 @@ void
|
|||
DOMRequest::UnrootResultVal()
|
||||
{
|
||||
NS_ASSERTION(mRooted, "Don't call me if not rooted!");
|
||||
mResult = JSVAL_VOID;
|
||||
NS_DROP_JS_OBJECTS(this, DOMRequest);
|
||||
mRooted = false;
|
||||
}
|
||||
|
|
|
@ -4144,12 +4144,13 @@ nsJSArgArray::~nsJSArgArray()
|
|||
void
|
||||
nsJSArgArray::ReleaseJSObjects()
|
||||
{
|
||||
if (mArgc > 0)
|
||||
NS_DROP_JS_OBJECTS(this, nsJSArgArray);
|
||||
if (mArgv) {
|
||||
PR_DELETE(mArgv);
|
||||
}
|
||||
mArgc = 0;
|
||||
if (mArgc > 0) {
|
||||
mArgc = 0;
|
||||
NS_DROP_JS_OBJECTS(this, nsJSArgArray);
|
||||
}
|
||||
}
|
||||
|
||||
// QueryInterface implementation for nsJSArgArray
|
||||
|
|
|
@ -141,17 +141,12 @@ nsJSScriptTimeoutHandler::~nsJSScriptTimeoutHandler()
|
|||
void
|
||||
nsJSScriptTimeoutHandler::ReleaseJSObjects()
|
||||
{
|
||||
if (mExpr || mFunObj) {
|
||||
if (mExpr) {
|
||||
NS_DROP_JS_OBJECTS(this, nsJSScriptTimeoutHandler);
|
||||
mExpr = nullptr;
|
||||
} else if (mFunObj) {
|
||||
NS_DROP_JS_OBJECTS(this, nsJSScriptTimeoutHandler);
|
||||
mFunObj = nullptr;
|
||||
} else {
|
||||
NS_WARNING("No func and no expr - roots may not have been removed");
|
||||
}
|
||||
if (mExpr) {
|
||||
mExpr = nullptr;
|
||||
} else {
|
||||
mFunObj = nullptr;
|
||||
}
|
||||
NS_DROP_JS_OBJECTS(this, nsJSScriptTimeoutHandler);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -91,8 +91,8 @@ protected:
|
|||
void DropCallback()
|
||||
{
|
||||
if (mCallable) {
|
||||
NS_DROP_JS_OBJECTS(this, CallbackFunction);
|
||||
mCallable = nullptr;
|
||||
NS_DROP_JS_OBJECTS(this, CallbackFunction);
|
||||
nsLayoutStatics::Release();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -163,6 +163,8 @@ BluetoothAdapter::Unroot()
|
|||
if (!mIsRooted) {
|
||||
return;
|
||||
}
|
||||
mJsUuids = nullptr;
|
||||
mJsDeviceAddresses = nullptr;
|
||||
NS_DROP_JS_OBJECTS(this, BluetoothAdapter);
|
||||
mIsRooted = false;
|
||||
}
|
||||
|
|
|
@ -87,6 +87,8 @@ void
|
|||
BluetoothDevice::Unroot()
|
||||
{
|
||||
if (mIsRooted) {
|
||||
mJsUuids = nullptr;
|
||||
mJsServices = nullptr;
|
||||
NS_DROP_JS_OBJECTS(this, BluetoothDevice);
|
||||
mIsRooted = false;
|
||||
}
|
||||
|
|
|
@ -1141,8 +1141,8 @@ nsDOMDeviceStorageCursor::Continue()
|
|||
if (mRooted) {
|
||||
// We call onsuccess multiple times. clear the last
|
||||
// rooted result.
|
||||
NS_DROP_JS_OBJECTS(this, nsDOMDeviceStorageCursor);
|
||||
mResult = JSVAL_VOID;
|
||||
NS_DROP_JS_OBJECTS(this, nsDOMDeviceStorageCursor);
|
||||
mDone = false;
|
||||
mRooted = false;
|
||||
}
|
||||
|
|
|
@ -369,12 +369,28 @@ IDBCursor::~IDBCursor()
|
|||
NS_ASSERTION(!mActorChild, "Should have cleared in Send__delete__!");
|
||||
}
|
||||
|
||||
if (mRooted) {
|
||||
NS_DROP_JS_OBJECTS(this, IDBCursor);
|
||||
}
|
||||
DropJSObjects();
|
||||
IDBObjectStore::ClearCloneReadInfo(mCloneReadInfo);
|
||||
}
|
||||
|
||||
void
|
||||
IDBCursor::DropJSObjects()
|
||||
{
|
||||
if (!mRooted) {
|
||||
return;
|
||||
}
|
||||
mScriptOwner = nullptr;
|
||||
mCachedKey = JSVAL_VOID;
|
||||
mCachedPrimaryKey = JSVAL_VOID;
|
||||
mCachedValue = JSVAL_VOID;
|
||||
mHaveCachedKey = false;
|
||||
mHaveCachedPrimaryKey = false;
|
||||
mHaveCachedValue = false;
|
||||
mRooted = false;
|
||||
mHaveValue = false;
|
||||
NS_DROP_JS_OBJECTS(this, IDBCursor);
|
||||
}
|
||||
|
||||
nsresult
|
||||
IDBCursor::ContinueInternal(const Key& aKey,
|
||||
int32_t aCount)
|
||||
|
@ -455,18 +471,7 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
|||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(IDBCursor)
|
||||
// Don't unlink mObjectStore, mIndex, or mTransaction!
|
||||
if (tmp->mRooted) {
|
||||
NS_DROP_JS_OBJECTS(tmp, IDBCursor);
|
||||
tmp->mScriptOwner = nullptr;
|
||||
tmp->mCachedKey = JSVAL_VOID;
|
||||
tmp->mCachedPrimaryKey = JSVAL_VOID;
|
||||
tmp->mCachedValue = JSVAL_VOID;
|
||||
tmp->mHaveCachedKey = false;
|
||||
tmp->mHaveCachedPrimaryKey = false;
|
||||
tmp->mHaveCachedValue = false;
|
||||
tmp->mRooted = false;
|
||||
tmp->mHaveValue = false;
|
||||
}
|
||||
tmp->DropJSObjects();
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mRequest)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
|
|
|
@ -151,6 +151,8 @@ protected:
|
|||
IDBCursor();
|
||||
~IDBCursor();
|
||||
|
||||
void DropJSObjects();
|
||||
|
||||
static
|
||||
already_AddRefed<IDBCursor>
|
||||
CreateCommon(IDBRequest* aRequest,
|
||||
|
|
|
@ -244,8 +244,6 @@ IDBDatabase::~IDBDatabase()
|
|||
mgr->UnregisterDatabase(this);
|
||||
}
|
||||
}
|
||||
|
||||
nsContentUtils::ReleaseWrapper(static_cast<nsIDOMEventTarget*>(this), this);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -77,6 +77,7 @@ IDBFactory::~IDBFactory()
|
|||
NS_ASSERTION(!mActorChild, "Should have cleared in Send__delete__!");
|
||||
}
|
||||
if (mRootedOwningObject) {
|
||||
mOwningObject = nullptr;
|
||||
NS_DROP_JS_OBJECTS(this, IDBFactory);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -414,6 +414,7 @@ IDBIndex::~IDBIndex()
|
|||
NS_ASSERTION(!mActorParent, "Actor parent owns us, how can we be dying?!");
|
||||
|
||||
if (mRooted) {
|
||||
mCachedKeyPath = JSVAL_VOID;
|
||||
NS_DROP_JS_OBJECTS(this, IDBIndex);
|
||||
}
|
||||
|
||||
|
|
|
@ -318,14 +318,7 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(IDBKeyRange)
|
|||
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(IDBKeyRange)
|
||||
if (tmp->mRooted) {
|
||||
NS_DROP_JS_OBJECTS(tmp, IDBKeyRange);
|
||||
tmp->mCachedLowerVal = JSVAL_VOID;
|
||||
tmp->mCachedUpperVal = JSVAL_VOID;
|
||||
tmp->mHaveCachedLowerVal = false;
|
||||
tmp->mHaveCachedUpperVal = false;
|
||||
tmp->mRooted = false;
|
||||
}
|
||||
tmp->DropJSObjects();
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(IDBKeyRange)
|
||||
|
@ -339,11 +332,23 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(IDBKeyRange)
|
|||
|
||||
DOMCI_DATA(IDBKeyRange, IDBKeyRange)
|
||||
|
||||
void
|
||||
IDBKeyRange::DropJSObjects()
|
||||
{
|
||||
if (!mRooted) {
|
||||
return;
|
||||
}
|
||||
mCachedLowerVal = JSVAL_VOID;
|
||||
mCachedUpperVal = JSVAL_VOID;
|
||||
mHaveCachedLowerVal = false;
|
||||
mHaveCachedUpperVal = false;
|
||||
mRooted = false;
|
||||
NS_DROP_JS_OBJECTS(this, IDBKeyRange);
|
||||
}
|
||||
|
||||
IDBKeyRange::~IDBKeyRange()
|
||||
{
|
||||
if (mRooted) {
|
||||
NS_DROP_JS_OBJECTS(this, IDBKeyRange);
|
||||
}
|
||||
DropJSObjects();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -150,6 +150,8 @@ public:
|
|||
template <class T>
|
||||
void ToSerializedKeyRange(T& aKeyRange);
|
||||
|
||||
void DropJSObjects();
|
||||
|
||||
private:
|
||||
~IDBKeyRange();
|
||||
|
||||
|
|
|
@ -1543,6 +1543,7 @@ IDBObjectStore::~IDBObjectStore()
|
|||
}
|
||||
|
||||
if (mRooted) {
|
||||
mCachedKeyPath = JSVAL_VOID;
|
||||
NS_DROP_JS_OBJECTS(this, IDBObjectStore);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ IDBRequest::IDBRequest()
|
|||
|
||||
IDBRequest::~IDBRequest()
|
||||
{
|
||||
mResultVal = JSVAL_VOID;
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
}
|
||||
|
||||
|
|
|
@ -189,8 +189,6 @@ IDBTransaction::~IDBTransaction()
|
|||
mActorChild->Send__delete__(mActorChild);
|
||||
NS_ASSERTION(!mActorChild, "Should have cleared in Send__delete__!");
|
||||
}
|
||||
|
||||
nsContentUtils::ReleaseWrapper(static_cast<nsIDOMEventTarget*>(this), this);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -20,8 +20,8 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IDBWrapperCache,
|
||||
nsDOMEventTargetHelper)
|
||||
if (tmp->mScriptOwner) {
|
||||
NS_DROP_JS_OBJECTS(tmp, IDBWrapperCache);
|
||||
tmp->mScriptOwner = nullptr;
|
||||
NS_DROP_JS_OBJECTS(tmp, IDBWrapperCache);
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
|
@ -40,9 +40,9 @@ NS_IMPL_RELEASE_INHERITED(IDBWrapperCache, nsDOMEventTargetHelper)
|
|||
|
||||
IDBWrapperCache::~IDBWrapperCache()
|
||||
{
|
||||
if (mScriptOwner) {
|
||||
NS_DROP_JS_OBJECTS(this, IDBWrapperCache);
|
||||
}
|
||||
mScriptOwner = nullptr;
|
||||
nsContentUtils::ReleaseWrapper(this, this);
|
||||
NS_DROP_JS_OBJECTS(this, IDBWrapperCache);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -43,7 +43,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(SmsRequest,
|
||||
nsDOMEventTargetHelper)
|
||||
if (tmp->mResultRooted) {
|
||||
tmp->mResult = JSVAL_VOID;
|
||||
tmp->UnrootResult();
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mCursor)
|
||||
|
@ -137,6 +136,7 @@ void
|
|||
SmsRequest::UnrootResult()
|
||||
{
|
||||
NS_ASSERTION(mResultRooted, "Don't call UnrotResult() if not rooted!");
|
||||
mResult = JSVAL_VOID;
|
||||
NS_DROP_JS_OBJECTS(this, SmsRequest);
|
||||
mResultRooted = false;
|
||||
}
|
||||
|
@ -206,7 +206,6 @@ SmsRequest::SetSuccessInternal(nsISupports* aObject)
|
|||
|
||||
if (NS_FAILED(nsContentUtils::WrapNative(cx, global, aObject, &mResult))) {
|
||||
UnrootResult();
|
||||
mResult = JSVAL_VOID;
|
||||
SetError(nsISmsRequest::INTERNAL_ERROR);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -61,6 +61,7 @@ nsJSEventListener::nsJSEventListener(nsIScriptContext *aContext,
|
|||
nsJSEventListener::~nsJSEventListener()
|
||||
{
|
||||
if (mScopeObject) {
|
||||
mScopeObject = nullptr;
|
||||
NS_DROP_JS_OBJECTS(this, nsJSEventListener);
|
||||
}
|
||||
}
|
||||
|
@ -70,6 +71,7 @@ void
|
|||
nsJSEventListener::UpdateScopeObject(JSObject* aScopeObject)
|
||||
{
|
||||
if (mScopeObject && !aScopeObject) {
|
||||
mScopeObject = nullptr;
|
||||
NS_DROP_JS_OBJECTS(this, nsJSEventListener);
|
||||
} else if (aScopeObject && !mScopeObject) {
|
||||
NS_HOLD_JS_OBJECTS(this, nsJSEventListener);
|
||||
|
@ -80,8 +82,8 @@ nsJSEventListener::UpdateScopeObject(JSObject* aScopeObject)
|
|||
NS_IMPL_CYCLE_COLLECTION_CLASS(nsJSEventListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsJSEventListener)
|
||||
if (tmp->mScopeObject) {
|
||||
NS_DROP_JS_OBJECTS(tmp, nsJSEventListener);
|
||||
tmp->mScopeObject = nullptr;
|
||||
NS_DROP_JS_OBJECTS(tmp, nsJSEventListener);
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mContext)
|
||||
}
|
||||
tmp->mHandler.ForgetHandler();
|
||||
|
|
|
@ -53,6 +53,7 @@ Telephony::~Telephony()
|
|||
}
|
||||
|
||||
if (mRooted) {
|
||||
mCallsArray = nullptr;
|
||||
NS_DROP_JS_OBJECTS(this, Telephony);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче