revision 1188:1cc9bb0b3848
summary |
tree |
shortlog |
changelog |
graph |
changeset |
raw | bz2 | zip | gz changeset | 1188:1cc9bb0b3848 |
parent | 1187:266e7a1bae90 |
child | 1189:1540105786c8 |
author | Nathan Keynes <nkeynes@lxdream.org> |
date | Thu Dec 01 01:50:44 2011 +1000 (12 years ago) |
Rearrange the profile dump code so as to avoid xlat => SH4 references
1.1 --- a/src/sh4/sh4.c Tue Nov 29 17:52:43 2011 +10001.2 +++ b/src/sh4/sh4.c Thu Dec 01 01:50:44 2011 +10001.3 @@ -236,7 +236,7 @@1.4 sh4r.new_pc = sh4r.pc+2;1.5 sh4r.in_delay_slot = FALSE;1.6 if( sh4_translate_get_profile_blocks() ) {1.7 - xlat_dump_cache_by_activity(30);1.8 + sh4_translate_dump_cache_by_activity(30);1.9 }1.10 }
2.1 --- a/src/sh4/sh4trans.c Tue Nov 29 17:52:43 2011 +10002.2 +++ b/src/sh4/sh4trans.c Thu Dec 01 01:50:44 2011 +10002.3 @@ -292,3 +292,14 @@2.4 sh4_translate_disasm_block( stderr, code, sh4_pc, NULL );2.5 }2.7 +void sh4_translate_dump_cache_by_activity( unsigned int topN )2.8 +{2.9 + struct xlat_block_ref blocks[topN];2.10 + topN = xlat_get_cache_blocks_by_activity(blocks, topN);2.11 + unsigned int i;2.12 + for( i=0; i<topN; i++ ) {2.13 + fprintf( stderr, "0x%08X (%p): %d \n", blocks[i].pc, blocks[i].block->code, blocks[i].block->active);2.14 + sh4_translate_disasm_block( stderr, blocks[i].block->code, blocks[i].pc, NULL );2.15 + fprintf( stderr, "\n" );2.16 + }2.17 +}
3.1 --- a/src/sh4/sh4trans.h Tue Nov 29 17:52:43 2011 +10003.2 +++ b/src/sh4/sh4trans.h Thu Dec 01 01:50:44 2011 +10003.3 @@ -171,6 +171,11 @@3.4 */3.5 void sh4_translate_disasm_block( FILE *out, void *code, sh4addr_t source_start, void *native_pc );3.7 +/**3.8 + * Dump the top N blocks in the SH4 translation cache3.9 + */3.10 +void sh4_translate_dump_cache_by_activity( unsigned int topN );3.11 +3.12 #ifdef __cplusplus3.13 }3.14 #endif
4.1 --- a/src/xlat/xltcache.c Tue Nov 29 17:52:43 2011 +10004.2 +++ b/src/xlat/xltcache.c Thu Dec 01 01:50:44 2011 +10004.3 @@ -583,11 +583,6 @@4.4 #endif4.5 }4.7 -typedef struct {4.8 - xlat_cache_block_t block;4.9 - sh4addr_t sh4_pc;4.10 -} block_sh4_entry;4.11 -4.12 unsigned int xlat_get_active_block_count()4.13 {4.14 unsigned int count = 0;4.15 @@ -601,14 +596,14 @@4.16 return count;4.17 }4.19 -unsigned int xlat_get_active_blocks( block_sh4_entry *blocks, unsigned int size )4.20 +unsigned int xlat_get_active_blocks( struct xlat_block_ref *blocks, unsigned int size )4.21 {4.22 unsigned int count = 0;4.23 xlat_cache_block_t ptr = xlat_new_cache;4.24 while( ptr->size != 0 ) {4.25 if( ptr->active != 0 ) {4.26 blocks[count].block = ptr;4.27 - blocks[count].sh4_pc = 0;4.28 + blocks[count].pc = 0;4.29 count++;4.30 }4.31 if( count >= size )4.32 @@ -618,7 +613,7 @@4.33 return count;4.34 }4.36 -void xlat_get_block_sh4addrs( block_sh4_entry *blocks, unsigned int size )4.37 +void xlat_get_block_sh4addrs( struct xlat_block_ref *blocks, unsigned int size )4.38 {4.39 unsigned i;4.40 for( i=0; i<XLAT_LUT_PAGES;i ++ ) {4.41 @@ -631,7 +626,7 @@4.42 sh4addr_t pc = XLAT_ADDR_FROM_ENTRY(i,j);4.43 for( unsigned k=0; k<size; k++ ) {4.44 if( blocks[k].block == ptr ) {4.45 - blocks[k].sh4_pc = pc;4.46 + blocks[k].pc = pc;4.47 ptr = ptr->chain;4.48 if( ptr == NULL )4.49 break;4.50 @@ -649,26 +644,23 @@4.52 static int xlat_compare_active_field( const void *a, const void *b )4.53 {4.54 - const block_sh4_entry *ptra = (const block_sh4_entry *)a;4.55 - const block_sh4_entry *ptrb = (const block_sh4_entry *)b;4.56 + const struct xlat_block_ref *ptra = (const struct xlat_block_ref *)a;4.57 + const struct xlat_block_ref *ptrb = (const struct xlat_block_ref *)b;4.58 return ptrb->block->active - ptra->block->active;4.59 }4.61 -void xlat_dump_cache_by_activity( unsigned int topN )4.62 +unsigned int xlat_get_cache_blocks_by_activity( xlat_block_ref_t outblocks, size_t topN )4.63 {4.64 int i=0;4.65 int count = xlat_get_active_block_count();4.67 - block_sh4_entry blocks[count];4.68 + struct xlat_block_ref blocks[count];4.69 xlat_get_active_blocks(blocks, count);4.70 xlat_get_block_sh4addrs(blocks,count);4.71 - qsort(blocks, count, sizeof(block_sh4_entry), xlat_compare_active_field);4.72 + qsort(blocks, count, sizeof(struct xlat_block_ref), xlat_compare_active_field);4.74 - if( topN == 0 || topN > count )4.75 + if( topN > count )4.76 topN = count;4.77 - for( unsigned int i=0; i<topN; i++ ) {4.78 - fprintf(stderr, "0x%08X (%p): %d\n", blocks[i].sh4_pc, blocks[i].block->code, blocks[i].block->active);4.79 - sh4_translate_disasm_block( stderr, blocks[i].block->code, blocks[i].sh4_pc, NULL );4.80 - fprintf(stderr, "\n");4.81 - }4.82 + memcpy(outblocks, blocks, topN*sizeof(struct xlat_block_ref));4.83 + return topN;4.84 }
5.1 --- a/src/xlat/xltcache.h Tue Nov 29 17:52:43 2011 +10005.2 +++ b/src/xlat/xltcache.h Thu Dec 01 01:50:44 2011 +10005.3 @@ -183,10 +183,21 @@5.4 void xlat_check_integrity();5.6 /**5.7 - * Dump out the top N translated blocks by number of executions (requires block5.8 + * Short record with block + pc, used for activity dumps5.9 + */5.10 +typedef struct xlat_block_ref {5.11 + xlat_cache_block_t block;5.12 + uint32_t pc;5.13 +} *xlat_block_ref_t;5.14 +5.15 +/**5.16 + * Fetch the top numRecords translated blocks by number of executions (requires block5.17 * profiling to be turned on in order to give meaningful results).5.18 - * @param topN Number of blocks to print. If 0, print all blocks in the cache5.19 + * @param topN Number of blocks to print.5.20 + * @return the number of records retrieved5.21 */5.22 +unsigned int xlat_get_cache_blocks_by_activity( xlat_block_ref_t records, size_t numRecords );5.23 +5.24 void xlat_dump_cache_by_activity( unsigned int topN );5.26 #endif /* lxdream_xltcache_H */
.