mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 993772 - Introduce a singleton compilation scope. r=mrbkap
This commit is contained in:
parent
8cb91cd665
commit
f56f915374
@ -587,6 +587,14 @@ GetJunkScopeGlobal()
|
||||
return GetNativeForGlobal(junkScope);
|
||||
}
|
||||
|
||||
JSObject *
|
||||
GetCompilationScope()
|
||||
{
|
||||
XPCJSRuntime *self = nsXPConnect::GetRuntimeInstance();
|
||||
NS_ENSURE_TRUE(self, nullptr);
|
||||
return self->GetCompilationScope();
|
||||
}
|
||||
|
||||
JSObject *
|
||||
GetSafeJSContextGlobal()
|
||||
{
|
||||
@ -3045,6 +3053,7 @@ XPCJSRuntime::XPCJSRuntime(nsXPConnect* aXPConnect)
|
||||
mObjectHolderRoots(nullptr),
|
||||
mWatchdogManager(new WatchdogManager(MOZ_THIS_IN_INITIALIZER_LIST())),
|
||||
mJunkScope(MOZ_THIS_IN_INITIALIZER_LIST()->Runtime(), nullptr),
|
||||
mCompilationScope(MOZ_THIS_IN_INITIALIZER_LIST()->Runtime(), nullptr),
|
||||
mAsyncSnowWhiteFreer(new AsyncFreeSnowWhite())
|
||||
{
|
||||
DOM_InitInterfaces();
|
||||
@ -3476,7 +3485,7 @@ XPCJSRuntime::GetJunkScope()
|
||||
if (!mJunkScope) {
|
||||
AutoSafeJSContext cx;
|
||||
SandboxOptions options;
|
||||
options.sandboxName.AssignASCII("XPConnect Junk Compartment");
|
||||
options.sandboxName.AssignLiteral("XPConnect Junk Compartment");
|
||||
RootedValue v(cx);
|
||||
nsresult rv = CreateSandboxObject(cx, &v, nsContentUtils::GetSystemPrincipal(), options);
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
@ -3486,8 +3495,27 @@ XPCJSRuntime::GetJunkScope()
|
||||
return mJunkScope;
|
||||
}
|
||||
|
||||
JSObject *
|
||||
XPCJSRuntime::GetCompilationScope()
|
||||
{
|
||||
if (!mCompilationScope) {
|
||||
AutoSafeJSContext cx;
|
||||
SandboxOptions options;
|
||||
options.sandboxName.AssignLiteral("XPConnect Compilation Compartment");
|
||||
options.invisibleToDebugger = true;
|
||||
RootedValue v(cx);
|
||||
nsresult rv = CreateSandboxObject(cx, &v, /* principal = */ nullptr, options);
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
|
||||
mCompilationScope = js::UncheckedUnwrap(&v.toObject());
|
||||
}
|
||||
return mCompilationScope;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
XPCJSRuntime::DeleteJunkScope()
|
||||
XPCJSRuntime::DeleteSingletonScopes()
|
||||
{
|
||||
mJunkScope = nullptr;
|
||||
mCompilationScope = nullptr;
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ nsXPConnect::nsXPConnect()
|
||||
|
||||
nsXPConnect::~nsXPConnect()
|
||||
{
|
||||
mRuntime->DeleteJunkScope();
|
||||
mRuntime->DeleteSingletonScopes();
|
||||
mRuntime->DestroyJSContextStack();
|
||||
|
||||
// In order to clean up everything properly, we need to GC twice: once now,
|
||||
|
@ -557,7 +557,8 @@ public:
|
||||
AutoMarkingPtr** GetAutoRootsAdr() {return &mAutoRoots;}
|
||||
|
||||
JSObject* GetJunkScope();
|
||||
void DeleteJunkScope();
|
||||
JSObject* GetCompilationScope();
|
||||
void DeleteSingletonScopes();
|
||||
|
||||
PRTime GetWatchdogTimestamp(WatchdogTimestampCategory aCategory);
|
||||
void OnAfterProcessNextEvent() { mSlowScriptCheckpoint = mozilla::TimeStamp(); }
|
||||
@ -598,6 +599,7 @@ private:
|
||||
nsRefPtr<WatchdogManager> mWatchdogManager;
|
||||
JS::GCSliceCallback mPrevGCSliceCallback;
|
||||
JS::PersistentRootedObject mJunkScope;
|
||||
JS::PersistentRootedObject mCompilationScope;
|
||||
nsRefPtr<AsyncFreeSnowWhite> mAsyncSnowWhiteFreer;
|
||||
|
||||
mozilla::TimeStamp mSlowScriptCheckpoint;
|
||||
|
@ -435,6 +435,14 @@ GetJunkScope();
|
||||
nsIGlobalObject *
|
||||
GetJunkScopeGlobal();
|
||||
|
||||
/**
|
||||
* Shared compilation scope for XUL prototype documents and XBL
|
||||
* precompilation. This compartment has a null principal. No code may run, and
|
||||
* it is invisible to the debugger.
|
||||
*/
|
||||
JSObject *
|
||||
GetCompilationScope();
|
||||
|
||||
/**
|
||||
* If |aObj| is a window, returns the associated nsGlobalWindow.
|
||||
* Otherwise, returns null.
|
||||
|
Loading…
Reference in New Issue
Block a user