mirror of
https://github.com/kanjitalk755/macemu.git
synced 2024-11-26 10:49:21 +00:00
Really make translation through constant jumps functional. This can be
disabled with the new prefs item "jitinline". Some rapid Speedometer 4 benchmarks showed only a 4% improvement.
This commit is contained in:
parent
83b228cf30
commit
c0cc43a87b
@ -63,6 +63,7 @@ prefs_desc common_prefs_items[] = {
|
|||||||
{"jitdebug", TYPE_BOOLEAN, false, "enable JIT debugger (requires mon builtin)"},
|
{"jitdebug", TYPE_BOOLEAN, false, "enable JIT debugger (requires mon builtin)"},
|
||||||
{"jitcachesize", TYPE_INT32, false, "translation cache size in KB"},
|
{"jitcachesize", TYPE_INT32, false, "translation cache size in KB"},
|
||||||
{"jitlazyflush", TYPE_BOOLEAN, false, "enable lazy invalidation of translation cache"},
|
{"jitlazyflush", TYPE_BOOLEAN, false, "enable lazy invalidation of translation cache"},
|
||||||
|
{"jitinline", TYPE_BOOLEAN, false, "enable translation through constant jumps"},
|
||||||
{"jitblacklist", TYPE_STRING, false, "blacklist opcodes from translation"},
|
{"jitblacklist", TYPE_STRING, false, "blacklist opcodes from translation"},
|
||||||
{"keyboardtype", TYPE_INT32, false, "hardware keyboard type"},
|
{"keyboardtype", TYPE_INT32, false, "hardware keyboard type"},
|
||||||
{NULL, TYPE_END, false, NULL} // End of list
|
{NULL, TYPE_END, false, NULL} // End of list
|
||||||
@ -97,6 +98,7 @@ void AddPrefsDefaults(void)
|
|||||||
PrefsAddBool("jitdebug", false);
|
PrefsAddBool("jitdebug", false);
|
||||||
PrefsAddInt32("jitcachesize", 8192);
|
PrefsAddInt32("jitcachesize", 8192);
|
||||||
PrefsAddInt32("jitlazyflush", true);
|
PrefsAddInt32("jitlazyflush", true);
|
||||||
|
PrefsAddBool("jitinline", true);
|
||||||
#else
|
#else
|
||||||
PrefsAddBool("jit", false);
|
PrefsAddBool("jit", false);
|
||||||
#endif
|
#endif
|
||||||
|
@ -149,6 +149,11 @@ static bool JITDebug = false; // Enable runtime disassemblers through mon?
|
|||||||
#else
|
#else
|
||||||
const bool JITDebug = false; // Don't use JIT debug mode at all
|
const bool JITDebug = false; // Don't use JIT debug mode at all
|
||||||
#endif
|
#endif
|
||||||
|
#if USE_INLINING
|
||||||
|
static bool follow_const_jumps = true; // Flag: translation through constant jumps
|
||||||
|
#else
|
||||||
|
const bool follow_const_jumps = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
const uae_u32 MIN_CACHE_SIZE = 1024; // Minimal translation cache size (1 MB)
|
const uae_u32 MIN_CACHE_SIZE = 1024; // Minimal translation cache size (1 MB)
|
||||||
static uae_u32 cache_size = 0; // Size of total cache allocated for compiled blocks
|
static uae_u32 cache_size = 0; // Size of total cache allocated for compiled blocks
|
||||||
@ -5016,7 +5021,10 @@ void compiler_init(void)
|
|||||||
write_log("<JIT compiler> : register aliasing : %s\n", str_on_off(1));
|
write_log("<JIT compiler> : register aliasing : %s\n", str_on_off(1));
|
||||||
write_log("<JIT compiler> : FP register aliasing : %s\n", str_on_off(USE_F_ALIAS));
|
write_log("<JIT compiler> : FP register aliasing : %s\n", str_on_off(USE_F_ALIAS));
|
||||||
write_log("<JIT compiler> : lazy constant offsetting : %s\n", str_on_off(USE_OFFSET));
|
write_log("<JIT compiler> : lazy constant offsetting : %s\n", str_on_off(USE_OFFSET));
|
||||||
write_log("<JIT compiler> : block inlining : %s\n", str_on_off(USE_INLINING));
|
#if USE_INLINING
|
||||||
|
follow_const_jumps = PrefsFindBool("jitinline");
|
||||||
|
#endif
|
||||||
|
write_log("<JIT compiler> : translate through constant jumps : %s\n", str_on_off(follow_const_jumps));
|
||||||
write_log("<JIT compiler> : separate blockinfo allocation : %s\n", str_on_off(USE_SEPARATE_BIA));
|
write_log("<JIT compiler> : separate blockinfo allocation : %s\n", str_on_off(USE_SEPARATE_BIA));
|
||||||
|
|
||||||
// Build compiler tables
|
// Build compiler tables
|
||||||
@ -6249,7 +6257,7 @@ void build_comp(void)
|
|||||||
|
|
||||||
for (i = 0; tbl[i].opcode < 65536; i++) {
|
for (i = 0; tbl[i].opcode < 65536; i++) {
|
||||||
int cflow = table68k[tbl[i].opcode].cflow;
|
int cflow = table68k[tbl[i].opcode].cflow;
|
||||||
if (USE_INLINING && ((cflow & fl_const_jump) != 0))
|
if (follow_const_jumps && (tbl[i].specific & 16))
|
||||||
cflow = fl_const_jump;
|
cflow = fl_const_jump;
|
||||||
else
|
else
|
||||||
cflow &= ~fl_const_jump;
|
cflow &= ~fl_const_jump;
|
||||||
@ -6301,6 +6309,10 @@ void build_comp(void)
|
|||||||
}
|
}
|
||||||
prop[cft_map(opcode)].set_flags = table68k[opcode].flagdead;
|
prop[cft_map(opcode)].set_flags = table68k[opcode].flagdead;
|
||||||
prop[cft_map(opcode)].use_flags = table68k[opcode].flaglive;
|
prop[cft_map(opcode)].use_flags = table68k[opcode].flaglive;
|
||||||
|
/* Unconditional jumps don't evaluate condition codes, so they
|
||||||
|
* don't actually use any flags themselves */
|
||||||
|
if (prop[cft_map(opcode)].cflow & fl_const_jump)
|
||||||
|
prop[cft_map(opcode)].use_flags = 0;
|
||||||
}
|
}
|
||||||
for (i = 0; nfctbl[i].handler != NULL; i++) {
|
for (i = 0; nfctbl[i].handler != NULL; i++) {
|
||||||
if (nfctbl[i].specific)
|
if (nfctbl[i].specific)
|
||||||
@ -6652,8 +6664,7 @@ static void compile_block(cpu_history* pc_hist, int blocklen)
|
|||||||
|
|
||||||
#if USE_CHECKSUM_INFO
|
#if USE_CHECKSUM_INFO
|
||||||
trace_in_rom = trace_in_rom && isinrom((uintptr)currpcp);
|
trace_in_rom = trace_in_rom && isinrom((uintptr)currpcp);
|
||||||
#if USE_INLINING
|
if (follow_const_jumps && is_const_jump(op)) {
|
||||||
if (is_const_jump(op)) {
|
|
||||||
checksum_info *csi = alloc_checksum_info();
|
checksum_info *csi = alloc_checksum_info();
|
||||||
csi->start_p = (uae_u8 *)min_pcp;
|
csi->start_p = (uae_u8 *)min_pcp;
|
||||||
csi->length = max_pcp - min_pcp + LONGEST_68K_INST;
|
csi->length = max_pcp - min_pcp + LONGEST_68K_INST;
|
||||||
@ -6661,7 +6672,6 @@ static void compile_block(cpu_history* pc_hist, int blocklen)
|
|||||||
bi->csi = csi;
|
bi->csi = csi;
|
||||||
max_pcp = (uintptr)currpcp;
|
max_pcp = (uintptr)currpcp;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
min_pcp = (uintptr)currpcp;
|
min_pcp = (uintptr)currpcp;
|
||||||
#else
|
#else
|
||||||
if ((uintptr)currpcp<min_pcp)
|
if ((uintptr)currpcp<min_pcp)
|
||||||
|
@ -754,6 +754,34 @@ static void build_insn (int insn)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Fix flags used information for Scc, Bcc, TRAPcc, DBcc instructions
|
||||||
|
if ( table68k[opc].mnemo == i_Scc
|
||||||
|
|| table68k[opc].mnemo == i_Bcc
|
||||||
|
|| table68k[opc].mnemo == i_DBcc
|
||||||
|
|| table68k[opc].mnemo == i_TRAPcc
|
||||||
|
) {
|
||||||
|
switch (table68k[opc].cc) {
|
||||||
|
// CC mask: XNZVC
|
||||||
|
// 8421
|
||||||
|
case 0: flags_used = 0x00; break; /* T */
|
||||||
|
case 1: flags_used = 0x00; break; /* F */
|
||||||
|
case 2: flags_used = 0x05; break; /* HI */
|
||||||
|
case 3: flags_used = 0x05; break; /* LS */
|
||||||
|
case 4: flags_used = 0x01; break; /* CC */
|
||||||
|
case 5: flags_used = 0x01; break; /* CS */
|
||||||
|
case 6: flags_used = 0x04; break; /* NE */
|
||||||
|
case 7: flags_used = 0x04; break; /* EQ */
|
||||||
|
case 8: flags_used = 0x02; break; /* VC */
|
||||||
|
case 9: flags_used = 0x02; break; /* VS */
|
||||||
|
case 10:flags_used = 0x08; break; /* PL */
|
||||||
|
case 11:flags_used = 0x08; break; /* MI */
|
||||||
|
case 12:flags_used = 0x0A; break; /* GE */
|
||||||
|
case 13:flags_used = 0x0A; break; /* LT */
|
||||||
|
case 14:flags_used = 0x0E; break; /* GT */
|
||||||
|
case 15:flags_used = 0x0E; break; /* LE */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
/* gb-- flagdead and flaglive would not have correct information */
|
/* gb-- flagdead and flaglive would not have correct information */
|
||||||
table68k[opc].flagdead = flags_set;
|
table68k[opc].flagdead = flags_set;
|
||||||
@ -781,57 +809,6 @@ void read_table68k (void)
|
|||||||
for (i = 0; i < n_defs68k; i++) {
|
for (i = 0; i < n_defs68k; i++) {
|
||||||
build_insn (i);
|
build_insn (i);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Extra fixes in table68k for control flow information and flag usage */
|
|
||||||
for (i = 0; i < 65536; i++) {
|
|
||||||
instrmnem mnemo = (instrmnem)(table68k[i].mnemo);
|
|
||||||
|
|
||||||
#define IS_CONST_JUMP(opc) \
|
|
||||||
( ((table68k[opc].mnemo == i_Bcc) && (table68k[opc].cc < 2)) \
|
|
||||||
|| (table68k[opc].mnemo == i_BSR) \
|
|
||||||
)
|
|
||||||
|
|
||||||
// Precise const jumps as such. The JIT compiler will take
|
|
||||||
// care to actually enable that optimization or not
|
|
||||||
if (IS_CONST_JUMP(i))
|
|
||||||
table68k[i].cflow |= fl_const_jump;
|
|
||||||
|
|
||||||
// Fix flags used information for Scc, Bcc, TRAPcc, DBcc instructions
|
|
||||||
int flags_used = table68k[i].flaglive;
|
|
||||||
if ( (mnemo == i_Scc)
|
|
||||||
|| (mnemo == i_Bcc)
|
|
||||||
|| (mnemo == i_DBcc)
|
|
||||||
|| (mnemo == i_TRAPcc)
|
|
||||||
) {
|
|
||||||
switch (table68k[i].cc) {
|
|
||||||
// CC mask: XNZVC
|
|
||||||
// 8421
|
|
||||||
case 0: flags_used = 0x00; break; /* T */
|
|
||||||
case 1: flags_used = 0x00; break; /* F */
|
|
||||||
case 2: flags_used = 0x05; break; /* HI */
|
|
||||||
case 3: flags_used = 0x05; break; /* LS */
|
|
||||||
case 4: flags_used = 0x01; break; /* CC */
|
|
||||||
case 5: flags_used = 0x01; break; /* CS */
|
|
||||||
case 6: flags_used = 0x04; break; /* NE */
|
|
||||||
case 7: flags_used = 0x04; break; /* EQ */
|
|
||||||
case 8: flags_used = 0x02; break; /* VC */
|
|
||||||
case 9: flags_used = 0x02; break; /* VS */
|
|
||||||
case 10:flags_used = 0x08; break; /* PL */
|
|
||||||
case 11:flags_used = 0x08; break; /* MI */
|
|
||||||
case 12:flags_used = 0x0A; break; /* GE */
|
|
||||||
case 13:flags_used = 0x0A; break; /* LT */
|
|
||||||
case 14:flags_used = 0x0E; break; /* GT */
|
|
||||||
case 15:flags_used = 0x0E; break; /* LE */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Unconditional jumps don't evaluate condition codes, so they
|
|
||||||
don't actually use any flags themselves */
|
|
||||||
if (IS_CONST_JUMP(i))
|
|
||||||
flags_used = 0;
|
|
||||||
|
|
||||||
table68k[i].flaglive = flags_used;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mismatch;
|
static int mismatch;
|
||||||
|
Loading…
Reference in New Issue
Block a user