From 0e0b3b6c7c7c08418c657fb8e7c5b6ac088baae6 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Sun, 20 Apr 2014 11:48:14 -0700 Subject: [PATCH] Bug 993772 - Switch to the singleton compilation scope for XBL compilation. r=mrbkap --- dom/xbl/nsXBLDocumentInfo.cpp | 4 ++-- dom/xbl/nsXBLProtoImpl.cpp | 2 +- dom/xbl/nsXBLPrototypeBinding.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dom/xbl/nsXBLDocumentInfo.cpp b/dom/xbl/nsXBLDocumentInfo.cpp index 0d55317119cb..ed92cb3c2651 100644 --- a/dom/xbl/nsXBLDocumentInfo.cpp +++ b/dom/xbl/nsXBLDocumentInfo.cpp @@ -566,7 +566,7 @@ void AssertInCompilationScope() { AutoJSContext cx; - MOZ_ASSERT(JS_GetClass(JS::CurrentGlobalOrNull(cx)) == - &nsXBLDocGlobalObject::gSharedGlobalClass); + // Note - Inverting the order of these operands is a rooting hazard. + MOZ_ASSERT(xpc::GetCompilationScope() == JS::CurrentGlobalOrNull(cx)); } #endif diff --git a/dom/xbl/nsXBLProtoImpl.cpp b/dom/xbl/nsXBLProtoImpl.cpp index df3fc28f2efb..33d82dc486e5 100644 --- a/dom/xbl/nsXBLProtoImpl.cpp +++ b/dom/xbl/nsXBLProtoImpl.cpp @@ -201,7 +201,7 @@ nsXBLProtoImpl::CompilePrototypeMembers(nsXBLPrototypeBinding* aBinding) // bind the prototype to a real xbl instance, we'll clone the pre-compiled JS into the real instance's // context. AutoSafeJSContext cx; - JS::Rooted compilationGlobal(cx, aBinding->XBLDocumentInfo()->GetCompilationGlobal()); + JS::Rooted compilationGlobal(cx, xpc::GetCompilationScope()); NS_ENSURE_TRUE(compilationGlobal, NS_ERROR_UNEXPECTED); JSAutoCompartment ac(cx, compilationGlobal); diff --git a/dom/xbl/nsXBLPrototypeBinding.cpp b/dom/xbl/nsXBLPrototypeBinding.cpp index e0bc83ccb56d..100c4f432296 100644 --- a/dom/xbl/nsXBLPrototypeBinding.cpp +++ b/dom/xbl/nsXBLPrototypeBinding.cpp @@ -919,7 +919,7 @@ nsXBLPrototypeBinding::Read(nsIObjectInputStream* aStream, } AutoSafeJSContext cx; - JS::Rooted compilationGlobal(cx, aDocInfo->GetCompilationGlobal()); + JS::Rooted compilationGlobal(cx, xpc::GetCompilationScope()); NS_ENSURE_TRUE(compilationGlobal, NS_ERROR_UNEXPECTED); JSAutoCompartment ac(cx, compilationGlobal); @@ -1072,7 +1072,7 @@ nsXBLPrototypeBinding::Write(nsIObjectOutputStream* aStream) // computed on demand. AutoSafeJSContext cx; - JS::Rooted compilationGlobal(cx, mXBLDocInfoWeak->GetCompilationGlobal()); + JS::Rooted compilationGlobal(cx, xpc::GetCompilationScope()); NS_ENSURE_TRUE(compilationGlobal, NS_ERROR_UNEXPECTED); JSAutoCompartment ac(cx, compilationGlobal);