void Vgen::patch(Venv& env) { for (auto& p : env.jmps) { assertx(env.addrs[p.target]); smashJmp(p.instr, env.addrs[p.target]); } for (auto& p : env.jccs) { assertx(env.addrs[p.target]); smashJcc(p.instr, env.addrs[p.target]); } for (auto& p : env.bccs) { assertx(env.addrs[p.target]); auto link = (Instruction*) p.instr; link->SetImmPCOffsetTarget(Instruction::Cast(env.addrs[p.target])); } }
void SrcRec::patchIncomingBranches(TCA newStart) { if (hasDebuggerGuard()) { // We have a debugger guard, so all jumps to us funnel through // this. Just smash m_dbgBranchGuardSrc. TRACE(1, "smashing m_dbgBranchGuardSrc @%p\n", m_dbgBranchGuardSrc.get()); smashJmp(m_dbgBranchGuardSrc, newStart); return; } TRACE(1, "%zd incoming branches to rechain\n", m_incomingBranches.size()); for (auto &br : m_incomingBranches) { TRACE(1, "SrcRec(%p)::newTranslation rechaining @%p -> %p\n", this, br.toSmash(), newStart); br.patch(newStart); } }