mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 10:07:15 +02:00
Instead of storing a u32 index into a cache vector and looking up the cache at runtime through a chain of dependent loads (load Executable*, load vector data pointer, multiply index, add), store the actual cache pointer as a u64 directly in the instruction stream. A fixup pass (Executable::fixup_cache_pointers()) runs after Executable construction in both the Rust and C++ pipelines, walking the bytecode and replacing each index with the corresponding pointer. The cache pointer type is encoded in Bytecode.def (e.g. PropertyLookupCache*, GlobalVariableCache*) so the fixup switch is auto-generated by the Python Op code generator, making it impossible to forget updating the fixup when adding new cached instructions. This eliminates 3-4 dependent loads on every inline cache access in both the C++ interpreter and the assembly interpreter.
29 lines
1.4 KiB
Plaintext
29 lines
1.4 KiB
Plaintext
JS bytecode executable ""
|
|
[ 0] 0: GetLexicalEnvironment dst:reg4
|
|
[ 8] GetGlobal dst:reg6, identifier:f
|
|
[ 20] Call dst:reg5, callee:reg6, this_value:Undefined, f, arguments:[Int32(1), Int32(2), Int32(3)]
|
|
[ 50] End value:reg5
|
|
|
|
JS bytecode executable "f"
|
|
[ 0] 0: GetLexicalEnvironment dst:reg4
|
|
[ 8] CreateVariable identifier:a, is_immutable:false, is_global:false, is_strict:false
|
|
[ 18] CreateVariable identifier:b, is_immutable:false, is_global:false, is_strict:false
|
|
[ 28] CreateVariable identifier:c, is_immutable:false, is_global:false, is_strict:false
|
|
[ 38] InitializeLexicalBinding identifier:a, src:arg0
|
|
[ 50] InitializeLexicalBinding identifier:b, src:arg1
|
|
[ 68] InitializeLexicalBinding identifier:c, src:arg2
|
|
[ 80] Mov dst:inner~0, src:Undefined
|
|
[ 90] NewFunction dst:reg5, shared_function_data_index:0, lhs_name:inner
|
|
[ a8] Mov dst:inner~0, src:reg5
|
|
[ b8] Mov dst:reg6, src:inner~0
|
|
[ c8] Call dst:reg5, callee:reg6, this_value:Undefined, inner
|
|
[ e8] Return value:reg5
|
|
|
|
JS bytecode executable "inner"
|
|
[ 0] 0: GetLexicalEnvironment dst:reg4
|
|
[ 8] GetBinding dst:reg5, identifier:a
|
|
[ 20] GetBinding dst:reg6, identifier:b
|
|
[ 38] Add dst:reg7, lhs:reg5, rhs:reg6
|
|
[ 48] GetBinding dst:reg5, identifier:c
|
|
[ 60] Add dst:reg6, lhs:reg7, rhs:reg5
|
|
[ 70] Return value:reg6 |