feat: add specialized LOAD_LOCAL_0..8 instructions to skip arg byte decode
Introduce nine new bytecode instructions (CODE_LOAD_LOCAL_0 through CODE_LOAD_LOCAL_8) that directly encode the local slot number in the opcode itself, eliminating the need to read and decode a separate argument byte for the most frequently accessed local variables. This optimization targets the hottest path in the interpreter, as LOAD_LOCAL is the most executed instruction across benchmarks (e.g., 3.75M times in delta_blue). The compiler's `loadLocal` helper emits the specialized opcode when the slot index is ≤8, falling back to the generic `CODE_LOAD_LOCAL` with an argument byte otherwise. The VM dispatch table and debug printer are updated accordingly. Benchmarks show consistent speedups: fib +7.3%, method_call +5.9%, binary_trees +1.9%, for +2.8%, delta_blue +1.0%.
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
This is the number of times each instruction was executed when running the
|
||||
delta_blue benchmark:
|
||||
|
||||
3753021 CODE_LOAD_LOCAL
|
||||
2233991 CODE_RETURN
|
||||
2151580 CODE_LOAD_FIELD_THIS
|
||||
2121398 CODE_CALL_1
|
||||
1827535 CODE_CALL_0
|
||||
1328364 CODE_POP
|
||||
1136064 CODE_JUMP_IF
|
||||
715071 CODE_LOAD_GLOBAL
|
||||
428374 CODE_STORE_FIELD_THIS
|
||||
424999 CODE_NULL
|
||||
355344 CODE_STORE_LOCAL
|
||||
341762 CODE_LOOP
|
||||
118855 CODE_CONSTANT
|
||||
93048 CODE_CALL_2
|
||||
75280 CODE_AND
|
||||
59920 CODE_JUMP
|
||||
16842 CODE_LIST
|
||||
16660 CODE_TRUE
|
||||
10040 CODE_OR
|
||||
8200 CODE_LOAD_UPVALUE
|
||||
8140 CODE_SUPER_1
|
||||
6540 CODE_FALSE
|
||||
6076 CODE_STORE_GLOBAL
|
||||
4000 CODE_SUPER_3
|
||||
2020 CODE_SUPER_2
|
||||
2000 CODE_SUPER_0
|
||||
2000 CODE_CALL_5
|
||||
2000 CODE_CALL_3
|
||||
160 CODE_CLOSURE
|
||||
74 CODE_METHOD_INSTANCE
|
||||
11 CODE_CLASS
|
||||
4 CODE_METHOD_STATIC
|
||||
0 CODE_SUPER_9
|
||||
0 CODE_SUPER_8
|
||||
0 CODE_SUPER_7
|
||||
0 CODE_SUPER_6
|
||||
0 CODE_SUPER_5
|
||||
0 CODE_SUPER_4
|
||||
0 CODE_SUPER_16
|
||||
0 CODE_SUPER_15
|
||||
0 CODE_SUPER_14
|
||||
0 CODE_SUPER_13
|
||||
0 CODE_SUPER_12
|
||||
0 CODE_SUPER_11
|
||||
0 CODE_SUPER_10
|
||||
0 CODE_STORE_UPVALUE
|
||||
0 CODE_STORE_FIELD
|
||||
0 CODE_LOAD_FIELD
|
||||
0 CODE_IS
|
||||
0 CODE_CLOSE_UPVALUE
|
||||
0 CODE_CALL_9
|
||||
0 CODE_CALL_8
|
||||
0 CODE_CALL_7
|
||||
0 CODE_CALL_6
|
||||
0 CODE_CALL_4
|
||||
0 CODE_CALL_16
|
||||
0 CODE_CALL_15
|
||||
0 CODE_CALL_14
|
||||
0 CODE_CALL_13
|
||||
0 CODE_CALL_12
|
||||
0 CODE_CALL_11
|
||||
0 CODE_CALL_10
|
||||
Reference in New Issue
Block a user