mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-26 02:11:36 -04:00
9ed788f125
Persist validated sljit shards across launches (SLJIT_PERSIST_CACHE.md). On JIT, serialize the (position-independent, Stage 1) LIR and write it to <cache>/<game_id>/sljit/<arch-abi>/cg<N>/<entry8>_<crc8>.sljit with a small header (magic, format/helper-order versions, entry/lo/len/crc/size). At init, scan that dir, deserialize + sljit_generate_code for THIS process, and register each as a dll<0 candidate carrying the blob's crc; dispatch re-hashes live RAM against it so a reloaded shard re-earns trust exactly like a fresh JIT. Priority gcc > sljit > interp is unchanged (a gcc DLL still supersedes a reloaded shard via the obsolete path). Persist is write-on-generate (measured negligible; crash-safe). Threads the serialized blob through OverlaySljitResult -> CompiledFragment; register_sljit_candidate gains a crc_override (reloaded shards use the header crc since the overlay RAM may not be loaded at init). sljit_status exposes reloaded / persist / reload-diagnostic counters. Two gotchas found + fixed in testing (vs the original design notes): - serialize MUST precede generate_code (generate sets compiler->error = SLJIT_ERR_COMPILED, after which serialize returns NULL); - serialize with options=0, not SLJIT_SERIALIZE_IGNORE_DEBUG, so an argument-checks build can deserialize its own blobs. Validated: two-launch test reloaded 12 shards (deserfail=0), ran them at a fresh process base with no crash, gameplay renders correctly. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>