filename | src/sh4/sh4x86.in |
changeset | 1182:b38a327ad8fa |
prev | 1176:70feb1749427 |
next | 1186:2dc47c67bb93 |
author | nkeynes |
date | Sun Nov 27 18:20:21 2011 +1000 (10 years ago) |
permissions | -rw-r--r-- |
last change | Add block profiling option to count the number of executions of each block, and dump them out from most-to-least used. |
file | annotate | diff | log | raw |
1.1 --- a/src/sh4/sh4x86.in Thu May 12 08:45:25 2011 +10001.2 +++ b/src/sh4/sh4x86.in Sun Nov 27 18:20:21 2011 +10001.3 @@ -106,6 +106,7 @@1.4 xlat_block_begin_callback_t begin_callback;1.5 xlat_block_end_callback_t end_callback;1.6 gboolean fastmem;1.7 + gboolean profile_blocks;1.9 /* Allocated memory for the (block-wide) back-patch list */1.10 struct backpatch_record *backpatch_list;1.11 @@ -166,6 +167,7 @@1.12 sh4_x86.end_callback = NULL;1.13 sh4_translate_set_address_space( sh4_address_space, sh4_user_address_space );1.14 sh4_x86.fastmem = TRUE;1.15 + sh4_x86.profile_blocks = FALSE;1.16 sh4_x86.sse3_enabled = is_sse3_supported();1.17 x86_disasm_init();1.18 x86_set_symtab( x86_symbol_table, sizeof(x86_symbol_table)/sizeof(struct x86_symbol) );1.19 @@ -182,6 +184,16 @@1.20 sh4_x86.fastmem = flag;1.21 }1.23 +void sh4_translate_set_profile_blocks( gboolean flag )1.24 +{1.25 + sh4_x86.profile_blocks = flag;1.26 +}1.27 +1.28 +gboolean sh4_translate_get_profile_blocks()1.29 +{1.30 + return sh4_x86.profile_blocks;1.31 +}1.32 +1.33 /**1.34 * Disassemble the given translated code block, and it's source SH4 code block1.35 * side-by-side. The current native pc will be marked if non-null.1.36 @@ -476,6 +488,11 @@1.38 #define SLOTILLEGAL() exit_block_exc(EXC_SLOT_ILLEGAL, pc-2); sh4_x86.in_delay_slot = DELAY_NONE; return 2;1.40 +/** Offset of xlat_sh4_mode field relative to the code pointer */1.41 +#define XLAT_SH4_MODE_CODE_OFFSET (uint32_t)(offsetof(struct xlat_cache_block, xlat_sh4_mode) - offsetof(struct xlat_cache_block,code) )1.42 +#define XLAT_CHAIN_CODE_OFFSET (uint32_t)(offsetof(struct xlat_cache_block, chain) - offsetof(struct xlat_cache_block,code) )1.43 +#define XLAT_ACTIVE_CODE_OFFSET (uint32_t)(offsetof(struct xlat_cache_block, active) - offsetof(struct xlat_cache_block,code) )1.44 +1.45 void sh4_translate_begin_block( sh4addr_t pc )1.46 {1.47 sh4_x86.code = xlat_output;1.48 @@ -493,6 +510,10 @@1.49 if( sh4_x86.begin_callback ) {1.50 CALL_ptr( sh4_x86.begin_callback );1.51 }1.52 + if( sh4_x86.profile_blocks ) {1.53 + MOVP_immptr_rptr( ((uintptr_t)sh4_x86.code) + XLAT_ACTIVE_CODE_OFFSET, REG_EAX );1.54 + ADDL_imms_r32disp( 1, REG_EAX, 0 );1.55 + }1.56 }1.59 @@ -519,10 +540,6 @@1.61 #define UNTRANSLATABLE(pc) !IS_IN_ICACHE(pc)1.63 -/** Offset of xlat_sh4_mode field relative to the code pointer */1.64 -#define XLAT_SH4_MODE_CODE_OFFSET (uint32_t)(offsetof(struct xlat_cache_block, xlat_sh4_mode) - offsetof(struct xlat_cache_block,code) )1.65 -#define XLAT_CHAIN_CODE_OFFSET (uint32_t)(offsetof(struct xlat_cache_block, chain) - offsetof(struct xlat_cache_block,code) )1.66 -1.67 /**1.68 * Test if the loaded target code pointer in %eax is valid, and if so jump1.69 * directly into it, bypassing the normal exit.
.