[go: nahoru, domu]

Skip to content

Commit

Permalink
Bug 1479363 part 6 - Use JSAutoRealm instead of JSAutoRealmAllowCCW i…
Browse files Browse the repository at this point in the history
…n js/xpconnect/loader. r=kmag
  • Loading branch information
jandem committed Aug 2, 2018
1 parent edfe81b commit 2d8dde0
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion js/xpconnect/loader/ChromeScriptLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ PrecompiledScript::ExecuteInGlobal(JSContext* aCx, HandleObject aGlobal,
{
{
RootedObject targetObj(aCx, JS_FindCompilationScope(aCx, aGlobal));
JSAutoRealmAllowCCW ar(aCx, targetObj);
JSAutoRealm ar(aCx, targetObj);

Rooted<JSScript*> script(aCx, mScript);
if (!JS::CloneAndExecuteScript(aCx, script, aRval)) {
Expand Down
6 changes: 3 additions & 3 deletions js/xpconnect/loader/ScriptPreloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,7 @@ ScriptPreloader::MaybeFinishOffThreadDecode()
AutoSafeJSAPI jsapi;
JSContext* cx = jsapi.cx();

JSAutoRealmAllowCCW ar(cx, xpc::CompilationScope());
JSAutoRealm ar(cx, xpc::CompilationScope());
JS::Rooted<JS::ScriptVector> jsScripts(cx, JS::ScriptVector(cx));

// If this fails, we still need to mark the scripts as finished. Any that
Expand Down Expand Up @@ -1122,7 +1122,7 @@ ScriptPreloader::DecodeNextBatch(size_t chunkSize, JS::HandleObject scope)

AutoSafeJSAPI jsapi;
JSContext* cx = jsapi.cx();
JSAutoRealmAllowCCW ar(cx, scope ? scope : xpc::CompilationScope());
JSAutoRealm ar(cx, scope ? scope : xpc::CompilationScope());

JS::CompileOptions options(cx);
options.setNoScriptRval(true)
Expand Down Expand Up @@ -1172,7 +1172,7 @@ ScriptPreloader::CachedScript::XDREncode(JSContext* cx)
MaybeDropScript();
});

JSAutoRealmAllowCCW ar(cx, mScript);
JSAutoRealm ar(cx, mScript);
JS::RootedScript jsscript(cx, mScript);

mXDRData.construct<JS::TranscodeBuffer>();
Expand Down
14 changes: 7 additions & 7 deletions js/xpconnect/loader/mozJSComponentLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ mozJSComponentLoader::LoadModule(FileLocation& aFile)
if (isCriticalModule && !exn.isUndefined()) {
AnnotateCrashReport();

JSAutoRealmAllowCCW ar(cx, xpc::PrivilegedJunkScope());
JSAutoRealm ar(cx, xpc::PrivilegedJunkScope());
JS_WrapValue(cx, &exn);

nsAutoCString file;
Expand All @@ -468,7 +468,7 @@ mozJSComponentLoader::LoadModule(FileLocation& aFile)
if (NS_FAILED(rv))
return nullptr;

JSAutoRealmAllowCCW ar(cx, entry->obj);
JSAutoRealm ar(cx, entry->obj);
RootedObject entryObj(cx, entry->obj);

RootedObject NSGetFactoryHolder(cx, ResolveModuleObjectProperty(cx, entryObj, "NSGetFactory"));
Expand Down Expand Up @@ -597,7 +597,7 @@ mozJSComponentLoader::CreateLoaderGlobal(JSContext* aCx,

backstagePass->SetGlobalObject(global);

JSAutoRealmAllowCCW ar(aCx, global);
JSAutoRealm ar(aCx, global);
if (!JS_DefineFunctions(aCx, global, gGlobalFun) ||
!JS_DefineProfilingFunctions(aCx, global)) {
return;
Expand Down Expand Up @@ -692,7 +692,7 @@ mozJSComponentLoader::PrepareObjectForLocation(JSContext* aCx,
RootedObject thisObj(aCx, globalObj);
NS_ENSURE_TRUE(thisObj, nullptr);

JSAutoRealmAllowCCW ar(aCx, thisObj);
JSAutoRealm ar(aCx, thisObj);

if (reuseGlobal) {
thisObj = js::NewJSMEnvironment(aCx);
Expand Down Expand Up @@ -801,7 +801,7 @@ mozJSComponentLoader::ObjectForLocation(ComponentLoaderInfo& aInfo,
NS_ENSURE_TRUE(obj, NS_ERROR_FAILURE);
MOZ_ASSERT(JS_IsGlobalObject(obj) == !reuseGlobal);

JSAutoRealmAllowCCW ar(cx, obj);
JSAutoRealm ar(cx, obj);

RootedScript script(cx);

Expand Down Expand Up @@ -965,7 +965,7 @@ mozJSComponentLoader::UnloadModules()
jsapi.Init();
JSContext* cx = jsapi.cx();
RootedObject global(cx, mLoaderGlobal);
JSAutoRealmAllowCCW ar(cx, global);
JSAutoRealm ar(cx, global);
MOZ_ASSERT(JS_HasExtensibleLexicalEnvironment(global));
JS_SetAllNonReservedSlotsToUndefined(cx, JS_ExtensibleLexicalEnvironment(global));
JS_SetAllNonReservedSlotsToUndefined(cx, global);
Expand Down Expand Up @@ -1195,7 +1195,7 @@ mozJSComponentLoader::ExtractExports(JSContext* aCx, ComponentLoaderInfo& aInfo,
dom::AutoJSAPI jsapi;
jsapi.Init();
JSContext* cx = jsapi.cx();
JSAutoRealmAllowCCW ar(cx, aMod->obj);
JSAutoRealm ar(cx, aMod->obj);

RootedValue symbols(cx);
{
Expand Down
2 changes: 1 addition & 1 deletion js/xpconnect/loader/mozJSComponentLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class mozJSComponentLoader final : public mozilla::ModuleLoader,

if (obj) {
mozilla::AutoJSContext cx;
JSAutoRealmAllowCCW ar(cx, obj);
JSAutoRealm ar(cx, obj);

if (JS_HasExtensibleLexicalEnvironment(obj)) {
JS_SetAllNonReservedSlotsToUndefined(cx, JS_ExtensibleLexicalEnvironment(obj));
Expand Down
8 changes: 4 additions & 4 deletions js/xpconnect/loader/mozJSSubScriptLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ EvalScript(JSContext* cx,
}
}

JSAutoRealmAllowCCW rar(cx, targetObj);
JSAutoRealm rar(cx, targetObj);
if (!JS_WrapValue(cx, retval)) {
return false;
}
Expand Down Expand Up @@ -270,7 +270,7 @@ EvalScript(JSContext* cx,
}

if (startupCache) {
JSAutoRealmAllowCCW ar(cx, script);
JSAutoRealm ar(cx, script);
WriteCachedScript(StartupCache::GetSingleton(), cachePath, cx, script);
}
}
Expand Down Expand Up @@ -558,7 +558,7 @@ mozJSSubScriptLoader::ReadScript(nsIURI* uri,
rv = NS_ReadInputStreamToString(instream, buf, len);
NS_ENSURE_SUCCESS(rv, false);

Maybe<JSAutoRealmAllowCCW> ar;
Maybe<JSAutoRealm> ar;

// Note that when using the ScriptPreloader cache with loadSubScript, there
// will be a side-effect of keeping the global that the script was compiled
Expand Down Expand Up @@ -656,7 +656,7 @@ mozJSSubScriptLoader::DoLoadSubScriptWithOptions(const nsAString& url,
return NS_ERROR_FAILURE;
}

JSAutoRealmAllowCCW ar(cx, targetObj);
JSAutoRealm ar(cx, targetObj);

nsCOMPtr<nsIIOService> serv = do_GetService(NS_IOSERVICE_CONTRACTID);
if (!serv) {
Expand Down

0 comments on commit 2d8dde0

Please sign in to comment.