revision 711:4f0ba72e58fe
summary |
tree |
shortlog |
changelog |
graph |
changeset |
raw | bz2 | zip | gz changeset | 711:4f0ba72e58fe |
parent | 710:f6eaa3bcfa5b |
child | 712:1ef156f22109 |
author | nkeynes |
date | Wed Jun 25 22:50:41 2008 +0000 (15 years ago) |
Fix size test before end-of-block extension, and add assert after sh4_translate_end_block() for consistency
1.1 --- a/src/sh4/sh4trans.c Wed Jun 25 10:42:43 2008 +00001.2 +++ b/src/sh4/sh4trans.c Wed Jun 25 22:50:41 2008 +00001.3 @@ -135,31 +135,31 @@1.4 uint8_t *eob = xlat_output + xlat_current_block->size;1.6 if( GET_ICACHE_END() < lastpc ) {1.7 - lastpc = GET_ICACHE_END();1.8 + lastpc = GET_ICACHE_END();1.9 }1.11 sh4_translate_begin_block(pc);1.13 do {1.14 - /* check for breakpoints at this pc */1.15 - for( i=0; i<sh4_breakpoint_count; i++ ) {1.16 - if( sh4_breakpoints[i].address == pc ) {1.17 - sh4_translate_emit_breakpoint(pc);1.18 - break;1.19 - }1.20 - }1.21 - if( eob - xlat_output < MAX_INSTRUCTION_SIZE ) {1.22 - uint8_t *oldstart = xlat_current_block->code;1.23 - xlat_current_block = xlat_extend_block( xlat_output - oldstart + MAX_INSTRUCTION_SIZE );1.24 - xlat_output = xlat_current_block->code + (xlat_output - oldstart);1.25 - eob = xlat_current_block->code + xlat_current_block->size;1.26 - }1.27 - done = sh4_translate_instruction( pc );1.28 - assert( xlat_output <= eob );1.29 - pc += 2;1.30 - if ( pc >= lastpc ) {1.31 - done = 2;1.32 - }1.33 + /* check for breakpoints at this pc */1.34 + for( i=0; i<sh4_breakpoint_count; i++ ) {1.35 + if( sh4_breakpoints[i].address == pc ) {1.36 + sh4_translate_emit_breakpoint(pc);1.37 + break;1.38 + }1.39 + }1.40 + if( eob - xlat_output < MAX_INSTRUCTION_SIZE ) {1.41 + uint8_t *oldstart = xlat_current_block->code;1.42 + xlat_current_block = xlat_extend_block( xlat_output - oldstart + MAX_INSTRUCTION_SIZE );1.43 + xlat_output = xlat_current_block->code + (xlat_output - oldstart);1.44 + eob = xlat_current_block->code + xlat_current_block->size;1.45 + }1.46 + done = sh4_translate_instruction( pc );1.47 + assert( xlat_output <= eob );1.48 + pc += 2;1.49 + if ( pc >= lastpc ) {1.50 + done = 2;1.51 + }1.52 } while( !done );1.53 pc += (done - 2);1.55 @@ -168,14 +168,15 @@1.57 int epilogue_size = sh4_translate_end_block_size();1.58 uint32_t recovery_size = sizeof(struct xlat_recovery_record)*xlat_recovery_posn;1.59 - uint32_t finalsize = xlat_output - xlat_current_block->code + epilogue_size + recovery_size;1.60 - if( eob - xlat_output < finalsize ) {1.61 - uint8_t *oldstart = xlat_current_block->code;1.62 - xlat_current_block = xlat_extend_block( finalsize );1.63 - xlat_output = xlat_current_block->code + (xlat_output - oldstart);1.64 + uint32_t finalsize = (xlat_output - xlat_current_block->code) + epilogue_size + recovery_size;1.65 + if( xlat_current_block->size < finalsize ) {1.66 + uint8_t *oldstart = xlat_current_block->code;1.67 + xlat_current_block = xlat_extend_block( finalsize );1.68 + xlat_output = xlat_current_block->code + (xlat_output - oldstart);1.69 }1.70 sh4_translate_end_block(pc);1.71 -1.72 + assert( xlat_output <= (xlat_current_block->code + xlat_current_block->size - recovery_size) );1.73 +1.74 /* Write the recovery records onto the end of the code block */1.75 memcpy( xlat_output, xlat_recovery, recovery_size);1.76 xlat_current_block->recover_table_offset = xlat_output - (uint8_t *)xlat_current_block->code;
.