-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shorten the time spent checking instruction length #92
Shorten the time spent checking instruction length #92
Conversation
Once we complete the instruction decoding, we can definitely know the length of instruction(s) pointed by specific address. Would it make sense? |
Yes, we can know the length of instruction once instruction decoding completes. However, we should send a value to the exception handler if we want to reduce the number of times we check the instruction length. |
If we can look up the instruction length (RV32 vs. RV32C) from a specific address, there is no need to preserve extra parameter in exception handlers. Let's keep it simple and stupid (KISS principle). |
Sorry, I miss the important information that we get instruction length by parsing instruction opcode, instead of specific address. If we don't want to pass more parameter to exception handlers, we need to save more information in struct |
Since preliminary basic block was introduced, speculated execution can take place without frequent instruction length checks. That is, the explicit transition from 32-bit ISA to 16-bit counterpart (vice versa) can be lazily evaluated in a basic block. |
I think the idea above is checking instruction length in a basic block. However, there is a situation I am unsure whether it will occur or not. If a 32-bit instruction and a 16-bit compressed instruction coexist in the same basic block, it is unsafe to determine whether the instruction is compressed in basic block. |
We need to know the instruction is compressed or not when the exception occurred. So, I think that For example, rewrite instruction case rv_insn_jal: { /* JAL: Jump and Link */
...
/* check instruction misaligned */
if (insn_is_misaligned(rv->PC)) {
+ rv->compressed = false;
rv_except_insn_misaligned(rv, pc);
return false;
}
/* can branch */
return true;
} Therefore, we don't need to pass instruction length to exception handler and avoid to check |
Ok, I think it is better idea, I will follow this idea. |
55f30c9
to
3a6c4ff
Compare
3a6c4ff
to
3d36c67
Compare
b99b203
to
1f36f8b
Compare
87e36b9
to
0c39344
Compare
The commit |
0c39344
to
7f43836
Compare
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.
Read https://cbea.ms/git-commit/ carefully for writing informative git commit messages.
You should explain the purpose of the proposed changes as well as their advantages.
0f7858d
to
f202c3c
Compare
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.
Again, read https://cbea.ms/git-commit/ carefully.
Last but not least, clearly state how the proposed changes would be beneficial.
Move instruction length checking into exception block to avoid frequently checking. In the past, each time the function "emulate" was called, we had to check the instruction length. Actually, we only need to check the instruction length when the exception occurs; otherwise, we can simply set "rv->compressed" to the appropriate value before invoking the exception handler. By doing this, we can save the overhead of checking instruction length if exception doesn't occur. Resolves: sysprog21#92
f202c3c
to
cd8ebae
Compare
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.
Do you understand what Wrap the body at 72 characters means?
By the way, use QuillBot to improve your writing. |
I see, I need to change line when characters in a line more than 72. |
To avoid frequent instruction length checking, move checking into exception handler inoking block. Previously, we had to check the instruction length each time the function 'emulate' was called. Actually, we only need to check it when the exception occurs; otherwise, we can simply set 'rv->compressed' to the appropriate value before running the exception handler. By doing so, we can avoid the overhead of checking instruction length if an exception does not happen. Resolves: sysprog21#92
cd8ebae
to
4bbb2c3
Compare
To avoid frequent instruction length checking, move checking into exception handler block. Previously, we had to check the instruction length each time the function 'emulate' was called. Actually, we only need to check it when the exception occurs; otherwise, we can simply set rv->compressed to the appropriate value before running the exception handler. By doing so, we can avoid the overhead of checking instruction length if an exception does not happen.
I think we can pass the value of instruction length in IR to the exception handler rather than verifying it each time the emulate function is called, because we only need the value of rv->compressed in the exception handler.