runtime: add PSX_OVERLAY_REGION_FLOOR override for streamed-over text ranges

Some titles stream level code over pages inside their own static text
range (Driver 2 streams mission code over its boot text), leaving those
pages permanently diverged: below the overlay floor they are excluded
from overlay capture and fall into single-instruction dispatch thrash
(hundreds of thousands of one-instruction dispatches per window).

PSX_OVERLAY_REGION_FLOOR lowers the floor per title so diverged text
pages become overlay-cache candidates and chain through local flow.
Value is clamped above the kernel window; default behavior is unchanged
when the variable is unset. On Driver 2 this took text-blocked
interpreter work from 278M to 37M instructions per window.
This commit is contained in:
Alexandros Mandravillis
2026-08-19 16:47:15 +03:00
parent 9913b146cd
commit 4a30c5cc01
+14
View File
@@ -10897,6 +10897,20 @@ int main(int argc, char** argv) {
uint32_t text_end = (gc.load_address + gc.text_size) & 0x1FFFFFFFu;
if (text_end > 0x00010000u /* DIRTY_RAM_KERNEL_WINDOW_END */)
g_overlay_region_floor = text_end;
/* PSX_OVERLAY_REGION_FLOOR: per-title override for games whose TEXT
* range is itself partially overwritten by streamed level data
* (Driver 2 streams mission code over pages inside its static text
* range). Lowering the floor routes those regions through local-flow
* chaining and makes them overlay-cache candidates, so live-byte
* closures can own them instead of single-instruction dispatch
* thrash. Clamped to stay above the kernel window. */
{
const char* fenv = std::getenv("PSX_OVERLAY_REGION_FLOOR");
if (fenv && fenv[0]) {
uint32_t v = (uint32_t)strtoul(fenv, nullptr, 0) & 0x1FFFFFFFu;
if (v >= 0x00010000u) g_overlay_region_floor = v;
}
}
std::fprintf(stdout,
"psxrecomp: overlay_region_floor = 0x%05X (game text end)\n",
g_overlay_region_floor);