Skip to content

PS2 games in the browser: static recompilation to WebAssembly with a native runtime

C++

Follow saved-register addresses further to find pointer-only methods

Samir Nuriebf86d3b8fa9
diff --git a/recomp/analysis.cpp b/recomp/analysis.cpp
index 6d5f989..2d964ba 100644
--- a/recomp/analysis.cpp
+++ b/recomp/analysis.cpp
@@ -116,7 +116,8 @@ std::vector<std::uint32_t> address_constants(const Image &image, const Program &
if (!p.is_code(pc)) continue;
const Insn lui = decode(*image.word(pc), pc);
if (lui.op != Op::Lui) continue;
- std::uint32_t stop = pc + 160;
+ const bool saved = (lui.rt() >= 16 && lui.rt() <= 23) || lui.rt() == 30;
+ std::uint32_t stop = pc + (saved ? 1024 : 160);
for (std::uint32_t next = pc + 4; next < stop && p.is_code(next); next += 4) {
const Insn insn = decode(*image.word(next), next);
if ((insn.op == Op::Addiu || insn.op == Op::Ori) && insn.rs() == lui.rt()) {