74 |
|
cpuop_func *nfcpufunctbl[65536]; |
75 |
|
uae_u8* comp_pc_p; |
76 |
|
|
77 |
+ |
// From newcpu.cpp |
78 |
+ |
extern bool quit_program; |
79 |
+ |
|
80 |
|
// gb-- Extra data for Basilisk II/JIT |
81 |
|
#if JIT_DEBUG |
82 |
|
static bool JITDebug = false; // Enable runtime disassemblers through mon? |
91 |
|
static bool avoid_fpu = true; // Flag: compile FPU instructions ? |
92 |
|
static bool have_cmov = false; // target has CMOV instructions ? |
93 |
|
static bool have_rat_stall = true; // target has partial register stalls ? |
94 |
+ |
static bool tune_alignment = false; // Tune code alignments for running CPU ? |
95 |
+ |
static int align_loops = 32; // Align the start of loops |
96 |
+ |
static int align_jumps = 32; // Align the start of jumps |
97 |
|
static int zero_fd = -1; |
98 |
|
static int optcount[10] = { |
99 |
|
10, // How often a block has to be executed before it is translated |
110 |
|
}; |
111 |
|
static op_properties prop[65536]; |
112 |
|
|
107 |
– |
// gb-- Control Flow Predicates |
108 |
– |
|
113 |
|
static inline int end_block(uae_u32 opcode) |
114 |
|
{ |
115 |
|
return (prop[opcode].cflow & fl_end_block); |
116 |
|
} |
117 |
|
|
118 |
< |
static inline bool may_trap(uae_u32 opcode) |
118 |
> |
static inline bool is_const_jump(uae_u32 opcode) |
119 |
|
{ |
120 |
< |
return (prop[opcode].cflow & fl_trap); |
120 |
> |
return (prop[opcode].cflow == fl_const_jump); |
121 |
|
} |
122 |
|
|
123 |
|
uae_u8* start_pc_p; |
495 |
|
compiled. If the list of free blockinfos is empty, we allocate a new |
496 |
|
pool of blockinfos and link the newly created blockinfos altogether |
497 |
|
into the list of free blockinfos. Otherwise, we simply pop a structure |
498 |
< |
of the free list. |
498 |
> |
off the free list. |
499 |
|
|
500 |
|
Blockinfo are lazily deallocated, i.e. chained altogether in the |
501 |
|
list of free blockinfos whenvever a translation cache flush (hard or |
502 |
|
soft) request occurs. |
503 |
|
*/ |
504 |
|
|
505 |
< |
#if USE_SEPARATE_BIA |
506 |
< |
const int BLOCKINFO_POOL_SIZE = 128; |
507 |
< |
struct blockinfo_pool { |
508 |
< |
blockinfo bi[BLOCKINFO_POOL_SIZE]; |
509 |
< |
blockinfo_pool *next; |
505 |
> |
template< class T > |
506 |
> |
class LazyBlockAllocator |
507 |
> |
{ |
508 |
> |
enum { |
509 |
> |
kPoolSize = 1 + 4096 / sizeof(T) |
510 |
> |
}; |
511 |
> |
struct Pool { |
512 |
> |
T chunk[kPoolSize]; |
513 |
> |
Pool * next; |
514 |
> |
}; |
515 |
> |
Pool * mPools; |
516 |
> |
T * mChunks; |
517 |
> |
public: |
518 |
> |
LazyBlockAllocator() : mPools(0), mChunks(0) { } |
519 |
> |
~LazyBlockAllocator(); |
520 |
> |
T * acquire(); |
521 |
> |
void release(T * const); |
522 |
|
}; |
507 |
– |
static blockinfo_pool * blockinfo_pools = 0; |
508 |
– |
static blockinfo * free_blockinfos = 0; |
509 |
– |
#endif |
523 |
|
|
524 |
< |
static __inline__ blockinfo *alloc_blockinfo(void) |
524 |
> |
template< class T > |
525 |
> |
LazyBlockAllocator<T>::~LazyBlockAllocator() |
526 |
|
{ |
527 |
< |
#if USE_SEPARATE_BIA |
528 |
< |
if (!free_blockinfos) { |
529 |
< |
// There is no blockinfo struct left, allocate a new |
530 |
< |
// pool and link the chunks into the free list |
531 |
< |
blockinfo_pool *bi_pool = (blockinfo_pool *)malloc(sizeof(blockinfo_pool)); |
532 |
< |
for (blockinfo *bi = &bi_pool->bi[0]; bi < &bi_pool->bi[BLOCKINFO_POOL_SIZE]; bi++) { |
533 |
< |
bi->next = free_blockinfos; |
534 |
< |
free_blockinfos = bi; |
527 |
> |
Pool * currentPool = mPools; |
528 |
> |
while (currentPool) { |
529 |
> |
Pool * deadPool = currentPool; |
530 |
> |
currentPool = currentPool->next; |
531 |
> |
free(deadPool); |
532 |
> |
} |
533 |
> |
} |
534 |
> |
|
535 |
> |
template< class T > |
536 |
> |
T * LazyBlockAllocator<T>::acquire() |
537 |
> |
{ |
538 |
> |
if (!mChunks) { |
539 |
> |
// There is no chunk left, allocate a new pool and link the |
540 |
> |
// chunks into the free list |
541 |
> |
Pool * newPool = (Pool *)malloc(sizeof(Pool)); |
542 |
> |
for (T * chunk = &newPool->chunk[0]; chunk < &newPool->chunk[kPoolSize]; chunk++) { |
543 |
> |
chunk->next = mChunks; |
544 |
> |
mChunks = chunk; |
545 |
|
} |
546 |
< |
bi_pool->next = blockinfo_pools; |
547 |
< |
blockinfo_pools = bi_pool; |
546 |
> |
newPool->next = mPools; |
547 |
> |
mPools = newPool; |
548 |
|
} |
549 |
< |
blockinfo *bi = free_blockinfos; |
550 |
< |
free_blockinfos = bi->next; |
551 |
< |
#else |
528 |
< |
blockinfo *bi = (blockinfo*)current_compile_p; |
529 |
< |
current_compile_p += sizeof(blockinfo); |
530 |
< |
#endif |
531 |
< |
return bi; |
549 |
> |
T * chunk = mChunks; |
550 |
> |
mChunks = chunk->next; |
551 |
> |
return chunk; |
552 |
|
} |
553 |
|
|
554 |
< |
static __inline__ void free_blockinfo(blockinfo *bi) |
554 |
> |
template< class T > |
555 |
> |
void LazyBlockAllocator<T>::release(T * const chunk) |
556 |
> |
{ |
557 |
> |
chunk->next = mChunks; |
558 |
> |
mChunks = chunk; |
559 |
> |
} |
560 |
> |
|
561 |
> |
template< class T > |
562 |
> |
class HardBlockAllocator |
563 |
|
{ |
564 |
+ |
public: |
565 |
+ |
T * acquire() { |
566 |
+ |
T * data = (T *)current_compile_p; |
567 |
+ |
current_compile_p += sizeof(T); |
568 |
+ |
return data; |
569 |
+ |
} |
570 |
+ |
|
571 |
+ |
void release(T * const chunk) { |
572 |
+ |
// Deallocated on invalidation |
573 |
+ |
} |
574 |
+ |
}; |
575 |
+ |
|
576 |
|
#if USE_SEPARATE_BIA |
577 |
< |
bi->next = free_blockinfos; |
578 |
< |
free_blockinfos = bi; |
577 |
> |
static LazyBlockAllocator<blockinfo> BlockInfoAllocator; |
578 |
> |
static LazyBlockAllocator<checksum_info> ChecksumInfoAllocator; |
579 |
> |
#else |
580 |
> |
static HardBlockAllocator<blockinfo> BlockInfoAllocator; |
581 |
> |
static HardBlockAllocator<checksum_info> ChecksumInfoAllocator; |
582 |
|
#endif |
583 |
+ |
|
584 |
+ |
static __inline__ checksum_info *alloc_checksum_info(void) |
585 |
+ |
{ |
586 |
+ |
checksum_info *csi = ChecksumInfoAllocator.acquire(); |
587 |
+ |
csi->next = NULL; |
588 |
+ |
return csi; |
589 |
|
} |
590 |
|
|
591 |
< |
static void free_blockinfo_pools(void) |
591 |
> |
static __inline__ void free_checksum_info(checksum_info *csi) |
592 |
|
{ |
593 |
< |
#if USE_SEPARATE_BIA |
594 |
< |
int blockinfo_pool_count = 0; |
595 |
< |
blockinfo_pool *curr_pool = blockinfo_pools; |
596 |
< |
while (curr_pool) { |
597 |
< |
blockinfo_pool_count++; |
598 |
< |
blockinfo_pool *dead_pool = curr_pool; |
599 |
< |
curr_pool = curr_pool->next; |
600 |
< |
free(dead_pool); |
593 |
> |
csi->next = NULL; |
594 |
> |
ChecksumInfoAllocator.release(csi); |
595 |
> |
} |
596 |
> |
|
597 |
> |
static __inline__ void free_checksum_info_chain(checksum_info *csi) |
598 |
> |
{ |
599 |
> |
while (csi != NULL) { |
600 |
> |
checksum_info *csi2 = csi->next; |
601 |
> |
free_checksum_info(csi); |
602 |
> |
csi = csi2; |
603 |
|
} |
604 |
< |
|
605 |
< |
uae_u32 blockinfo_pools_size = blockinfo_pool_count * BLOCKINFO_POOL_SIZE * sizeof(blockinfo); |
606 |
< |
write_log("### Blockinfo allocation statistics\n"); |
607 |
< |
write_log("Number of blockinfo pools : %d\n", blockinfo_pool_count); |
608 |
< |
write_log("Total number of blockinfos : %d (%d KB)\n", |
609 |
< |
blockinfo_pool_count * BLOCKINFO_POOL_SIZE, |
610 |
< |
blockinfo_pools_size / 1024); |
560 |
< |
write_log("\n"); |
604 |
> |
} |
605 |
> |
|
606 |
> |
static __inline__ blockinfo *alloc_blockinfo(void) |
607 |
> |
{ |
608 |
> |
blockinfo *bi = BlockInfoAllocator.acquire(); |
609 |
> |
#if USE_CHECKSUM_INFO |
610 |
> |
bi->csi = NULL; |
611 |
|
#endif |
612 |
+ |
return bi; |
613 |
+ |
} |
614 |
+ |
|
615 |
+ |
static __inline__ void free_blockinfo(blockinfo *bi) |
616 |
+ |
{ |
617 |
+ |
#if USE_CHECKSUM_INFO |
618 |
+ |
free_checksum_info_chain(bi->csi); |
619 |
+ |
bi->csi = NULL; |
620 |
+ |
#endif |
621 |
+ |
BlockInfoAllocator.release(bi); |
622 |
|
} |
623 |
|
|
624 |
|
static __inline__ void alloc_blockinfos(void) |
4622 |
|
raw_init_cpu(); |
4623 |
|
write_log("<JIT compiler> : target processor has CMOV instructions : %s\n", have_cmov ? "yes" : "no"); |
4624 |
|
write_log("<JIT compiler> : target processor can suffer from partial register stalls : %s\n", have_rat_stall ? "yes" : "no"); |
4625 |
+ |
write_log("<JIT compiler> : alignment for loops, jumps are %d, %d\n", align_loops, align_jumps); |
4626 |
|
|
4627 |
|
// Translation cache flush mechanism |
4628 |
|
lazy_flush = PrefsFindBool("jitlazyflush"); |
4633 |
|
write_log("<JIT compiler> : register aliasing : %s\n", str_on_off(1)); |
4634 |
|
write_log("<JIT compiler> : FP register aliasing : %s\n", str_on_off(USE_F_ALIAS)); |
4635 |
|
write_log("<JIT compiler> : lazy constant offsetting : %s\n", str_on_off(USE_OFFSET)); |
4636 |
+ |
write_log("<JIT compiler> : block inlining : %s\n", str_on_off(USE_INLINING)); |
4637 |
|
write_log("<JIT compiler> : separate blockinfo allocation : %s\n", str_on_off(USE_SEPARATE_BIA)); |
4638 |
|
|
4639 |
|
// Build compiler tables |
4659 |
|
compiled_code = 0; |
4660 |
|
} |
4661 |
|
|
4600 |
– |
// Deallocate blockinfo pools |
4601 |
– |
free_blockinfo_pools(); |
4602 |
– |
|
4662 |
|
#ifndef WIN32 |
4663 |
|
// Close /dev/zero |
4664 |
|
if (zero_fd > 0) |
5233 |
|
|
5234 |
|
static void calc_checksum(blockinfo* bi, uae_u32* c1, uae_u32* c2) |
5235 |
|
{ |
5236 |
< |
uae_u32 k1=0; |
5237 |
< |
uae_u32 k2=0; |
5179 |
< |
uae_s32 len=bi->len; |
5180 |
< |
uae_u32 tmp=bi->min_pcp; |
5181 |
< |
uae_u32* pos; |
5236 |
> |
uae_u32 k1 = 0; |
5237 |
> |
uae_u32 k2 = 0; |
5238 |
|
|
5239 |
< |
len+=(tmp&3); |
5240 |
< |
tmp&=(~3); |
5241 |
< |
pos=(uae_u32*)tmp; |
5239 |
> |
#if USE_CHECKSUM_INFO |
5240 |
> |
checksum_info *csi = bi->csi; |
5241 |
> |
Dif(!csi) abort(); |
5242 |
> |
while (csi) { |
5243 |
> |
uae_s32 len = csi->length; |
5244 |
> |
uae_u32 tmp = (uae_u32)csi->start_p; |
5245 |
> |
#else |
5246 |
> |
uae_s32 len = bi->len; |
5247 |
> |
uae_u32 tmp = (uae_u32)bi->min_pcp; |
5248 |
> |
#endif |
5249 |
> |
uae_u32*pos; |
5250 |
|
|
5251 |
< |
if (len<0 || len>MAX_CHECKSUM_LEN) { |
5252 |
< |
*c1=0; |
5253 |
< |
*c2=0; |
5254 |
< |
} |
5255 |
< |
else { |
5256 |
< |
while (len>0) { |
5257 |
< |
k1+=*pos; |
5258 |
< |
k2^=*pos; |
5259 |
< |
pos++; |
5260 |
< |
len-=4; |
5251 |
> |
len += (tmp & 3); |
5252 |
> |
tmp &= ~3; |
5253 |
> |
pos = (uae_u32 *)tmp; |
5254 |
> |
|
5255 |
> |
if (len >= 0 && len <= MAX_CHECKSUM_LEN) { |
5256 |
> |
while (len > 0) { |
5257 |
> |
k1 += *pos; |
5258 |
> |
k2 ^= *pos; |
5259 |
> |
pos++; |
5260 |
> |
len -= 4; |
5261 |
> |
} |
5262 |
> |
} |
5263 |
> |
|
5264 |
> |
#if USE_CHECKSUM_INFO |
5265 |
> |
csi = csi->next; |
5266 |
|
} |
5267 |
< |
*c1=k1; |
5268 |
< |
*c2=k2; |
5269 |
< |
} |
5267 |
> |
#endif |
5268 |
> |
|
5269 |
> |
*c1 = k1; |
5270 |
> |
*c2 = k2; |
5271 |
|
} |
5272 |
|
|
5273 |
< |
static void show_checksum(blockinfo* bi) |
5273 |
> |
#if 0 |
5274 |
> |
static void show_checksum(CSI_TYPE* csi) |
5275 |
|
{ |
5276 |
|
uae_u32 k1=0; |
5277 |
|
uae_u32 k2=0; |
5278 |
< |
uae_s32 len=bi->len; |
5279 |
< |
uae_u32 tmp=(uae_u32)bi->pc_p; |
5278 |
> |
uae_s32 len=CSI_LENGTH(csi); |
5279 |
> |
uae_u32 tmp=(uae_u32)CSI_START_P(csi); |
5280 |
|
uae_u32* pos; |
5281 |
|
|
5282 |
|
len+=(tmp&3); |
5295 |
|
write_log(" bla\n"); |
5296 |
|
} |
5297 |
|
} |
5298 |
+ |
#endif |
5299 |
|
|
5300 |
|
|
5301 |
|
int check_for_cache_miss(void) |
5349 |
|
static inline int block_check_checksum(blockinfo* bi) |
5350 |
|
{ |
5351 |
|
uae_u32 c1,c2; |
5352 |
< |
int isgood; |
5352 |
> |
bool isgood; |
5353 |
|
|
5354 |
|
if (bi->status!=BI_NEED_CHECK) |
5355 |
|
return 1; /* This block is in a checked state */ |
5356 |
|
|
5357 |
|
checksum_count++; |
5358 |
+ |
|
5359 |
|
if (bi->c1 || bi->c2) |
5360 |
|
calc_checksum(bi,&c1,&c2); |
5361 |
|
else { |
5362 |
|
c1=c2=1; /* Make sure it doesn't match */ |
5363 |
< |
} |
5363 |
> |
} |
5364 |
|
|
5365 |
|
isgood=(c1==bi->c1 && c2==bi->c2); |
5366 |
+ |
|
5367 |
|
if (isgood) { |
5368 |
|
/* This block is still OK. So we reactivate. Of course, that |
5369 |
|
means we have to move it into the needs-to-be-flushed list */ |
5481 |
|
registers before jumping back to the various get-out routines. |
5482 |
|
This generates the code for it. |
5483 |
|
*/ |
5484 |
< |
popall_do_nothing=current_compile_p; |
5484 |
> |
align_target(align_jumps); |
5485 |
> |
popall_do_nothing=get_target(); |
5486 |
|
for (i=0;i<N_REGS;i++) { |
5487 |
|
if (need_to_preserve[i]) |
5488 |
|
raw_pop_l_r(i); |
5489 |
|
} |
5490 |
|
raw_jmp((uae_u32)do_nothing); |
5416 |
– |
align_target(32); |
5491 |
|
|
5492 |
+ |
align_target(align_jumps); |
5493 |
|
popall_execute_normal=get_target(); |
5494 |
|
for (i=0;i<N_REGS;i++) { |
5495 |
|
if (need_to_preserve[i]) |
5496 |
|
raw_pop_l_r(i); |
5497 |
|
} |
5498 |
|
raw_jmp((uae_u32)execute_normal); |
5424 |
– |
align_target(32); |
5499 |
|
|
5500 |
+ |
align_target(align_jumps); |
5501 |
|
popall_cache_miss=get_target(); |
5502 |
|
for (i=0;i<N_REGS;i++) { |
5503 |
|
if (need_to_preserve[i]) |
5504 |
|
raw_pop_l_r(i); |
5505 |
|
} |
5506 |
|
raw_jmp((uae_u32)cache_miss); |
5432 |
– |
align_target(32); |
5507 |
|
|
5508 |
+ |
align_target(align_jumps); |
5509 |
|
popall_recompile_block=get_target(); |
5510 |
|
for (i=0;i<N_REGS;i++) { |
5511 |
|
if (need_to_preserve[i]) |
5512 |
|
raw_pop_l_r(i); |
5513 |
|
} |
5514 |
|
raw_jmp((uae_u32)recompile_block); |
5515 |
< |
align_target(32); |
5516 |
< |
|
5515 |
> |
|
5516 |
> |
align_target(align_jumps); |
5517 |
|
popall_exec_nostats=get_target(); |
5518 |
|
for (i=0;i<N_REGS;i++) { |
5519 |
|
if (need_to_preserve[i]) |
5520 |
|
raw_pop_l_r(i); |
5521 |
|
} |
5522 |
|
raw_jmp((uae_u32)exec_nostats); |
5523 |
< |
align_target(32); |
5524 |
< |
|
5523 |
> |
|
5524 |
> |
align_target(align_jumps); |
5525 |
|
popall_check_checksum=get_target(); |
5526 |
|
for (i=0;i<N_REGS;i++) { |
5527 |
|
if (need_to_preserve[i]) |
5528 |
|
raw_pop_l_r(i); |
5529 |
|
} |
5530 |
|
raw_jmp((uae_u32)check_checksum); |
5531 |
< |
align_target(32); |
5532 |
< |
|
5531 |
> |
|
5532 |
> |
align_target(align_jumps); |
5533 |
|
current_compile_p=get_target(); |
5534 |
|
#else |
5535 |
|
popall_exec_nostats=(void *)exec_nostats; |
5538 |
|
popall_recompile_block=(void *)recompile_block; |
5539 |
|
popall_do_nothing=(void *)do_nothing; |
5540 |
|
popall_check_checksum=(void *)check_checksum; |
5466 |
– |
pushall_call_handler=get_target(); |
5541 |
|
#endif |
5542 |
|
|
5543 |
|
/* And now, the code to do the matching pushes and then jump |
5553 |
|
raw_mov_l_rm(r,(uae_u32)®s.pc_p); |
5554 |
|
raw_and_l_ri(r,TAGMASK); |
5555 |
|
raw_jmp_m_indexed((uae_u32)cache_tags,r,4); |
5556 |
+ |
|
5557 |
+ |
#ifdef X86_ASSEMBLY |
5558 |
+ |
align_target(align_jumps); |
5559 |
+ |
m68k_compile_execute = (void (*)(void))get_target(); |
5560 |
+ |
for (i=N_REGS;i--;) { |
5561 |
+ |
if (need_to_preserve[i]) |
5562 |
+ |
raw_push_l_r(i); |
5563 |
+ |
} |
5564 |
+ |
align_target(align_loops); |
5565 |
+ |
uae_u32 dispatch_loop = (uae_u32)get_target(); |
5566 |
+ |
r=REG_PC_TMP; |
5567 |
+ |
raw_mov_l_rm(r,(uae_u32)®s.pc_p); |
5568 |
+ |
raw_and_l_ri(r,TAGMASK); |
5569 |
+ |
raw_call_m_indexed((uae_u32)cache_tags,r,4); |
5570 |
+ |
raw_cmp_l_mi((uae_u32)®s.spcflags,0); |
5571 |
+ |
raw_jcc_b_oponly(NATIVE_CC_EQ); |
5572 |
+ |
emit_byte(dispatch_loop-((uae_u32)get_target()+1)); |
5573 |
+ |
raw_call((uae_u32)m68k_do_specialties); |
5574 |
+ |
raw_test_l_rr(REG_RESULT,REG_RESULT); |
5575 |
+ |
raw_jcc_b_oponly(NATIVE_CC_EQ); |
5576 |
+ |
emit_byte(dispatch_loop-((uae_u32)get_target()+1)); |
5577 |
+ |
raw_cmp_b_mi((uae_u32)&quit_program,0); |
5578 |
+ |
raw_jcc_b_oponly(NATIVE_CC_EQ); |
5579 |
+ |
emit_byte(dispatch_loop-((uae_u32)get_target()+1)); |
5580 |
+ |
for (i=0;i<N_REGS;i++) { |
5581 |
+ |
if (need_to_preserve[i]) |
5582 |
+ |
raw_pop_l_r(i); |
5583 |
+ |
} |
5584 |
+ |
raw_ret(); |
5585 |
+ |
#endif |
5586 |
|
} |
5587 |
|
|
5588 |
|
static __inline__ void reset_lists(void) |
5600 |
|
int i; |
5601 |
|
|
5602 |
|
set_target(current_compile_p); |
5603 |
< |
align_target(32); |
5603 |
> |
align_target(align_jumps); |
5604 |
|
bi->direct_pen=(cpuop_func *)get_target(); |
5605 |
|
raw_mov_l_rm(0,(uae_u32)&(bi->pc_p)); |
5606 |
|
raw_mov_l_mr((uae_u32)®s.pc_p,0); |
5607 |
|
raw_jmp((uae_u32)popall_execute_normal); |
5608 |
|
|
5609 |
< |
align_target(32); |
5609 |
> |
align_target(align_jumps); |
5610 |
|
bi->direct_pcc=(cpuop_func *)get_target(); |
5611 |
|
raw_mov_l_rm(0,(uae_u32)&(bi->pc_p)); |
5612 |
|
raw_mov_l_mr((uae_u32)®s.pc_p,0); |
5613 |
|
raw_jmp((uae_u32)popall_check_checksum); |
5510 |
– |
|
5511 |
– |
align_target(32); |
5614 |
|
current_compile_p=get_target(); |
5615 |
|
|
5616 |
|
bi->deplist=NULL; |
5661 |
|
prop[opcode].cflow = fl_trap; // ILLEGAL instructions do trap |
5662 |
|
} |
5663 |
|
|
5664 |
+ |
#define IS_CONST_JUMP(opc) \ |
5665 |
+ |
( ((table68k[opc].mnemo == i_Bcc) && (table68k[opc].cc < 2)) \ |
5666 |
+ |
|| (table68k[opc].mnemo == i_BSR) \ |
5667 |
+ |
) |
5668 |
+ |
|
5669 |
|
for (i = 0; tbl[i].opcode < 65536; i++) { |
5670 |
|
int cflow = table68k[tbl[i].opcode].cflow; |
5671 |
< |
prop[cft_map(tbl[i].opcode)].cflow = cflow; |
5671 |
> |
if (USE_INLINING && IS_CONST_JUMP(tbl[i].opcode)) |
5672 |
> |
prop[cft_map(tbl[i].opcode)].cflow = fl_const_jump; |
5673 |
> |
else |
5674 |
> |
prop[cft_map(tbl[i].opcode)].cflow = cflow; |
5675 |
|
|
5676 |
|
int uses_fpu = tbl[i].specific & 32; |
5677 |
|
if (uses_fpu && avoid_fpu) |
5680 |
|
compfunctbl[cft_map(tbl[i].opcode)] = tbl[i].handler; |
5681 |
|
} |
5682 |
|
|
5683 |
+ |
#undef IS_CONST_JUMP |
5684 |
+ |
|
5685 |
|
for (i = 0; nftbl[i].opcode < 65536; i++) { |
5686 |
|
int uses_fpu = tbl[i].specific & 32; |
5687 |
|
if (uses_fpu && avoid_fpu) |
5966 |
|
int r; |
5967 |
|
int was_comp=0; |
5968 |
|
uae_u8 liveflags[MAXRUN+1]; |
5969 |
+ |
#if USE_CHECKSUM_INFO |
5970 |
+ |
bool trace_in_rom = isinrom((uintptr)pc_hist[0].location); |
5971 |
+ |
uae_u32 max_pcp=(uae_u32)pc_hist[blocklen - 1].location; |
5972 |
+ |
uae_u32 min_pcp=max_pcp; |
5973 |
+ |
#else |
5974 |
|
uae_u32 max_pcp=(uae_u32)pc_hist[0].location; |
5975 |
|
uae_u32 min_pcp=max_pcp; |
5976 |
+ |
#endif |
5977 |
|
uae_u32 cl=cacheline(pc_hist[0].location); |
5978 |
|
void* specflags=(void*)®s.spcflags; |
5979 |
|
blockinfo* bi=NULL; |
6017 |
|
remove_deps(bi); /* We are about to create new code */ |
6018 |
|
bi->optlevel=optlev; |
6019 |
|
bi->pc_p=(uae_u8*)pc_hist[0].location; |
6020 |
+ |
#if USE_CHECKSUM_INFO |
6021 |
+ |
free_checksum_info_chain(bi->csi); |
6022 |
+ |
bi->csi = NULL; |
6023 |
+ |
#endif |
6024 |
|
|
6025 |
|
liveflags[blocklen]=0x1f; /* All flags needed afterwards */ |
6026 |
|
i=blocklen; |
6028 |
|
uae_u16* currpcp=pc_hist[i].location; |
6029 |
|
uae_u32 op=DO_GET_OPCODE(currpcp); |
6030 |
|
|
6031 |
+ |
#if USE_CHECKSUM_INFO |
6032 |
+ |
trace_in_rom = trace_in_rom && isinrom((uintptr)currpcp); |
6033 |
+ |
#if USE_INLINING |
6034 |
+ |
if (is_const_jump(op)) { |
6035 |
+ |
checksum_info *csi = alloc_checksum_info(); |
6036 |
+ |
csi->start_p = (uae_u8 *)min_pcp; |
6037 |
+ |
csi->length = max_pcp - min_pcp + LONGEST_68K_INST; |
6038 |
+ |
csi->next = bi->csi; |
6039 |
+ |
bi->csi = csi; |
6040 |
+ |
max_pcp = (uae_u32)currpcp; |
6041 |
+ |
} |
6042 |
+ |
#endif |
6043 |
+ |
min_pcp = (uae_u32)currpcp; |
6044 |
+ |
#else |
6045 |
|
if ((uae_u32)currpcp<min_pcp) |
6046 |
|
min_pcp=(uae_u32)currpcp; |
6047 |
|
if ((uae_u32)currpcp>max_pcp) |
6048 |
|
max_pcp=(uae_u32)currpcp; |
6049 |
+ |
#endif |
6050 |
|
|
6051 |
|
liveflags[i]=((liveflags[i+1]& |
6052 |
|
(~prop[op].set_flags))| |
6055 |
|
liveflags[i]&= ~FLAG_Z; |
6056 |
|
} |
6057 |
|
|
6058 |
+ |
#if USE_CHECKSUM_INFO |
6059 |
+ |
checksum_info *csi = alloc_checksum_info(); |
6060 |
+ |
csi->start_p = (uae_u8 *)min_pcp; |
6061 |
+ |
csi->length = max_pcp - min_pcp + LONGEST_68K_INST; |
6062 |
+ |
csi->next = bi->csi; |
6063 |
+ |
bi->csi = csi; |
6064 |
+ |
#endif |
6065 |
+ |
|
6066 |
|
bi->needed_flags=liveflags[0]; |
6067 |
|
|
6068 |
< |
align_target(32); |
6068 |
> |
align_target(align_loops); |
6069 |
|
was_comp=0; |
6070 |
|
|
6071 |
|
bi->direct_handler=(cpuop_func *)get_target(); |
6240 |
|
raw_jmp((uae_u32)popall_do_nothing); |
6241 |
|
create_jmpdep(bi,0,tba,t1); |
6242 |
|
|
6243 |
< |
align_target(16); |
6243 |
> |
align_target(align_jumps); |
6244 |
|
/* not-predicted outcome */ |
6245 |
|
*branchadd=(uae_u32)get_target()-((uae_u32)branchadd+4); |
6246 |
|
live=tmp; /* Ouch again */ |
6309 |
|
big_to_small_state(&live,&(bi->env)); |
6310 |
|
#endif |
6311 |
|
|
6312 |
+ |
#if USE_CHECKSUM_INFO |
6313 |
+ |
remove_from_list(bi); |
6314 |
+ |
if (trace_in_rom) { |
6315 |
+ |
// No need to checksum that block trace on cache invalidation |
6316 |
+ |
free_checksum_info_chain(bi->csi); |
6317 |
+ |
bi->csi = NULL; |
6318 |
+ |
add_to_dormant(bi); |
6319 |
+ |
} |
6320 |
+ |
else { |
6321 |
+ |
calc_checksum(bi,&(bi->c1),&(bi->c2)); |
6322 |
+ |
add_to_active(bi); |
6323 |
+ |
} |
6324 |
+ |
#else |
6325 |
|
if (next_pc_p+extra_len>=max_pcp && |
6326 |
|
next_pc_p+extra_len<max_pcp+LONGEST_68K_INST) |
6327 |
|
max_pcp=next_pc_p+extra_len; /* extra_len covers flags magic */ |
6328 |
|
else |
6329 |
|
max_pcp+=LONGEST_68K_INST; |
6330 |
+ |
|
6331 |
|
bi->len=max_pcp-min_pcp; |
6332 |
|
bi->min_pcp=min_pcp; |
6333 |
< |
|
6333 |
> |
|
6334 |
|
remove_from_list(bi); |
6335 |
|
if (isinrom(min_pcp) && isinrom(max_pcp)) { |
6336 |
|
add_to_dormant(bi); /* No need to checksum it on cache flush. |
6341 |
|
calc_checksum(bi,&(bi->c1),&(bi->c2)); |
6342 |
|
add_to_active(bi); |
6343 |
|
} |
6344 |
+ |
#endif |
6345 |
|
|
6346 |
|
current_cache_size += get_target() - (uae_u8 *)current_compile_p; |
6347 |
|
|
6361 |
|
#endif |
6362 |
|
|
6363 |
|
log_dump(); |
6364 |
< |
align_target(32); |
6364 |
> |
align_target(align_jumps); |
6365 |
|
|
6366 |
|
/* This is the non-direct handler */ |
6367 |
|
bi->handler= |
6377 |
|
|
6378 |
|
raw_jmp((uae_u32)bi->direct_handler); |
6379 |
|
|
6220 |
– |
align_target(32); |
6380 |
|
current_compile_p=get_target(); |
6222 |
– |
|
6381 |
|
raise_in_cl_list(bi); |
6382 |
|
|
6383 |
|
/* We will flush soon, anyway, so let's do it now */ |
6403 |
|
{ |
6404 |
|
for (;;) { |
6405 |
|
uae_u32 opcode = GET_OPCODE; |
6248 |
– |
#ifdef X86_ASSEMBLY__disable |
6249 |
– |
__asm__ __volatile__("\tpushl %%ebp\n\tcall *%%ebx\n\tpopl %%ebp" /* FIXME */ |
6250 |
– |
: : "b" (cpufunctbl[opcode]), "a" (opcode) |
6251 |
– |
: "%edx", "%ecx", "%esi", "%edi", "%ebp", "memory", "cc"); |
6252 |
– |
#else |
6406 |
|
(*cpufunctbl[opcode])(opcode); |
6254 |
– |
#endif |
6407 |
|
if (end_block(opcode) || SPCFLAGS_TEST(SPCFLAG_ALL)) { |
6408 |
|
return; /* We will deal with the spcflags in the caller */ |
6409 |
|
} |
6428 |
|
#if FLIGHT_RECORDER |
6429 |
|
m68k_record_step(m68k_getpc()); |
6430 |
|
#endif |
6279 |
– |
#ifdef X86_ASSEMBLY__disable |
6280 |
– |
__asm__ __volatile__("\tpushl %%ebp\n\tcall *%%ebx\n\tpopl %%ebp" /* FIXME */ |
6281 |
– |
: : "b" (cpufunctbl[opcode]), "a" (opcode) |
6282 |
– |
: "%edx", "%ecx", "%esi", "%edi", "%ebp", "memory", "cc"); |
6283 |
– |
#else |
6431 |
|
(*cpufunctbl[opcode])(opcode); |
6285 |
– |
#endif |
6432 |
|
if (end_block(opcode) || SPCFLAGS_TEST(SPCFLAG_ALL) || blocklen>=MAXRUN) { |
6433 |
|
compile_block(pc_hist, blocklen); |
6434 |
|
return; /* We will deal with the spcflags in the caller */ |
6441 |
|
|
6442 |
|
typedef void (*compiled_handler)(void); |
6443 |
|
|
6444 |
+ |
#ifdef X86_ASSEMBLY |
6445 |
+ |
void (*m68k_compile_execute)(void) = NULL; |
6446 |
+ |
#else |
6447 |
|
void m68k_do_compile_execute(void) |
6448 |
|
{ |
6449 |
|
for (;;) { |
6301 |
– |
#ifdef X86_ASSEMBLY |
6302 |
– |
__asm__ __volatile__("\tpushl %%ebp\n\tcall *%%ebx\n\tpopl %%ebp" /* FIXME */ |
6303 |
– |
: : "b" (cache_tags[cacheline(regs.pc_p)].handler) |
6304 |
– |
: "%edx", "%ecx", "%eax", "%esi", "%edi", "%ebp", "memory", "cc"); |
6305 |
– |
#else |
6450 |
|
((compiled_handler)(pushall_call_handler))(); |
6307 |
– |
#endif |
6451 |
|
/* Whenever we return from that, we should check spcflags */ |
6452 |
|
if (SPCFLAGS_TEST(SPCFLAG_ALL)) { |
6453 |
|
if (m68k_do_specialties ()) |
6455 |
|
} |
6456 |
|
} |
6457 |
|
} |
6458 |
+ |
#endif |