Open Bug 1899502 Opened 1 year ago Updated 5 months ago

Optimise scope object creation for explicit resource management

Categories

(Core :: JavaScript Engine, enhancement, P3)

enhancement

Tracking

()

People

(Reporter: debadree333, Unassigned)

References

(Blocks 1 open bug)

Details

No description provided.
Blocks: 1569081
Status: UNCONFIRMED → NEW
Ever confirmed: true
Severity: -- → N/A
Priority: -- → P3

Ideas on how it can be improved:

Presently we store disposables inside an Environment Object [1] and we emit a dispose loop when we leave the scope [2] this might be inefficient now it is possible to instead create branching try {} finally s every time we encounter a using decl [3] but that is presently blocked by the allowance of using decls in base switch cases [3] so as and when the present implementation's performance becomes a concern we can consider reimplmenting the bytecode like this.

Some further idea reagarding switch case being a blocker we already store whether the block we are entering is a switch case block here [4] so it might not be impossible to implement the unrolling here.

[1] https://searchfox.org/mozilla-central/source/js/src/vm/EnvironmentObject.h#512
[2] https://searchfox.org/mozilla-central/source/js/src/frontend/UsingEmitter.cpp#206
[3] https://github.com/tc39/proposal-explicit-resource-management/issues/215#issuecomment-2302865619
[4] https://searchfox.org/mozilla-central/source/js/src/frontend/EmitterScope.h#61

Blocks: 1930461
No longer blocks: 1569081

We've got consensus to merge https://github.com/rbuckton/ecma262/pull/14 at the April 2025 TC39 plenary, so the branching try {} optimization should now be unblocked, as we no longer using decls in bare switch cases :)

I believe we'd want to implement this optimization prior to shipping Explicit Resource Management.

Hmm the branching implementation i believe would probably be a full rewrite 😅 nonetheless will give it a try and for now will submit a patch to implement the pr!

Blocks: 1967744
No longer blocks: 1967744
Depends on: 1969430
You need to log in before you can comment on or make changes to this bug.