Closed Bug 1724236 Opened 4 years ago Closed 1 year ago

Use JS::Stencil directly in dom::ScriptLoader

Categories

(Core :: JavaScript Engine, task, P2)

task

Tracking

()

RESOLVED FIXED
134 Branch
Tracking Status
firefox134 --- fixed

People

(Reporter: tcampbell, Assigned: bthrall)

References

(Blocks 2 open bugs)

Details

Attachments

(24 files)

48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review

Now that Stencil is core to all our parsing and caching flows for JS, we should directly use the JS::Stencil type from the dom::ScriptLoader and explicitly calling instantiate. This will allow us to build in-memory caches around JS::Stencil to improve our caching story.

Blocks: 1646494

It might be necessary to fix Bug 1687973 so that this proposed change can also cover the decode case. Even without that, it is still possible to support to do in-memory caching with just the non-decode path.

Depends on: 1687973
Assignee: tcampbell → nobody

No one is actively working on this, so it is unlikely to land before the next release.

Priority: P1 → P2
Severity: S3 → N/A

According to :arai:

we'll need to introduce some structure to hold the delazification result. it may be hidden behind current Stencil struct, or maybe exposed as separate struct. if latter, it may be owned by embedding side, and then removing the indirection from JSExecutionContext beforehand would work nicely

Assignee: nobody → bthrall

ExecScript returning a value was only used in one place, and that call always
coerced the return value to a string.

The remaining Compile(nsAString) could be inlined as well, but it is only used
in nsJSThunk::EvaluateScript and WindowScriptTimeoutHandler::Call. Right now,
I'm just focusing on use by ScriptLoader.

ScriptLoader is the only place that calls it, and inlining it made the call
site too hard to follow.

I think the constructor assertions don't need to be preserved, since the
locations where JSExecutionContext was constructed are obviously using a real
global on the main thread. I'm less confident in removing the check for
CycleCollectedJSContext::Get()->MicroTaskLevel(), but it should be ok since the
assertion wasn't failing already.

I'm leaving the profiler label "JSExecutionContext" intact for now so there's
no change in recorded profiles, but we should consider a better name for it in
the future.

Attachment #9417535 - Attachment description: WIP: Bug 1724236 - Move error tracking to JSExecutionContext caller → Bug 1724236 - Move error tracking to JSExecutionContext caller r=arai!
Attachment #9417536 - Attachment description: WIP: Bug 1724236 - Get CompileOptions from function arguments instead of member → Bug 1724236 - Get CompileOptions from function arguments instead of member r=arai!
Attachment #9417537 - Attachment description: WIP: Bug 1724236 - Get encodeBytecode and coerceToString from function arguments instead of members → Bug 1724236 - Get encodeBytecode and coerceToString from function arguments instead of members r=arai!
Attachment #9417538 - Attachment description: WIP: Bug 1724236 - Move profiler label and JSAutoRealm out of JSExecutionContext → Bug 1724236 - Move profiler label and JSAutoRealm out of JSExecutionContext r=arai!
Attachment #9417539 - Attachment description: WIP: Bug 1724236 - Check options directly if script wants return value → Bug 1724236 - Check options directly if script wants return value r=arai!
Attachment #9417540 - Attachment description: WIP: Bug 1724236 - Pass script as function argument instead of member → Bug 1724236 - Pass script as function argument instead of member r=arai!
Attachment #9417541 - Attachment description: WIP: Bug 1724236 - Pass cx as function argument instead of member → Bug 1724236 - Pass cx as function argument instead of member r=arai!
Attachment #9417542 - Attachment description: WIP: Bug 1724236 - Move ExecScript out of JSExecutionContext → Bug 1724236 - Move ExecScript out of JSExecutionContext r=arai!
Attachment #9417543 - Attachment description: WIP: Bug 1724236 - Move InstantiateStencil out of Compile and Decode → Bug 1724236 - Move InstantiateStencil out of Compile and Decode r=arai!
Attachment #9425033 - Attachment description: WIP: Bug 1724236 - Move stencil duplication out of InternalCompile(), JoinOffThread(), and Decode() → Bug 1724236 - Move stencil duplication out of InternalCompile(), JoinOffThread(), and Decode() r=arai!
Attachment #9417544 - Attachment description: WIP: Bug 1724236 - Move Compile and Decode out of JSExecutionContext → Bug 1724236 - Move Compile and Decode out of JSExecutionContext r=arai!
Attachment #9417545 - Attachment description: WIP: Bug 1724236 - Inline ExecScript and move ExecScriptAndCoerceString to where it is used → Bug 1724236 - Inline ExecScript and move ExecScriptAndCoerceString to where it is used r=arai!
Attachment #9417546 - Attachment description: WIP: Bug 1724236 - Inline Compile(JS::SourceText) → Bug 1724236 - Inline Compile(JS::SourceText) r=arai!
Attachment #9417547 - Attachment description: WIP: Bug 1724236 - Move Decode to ScriptLoader → Bug 1724236 - Move Decode to ScriptLoader r=arai!
Attachment #9417548 - Attachment description: WIP: Bug 1724236 - Pass debugger parameters as arguments instead of members → Bug 1724236 - Pass debugger parameters as arguments instead of members r=arai!
Attachment #9417549 - Attachment description: WIP: Bug 1724236 - Move JoinOffThread and InstantiateStencil out of JSExecutionContext → Bug 1724236 - Move JoinOffThread and InstantiateStencil out of JSExecutionContext r=arai!
Attachment #9417550 - Attachment description: WIP: Bug 1724236 - Move JoinOffThread to ScriptLoader → Bug 1724236 - Move JoinOffThread to ScriptLoader r=arai!
Attachment #9417551 - Attachment description: WIP: Bug 1724236 - Remove JSExecutionContext → Bug 1724236 - Remove JSExecutionContext r=arai!
Attachment #9417552 - Attachment description: WIP: Bug 1724236 - Rename JSExecutionUtils from JSExecutionContext → Bug 1724236 - Rename JSExecutionUtils from JSExecutionContext r=arai!
Attachment #9425030 - Attachment description: WIP: Bug 1724236 - Inline InstantiateStencil(cx, options, stencil, script) → Bug 1724236 - Inline InstantiateStencil(cx, options, stencil, script) r=arai!
Attachment #9425031 - Attachment description: WIP: Bug 1724236 - Move InstantiateStencil() to ScriptLoader → Bug 1724236 - Move InstantiateStencil() to ScriptLoader r=arai!
Attachment #9417535 - Attachment description: Bug 1724236 - Move error tracking to JSExecutionContext caller r=arai! → Bug 1724236 - Move error tracking to JSExecutionContext callers r=arai!
Attachment #9430407 - Attachment description: WIP: Bug 1724236 - Move InstantiateStencil call out of JoinOffThread → Bug 1724236 - Move InstantiateStencil call out of JoinOffThread r=arai!
Attachment #9425033 - Attachment description: Bug 1724236 - Move stencil duplication out of InternalCompile(), JoinOffThread(), and Decode() r=arai! → Bug 1724236 - Move stencil duplication out of JoinOffThread, Decode, Compile r=arai!
Attachment #9417550 - Attachment description: Bug 1724236 - Move JoinOffThread to ScriptLoader r=arai! → Bug 1724236 - Inline JoinOffThread r=arai!
Pushed by bthrall@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/5f393558af46 Move error tracking to JSExecutionContext callers r=arai https://hg.mozilla.org/integration/autoland/rev/6b848af68b04 Simplify error handling via ErrorResult r=arai https://hg.mozilla.org/integration/autoland/rev/e639f1a9629f Get CompileOptions from function arguments instead of member r=arai https://hg.mozilla.org/integration/autoland/rev/1a3d0a484cc7 Get encodeBytecode and coerceToString from function arguments instead of members r=arai https://hg.mozilla.org/integration/autoland/rev/a9662e54468c Move profiler label and JSAutoRealm out of JSExecutionContext r=arai https://hg.mozilla.org/integration/autoland/rev/a5c8b186811b Check options directly if script wants return value r=arai https://hg.mozilla.org/integration/autoland/rev/f74774467596 Pass script as function argument instead of member r=arai https://hg.mozilla.org/integration/autoland/rev/617a207931b0 Pass cx as function argument instead of member r=arai https://hg.mozilla.org/integration/autoland/rev/cc1882488435 Move ExecScript out of JSExecutionContext r=arai https://hg.mozilla.org/integration/autoland/rev/7b334fe58713 Move InstantiateStencil out of Compile and Decode r=arai https://hg.mozilla.org/integration/autoland/rev/71cceb0503ab Move InstantiateStencil call out of JoinOffThread r=arai https://hg.mozilla.org/integration/autoland/rev/6d67fc5a1f35 Move stencil duplication out of JoinOffThread, Decode, Compile r=arai https://hg.mozilla.org/integration/autoland/rev/4ca74ab38fb2 Move Compile and Decode out of JSExecutionContext r=arai https://hg.mozilla.org/integration/autoland/rev/0e62b884ada0 Inline ExecScript and move ExecScriptAndCoerceString to where it is used r=arai https://hg.mozilla.org/integration/autoland/rev/fea0294e3205 Inline Compile(JS::SourceText) r=arai https://hg.mozilla.org/integration/autoland/rev/62b9acbd2a69 Move Decode to ScriptLoader r=arai https://hg.mozilla.org/integration/autoland/rev/a951b39e3346 Pass debugger parameters as arguments instead of members r=arai https://hg.mozilla.org/integration/autoland/rev/0233a41b9f9c Move JoinOffThread and InstantiateStencil out of JSExecutionContext r=arai https://hg.mozilla.org/integration/autoland/rev/fecec3d85af1 Inline JoinOffThread r=arai https://hg.mozilla.org/integration/autoland/rev/f966c15bbee6 Remove JSExecutionContext r=arai https://hg.mozilla.org/integration/autoland/rev/542fd2b11f0b Rename JSExecutionUtils from JSExecutionContext r=arai https://hg.mozilla.org/integration/autoland/rev/9bbb86e07d45 Inline InstantiateStencil(cx, options, stencil, script) r=arai https://hg.mozilla.org/integration/autoland/rev/75093f3e947c Move InstantiateStencil() to ScriptLoader r=arai https://hg.mozilla.org/integration/autoland/rev/ce9f60c59095 Perform early return on permission check r=arai
Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 134 Branch
Regressions: 1929227
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: