First post, by M-HT
Hi,
I have some ideas about speeding up the dynrec (both old (x86) and new (non-x86)).
Idea 1:
When translating the instruction stream and the maximum number of instructions is reached, the code block is closed and exited.
The idea is to link the block to the following block (something like when doing unconditional short/near jump).
Implementation for the non-x86 dynrec is in the attached file - decoder.h
Idea 2:
If an instruction uses immediate value (as an operand or in memory access) the value is not encoded in the translated code, but it's read from original instruction stream.
This helps the self-modifying code (SMC), because if only the immediate value is changed the code doesn't need to be translated again.
But, it's also slower than encoding the immediate value in the translated code because the generated code is (slightly) longer and there's one more memory access when executing the code.
The idea is to encode the immediate value in the translated code unless the immediate value was changed by the SMC - in this case the immediate value is read from original instruction stream (like it's now).
That means that when a code block is translated for the first time, the immediate value is encoded in the translated code. When the SMC changes the immediate value, the code block is translated again, but this time the immediate value is read from original instruction stream.
Implementation for the non-x86 dynrec (modified functions decode_fetchb_imm, decode_fetchw_imm and decode_fetchd_imm) is in the attached file - decoder_basic.h
I don't know if there are some disadvantages in these ideas (or my implementations), but if there are some, I would like to know them.
I also have a question related to idea 2 - in non-x86 dynrec, some instructions use function dyn_dop_word_imm (which reads immediate values from original instruction stream) and some instructions use function dyn_dop_word_imm_old (which encodes immediate values in the translated code) - the question is why ?
And lastly an observation - in the latest version of file core_dynrec.cpp (in cvs) a new definition was added - POWERPC, but it has the same value as ARMV4LE. Also, new include is referenced (core_dynrec/risc_ppc.h), which isn't in the cvs.