-
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
Use computed-goto to lower instruction dispatch overhead #2
Conversation
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.
Change the subject (of pull request and git commit message) to "Use computed-goto to lower instruction dispatch overhead"
The commit message should be amended, mentioning the benefit of the proposed computed-goto change. |
+ This commit applies the computed goto technique to the main loop. This modification is tested to have 15 to 23 percent improvement on performance. + The old implementation of rv_step can be enabled by setting the environment variable ENABLE_COMPUTED_GOTO to 0. + Only clang and gcc is supported by computed goto feature, ENABLE_COMPUTED_GOTO will be ignored if other compiler is used. + An op_unimp handler is also added in order to acheive this. This also allows better handling of unimplemented opcodes instead of jumping into NULL.
7087c7f
to
3ecac53
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.
The commit message should provide the measurement (numbers) for speedup.
@sammer1107, would you continue this work recently? |
Thank @sammer1107 for contributing! |
-fsanitize=address report when CTRL+a x exiting: ================================================================= ==297977==ERROR: LeakSanitizer: detected memory leaks Direct leak of 23400 byte(s) in 117 object(s) allocated from: #0 0x761b706fd340 in calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:77 #1 0x633ad9c5e310 in block_translate src/emulate.c:649 sysprog21#2 0x633ad9c5e310 in block_find_or_translate src/emulate.c:865 sysprog21#3 0x633ad9c5e310 in rv_step src/emulate.c:1029 sysprog21#4 0x633ad9c5e310 in rv_run src/riscv.c:498 sysprog21#5 0x633ad9c5e310 in main src/main.c:279 Direct leak of 3136 byte(s) in 125 object(s) allocated from: #0 0x761b706fd9c7 in malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69 #1 0x633ad9c5fea4 in match_pattern src/emulate.c:767 sysprog21#2 0x633ad9c5fea4 in block_find_or_translate src/emulate.c:872 sysprog21#3 0x633ad9c5fea4 in rv_step src/emulate.c:1029 sysprog21#4 0x633ad9c5fea4 in rv_run src/riscv.c:498 sysprog21#5 0x633ad9c5fea4 in main src/main.c:279 Register a clean up callback, async_block_clear() to free all the allocated memory fix this when emulator exits.
Use computed-goto to lower instruction dispatch overhead
main loop. This modification is tested to have 15 to 23
percent improvement on performance.
by setting the environment variable ENABLE_COMPUTED_GOTO to 0.
ENABLE_COMPUTED_GOTO will be ignored if other compiler is used.
this. This also allows better handling of unimplemented
opcodes instead of jumping into NULL.