mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-28 10:37:17 +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.
15 lines
862 B
Plaintext
15 lines
862 B
Plaintext
JS bytecode executable ""
|
|
[ 0] 0: GetLexicalEnvironment dst:reg4
|
|
[ 8] CreateLexicalEnvironment dst:reg5, parent:reg4, capacity:0
|
|
[ 18] CreateMutableBinding environment:reg5, identifier:f1, can_be_deleted:false
|
|
[ 28] NewFunction dst:reg6, shared_function_data_index:0
|
|
[ 40] InitializeLexicalBinding identifier:f1, src:reg6
|
|
[ 58] CreateMutableBinding environment:reg5, identifier:f2, can_be_deleted:false
|
|
[ 68] NewFunction dst:reg6, shared_function_data_index:1
|
|
[ 80] InitializeLexicalBinding identifier:f2, src:reg6
|
|
[ 98] GetBinding dst:reg6, identifier:f1
|
|
[ b0] SetVariableBinding identifier:f1, src:reg6
|
|
[ c8] GetBinding dst:reg6, identifier:f2
|
|
[ e0] SetVariableBinding identifier:f2, src:reg6
|
|
[ f8] SetLexicalEnvironment environment:reg4
|
|
[ 100] End value:Undefined |