Posts: 1.157
Threads: 11
Joined: Dec 2008
Reputation:
4
Well. First of all, there is a kind of operations named "jumpes". For example, jump on calculated address, that stored in some register. If we do static compilation, than we should store virtual store table for EVERY operand of code (or we could have a lot of NOPs and translate one command in fixed lenght sequence, but it's stupid choice). Right now such jumpes triggered new translation sequence (well, I look at this code 2000 revisions ago, so it could be changed), and vtlb addressing routine is highly effective.
Second, there is self modifying code, that simple could not be staticaly translated at all. In "normal" programming style modifying code is forbidden, but for PS2 programmers such trick are osometimes unawoidable
Third (and may be most important) is timing scheme. PS2 system consist form few parts, that are functioned "as whole" with help of rather cleverly made and fast system. Several parts should not be working correcly if you don't made correct timings, and it's rather unpredictable outside runtime.
Posts: 730
Threads: 29
Joined: Nov 2008
Reputation:
20
05-14-2010, 10:04 PM
(This post was last modified: 05-14-2010, 10:51 PM by cottonvibes.)
Static recompilation won't work out in a way that would be useful.
Basically the static recompiled resulting program will still have to use a lot of dynamic recompilation since many things won't be known at the time at static recompilation.
The more vigerous you want the static recompilation to be, the more you have to make assumptions about the game's code.
This effectively means worse and worse compatibility.
Stuff like self-modifying code need dynamic recompilation techniques and the result of the SMC can't be predicted most of the time (or else they wouldn't have been using SMC in the first place).
Anyways static recompilation for pcsx2 isn't a good idea...
Posts: 195
Threads: 0
Joined: Feb 2009
Reputation:
5
I've already said most of what I think needs saying on the topic, but the SMC code issue should be addressed.
PS2 games do not use SMC. No, really, they don't. (I do in some of my own test programs but game programmers have more of a life.)
What they do is load and unload modules which is a similar problem for emulator developers as the code can be different when you revisit an instruction, but there are ways to avoid checking all the time as the loading is done with DMA. (We don't do this yet.)
Complicating the issue, we protect pages in order to detect modifications to them but games (...and the kernel) often keep code and data within the same page. Most blocks that pcsx2 installs manual protection on are victims of this, not actual modification.
Posts: 9.761
Threads: 163
Joined: Dec 2008
Reputation:
154
05-15-2010, 06:05 PM
(This post was last modified: 05-15-2010, 06:20 PM by Shadow Lady.)
(05-15-2010, 03:57 PM)tommy87 Wrote: what do you think is on a PS2 disc? Bananas?
I knew it!
But no... you're mistaking what the source code is...
Core i5 3570k -- Geforce GTX 670 -- Windows 7 x64
Posts: 2
Threads: 0
Joined: May 2010
Reputation:
0
I remember I had asked a similar question to the OP's question back on the generalemu board. echosierra set me straight with many of the same ideas the fine developers of pcsx2 have stated in this thread (though I didn't make the follow claims [about which I will not comment] that tommy87 is now making).
One idea I was wondering though is whether there is any caching in the dynamic recompiler between uses of the same code block? i.e. when an RPG moves from world screen to fight screen, can (is?) the fight screen start up code's dynamic recompiled code be reused?
And if so, couldn't this then be cached in a file for the next time pcsx2 emulates that game. Or do the same pitfalls related to memory pointers etc. obviate the possibility or the benefits of?
Posts: 7.414
Threads: 66
Joined: Nov 2008
Reputation:
122
Location: Germany
If you mean profiling then yea we do that.
So lemme get this straight:
Native PS2 machine code (heavily optimized by various compilers for EE / VU) is the same to you as the original game sources?