mirror of
https://github.com/ran-j/PS2Recomp.git
synced 2026-09-27 01:03:31 -04:00
Don't promote a whole function because of an indirect call
When a computed jump cannot be resolved to a jump table, every instruction in the function becomes an entry point, because the jump could land on any of them. That fallback was also applied to JALR, which is not a jump but a call: it transfers control to another function and returns to the instruction after the delay slot. That return address is already queued as a resume target a few lines above, so nothing else in the function needs to be reachable from outside. Indirect calls are ordinary code -- function pointers, virtual dispatch, callbacks -- so the fallback fired constantly. On a 3 MB PS2 executable, 2,210 of the 2,422 unresolved sites were JALR, and 1,078 of the 1,282 affected functions contained no unresolved jump at all. Restrict the fallback to JR. Promoted entries drop from 189,876 to 1,688, registered table entries from 156,783 to 75,386, the generated registration file from 13 MB to 6 MB, and total output from 180 MB to 163 MB. Every indirect call site in real code keeps its return-address resume entry (the only sites that lose one are bogus functions carved out of rodata, where the address is outside the function anyway).
This commit is contained in:
@@ -385,7 +385,14 @@ namespace ps2recomp
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!foundTable)
|
||||
// Only an unresolved computed *jump* can land on an arbitrary
|
||||
// instruction of this function and therefore force every address to
|
||||
// become an entry point. JALR is a call: it transfers control to
|
||||
// another function and comes back to the instruction after the delay
|
||||
// slot, which is already queued as a resume target above. Treating a
|
||||
// call like a jump here promotes the whole function for what is
|
||||
// usually just a function pointer or virtual dispatch.
|
||||
if (!foundTable && jrInst->function != SPECIAL_JALR)
|
||||
{
|
||||
needsIndirectFallback = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user