зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset a505dcbe8a02 (bug 1359653)
This commit is contained in:
Родитель
7ed4c0581c
Коммит
a71ff9882a
|
@ -44,7 +44,6 @@
|
|||
#include "mozilla/scache/StartupCacheUtils.h"
|
||||
#include "mozilla/MacroForEach.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/ScriptPreloader.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
#include "mozilla/UniquePtrExtensions.h"
|
||||
#include "mozilla/Unused.h"
|
||||
|
@ -685,10 +684,7 @@ mozJSComponentLoader::ObjectForLocation(ComponentLoaderInfo& aInfo,
|
|||
|
||||
if (cache) {
|
||||
if (!mReuseLoaderGlobal) {
|
||||
script = ScriptPreloader::GetSingleton().GetCachedScript(cx, cachePath);
|
||||
if (!script) {
|
||||
rv = ReadCachedScript(cache, cachePath, cx, mSystemPrincipal, &script);
|
||||
}
|
||||
rv = ReadCachedScript(cache, cachePath, cx, mSystemPrincipal, &script);
|
||||
} else {
|
||||
rv = ReadCachedFunction(cache, cachePath, cx, mSystemPrincipal,
|
||||
function.address());
|
||||
|
@ -852,10 +848,6 @@ mozJSComponentLoader::ObjectForLocation(ComponentLoaderInfo& aInfo,
|
|||
MOZ_ASSERT(!!script != !!function);
|
||||
MOZ_ASSERT(!!script == JS_IsGlobalObject(obj));
|
||||
|
||||
if (script) {
|
||||
ScriptPreloader::GetSingleton().NoteScript(nativePath, cachePath, script);
|
||||
}
|
||||
|
||||
if (writeToCache) {
|
||||
// We successfully compiled the script, so cache it.
|
||||
if (script) {
|
||||
|
@ -898,8 +890,7 @@ mozJSComponentLoader::ObjectForLocation(ComponentLoaderInfo& aInfo,
|
|||
JSContext* aescx = aes.cx();
|
||||
bool ok;
|
||||
if (script) {
|
||||
JS::RootedValue rval(cx);
|
||||
ok = JS::CloneAndExecuteScript(aescx, script, &rval);
|
||||
ok = JS_ExecuteScript(aescx, script);
|
||||
} else {
|
||||
RootedValue rval(cx);
|
||||
ok = JS_CallFunction(aescx, obj, function,
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include "mozilla/dom/Promise.h"
|
||||
#include "mozilla/dom/ToJSValue.h"
|
||||
#include "mozilla/HoldDropJSObjects.h"
|
||||
#include "mozilla/ScriptPreloader.h"
|
||||
#include "mozilla/scache/StartupCache.h"
|
||||
#include "mozilla/scache/StartupCacheUtils.h"
|
||||
#include "mozilla/Unused.h"
|
||||
|
@ -194,8 +193,7 @@ EvalScript(JSContext* cx,
|
|||
HandleObject targetObj,
|
||||
MutableHandleValue retval,
|
||||
nsIURI* uri,
|
||||
bool startupCache,
|
||||
bool preloadCache,
|
||||
bool cache,
|
||||
MutableHandleScript script,
|
||||
HandleFunction function)
|
||||
{
|
||||
|
@ -209,7 +207,7 @@ EvalScript(JSContext* cx,
|
|||
}
|
||||
} else {
|
||||
if (JS_IsGlobalObject(targetObj)) {
|
||||
if (!JS::CloneAndExecuteScript(cx, script, retval)) {
|
||||
if (!JS_ExecuteScript(cx, script, retval)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
|
@ -217,7 +215,7 @@ EvalScript(JSContext* cx,
|
|||
if (!envChain.append(targetObj)) {
|
||||
return false;
|
||||
}
|
||||
if (!JS::CloneAndExecuteScript(cx, envChain, script, retval)) {
|
||||
if (!JS_ExecuteScript(cx, envChain, script, retval)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -228,7 +226,7 @@ EvalScript(JSContext* cx,
|
|||
return false;
|
||||
}
|
||||
|
||||
if (script && (startupCache || preloadCache)) {
|
||||
if (cache && !!script) {
|
||||
nsAutoCString cachePath;
|
||||
JSVersion version = JS_GetVersion(cx);
|
||||
cachePath.AppendPrintf("jssubloader/%d", version);
|
||||
|
@ -247,16 +245,8 @@ EvalScript(JSContext* cx,
|
|||
return false;
|
||||
}
|
||||
|
||||
nsCString uriStr;
|
||||
if (preloadCache && NS_SUCCEEDED(uri->GetSpec(uriStr))) {
|
||||
ScriptPreloader::GetSingleton().NoteScript(uriStr, cachePath, script);
|
||||
}
|
||||
|
||||
if (startupCache) {
|
||||
JSAutoCompartment ac(cx, script);
|
||||
WriteCachedScript(StartupCache::GetSingleton(),
|
||||
cachePath, cx, principal, script);
|
||||
}
|
||||
WriteCachedScript(StartupCache::GetSingleton(),
|
||||
cachePath, cx, principal, script);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -410,9 +400,7 @@ AsyncScriptLoader::OnStreamComplete(nsIIncrementalStreamLoader* aLoader,
|
|||
}
|
||||
|
||||
JS::Rooted<JS::Value> retval(cx);
|
||||
if (EvalScript(cx, targetObj, &retval, uri, mCache,
|
||||
mCache && !mWantReturnValue,
|
||||
&script, function)) {
|
||||
if (EvalScript(cx, targetObj, &retval, uri, mCache, &script, function)) {
|
||||
autoPromise.ResolvePromise(retval);
|
||||
}
|
||||
|
||||
|
@ -643,9 +631,9 @@ mozJSSubScriptLoader::DoLoadSubScriptWithOptions(const nsAString& url,
|
|||
JSAutoCompartment ac(cx, targetObj);
|
||||
|
||||
// Suppress caching if we're compiling as content.
|
||||
bool ignoreCache = options.ignoreCache || principal != mSystemPrincipal;
|
||||
StartupCache* cache = ignoreCache ? nullptr : StartupCache::GetSingleton();
|
||||
|
||||
StartupCache* cache = (principal == mSystemPrincipal)
|
||||
? StartupCache::GetSingleton()
|
||||
: nullptr;
|
||||
nsCOMPtr<nsIIOService> serv = do_GetService(NS_IOSERVICE_CONTRACTID);
|
||||
if (!serv) {
|
||||
ReportError(cx, NS_LITERAL_CSTRING(LOAD_ERROR_NOSERVICE));
|
||||
|
@ -698,11 +686,8 @@ mozJSSubScriptLoader::DoLoadSubScriptWithOptions(const nsAString& url,
|
|||
RootedFunction function(cx);
|
||||
RootedScript script(cx);
|
||||
if (cache && !options.ignoreCache) {
|
||||
if (!options.wantReturnValue)
|
||||
script = ScriptPreloader::GetSingleton().GetCachedScript(cx, cachePath);
|
||||
if (!script)
|
||||
rv = ReadCachedScript(cache, cachePath, cx, mSystemPrincipal, &script);
|
||||
if (NS_FAILED(rv) || !script) {
|
||||
rv = ReadCachedScript(cache, cachePath, cx, mSystemPrincipal, &script);
|
||||
if (NS_FAILED(rv)) {
|
||||
// ReadCachedScript may have set a pending exception.
|
||||
JS_ClearPendingException(cx);
|
||||
}
|
||||
|
@ -727,9 +712,7 @@ mozJSSubScriptLoader::DoLoadSubScriptWithOptions(const nsAString& url,
|
|||
cache = nullptr;
|
||||
}
|
||||
|
||||
Unused << EvalScript(cx, targetObj, retval, uri, !!cache,
|
||||
!ignoreCache && !options.wantReturnValue,
|
||||
&script, function);
|
||||
Unused << EvalScript(cx, targetObj, retval, uri, !!cache, &script, function);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче