Files
ladybird/Tests/LibJS/Bytecode/expected/eval-scope-optimization.txt
Andreas Kling 7f89158d20 LibJS: Replace implicit environment stack with explicit registers
Replace the saved_lexical_environments stack in ExecutionContextRareData
with explicit register-based environment tracking. Environments are now
stored in registers and restored via SetLexicalEnvironment, making the
environment flow visible in bytecode.

Key changes:
- Add GetLexicalEnvironment and SetLexicalEnvironment opcodes
- CreateLexicalEnvironment takes explicit parent and dst operands
- EnterObjectEnvironment stores new environment in a dst register
- NewClass takes an explicit class_environment operand
- Remove LeaveLexicalEnvironment opcode (instead: SetLexicalEnvironment)
- Remove saved_lexical_environments from ExecutionContextRareData
- Use a reserved register for the saved lexical environment to avoid
  dominance issues with lazily-emitted GetLexicalEnvironment
2026-02-09 16:35:39 +01:00

16 lines
718 B
Plaintext

JS bytecode executable ""
[ 0] 0: GetLexicalEnvironment dst:reg4
[ 8] GetGlobal dst:reg6, identifier:outer
[ 18] Call dst:reg5, callee:reg6, this_value:Undefined, outer
[ 38] End value:reg5
JS bytecode executable "outer"
[ 0] 0: GetLexicalEnvironment dst:reg4
[ 8] CreateVariable identifier:inner, is_immutable:false, is_global:false, is_strict:false
[ 18] InitializeVariableBinding identifier:inner, src:Undefined
[ 30] NewFunction dst:reg5
[ 48] SetVariableBinding identifier:inner, src:reg5
[ 60] GetGlobal dst:reg6, identifier:Number
[ 70] CallConstruct dst:reg5, callee:reg6, Number, arguments:[Int32(42)]
[ 90] Return value:reg5