[pypy-svn] r68122 - in pypy/branch/floats-via-sse2/pypy/jit/backend/x86: . test

fijal at codespeak.net fijal at codespeak.net
Thu Oct 1 19:40:35 CEST 2009


Author: fijal
Date: Thu Oct  1 19:40:35 2009
New Revision: 68122

Modified:
   pypy/branch/floats-via-sse2/pypy/jit/backend/x86/assembler.py
   pypy/branch/floats-via-sse2/pypy/jit/backend/x86/regalloc.py
   pypy/branch/floats-via-sse2/pypy/jit/backend/x86/test/test_regalloc.py
Log:
Fix it fix it fix it.


Modified: pypy/branch/floats-via-sse2/pypy/jit/backend/x86/assembler.py
==============================================================================
--- pypy/branch/floats-via-sse2/pypy/jit/backend/x86/assembler.py	(original)
+++ pypy/branch/floats-via-sse2/pypy/jit/backend/x86/assembler.py	Thu Oct  1 19:40:35 2009
@@ -722,28 +722,36 @@
         self.mc.CMP(mem(locs[0], offset), locs[1])
         return self.implement_guard(addr, self.mc.JNE)
 
+    def _no_const_locs(self, args, locs):
+        """ returns those locs which correspond to non-const args
+        """
+        newlocs = []
+        for i in range(len(args)):
+            arg = args[i]
+            if isinstance(arg, Box):
+                newlocs.append(locs[i])
+        return newlocs
+
     def implement_guard_recovery(self, guard_opnum, faildescr, failargs,
                                                                fail_locs):
         addr = self.mc2.tell()
         exc = (guard_opnum == rop.GUARD_EXCEPTION or
                guard_opnum == rop.GUARD_NO_EXCEPTION)
-        faildescr._x86_faillocs = fail_locs
+        faildescr._x86_faillocs = self._no_const_locs(failargs, fail_locs)
         self.generate_failure(self.mc2, faildescr, failargs, fail_locs, exc)
         return addr
 
     def generate_failure(self, mc, faildescr, failargs, locs, exc):
-        nonfloatlocs, floatlocs = locs
         assert len(failargs) < MAX_FAIL_BOXES
         pos = mc.tell()
         for i in range(len(failargs)):
             arg = failargs[i]
+            loc = locs[i]
             if arg.type == FLOAT:
-                loc = floatlocs[i]
                 if isinstance(loc, REG):
                     mc.MOVSD(addr64_add(imm(self.fail_box_float_addr),
                                         imm(i*WORD*2)), loc)
             else:
-                loc = nonfloatlocs[i]
                 if isinstance(loc, REG):
                     if arg.type == REF:
                         base = self.fail_box_ptr_addr
@@ -752,14 +760,13 @@
                     mc.MOV(addr_add(imm(base), imm(i*WORD)), loc)
         for i in range(len(failargs)):
             arg = failargs[i]
+            loc = locs[i]
             if arg.type == FLOAT:
-                loc = floatlocs[i]
                 if not isinstance(loc, REG):
                     mc.MOVSD(xmm0, loc)
                     mc.MOVSD(addr64_add(imm(self.fail_box_float_addr),
                                         imm(i*WORD*2)), xmm0)
             else:
-                loc = nonfloatlocs[i]
                 if not isinstance(loc, REG):
                     if arg.type == REF:
                         base = self.fail_box_ptr_addr
@@ -770,7 +777,7 @@
         if self.debug_markers:
             mc.MOV(eax, imm(pos))
             mc.MOV(addr_add(imm(self.fail_box_int_addr),
-                                 imm(len(nonfloatlocs) * WORD)),
+                                 imm(len(locs) * WORD)),
                                  eax)
 
         # we call a provided function that will

Modified: pypy/branch/floats-via-sse2/pypy/jit/backend/x86/regalloc.py
==============================================================================
--- pypy/branch/floats-via-sse2/pypy/jit/backend/x86/regalloc.py	(original)
+++ pypy/branch/floats-via-sse2/pypy/jit/backend/x86/regalloc.py	Thu Oct  1 19:40:35 2009
@@ -236,21 +236,17 @@
 
     def _update_bindings(self, locs, args):
         # XXX this should probably go to llsupport/regalloc.py
