On Nov-13, Leopold Toetsch wrote:
> Daniel Grunblatt wrote:
> 
> > On Wednesday 13 November 2002 08:06, Leopold Toetsch wrote:
> >
> >>I could localize a long outstanding bug in JIT causing 4 perl6 tests to
> >>fail.
> 
> > I wonder who was the #%$# that introduced that bug ..... D'OH! :)
> 
> Wow, Daniel, the lost son himself ;-)

Wow, it really is him! Here, quick, are these fixes correct? (The
emit_is8bit isn't a fix, but seemed clearer) I've been periodically
having various test failures with the jit, and trying to track them
down. This particular one was nasty -- if I added or removed
completely unrelated instructions, the bug would disappear. Which now
makes sense, given the following fix:

Index: jit/i386/jit_emit.h
===================================================================
RCS file: /cvs/public/parrot/jit/i386/jit_emit.h,v
retrieving revision 1.9
diff -p -u -b -r1.9 jit_emit.h
--- jit/i386/jit_emit.h 13 Oct 2002 10:03:59 -0000      1.9
+++ jit/i386/jit_emit.h 13 Nov 2002 17:45:32 -0000
@@ -72,7 +72,7 @@
 static int 
 emit_is8bit(long disp)
 {
-    return (((disp > -129) && (disp < 128)) ? 1 : 0);
+    return (disp & 0xff) == 0;
 }
 
 static char *
@@ -132,7 +132,7 @@ emit_r_X(char *pc, int reg_opcode, int b
         }
         /* modrm sib disp */
         else { 
-            *(pc++) = (emit_is8bit ? emit_Mod_b01 : emit_Mod_b10 ) 
+            *(pc++) = (emit_is8bit(disp) ? emit_Mod_b01 : emit_Mod_b10 ) 
                 | reg_opcode | emit_b100;
             emit_sib(pc++, scale, i, base);
             return emit_disp8_32(pc, disp);
@@ -843,7 +843,7 @@ emit_jcc(Parrot_jit_info_t *jit_info, in
                 offset += 
                     jit_info->optimizer->cur_section->branch_target->load_size;
 
-        if (emit_is8bit(offset)) {
+        if (emit_is8bit(offset - 2)) {
             emitm_jxs(jit_info->native_ptr, code, offset - 2);
         }
         else {
@@ -876,7 +876,7 @@ emit_jump(Parrot_jit_info_t *jit_info, o
     if (opcode <= jit_info->op_i) {
         offset = jit_info->arena.op_map[opcode].offset -
                                 (jit_info->native_ptr - jit_info->arena.start);
-        if (emit_is8bit(offset)) {
+        if (emit_is8bit(offset - 2)) {
             emitm_jumps(jit_info->native_ptr, offset - 2);
         }
         else {

Reply via email to