Closed Bug 1689734 Opened 4 years ago Closed 4 years ago

Usage of ScriptPreloader should be consistent about sourceIsLazy options

Categories

(Core :: XPConnect, task)

task

Tracking

()

RESOLVED FIXED
87 Branch
Tracking Status
firefox87 --- fixed

People

(Reporter: tcampbell, Assigned: tcampbell)

References

Details

Attachments

(2 files)

ScriptPreloader usage by nsFrameMessageManager does not force the sourceIsLazy script like other uses of the preloader. This leads to potential inconsistencies in the batch ScriptPreloader decode steps.

We (spidermonkey) would like to further disallow these sorts of mismatches to allow improving perf for all chrome-js caching. The fix here is simply to mark the few frame-scripts as having lazy source. The source hook will be able to fetch if needed, but in practice isn't used.

The tradeoff here is that the cache will have full bytecode for the few scripts and avoid storing source. Locally I only see about 6kB of source JS, so this is largely inconsequential either way.

(This made me discover Bug 1689733 where there are existing cases of sources being fetched during startup that should not happen)

For consistency with other uses of the ScriptPreloader, we ensure we use lazy
script source when compiling for the cache. This generates full bytecode for
the cache but also avoids saving a copy of the source. If the frame script
were to call Function.prototype.toString, the existing source-hook would load
it in the same way as the JSM loader. In practice, we avoid relying on this
in our chrome code. If we will not be writing to the cache, we can instead
compile with the JS syntax parser, similar to what we do for JSM loader.

The JS CompileOptions used to load cache entries must be consistent with
eachother to avoid subtle and serious bugs. This adds additional checks and
makes more consistent use of FillCompileOptionsForCachedScript.

This patch is a refactoring and should not change any behaviour.

Depends on D103515

Pushed by tcampbell@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/4a4a2311a274 Cleanup lazy-source in nsFrameMessageManager if using ScriptPreloader. r=kmag https://hg.mozilla.org/integration/autoland/rev/bb3cce82c923 Further restrict ScriptPreloader use of CompileOptions. r=kmag,arai
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 87 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: