Closed Bug 1759123 Opened 2 years ago Closed 9 months ago

Remove helper thread JSContexts


(Core :: JavaScript Engine, task, P2)




117 Branch
Tracking Status
firefox117 --- fixed


(Reporter: jandem, Assigned: arai)


(Depends on 1 open bug, Blocks 2 open bugs)



(5 files)

At this point helper threads only use a JSContext for the parse tasks. After Stencil, it should now be feasible to remove helper thread JSContexts completely. Remaining dependencies include things like:

  • Exception handling
  • Stack limit checks
  • TempAllocPolicy
  • cx->dtoaState

We could replace these uses with a stack-allocated class that contains just the data the frontend needs (ParseContext is already taken, let's call it FrontendContext for now). This would let us decouple the frontend from JSContext, very similar to how other Stencil changes decoupled the parser from the VM.

For the stack limit checks, we could copy the stack limit from the main thread's JSContext to the FrontendContext if we're parsing on the main thread. If we're parsing off-thread, we would do something similar to what we do now in JSContext::setHelperThread.

When parsing is finished, exceptions would be converted from the FrontendContext to an actual JS exception in JSContext. This will let us unify exception handling in the frontend (instead of having different code paths for main thread vs helper thread contexts).

Severity: normal → N/A
Priority: -- → P2
See Also: → 1761581

Bug 1770158 and bug 1771874 will take care of cx->dtoaState. (The remaining use is for non-base-10 double to string conversion and that's not used by the frontend.)

Depends on: 1770158, 1771874
Blocks: 1773319
Depends on: 1773324
Depends on: 1773335
Depends on: 1781008
Depends on: 1781255
Depends on: 1782569
Depends on: 1782571
Depends on: 1782573
Depends on: 1782706
Depends on: 1783935
Depends on: 1783951
Depends on: 1785762
Depends on: 1786117
Depends on: 1786819
Depends on: 1786834
Depends on: 1787528
Depends on: 1797024
Depends on: 1797183
Whiteboard: [orb:m1]
Depends on: 1804613
Depends on: 1804837
Depends on: 1805141
Depends on: 1805622
Depends on: 1805856
Depends on: 1806366
No longer depends on: 1806366
Depends on: 1806499
Depends on: 1806744
Depends on: 1807216
Depends on: 1808216
Depends on: 1808881
Whiteboard: [orb:m1] → [orb:m2]

The ORB M1 milestone can use existing parser APIs, so we can move this to M2 as potential performance work.

No longer blocks: 1773319
Whiteboard: [orb:m2]
Depends on: 1827773
Depends on: 1840350
Depends on: 1843028
Depends on: 1843965
Assignee: nobody → arai.unmht

Depends on D183843

Depends on D183845

Pushed by
Part 1: Remove GlobalHelperThreadState::helperContexts_. r=nbp
Part 2: Remove JSContext::isHelperThreadContext. r=nbp
Part 3: Remove JSContext::errors_. r=nbp
Part 4: Remove JSContext::isMainThreadContext. r=nbp
Part 5: Remove JSContext::kind_. r=nbp
Blocks: 1845074
Depends on: 1857536
You need to log in before you can comment on or make changes to this bug.