-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Avoid generating machine code repeatly for same basic block #378
Conversation
172daff
to
eb9221c
Compare
@@ -56,7 +56,8 @@ | |||
#define JIT_OP_MOD_REG (JIT_CLS_ALU | JIT_SRC_REG | 0x90) | |||
|
|||
#define STACK_SIZE 512 | |||
#define MAX_INSNS 1024 | |||
#define MAX_JUMPS 1024 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you show empirical adjustments for both MAX_JUMPS
and MAX_INSNS
. I wonder how they can be calculated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The MAX_JUMPS
means the number of host branch instructions within a chained block collection need to be resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I modified MAX_INSNS
into MAX_BLOCKS
because it refers to the total number of basic blocks within our code cache. Considering that our block cache size is 4096 and some blocks may be replaced, I set MAX_BLOCKS
to 8192.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drop the trailing dot in the subject of git commit messages.
See https://cbea.ms/git-commit/
eb9221c
to
963b225
Compare
We set 256 as the threshold because we recorded 16 indirect jumps, and the threshold for launching T1C is 4096. This modification also saves code cache space by avoiding storing the machine code with less usage.
Originally, every execution path had its own machine code. Therefore, even if some basic blocks had been traced in other execution paths, we still generated a new copy of machine code. To use the code cache space more efficiently, we modified the recorded table to be global, allowing every execution path to share the machine code. This modification ensures that every basic block has only one copy of machine code, thus saving code cache space. For example, the code cache stored 1,926,471 (1.9 MB) bytes of machine code for AES previously. After the modification, the code cache stored 182,730 (0.18 MB) bytes of machine code.
963b225
to
8be2b88
Compare
Avoid generating machine code repeatly for same basic block
Originally, every execution path had its own machine code. Therefore, even if some basic blocks had been traced in other execution paths, we still generated a new copy of machine code. To use the code cache space more efficiently, we modified the recorded table to be global, allowing every execution path to share the machine code. This modification ensures that every basic block has only one copy of machine code, thus saving code cache space.
For example, the code cache stored 1,926,471 (1.9 MB) bytes of machine code for AES previously. After the modification, the code cache stored 182,730 (0.18 MB) bytes of machine code.