Re: 26bit CPU support
Posted: Thu Dec 05, 2013 2:31 pm
It's just occurred to me that we can't use a DA to store the converted code...DA's are created above 64mb so would potentially overlap the PSR flags in registers. Creating a DA below 64mb isn't possible due to the restricted memory map - it's mostly taken up by Application space. The RMA is out as well, as it's above the 64mb boundry on the Pi. This leaves Application space.
If we increase Application space to the max (28mb on RO3.6-RO4.x), we can use the top 16mb for the JIT translated code / codelets.
This creates some further issues:
1. There's currently 12 known games that require more than 8mb of RAM. However, it's not as bad as it sounds as on RO3.6-RO4.x we only need to support SA incompatible games. The max RAM requirement there is currently 5mb (Emotions - Search for Humanity).
On a 32-bit OS, we can increase Application space by a larger amount, say 64mb and use the top 32mb for the JIT translated code / codelets. The max RAM requirement for a StrongARM compatible game is currently 18mb (Descent 2).
2. Some compilers back in the day, altered the stack (R13) to go from the top of Application space down. Provided we work upwards in the JIT space, we should hopefully avoid this issue.
The proposed memory map on RO3/4 will look as follows:
----------------------- 1B80000
....
JIT translated code
----------------------- 1380000
Codelets
....
----------------------- 1000000
....
Original code
----------------------- 8000
NOTE 1: The Codelets grow downwards from the top of their memory space
NOTE 2: It's not clear at this point if allocating 4mb to the Codelets is enough. Each Codelet is between 16 and 48 bytes depending on the instruction being translated, with 4mb we have space for about 131,000 translated instructions
NOTE 3: To handle self-modifying code, as pages are touched by the JIT, it flags them as read-only. Should an abort subsequently occur caused by a write, the matching word in the JIT translated code is checked to see if the write is going over an instruction we've previously processed (if it's not the instruction we use to enter the JIT, it must be an instruction), if it is, the write is allowed to the original code space and the equivalent instruction in JIT memory space is replaced with a jump back into the JIT to re-interpret it
If we increase Application space to the max (28mb on RO3.6-RO4.x), we can use the top 16mb for the JIT translated code / codelets.
This creates some further issues:
1. There's currently 12 known games that require more than 8mb of RAM. However, it's not as bad as it sounds as on RO3.6-RO4.x we only need to support SA incompatible games. The max RAM requirement there is currently 5mb (Emotions - Search for Humanity).
On a 32-bit OS, we can increase Application space by a larger amount, say 64mb and use the top 32mb for the JIT translated code / codelets. The max RAM requirement for a StrongARM compatible game is currently 18mb (Descent 2).
2. Some compilers back in the day, altered the stack (R13) to go from the top of Application space down. Provided we work upwards in the JIT space, we should hopefully avoid this issue.
The proposed memory map on RO3/4 will look as follows:
----------------------- 1B80000
....
JIT translated code
----------------------- 1380000
Codelets
....
----------------------- 1000000
....
Original code
----------------------- 8000
NOTE 1: The Codelets grow downwards from the top of their memory space
NOTE 2: It's not clear at this point if allocating 4mb to the Codelets is enough. Each Codelet is between 16 and 48 bytes depending on the instruction being translated, with 4mb we have space for about 131,000 translated instructions
NOTE 3: To handle self-modifying code, as pages are touched by the JIT, it flags them as read-only. Should an abort subsequently occur caused by a write, the matching word in the JIT translated code is checked to see if the write is going over an instruction we've previously processed (if it's not the instruction we use to enter the JIT, it must be an instruction), if it is, the write is allowed to the original code space and the equivalent instruction in JIT memory space is replaced with a jump back into the JIT to re-interpret it