[pypy-svn] r67461 - in pypy/branch/no-recompilation/pypy/jit/backend/x86: . test

fijal at codespeak.net fijal at codespeak.net
Thu Sep 3 19:58:41 CEST 2009


Author: fijal
Date: Thu Sep  3 19:58:41 2009
New Revision: 67461

Modified:
   pypy/branch/no-recompilation/pypy/jit/backend/x86/assembler.py
   pypy/branch/no-recompilation/pypy/jit/backend/x86/regalloc.py
   pypy/branch/no-recompilation/pypy/jit/backend/x86/test/test_regalloc.py
Log:
* Kill _compute_inpargs
* Finish rewriting tests
* Store _fail_op on guard_op, just to preserve order of arguments
  that go into faillocs


Modified: pypy/branch/no-recompilation/pypy/jit/backend/x86/assembler.py
==============================================================================
--- pypy/branch/no-recompilation/pypy/jit/backend/x86/assembler.py	(original)
+++ pypy/branch/no-recompilation/pypy/jit/backend/x86/assembler.py	Thu Sep  3 19:58:41 2009
@@ -662,6 +662,9 @@
         exc = (guard_op.opnum == rop.GUARD_EXCEPTION or
                guard_op.opnum == rop.GUARD_NO_EXCEPTION)
         guard_op._x86_faillocs = fail_locs
+        # XXX horrible hack that allows us to preserve order
+        #     of inputargs to bridge
+        guard_op._fail_op = guard_op.suboperations[0]
         self.generate_failure(self.mc2, guard_op.suboperations[0], fail_locs,
                               exc)
         return addr

Modified: pypy/branch/no-recompilation/pypy/jit/backend/x86/regalloc.py
==============================================================================
--- pypy/branch/no-recompilation/pypy/jit/backend/x86/regalloc.py	(original)
+++ pypy/branch/no-recompilation/pypy/jit/backend/x86/regalloc.py	Thu Sep  3 19:58:41 2009
@@ -64,9 +64,10 @@
         self.tree = tree
         if guard_op is not None:
             locs = guard_op._x86_faillocs
-            inpargs, longevity = self._compute_inpargs(guard_op)
+            inpargs = [arg for arg in guard_op._fail_op.args if
+                       isinstance(arg, Box)]
+            self._compute_vars_longevity(inpargs, guard_op.suboperations)
             self.inputargs = inpargs
-            self.longevity = longevity
             self.position = -1
             self._update_bindings(locs, inpargs)
             self.current_stack_depth = guard_op._x86_stack_depth
@@ -250,32 +251,32 @@
             assert isinstance(arg, Box)
         self.longevity = longevity
 
-    def _compute_inpargs(self, guard):
-        operations = guard.suboperations
-        longevity = {}
-        end = {}
-        for i in range(len(operations)-1, -1, -1):
-            op = operations[i]
-            if op.is_guard():
-                for arg in op.suboperations[0].args:
-                    if isinstance(arg, Box) and arg not in end:
-                        end[arg] = i
-            for arg in op.args:
-                if isinstance(arg, Box) and arg not in end:
-                    end[arg] = i
-            if op.result:
-                if op.result in end:
-                    longevity[op.result] = (i, end[op.result])
-                    del end[op.result]
-                # otherwise this var is never ever used
-        for v, e in end.items():
-            longevity[v] = (0, e)
-        inputargs = end.keys()
-        for arg in longevity:
-            assert isinstance(arg, Box)
-        for arg in inputargs:
-            assert isinstance(arg, Box)
-        return inputargs, longevity
+#     def _compute_inpargs(self, guard):
+#         operations = guard.suboperations
+#         longevity = {}
+#         end = {}
+#         for i in range(len(operations)-1, -1, -1):
+#             op = operations[i]
+#             if op.is_guard():
+#                 for arg in op.suboperations[0].args:
+#                     if isinstance(arg, Box) and arg not in end:
+#                         end[arg] = i
+#             for arg in op.args:
+#                 if isinstance(arg, Box) and arg not in end:
+#                     end[arg] = i
+#             if op.result:
+#                 if op.result in end:
+#                     longevity[op.result] = (i, end[op.result])
+#                     del end[op.result]
+#                 # otherwise this var is never ever used
+#         for v, e in end.items():
+#             longevity[v] = (0, e)
+#         inputargs = end.keys()
+#         for arg in longevity:
+#             assert isinstance(arg, Box)
+#         for arg in inputargs:
+#             assert isinstance(arg, Box)
+#         return inputargs, longevity
 
     def try_allocate_reg(self, v, selected_reg=None, need_lower_byte=False):
         assert not isinstance(v, Const)

Modified: pypy/branch/no-recompilation/pypy/jit/backend/x86/test/test_regalloc.py
==============================================================================
--- pypy/branch/no-recompilation/pypy/jit/backend/x86/test/test_regalloc.py	(original)
+++ pypy/branch/no-recompilation/pypy/jit/backend/x86/test/test_regalloc.py	Thu Sep  3 19:58:41 2009
@@ -320,18 +320,24 @@
         assert not self.cpu.assembler.fail_boxes_ptr[1]
 
     def test_exception_bridge_no_exception(self):
-        py.test.skip("rewrite")
-        
         ops = '''
         [i0]
         call(ConstClass(raising_fptr), i0, descr=raising_calldescr)
         guard_exception(ConstClass(zero_division_error))
-            guard_no_exception()
-                fail(2)
             fail(1)
         fail(0)
         '''
-        self.interpret(ops, [0])
+        bridge_ops = '''
+        []
+        guard_no_exception()
+            fail(2)
+        fail(1)
+        '''
+        loop = self.interpret(ops, [0])
+        assert self.getint(0) == 1
+        bridge = self.attach_bridge(bridge_ops, loop, loop.operations[1])
+        self.cpu.set_future_value_int(0, 0)
+        self.cpu.execute_operations(loop)
         assert self.getint(0) == 1
 
     def test_inputarg_unused(self):
@@ -343,16 +349,25 @@
         # assert did not explode
 
     def test_nested_guards(self):
-        py.test.skip("rewrite")
         ops = '''
         [i0, i1]
         guard_true(i0)
-            guard_true(i0)
-                fail(i0, i1)
-            fail(3)
+            fail(i0, i1)
         fail(4)
         '''
-        self.interpret(ops, [0, 10])
+        bridge_ops = '''
+        [i0, i1]
+        guard_true(i0)
+            fail(i0, i1)
+        fail(3)
+        '''
+        loop = self.interpret(ops, [0, 10])
+        assert self.getint(0) == 0
+        assert self.getint(1) == 10
+        bridge = self.attach_bridge(bridge_ops, loop, loop.operations[0])
+        self.cpu.set_future_value_int(0, 0)
+        self.cpu.set_future_value_int(1, 10)
+        self.cpu.execute_operations(loop)
         assert self.getint(0) == 0
         assert self.getint(1) == 10
 



More information about the Pypy-commit mailing list