PCSX2 Documentation/PCSX2 EE Recompiler: Difference between revisions

Jump to navigation Jump to search
Line 147: Line 147:
Often, you know the next block at compile it. So you can directly do the lookup at compilation and directly jump from block1 to block2. It allow to save a couple of instructions. Small loops really profit of this optimization.
Often, you know the next block at compile it. So you can directly do the lookup at compilation and directly jump from block1 to block2. It allow to save a couple of instructions. Small loops really profit of this optimization.


TO BE CONTINUED
This optimization requires that you keep a record of the x86 pointer at end of the block and the destination PC. You can have severals blocks that jump to the same PC so you need a multi map.
 
There are 2 ways to handle the link creation.
# You want to link to a block that already exists (let's call it a direct link).
## You get the x86 function pointer of the destination block.
## You update the jump instruction of the current block to jump to the destination block.
## You save the link to handle the removal of the destination block.
# You want to link to a block that doesn't exists (let's call it a deferred link).
## You get the x86 function pointer of the destination block.
## You update the jump instruction of the current block to jump to the '''recompiler dispatcher'''
## You save the link '''to update the jump instruction later when a new block is created'''. As previously, you keep the link information to handle the removal of destination block.
 
Every time you create a new block, you will check if the new block is the destination block of any blocks. If you have some hits, a link will be established. This way it will handle all deferred links.
 
Every time you delete a block, again you will check if the deleted block is the destination block of any blocks. If you have some hits, the link will be deleted. It is important to delete dangling link otherwise you might jump into the void.


=== The Block Manager ===
=== The Block Manager ===