Friday, December 5, 2008

OSHLE for new dynarec

I spend some time to work on Daedalus. One big change I made is adding back the support of OSHLE.

OS HLE is a technology to simulate a "Operation System Call" in high level, which will bring some significant performance increase. However the limitation is obversious. You have to find out every os functions from ROM, understand the funcationality and implement the patch functions in C.

Originally, Daedalus has about 100 os functions which already be understanded. The approach is using a invalid OP to replace the first instruction in os function call. When the simulation reads this special op (OP_PATCH), the patched functions will be called.

I am not quite sure why oshle is not enabled in original Daedalus version. I guess that the problem is the original approach make it hand to handle the os function's return. (os function may use ret and eret as return. If you are fimiliar with x86 assembly, these are same as ret and iret.)

So I decide to use a different approach instead of patch the instruction. This new method make it is easy to integrate oshle patch function to new dynarec engine. For every os patch function, I create a Fragment. The fragment will be used as a normal fragment. I got the benifit like fragment linking for free. (If you want to learn more about dynarec engine. Please refer this paper: Dynamo: A Transparent Dynamic Optimization System)

Inside fragement, I dynamically generate the call to the patch function. Then emit the code to check the return code. Based on the return code, the indirect exit (RET) stub or the ERET exit stub will be called corresponding.

1 comment:

Unknown said...

so you are saying there can be "some significant performance increase." if OSHLE is enabled. i playing around with rev. 95 right now. it is very nice although there are a lot of bugs, hope that can be fixed someday ;)

but my question is however the significant performance increase is done now or if there can be more speed out of this method? would be soo cool if you could juice it up a little bit more :D

many thanx for coding on DX64, its hopefully going to be the best emulator for the psp :)

my daughter (who is 1 year old) and I play Mario 64 on my psp now and then, she loves it! best wishes in the future from us :)