22 |
|
#include "memory.h" |
23 |
|
#include "readcpu.h" |
24 |
|
#include "newcpu.h" |
25 |
+ |
#include "compiler/compemu.h" |
26 |
|
#include "fpu/fpu.h" |
27 |
|
|
28 |
|
#if defined(ENABLE_EXCLUSIVE_SPCFLAGS) && !defined(HAVE_HARDWARE_LOCKS) |
54 |
|
|
55 |
|
cpuop_func *cpufunctbl[65536]; |
56 |
|
|
56 |
– |
#define FLIGHT_RECORDER 0 |
57 |
– |
|
57 |
|
#if FLIGHT_RECORDER |
58 |
|
struct rec_step { |
59 |
|
uae_u32 d[8]; |
71 |
|
return name ? name : "log.68k"; |
72 |
|
} |
73 |
|
|
74 |
< |
static void record_step(uaecptr pc) |
74 |
> |
void m68k_record_step(uaecptr pc) |
75 |
|
{ |
76 |
|
for (int i = 0; i < 8; i++) { |
77 |
|
log[log_ptr].d[i] = m68k_dreg(regs, i); |
801 |
|
switch (regno) { |
802 |
|
case 0: regs.sfc = *regp & 7; break; |
803 |
|
case 1: regs.dfc = *regp & 7; break; |
804 |
< |
case 2: cacr = *regp & (CPUType < 4 ? 0x3 : 0x80008000); break; |
804 |
> |
case 2: |
805 |
> |
cacr = *regp & (CPUType < 4 ? 0x3 : 0x80008000); |
806 |
> |
#if USE_JIT |
807 |
> |
if (CPUType < 4) { |
808 |
> |
set_cache_state(cacr&1); |
809 |
> |
if (*regp & 0x08) |
810 |
> |
flush_icache(1); |
811 |
> |
} |
812 |
> |
else { |
813 |
> |
set_cache_state((cacr&0x8000) || 0); |
814 |
> |
// FIXME: The User Manual claims bit 3 of CACR is undefined |
815 |
> |
if (*regp & 0x08) |
816 |
> |
flush_icache(2); |
817 |
> |
} |
818 |
> |
#endif |
819 |
> |
break; |
820 |
|
case 3: tc = *regp & 0xc000; break; |
821 |
|
case 4: itt0 = *regp & 0xffffe364; break; |
822 |
|
case 5: itt1 = *regp & 0xffffe364; break; |
1205 |
|
} |
1206 |
|
|
1207 |
|
write_log ("Illegal instruction: %04x at %08lx\n", opcode, pc); |
1208 |
+ |
#if USE_JIT && JIT_DEBUG |
1209 |
+ |
compiler_dumpstate(); |
1210 |
+ |
#endif |
1211 |
|
|
1212 |
|
Exception (4,0); |
1213 |
|
cpuop_return(CFLOW_TRAP); |
1265 |
|
|
1266 |
|
int m68k_do_specialties (void) |
1267 |
|
{ |
1268 |
+ |
#if USE_JIT |
1269 |
+ |
// Block was compiled |
1270 |
+ |
SPCFLAGS_CLEAR( SPCFLAG_JIT_END_COMPILE ); |
1271 |
+ |
|
1272 |
+ |
// Retain the request to get out of compiled code until |
1273 |
+ |
// we reached the toplevel execution, i.e. the one that |
1274 |
+ |
// can compile then run compiled code. This also means |
1275 |
+ |
// we processed all (nested) EmulOps |
1276 |
+ |
if ((m68k_execute_depth == 0) && SPCFLAGS_TEST( SPCFLAG_JIT_EXEC_RETURN )) |
1277 |
+ |
SPCFLAGS_CLEAR( SPCFLAG_JIT_EXEC_RETURN ); |
1278 |
+ |
#endif |
1279 |
+ |
|
1280 |
|
if (SPCFLAGS_TEST( SPCFLAG_DOTRACE )) { |
1281 |
|
Exception (9,last_trace_ad); |
1282 |
|
} |
1318 |
|
for (;;) { |
1319 |
|
uae_u32 opcode = GET_OPCODE; |
1320 |
|
#if FLIGHT_RECORDER |
1321 |
< |
record_step(m68k_getpc()); |
1321 |
> |
m68k_record_step(m68k_getpc()); |
1322 |
|
#endif |
1323 |
|
#ifdef X86_ASSEMBLY |
1324 |
|
__asm__ __volatile__("\tpushl %%ebp\n\tcall *%%ebx\n\tpopl %%ebp" /* FIXME */ |
1334 |
|
} |
1335 |
|
} |
1336 |
|
|
1337 |
+ |
#if USE_JIT |
1338 |
+ |
void m68k_compile_execute (void) |
1339 |
+ |
{ |
1340 |
+ |
for (;;) { |
1341 |
+ |
if (quit_program > 0) { |
1342 |
+ |
if (quit_program == 1) |
1343 |
+ |
break; |
1344 |
+ |
quit_program = 0; |
1345 |
+ |
m68k_reset (); |
1346 |
+ |
} |
1347 |
+ |
m68k_do_compile_execute(); |
1348 |
+ |
} |
1349 |
+ |
if (debugging) { |
1350 |
+ |
uaecptr nextpc; |
1351 |
+ |
m68k_dumpstate(&nextpc); |
1352 |
+ |
exit(1); |
1353 |
+ |
} |
1354 |
+ |
} |
1355 |
+ |
#endif |
1356 |
+ |
|
1357 |
|
void m68k_execute (void) |
1358 |
|
{ |
1359 |
+ |
#if USE_JIT |
1360 |
+ |
++m68k_execute_depth; |
1361 |
+ |
#endif |
1362 |
+ |
|
1363 |
|
for (;;) { |
1364 |
|
if (quit_program > 0) { |
1365 |
|
if (quit_program == 1) |
1374 |
|
m68k_dumpstate(&nextpc); |
1375 |
|
exit(1); |
1376 |
|
} |
1377 |
+ |
|
1378 |
+ |
#if USE_JIT |
1379 |
+ |
--m68k_execute_depth; |
1380 |
+ |
#endif |
1381 |
|
} |
1382 |
|
|
1383 |
|
static void m68k_verify (uaecptr addr, uaecptr *nextpc) |