output_w32(0xe1500000|rd_rn_rm(0,rs,rt));
}
+static void emit_cmpcs(int rs,int rt)
+{
+ assem_debug("cmpcs %s,%s\n",regname[rs],regname[rt]);
+ output_w32(0x21500000|rd_rn_rm(0,rs,rt));
+}
+
static void emit_set_gz32(int rs, int rt)
{
//assem_debug("set_gz32\n");
output_w32(0x6b000000 | rm_rn_rd(rt, rs, WZR));
}
+static void emit_cmpcs(u_int rs,u_int rt)
+{
+ assem_debug("ccmp %s,%s,#0,cs\n",regname[rs],regname[rt]);
+ output_w32(0x7a400000 | (COND_CS << 12) | rm_rn_rd(rt, rs, 0));
+}
+
static void emit_set_gz32(u_int rs, u_int rt)
{
//assem_debug("set_gz32\n");
#define MAXBLOCK 4096
#define MAX_OUTPUT_BLOCK_SIZE 262144
+#if defined(HAVE_CONDITIONAL_CALL) && !defined(DESTRUCTIVE_SHIFT)
+#define INVALIDATE_USE_COND_CALL
+#endif
+
#ifdef VITA
// apparently Vita has a 16MB limit, so either we cut tc in half,
// or use this hack (it's a hack because tc size was designed to be power-of-2)
invalid_code[(i|j|0xa0000000u) >> 12] = invalid;
}
}
- if (!invalid)
+ if (!invalid && vaddr + len > inv_code_start && vaddr <= inv_code_end)
inv_code_start = inv_code_end = ~0;
}
static void do_invstub(int n)
{
literal_pool(20);
- u_int reglist=stubs[n].a;
+ u_int reglist = stubs[n].a;
set_jump_target(stubs[n].addr, out);
save_regs(reglist);
- if(stubs[n].b!=0) emit_mov(stubs[n].b,0);
+ if (stubs[n].b != 0)
+ emit_mov(stubs[n].b, 0);
+ emit_readword(&inv_code_start, 1);
+ emit_readword(&inv_code_end, 2);
+ emit_cmp(0, 1);
+ emit_cmpcs(2, 0);
+ void *jaddr = out;
+ emit_jc(0);
emit_far_call(ndrc_invalidate_addr);
+ set_jump_target(jaddr, out);
restore_regs(reglist);
emit_jmp(stubs[n].retaddr); // return address
}
#else
emit_cmpmem_indexedsr12_imm(invalid_code,addr,1);
#endif
- #if defined(HAVE_CONDITIONAL_CALL) && !defined(DESTRUCTIVE_SHIFT)
+ #ifdef INVALIDATE_USE_COND_CALL
emit_callne(invalidate_addr_reg[addr]);
#else
void *jaddr2 = out;
#else
emit_cmpmem_indexedsr12_imm(invalid_code,temp,1);
#endif
- #if defined(HAVE_CONDITIONAL_CALL) && !defined(DESTRUCTIVE_SHIFT)
+ #ifdef INVALIDATE_USE_COND_CALL
emit_callne(invalidate_addr_reg[temp]);
#else
void *jaddr2 = out;
#else
emit_cmpmem_indexedsr12_imm(invalid_code,ar,1);
#endif
- #if defined(HAVE_CONDITIONAL_CALL) && !defined(DESTRUCTIVE_SHIFT)
+ #ifdef INVALIDATE_USE_COND_CALL
emit_callne(invalidate_addr_reg[ar]);
#else
void *jaddr3 = out;