mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 16:55:40 +00:00
Bug 1382329: Part 1 - Enable lazy source whenever compiling for the preloader. r=mccr8,nbp
In general, we always want to compile with lazy source whenever we intend to store code in the startup bytecode cache. Currently, we only do so when the main StartupCache is available (which is only in the parent process), even if we'll be storing code in the ScriptPreloader cache. The main side-effect of this is that scripts which are used in a content process do not use lazy source, but *do* use lazy parsing. And since we need to clone pre-loaded scripts into their target compartment before executing, we end up eagerly compiling those lazy functions on the main thread as soon as we execute the script, in order to clone them. And this causes two side-effects of its own: 1) It's terrible for startup performance. 2) It creates new scope chains which didn't exist when the clone began, and which are likely responsible for bug 1367896. MozReview-Commit-ID: 6lZLb68zitp --HG-- extra : rebase_source : 2f2bc11d0123fd7e14c2a5e716a764e7ab8ded46
This commit is contained in:
parent
3aa4930b7a
commit
4c48c5dab8
@ -696,7 +696,7 @@ ScriptPreloader::NoteScript(const nsCString& url, const nsCString& cachePath,
|
||||
{
|
||||
// Don't bother trying to cache any URLs with cache-busting query
|
||||
// parameters.
|
||||
if (mStartupFinished || !mCacheInitialized || cachePath.FindChar('?') >= 0) {
|
||||
if (!Active() || cachePath.FindChar('?') >= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -940,7 +940,8 @@ ScriptPreloader::DecodeNextBatch(size_t chunkSize)
|
||||
JSContext* cx = jsapi.cx();
|
||||
|
||||
JS::CompileOptions options(cx, JSVERSION_LATEST);
|
||||
options.setNoScriptRval(true);
|
||||
options.setNoScriptRval(true)
|
||||
.setSourceIsLazy(true);
|
||||
|
||||
if (!JS::CanCompileOffThread(cx, options, size) ||
|
||||
!JS::DecodeMultiOffThreadScripts(cx, options, mParsingSources,
|
||||
|
@ -91,6 +91,11 @@ public:
|
||||
|
||||
Result<Ok, nsresult> InitCache(const Maybe<ipc::FileDescriptor>& cacheFile, ScriptCacheChild* cacheChild);
|
||||
|
||||
bool Active()
|
||||
{
|
||||
return mCacheInitialized && !mStartupFinished;
|
||||
}
|
||||
|
||||
private:
|
||||
Result<Ok, nsresult> InitCacheInternal();
|
||||
|
||||
|
@ -648,7 +648,7 @@ mozJSComponentLoader::ObjectForLocation(ComponentLoaderInfo& aInfo,
|
||||
options.setNoScriptRval(true)
|
||||
.setVersion(JSVERSION_LATEST)
|
||||
.setFileAndLine(nativePath.get(), 1)
|
||||
.setSourceIsLazy(!!cache);
|
||||
.setSourceIsLazy(cache || ScriptPreloader::GetSingleton().Active());
|
||||
|
||||
if (realFile) {
|
||||
AutoMemMap map;
|
||||
|
Loading…
Reference in New Issue
Block a user