-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve "JALR" execution with T2C JIT-cache
Currently, the "JALR" indirect jump instruction turns the mode of rv32emu from T2C back to the interpreter. This commit introduces a "JIT-cache" table lookup to make it redirect to the T2C JIT-ed code entry and avoid the mode change. There are several scenarios benefitting from this approach, e.g. function pointer invocation and far-way function call. The former like "qsort" can be speeded up by two times, and the latter like "fibonacci", which compiled from the hand-written assembly for creating "JALR" instructions, can even reach x4.8 performance enhencement.
- Loading branch information
Showing
8 changed files
with
187 additions
and
29 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
fib: | ||
li a5, 1 | ||
bleu a0, a5, .L3 | ||
addi sp, sp, -16 | ||
sw ra, 12(sp) | ||
sw s0, 8(sp) | ||
sw s1, 4(sp) | ||
mv s0, a0 | ||
addi a0, a0, -1 | ||
la t0, fib | ||
jalr ra, 0(t0) | ||
mv s1, a0 | ||
addi a0, s0, -2 | ||
la t0, fib | ||
jalr ra, 0(t0) | ||
add a0, s1, a0 | ||
lw ra, 12(sp) | ||
lw s0, 8(sp) | ||
lw s1, 4(sp) | ||
addi sp, sp, 16 | ||
jr ra | ||
.L3: | ||
li a0, 1 | ||
ret | ||
.LC0: | ||
.string "%d\n" | ||
.text | ||
.align 1 | ||
.globl main | ||
.type main, @function | ||
main: | ||
addi sp, sp, -16 | ||
sw ra, 12(sp) | ||
li a0, 42 | ||
call fib | ||
mv a1, a0 | ||
lui a0, %hi(.LC0) | ||
addi a0, a0, %lo(.LC0) | ||
call printf | ||
li a0, 0 | ||
lw ra, 12(sp) | ||
addi sp, sp, 16 | ||
jr ra |