3 ms·
But you can still have video games implement their own form of dynamically loaded modules, which (to a jit) is the same problem as self modifying code. I know s
by tsomctl 9y ago
But you can still have video games implement their own form of dynamically loaded modules, which (to a jit) is the same problem as self modifying code. I know several PS2 games do this.
- a_t48 9y agoThis still isn't really common. Code size typically pales in comparison to data size.
- tsomctl 9y agoBut it's still something to be aware of, so that you don't have to make major architectural changes to your jit so that one game will work. It's a million and one little things like this that make emulators hard.
- monocasa 9y agoYeah, you'd probably want an indirect table for inter-page calls, with maybe a soft TLB for this translation if the profiler gave you good results. You might be able to bank on the idea that any processor you'd be running the generated code on will have so much better branch prediction and speculative execution than the 360, that you'll be able to fit in the cracks even with this extra overhead.
- monocasa 9y agoThe Xbox 360 explicitly supported this concept with "overlays" IIRC. https://en.wikipedia.org/wiki/Overlay_(programming) https://en.wikipedia.org/wiki/Overlay_(programming) It always seemed like a poor security choice to me, but some game binaries are inexplicably massive and break up easily depending on what phase of the game that you're on.
- hrydgard 9y agoIt is very common on the PSP. Even actual traditional self modifying code is not uncommon.
- phire 9y agoSure, in the PS2/gamecube era custom dynamically loaded code mechanisms were common. But on modern consoles (360, PS3 and later) the OS bans games from loading/generating code. To load code they must call out to the OS, which loads it, checks the signatures and puts it in write protected memory. It's this security mechanism which makes static recompilation viable for 360/PS3 games.