<html>
<body>
  <div id="body" style="background-color:#ffffff;" >
<table cellspacing="0" cellpadding="0" border="0" rules="cols">
<tr class="head" style="border-bottom-width:1px;border-bottom-style:solid;" ><td class="headtd" style="padding:0;padding-top:.2em;" colspan="4">Commit in <b><tt>lxdream/src</tt></b></td></tr>
<tr><td><tt>sh4/<a href="#file1">sh4trans.c</a></tt></td><td id="added" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ddffdd;" align="right">+9</td><td id="removed" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ffdddd;" align="right">-1</td><td class="headtd2" style="padding-left:.3em;padding-right:.3em;" nowrap="nowrap">8e75fab17be8 -> da6124fceec6</td></tr>
<tr class="alt" style=";" ><td><tt>   /<a href="#file2">sh4x86.in</a></tt></td><td id="addedalt" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ccf7cc;" align="right">+7</td><td id="removed" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ffdddd;" align="right">-1</td><td class="headtd2" style="padding-left:.3em;padding-right:.3em;" nowrap="nowrap">8e75fab17be8 -> da6124fceec6</td></tr>
<tr><td><tt>xlat/<a href="#file3">xltcache.c</a></tt></td><td id="added" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ddffdd;" align="right">+16</td><td id="removed" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ffdddd;" align="right">-3</td><td class="headtd2" style="padding-left:.3em;padding-right:.3em;" nowrap="nowrap">8e75fab17be8 -> da6124fceec6</td></tr>
<tr class="alt" style=";" ><td><tt>    /<a href="#file4">xltcache.h</a></tt></td><td id="addedalt" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ccf7cc;" align="right">+2</td><td id="removed" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ffdddd;" align="right">-1</td><td class="headtd2" style="padding-left:.3em;padding-right:.3em;" nowrap="nowrap">8e75fab17be8 -> da6124fceec6</td></tr>
<tr><td></td><td id="added" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ddffdd;" align="right">+34</td><td id="removed" class="headtd2" style="padding-left:.3em;padding-right:.3em; background-color:#ffdddd;" align="right">-6</td><td></td></tr>
</table>
<small id="info" style="color: #888888;" >4 modified files</small><br />
<pre class="comment" style="white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;white-space:pre-wrap;word-wrap:break-word;padding:4px;border:1px dashed #000000;background-color:#ffffdd;" >
Add chain pointer to the xlat cache, so that we can maintain multiple blocks
for the same address. This prevents thrashing in cases where we would other
keep retranslating the same blocks over and over again due to varying
xlat_sh4_mode values
</pre>
<hr /><a name="file1" /><div class="file" style="border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;" >
<span class="pathname" style="font-family:monospace; float:right;" >lxdream/src/sh4</span><br />
<div class="fileheader" style="margin-bottom:.5em;" ><big><b>sh4trans.c</b></big> <small id="info" style="color: #888888;" >8e75fab17be8 -> da6124fceec6</small></div>
<pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >--- lxdream/src/sh4/sh4trans.c
+++ lxdream/src/sh4/sh4trans.c
@@ -58,7 +58,15 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >         }
 
         code = xlat_get_code_by_vma( sh4r.pc );
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-        if( code == NULL || sh4r.xlat_sh4_mode != XLAT_BLOCK_MODE(code) ) {
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+        if( code != NULL ) {
+            while( sh4r.xlat_sh4_mode != XLAT_BLOCK_MODE(code) ) {
+                code = XLAT_BLOCK_CHAIN(code);
+                if( code == NULL ) {
+                    code = sh4_translate_basic_block( sh4r.pc );
+                    break;
+                }
+            }
+        } else {
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >             code = sh4_translate_basic_block( sh4r.pc );
         }
         code();
</pre></div>
<hr /><a name="file2" /><div class="file" style="border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;" >
<span class="pathname" style="font-family:monospace; float:right;" >lxdream/src/sh4</span><br />
<div class="fileheader" style="margin-bottom:.5em;" ><big><b>sh4x86.in</b></big> <small id="info" style="color: #888888;" >8e75fab17be8 -> da6124fceec6</small></div>
<pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >--- lxdream/src/sh4/sh4x86.in
+++ lxdream/src/sh4/sh4x86.in
@@ -521,6 +521,7 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > 
 /** Offset of xlat_sh4_mode field relative to the code pointer */ 
 #define XLAT_SH4_MODE_CODE_OFFSET  (uint32_t)(offsetof(struct xlat_cache_block, xlat_sh4_mode) - offsetof(struct xlat_cache_block,code) )
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+#define XLAT_CHAIN_CODE_OFFSET (uint32_t)(offsetof(struct xlat_cache_block, chain) - offsetof(struct xlat_cache_block,code) )
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > 
 /**
  * Test if the loaded target code pointer in %eax is valid, and if so jump
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -528,6 +529,7 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >  */
 static void jump_next_block()
 {
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+     uint8_t *ptr = xlat_output;
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >    TESTP_rptr_rptr(REG_EAX, REG_EAX);
        JE_label(nocode);
        if( sh4_x86.sh4_mode == SH4_MODE_UNKNOWN ) {
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -549,7 +551,11 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >      } else {
            JMP_rptr(REG_EAX);
        }
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-   JMP_TARGET(nocode); JMP_TARGET(wrongmode);
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+     JMP_TARGET(wrongmode);
+       MOVL_r32disp_r32( REG_EAX, XLAT_CHAIN_CODE_OFFSET, REG_EAX );
+       int rel = ptr - xlat_output;
+    JMP_prerel(rel);
+       JMP_TARGET(nocode); 
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > }
 
 static void exit_block()
</pre></div>
<hr /><a name="file3" /><div class="file" style="border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;" >
<span class="pathname" style="font-family:monospace; float:right;" >lxdream/src/xlat</span><br />
<div class="fileheader" style="margin-bottom:.5em;" ><big><b>xltcache.c</b></big> <small id="info" style="color: #888888;" >8e75fab17be8 -> da6124fceec6</small></div>
<pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >--- lxdream/src/xlat/xltcache.c
+++ lxdream/src/xlat/xltcache.c
@@ -124,7 +124,12 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     int i;
     for( i=0; i<XLAT_LUT_PAGE_ENTRIES; i++ ) {
         if( IS_ENTRY_POINT(page[i]) ) {
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-            XLAT_BLOCK_FOR_CODE(page[i])->active = 0;
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+            void *p = page[i];
+            do {
+                xlat_cache_block_t block = XLAT_BLOCK_FOR_CODE(p);
+                block->active = 0;
+                p = block->chain;
+            } while( p != NULL );
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >         }
         page[i] = NULL;
     }
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -306,6 +311,7 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     start_block->active = 1;
     start_block->size = allocation;
     start_block->lut_entry = block->lut_entry;
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+    start_block->chain = block->chain;
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     start_block->fpscr_mask = block->fpscr_mask;
     start_block->fpscr = block->fpscr;
     start_block->recover_table_offset = block->recover_table_offset;
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -353,6 +359,7 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     start_block->active = 1;
     start_block->size = allocation;
     start_block->lut_entry = block->lut_entry;
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+    start_block->chain = block->chain;
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     start_block->fpscr_mask = block->fpscr_mask;
     start_block->fpscr = block->fpscr;
     start_block->recover_table_offset = block->recover_table_offset;
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -398,8 +405,12 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     }
 
     if( IS_ENTRY_POINT(xlat_lut[XLAT_LUT_PAGE(address)][XLAT_LUT_ENTRY(address)]) ) {
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >-        xlat_cache_block_t oldblock = XLAT_BLOCK_FOR_CODE(xlat_lut[XLAT_LUT_PAGE(address)][XLAT_LUT_ENTRY(address)]);
-        oldblock->active = 0;
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+        void *p = xlat_lut[XLAT_LUT_PAGE(address)][XLAT_LUT_ENTRY(address)];
+        xlat_cache_block_t oldblock = XLAT_BLOCK_FOR_CODE(p);
+        assert( oldblock->active );
+        xlat_new_create_ptr->chain = p;
+    } else {
+        xlat_new_create_ptr->chain = NULL;
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     }
 
     xlat_lut[XLAT_LUT_PAGE(address)][XLAT_LUT_ENTRY(address)] = 
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -419,6 +430,7 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >             int oldsize = xlat_new_create_ptr->size;
             int size = oldsize + MIN_BLOCK_SIZE; /* minimum expansion */
             void **lut_entry = xlat_new_create_ptr->lut_entry;
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+            void *chain = xlat_new_create_ptr->chain;
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >             int allocation = (int)-sizeof(struct xlat_cache_block);
             xlat_new_cache_ptr = xlat_new_cache;
             do {
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -432,6 +444,7 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >             xlat_new_create_ptr->active = 1;
             xlat_new_create_ptr->size = allocation;
             xlat_new_create_ptr->lut_entry = lut_entry;
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+            xlat_new_create_ptr->chain = chain;
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >             *lut_entry = &xlat_new_create_ptr->code;
             memmove( xlat_new_create_ptr->code, olddata, oldsize );
         } else {
</pre></div>
<hr /><a name="file4" /><div class="file" style="border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;" >
<span class="pathname" style="font-family:monospace; float:right;" >lxdream/src/xlat</span><br />
<div class="fileheader" style="margin-bottom:.5em;" ><big><b>xltcache.h</b></big> <small id="info" style="color: #888888;" >8e75fab17be8 -> da6124fceec6</small></div>
<pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >--- lxdream/src/xlat/xltcache.h
+++ lxdream/src/xlat/xltcache.h
@@ -41,6 +41,7 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     int active;  /* 0 = deleted, 1 = normal. 2 = accessed (temp-space only) */
     uint32_t size;
     void **lut_entry; /* For deletion */
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+    void *chain;
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >     uint32_t xlat_sh4_mode; /* comparison with sh4r.xlat_sh4_mode */
     uint32_t recover_table_offset; // Offset from code[0] of the recovery table;
     uint32_t recover_table_size;
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -52,6 +53,7 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > #define XLAT_BLOCK_FOR_CODE(code) (((xlat_cache_block_t)code)-1)
 
 #define XLAT_BLOCK_MODE(code) (XLAT_BLOCK_FOR_CODE(code)->xlat_sh4_mode)
</pre><pre id="added" class="diff" style="margin:0; background-color:#ddffdd;" >+#define XLAT_BLOCK_CHAIN(code) (XLAT_BLOCK_FOR_CODE(code)->chain)
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > #define XLAT_RECOVERY_TABLE(code) ((xlat_recovery_record_t)(((char *)code) + XLAT_BLOCK_FOR_CODE(code)->recover_table_offset))
 
 /**
</pre><pre class="diff" style="margin:0;" ><small id="info" style="color: #888888;" >@@ -74,7 +76,6 @@
</small></pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" > 
 /**
  * Commit the current translation block
</pre><pre id="removed" class="diff" style="margin:0; background-color:#ffdddd;" >- * @param addr target address (for the lookup table)
</pre><pre id="context" class="diff" style="margin:0; background-color:#eeeeee;" >  * @param destsize final size of the translation in bytes.
  * @param srcsize size of the original data that was translated in bytes
  */
</pre></div>
<center><small>Chaos Theory</small></center>
</div></body></html>