PCSX2 Documentation/PCSX2 EE Recompiler: Difference between revisions

Jump to navigation Jump to search
Line 118: Line 118:


== Blocks Management ==
== Blocks Management ==
=== Extended Base Block ===
Recompiler handles code by block. The standard base block was already disccussed above *TODO ADD A LINK*. The standard base block is rather primitive and allow only a translation from EE's PC to the x86 buffer address. It is the minimum to run but it isn't enough to manage them so they're extended to '''BASEBLOCKEX'''. This new structure contains both the EE's PC and x86 buffer address with their respective code segment size. Note: EE instructions have a constant size of 4 bytes so you can store directly the number of instructions. However X86 instructions have a variable length so you only have a byte length. An extended base block will be created every time you recompile a new block.
All extended base blocks are aggregated into a map/array class named '''BaseBlockArray'''. It has the following properties
# Entries are indexed with a continuous index. I.e. if you have 10 elements, they will be placed from index 0 to 9.
#* It means that every addition/removal will move the element (also know as self-balancing tree).
# Entries are sorted on the ascending order of EE's PC.
#* Be aware that block can overlap. So the Nth entry can finish before the previous N-1th entry.
# Lookups are implemented as a binary search. Easy to implement due to the 2 previous properties.
=== Block Link ===
At the end of execution of a block you have 2 possibilities
* Block was rather big so you will
# update the event
# lookup the next block
# then execute it
* Block was small so you will
# lookup the next block
# then execute it
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
=== The Block Manager ===


== Code Generation ==
== Code Generation ==
ninja
56

edits

Navigation menu