-        nonfloatlocs, floatlocs = locs
         used = {}
         for i in range(len(args)):
             arg = args[i]
+            loc = locs[i]
             if arg.type == FLOAT:
-                loc = floatlocs[i]
                 if isinstance(loc, REG):
                     self.xrm.reg_bindings[arg] = loc
                     used[loc] = None
                 else:
                     self.sm.stack_bindings[arg] = loc
             else:
-                loc = nonfloatlocs[i]
-                if isinstance(loc, IMM8) or isinstance(loc, IMM32):
-                    continue
                 if isinstance(loc, REG):
                     self.rm.reg_bindings[arg] = loc
                     used[loc] = None
@@ -264,6 +260,7 @@
         for reg in X86XMMRegisterManager.all_regs:
             if reg not in used:
                 self.xrm.free_regs.append(reg)
+        self.possibly_free_vars(args)
         self.rm._check_invariants()
         self.xrm._check_invariants()
 
@@ -279,16 +276,7 @@
         return self.locs_for_op(fail_op)
 
     def locs_for_op(self, fail_op):
-        nonfloatlocs = [None] * len(fail_op.args)
-        floatlocs    = [None] * len(fail_op.args)
-        for i in range(len(fail_op.args)):
-            v = fail_op.args[i]
-            loc = self.loc(v)
-            if v.type == FLOAT:
-                floatlocs[i] = loc
-            else:
-                nonfloatlocs[i] = loc
-        return nonfloatlocs, floatlocs
+        return [self.loc(v) for v in fail_op.args]
 
     def perform_with_guard(self, op, guard_op, arglocs, result_loc):
         faillocs = self.locs_for_fail(guard_op)

Modified: pypy/branch/floats-via-sse2/pypy/jit/backend/x86/test/test_regalloc.py
==============================================================================
--- pypy/branch/floats-via-sse2/pypy/jit/backend/x86/test/test_regalloc.py	(original)
+++ pypy/branch/floats-via-sse2/pypy/jit/backend/x86/test/test_regalloc.py	Thu Oct  1 19:40:35 2009
@@ -524,7 +524,7 @@
         ops.append('fail(f%d)' % (BASE_CONSTANT_SIZE * 2))
         ops = "\n".join(ops)
         self.interpret(ops, [0.1])
-        assert abs(self.getfloat(0) - (1 + BASE_CONSTANT_SIZE * 2) * 3.5 + 0.1) < 0.00001
+        assert abs(self.getfloat(0) - (BASE_CONSTANT_SIZE * 2) * 3.5 - 0.1) < 0.00001
 
     def test_lt_const(self):
         ops = '''
@@ -534,3 +534,24 @@
         '''
         self.interpret(ops, [0.1])
         assert self.getint(0) == 0
+
+    def test_bug_wrong_stack_adj(self):
+        ops = '''
+        [i0, i1, i2, i3, i4, i5, i6, i7, i8]
+        guard_true(i0)
+            fail(3.5, i0, i1, i2, i3, i4, i5, i6, i7, i8)
+        fail(4.5, i0, i1, i2, i3, i4, i5, i6, i7, i8)
+        '''
+        loop = self.interpret(ops, [0, 1, 2, 3, 4, 5, 6, 7, 8])
+        assert self.getint(0) == 0
+        bridge_ops = '''
+        [i0, i1, i2, i3, i4, i5, i6, i7, i8]
+        call(ConstClass(raising_fptr), 0, descr=raising_calldescr)
+        fail(i0, i1, i2, i3, i4, i5, i6, i7, i8)
+        '''
+        self.attach_bridge(bridge_ops, loop, 0)
+        for i in range(9):
+            self.cpu.set_future_value_int(i, i)
+        self.run(loop)
+        assert self.getints(9) == range(9)
+        assert self.getfloat(0) == 3.5



More information about the Pypy-commit mailing list