Closed Bug 1677580 Opened 4 years ago Closed 4 years ago

Remove JSop::Def{Var,Let,Const,Fun} opcodes

Categories

(Core :: JavaScript Engine, task, P2)

task

Tracking

()

RESOLVED FIXED
85 Branch
Tracking Status
firefox85 --- fixed

People

(Reporter: tcampbell, Assigned: tcampbell)

Details

Attachments

(4 files)

For global/eval scripts, we emit both CheckGlobalOrEvalDecl and a list of Def{Var,Let,Const} ops in prologue.

The implementations of these ops the JITs are simply CallVM and the distinct opcode per-binding does not gain us anything. The list of bindings can also be derived directly from the js::Scope binding list.

In an example like the large JS bundle on GMail that is compiled from Clojure, there are over 11,000 bindings in the prologue which consumes at least 12% of the top-level script bytecode.

Introducing a GlobalOrEvalDeclInstantiation operation would reduce the amount of bytecode and simplify code. It also is a bit closer to the spec which performs the redeclaration check and initialization in same internal method.

(This also frees up three opcode IDs)

This replaces CheckGlobalOrEvalDecl with an operation that also performs the
initialization. This let's us remove Def{Var,Let,Const} opcodes from our
prologue which can generate amount of duplicate data on complex sites that
are translated from languages such as Clojure. Subsequent patches will remove
the Def* opcodes altogether.

This change only applies to global/eval scripts and the existing JIT
behaviour (for example with eager flag) used a CallVM for each binding, so
we are no worse off performance-wise.

We should also remove DefFun in a similar way. The top-level function indices are contiguous, so the GlobalOrEvalDeclInstantiation opcode can take a start/end index into the gcthings array.

Summary: Remove JSop::Dev{Var,Let,Const} opcodes → Remove JSop::Dev{Var,Let,Const,Fun} opcodes
Summary: Remove JSop::Dev{Var,Let,Const,Fun} opcodes → Remove JSop::Def{Var,Let,Const,Fun} opcodes

Subsequent patches will absorb the Def* opcodes into this one to be better
align with the ECMAScript spec. We add a GCThingIndex argument as well that
will later be used to identify top-level function declarations.

This refactors the generation of Def* opcodes into a single
emitDeclarationInstantiation method. This will allow the Def* opcodes to be
later be removed entirely.

NOTE: In the sloppy-eval case with lexicals, this change results in the
GlobalOrEvalDeclInstantiation opcode being emitted after the eval lexical
environment is emitted.

Depends on D97502

Attachment #9188141 - Attachment description: Bug 1677580 - Add JSOp::GlobalOrEvalDeclInstantiation → Bug 1677580 - Allow JSOp::GlobalOrEvalDeclInstantiation to initialize bindings
Attachment #9188142 - Attachment description: Bug 1677580 - Remove JSOp::Dev{Var,Let,Const} opcodes → Bug 1677580 - Remove JSOp::Dev{Var,Let,Const,Fun} opcodes
Attachment #9188694 - Attachment description: Bug 1677580 - Rename JSOp::CheckGlobalOrEvalDecl to GlobalOrEvalDeclInstantiation → Bug 1677580 - Rename JSOp::CheckGlobalOrEvalDecl to GlobalOrEvalDeclInstantiation. r?jandem!
Attachment #9188695 - Attachment description: Bug 1677580 - Add BytecodeEmitter::emitDeclarationInstantiation → Bug 1677580 - Add BytecodeEmitter::emitDeclarationInstantiation. r?jandem!
Attachment #9188141 - Attachment description: Bug 1677580 - Allow JSOp::GlobalOrEvalDeclInstantiation to initialize bindings → Bug 1677580 - Allow JSOp::GlobalOrEvalDeclInstantiation to initialize bindings. r?jandem!
Attachment #9188142 - Attachment description: Bug 1677580 - Remove JSOp::Dev{Var,Let,Const,Fun} opcodes → Bug 1677580 - Remove JSOp::Dev{Var,Let,Const,Fun} opcodes. r?jandem!
Attachment #9188142 - Attachment description: Bug 1677580 - Remove JSOp::Dev{Var,Let,Const,Fun} opcodes. r?jandem! → Bug 1677580 - Remove JSOp::Def{Var,Let,Const,Fun} opcodes. r?jandem!
Pushed by tcampbell@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/fd55f1950eb4
Rename JSOp::CheckGlobalOrEvalDecl to GlobalOrEvalDeclInstantiation. r=jandem
https://hg.mozilla.org/integration/autoland/rev/a25a8624af26
Add BytecodeEmitter::emitDeclarationInstantiation. r=jandem
https://hg.mozilla.org/integration/autoland/rev/443b10f29275
Allow JSOp::GlobalOrEvalDeclInstantiation to initialize bindings. r=jandem
https://hg.mozilla.org/integration/autoland/rev/3fc26b5eba84
Remove JSOp::Def{Var,Let,Const,Fun} opcodes. r=jandem
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: