[pypy-svn] r67990 - in pypy/branch/remove-fail/pypy/jit/backend: llgraph llsupport test x86 x86/test

arigo at codespeak.net arigo at codespeak.net
Tue Sep 29 18:01:11 CEST 2009


Author: arigo
Date: Tue Sep 29 18:01:10 2009
New Revision: 67990

Modified:
   pypy/branch/remove-fail/pypy/jit/backend/llgraph/runner.py
   pypy/branch/remove-fail/pypy/jit/backend/llsupport/gc.py
   pypy/branch/remove-fail/pypy/jit/backend/test/runner_test.py
   pypy/branch/remove-fail/pypy/jit/backend/x86/assembler.py
   pypy/branch/remove-fail/pypy/jit/backend/x86/regalloc.py
   pypy/branch/remove-fail/pypy/jit/backend/x86/test/test_basic.py
   pypy/branch/remove-fail/pypy/jit/backend/x86/test/test_gc_integration.py
   pypy/branch/remove-fail/pypy/jit/backend/x86/test/test_recompilation.py
   pypy/branch/remove-fail/pypy/jit/backend/x86/test/test_regalloc.py
   pypy/branch/remove-fail/pypy/jit/backend/x86/test/test_regalloc2.py
   pypy/branch/remove-fail/pypy/jit/backend/x86/test/test_runner.py
Log:
Fix the tests in the x86 backend.


Modified: pypy/branch/remove-fail/pypy/jit/backend/llgraph/runner.py
==============================================================================
--- pypy/branch/remove-fail/pypy/jit/backend/llgraph/runner.py	(original)
+++ pypy/branch/remove-fail/pypy/jit/backend/llgraph/runner.py	Tue Sep 29 18:01:10 2009
@@ -158,9 +158,8 @@
                 index = llimpl.compile_add_fail(c, len(self.fail_descrs))
                 faildescr._compiled_fail = c, index
                 self.fail_descrs.append(faildescr)
-                if op.fail_args:
-                    for box in op.fail_args:
-                        llimpl.compile_add_fail_arg(c, var2index[box])
+                for box in op.fail_args:
+                    llimpl.compile_add_fail_arg(c, var2index[box])
             x = op.result
             if x is not None:
                 if isinstance(x, history.BoxInt):

Modified: pypy/branch/remove-fail/pypy/jit/backend/llsupport/gc.py
==============================================================================
--- pypy/branch/remove-fail/pypy/jit/backend/llsupport/gc.py	(original)
+++ pypy/branch/remove-fail/pypy/jit/backend/llsupport/gc.py	Tue Sep 29 18:01:10 2009
@@ -492,8 +492,6 @@
                     op = ResOperation(rop.SETARRAYITEM_RAW, op.args, None,
                                       descr=op.descr)
             # ----------
-            if op.is_guard():
-                self.rewrite_assembler(cpu, op.suboperations)
             newops.append(op)
         del operations[:]
         operations.extend(newops)

Modified: pypy/branch/remove-fail/pypy/jit/backend/test/runner_test.py
==============================================================================
--- pypy/branch/remove-fail/pypy/jit/backend/test/runner_test.py	(original)
+++ pypy/branch/remove-fail/pypy/jit/backend/test/runner_test.py	Tue Sep 29 18:01:10 2009
@@ -73,8 +73,10 @@
         operations = [ResOperation(opnum, valueboxes, result),
                       ResOperation(rop.FINISH, results, None,
                                    descr=BasicFailDescr())]
-        if operations[0].is_guard() and not descr:
-            descr = BasicFailDescr()
+        if operations[0].is_guard():
+            operations[0].fail_args = []
+            if not descr:
+                descr = BasicFailDescr()
         operations[0].descr = descr
         inputargs = []
         for box in valueboxes:
@@ -393,6 +395,7 @@
                     ResOperation(rop.FINISH, [v_res], None,
                                  descr=BasicFailDescr()),
                     ]
+                ops[1].fail_args = []
             else:
                 v_exc = self.cpu.ts.BoxRef()
                 ops = [

Modified: pypy/branch/remove-fail/pypy/jit/backend/x86/assembler.py
==============================================================================
--- pypy/branch/remove-fail/pypy/jit/backend/x86/assembler.py	(original)
+++ pypy/branch/remove-fail/pypy/jit/backend/x86/assembler.py	Tue Sep 29 18:01:10 2009
@@ -251,11 +251,10 @@
 
     def regalloc_perform_with_guard(self, op, guard_op, faillocs,
                                     arglocs, resloc, current_stack_depth):
-        fail_op = guard_op.suboperations[0]
-        faildescr = fail_op.descr
+        faildescr = guard_op.descr
         assert isinstance(faildescr, AbstractFailDescr)
         faildescr._x86_current_stack_depth = current_stack_depth
-        failargs = fail_op.args
+        failargs = guard_op.fail_args
         guard_opnum = guard_op.opnum
         failaddr = self.implement_guard_recovery(guard_opnum,
                                                  faildescr, failargs,

Modified: pypy/branch/remove-fail/pypy/jit/backend/x86/regalloc.py
==============================================================================
--- pypy/branch/remove-fail/pypy/jit/backend/x86/regalloc.py	(original)
+++ pypy/branch/remove-fail/pypy/jit/backend/x86/regalloc.py	Tue Sep 29 18:01:10 2009
@@ -149,10 +149,7 @@
         self.assembler.regalloc_perform(op, arglocs, result_loc)
 
     def locs_for_fail(self, guard_op):
-        assert len(guard_op.suboperations) == 1
-        fail_op = guard_op.suboperations[0]
-        assert fail_op.opnum == rop.FAIL
-        return [self.loc(v) for v in fail_op.args]
+        return [self.loc(v) for v in guard_op.fail_args]
 
     def perform_with_guard(self, op, guard_op, arglocs, result_loc):
         faillocs = self.locs_for_fail(guard_op)
@@ -161,7 +158,7 @@
                                                    arglocs, result_loc,
                                                    self.sm.stack_depth)
         self.rm.possibly_free_var(op.result)
-        self.rm.possibly_free_vars(guard_op.suboperations[0].args)
+        self.rm.possibly_free_vars(guard_op.fail_args)
 
     def perform_guard(self, guard_op, arglocs, result_loc):
         faillocs = self.locs_for_fail(guard_op)
@@ -174,7 +171,7 @@
         self.assembler.regalloc_perform_guard(guard_op, faillocs, arglocs,
                                               result_loc,
                                               self.sm.stack_depth)
-        self.rm.possibly_free_vars(guard_op.suboperations[0].args)        
+        self.rm.possibly_free_vars(guard_op.fail_args)
 
     def PerformDiscard(self, op, arglocs):
         if not we_are_translated():
@@ -191,7 +188,7 @@
         if operations[i + 1].args[0] is not op.result:
             return False
         if (self.rm.longevity[op.result][1] > i + 1 or
-            op.result in operations[i + 1].suboperations[0].args):
+            op.result in operations[i + 1].fail_args):
             return False
         return True
 
@@ -233,12 +230,12 @@
                         raise AssertionError
                     longevity[arg] = (start_live[arg], i)
             if op.is_guard():
-                for arg in op.suboperations[0].args:
-                    if isinstance(arg, Box):
-                        if arg not in start_live:
-                            print "Bogus arg in guard %d at %d" % (op.opnum, i)
-                            raise AssertionError
-                        longevity[arg] = (start_live[arg], i)
+                for arg in op.fail_args:
+                    assert isinstance(arg, Box)
+                    if arg not in start_live:
+                        print "Bogus arg in guard %d at %d" % (op.opnum, i)
+                        raise AssertionError
+                    longevity[arg] = (start_live[arg], i)
         for arg in inputargs:
             if arg not in longevity:
                 longevity[arg] = (-1, -1)
@@ -257,14 +254,12 @@
     consider_guard_true = _consider_guard
     consider_guard_false = _consider_guard
 
-    def consider_fail(self, op, ignored):
+    def consider_finish(self, op, ignored):
         locs = [self.loc(arg) for arg in op.args]
         self.assembler.generate_failure(self.assembler.mc, op.descr, op.args,
                                         locs, self.exc)
         self.rm.possibly_free_vars(op.args)
 
-    consider_finish = consider_fail # for now
-
     def consider_guard_no_exception(self, op, ignored):
         self.perform_guard(op, [], None)
 

Modified: pypy/branch/remove-fail/pypy/jit/backend/x86/test/test_basic.py
==============================================================================
--- pypy/branch/remove-fail/pypy/jit/backend/x86/test/test_basic.py	(original)
+++ pypy/branch/remove-fail/pypy/jit/backend/x86/test/test_basic.py	Tue Sep 29 18:01:10 2009
@@ -3,7 +3,7 @@
 from pypy.jit.metainterp.warmspot import ll_meta_interp
 from pypy.jit.metainterp.test import test_basic
 from pypy.jit.metainterp.policy import StopAtXPolicy
-from pypy.rlib.jit import JitDriver
+from pypy.rlib.jit import JitDriver, OPTIMIZER_SIMPLE
 
 class Jit386Mixin(test_basic.LLJitMixin):
     type_system = 'lltype'
@@ -29,7 +29,7 @@
                 n -= x.arg
                 x.arg = 6   # prevents 'x.arg' from being annotated as constant
             return n
-        res = self.meta_interp(f, [31], specialize=False)
+        res = self.meta_interp(f, [31], optimizer=OPTIMIZER_SIMPLE)
         assert res == -4
 
     def test_r_dict(self):

Modified: pypy/branch/remove-fail/pypy/jit/backend/x86/test/test_gc_integration.py
==============================================================================
--- pypy/branch/remove-fail/pypy/jit/backend/x86/test/test_gc_integration.py	(original)
+++ pypy/branch/remove-fail/pypy/jit/backend/x86/test/test_gc_integration.py	Tue Sep 29 18:01:10 2009
@@ -107,7 +107,7 @@
         ops = '''
         [p0]
         p1 = getfield_gc(p0, descr=fielddescr)
-        fail(p1)
+        finish(p1)
         '''
         self.interpret(ops, [self.struct_ptr])
         assert not self.getptr(0, lltype.Ptr(self.S))
@@ -116,7 +116,7 @@
         ops = '''
         []
         p1 = getfield_gc(ConstPtr(struct_ref), descr=fielddescr)
-        fail(p1)
+        finish(p1)
         '''
         self.interpret(ops, [])
         assert not self.getptr(0, lltype.Ptr(self.S))
@@ -124,29 +124,22 @@
     def test_bug_0(self):
         ops = '''
         [i0, i1, i2, i3, i4, i5, i6, i7, i8]
-        guard_value(i2, 1)
-            fail(i2, i3, i4, i5, i6, i7, i0, i1, i8)
-        guard_class(i4, 138998336)
-            fail(i4, i5, i6, i7, i0, i1, i8)
+        guard_value(i2, 1) [i2, i3, i4, i5, i6, i7, i0, i1, i8]
+        guard_class(i4, 138998336) [i4, i5, i6, i7, i0, i1, i8]
         i11 = getfield_gc(i4, descr=descr0)
         i12 = ooisnull(i11)
-        guard_false(i12)
-            fail(i4, i5, i6, i7, i0, i1, i11, i8)
+        guard_false(i12) [i4, i5, i6, i7, i0, i1, i11, i8]
         i13 = getfield_gc(i11, descr=descr0)
         i14 = ooisnull(i13)
-        guard_true(i14)
-            fail(i4, i5, i6, i7, i0, i1, i11, i8)
+        guard_true(i14) [i4, i5, i6, i7, i0, i1, i11, i8]
         i15 = getfield_gc(i4, descr=descr0)
         i17 = int_lt(i15, 0)
-        guard_false(i17)
-            fail(i4, i5, i6, i7, i0, i1, i11, i15, i8)
+        guard_false(i17) [i4, i5, i6, i7, i0, i1, i11, i15, i8]
         i18 = getfield_gc(i11, descr=descr0)
         i19 = int_ge(i15, i18)
-        guard_false(i19)
-            fail(i4, i5, i6, i7, i0, i1, i11, i15, i8)
+        guard_false(i19) [i4, i5, i6, i7, i0, i1, i11, i15, i8]
         i20 = int_lt(i15, 0)
-        guard_false(i20)
-            fail(i4, i5, i6, i7, i0, i1, i11, i15, i8)
+        guard_false(i20) [i4, i5, i6, i7, i0, i1, i11, i15, i8]
         i21 = getfield_gc(i11, descr=descr0)
         i22 = getfield_gc(i11, descr=descr0)
         i23 = int_mul(i15, i22)
@@ -157,11 +150,9 @@
         i29 = getfield_raw(144839744, descr=descr0)
         i31 = int_and(i29, -2141192192)
         i32 = int_is_true(i31)
-        guard_false(i32)
-            fail(i4, i6, i7, i0, i1, i24)
+        guard_false(i32) [i4, i6, i7, i0, i1, i24]
         i33 = getfield_gc(i0, descr=descr0)
-        guard_value(i33, ConstPtr(ptr0))
-            fail(i4, i6, i7, i0, i1, i33, i24)
+        guard_value(i33, ConstPtr(ptr0)) [i4, i6, i7, i0, i1, i33, i24]
         jump(i0, i1, 1, 17, i4, ConstPtr(ptr0), i6, i7, i24)
         '''
         self.interpret(ops, [0, 0, 0, 0, 0, 0, 0, 0, 0], run=False)

Modified: pypy/branch/remove-fail/pypy/jit/backend/x86/test/test_recompilation.py
==============================================================================
--- pypy/branch/remove-fail/pypy/jit/backend/x86/test/test_recompilation.py	(original)
+++ pypy/branch/remove-fail/pypy/jit/backend/x86/test/test_recompilation.py	Tue Sep 29 18:01:10 2009
@@ -8,8 +8,7 @@
         [i0]
         i1 = int_add(i0, 1)
         i2 = int_lt(i1, 20)
-        guard_true(i2)
-           fail(i1)
+        guard_true(i2) [i1]
         jump(i1)
         '''
         loop = self.interpret(ops, [0])
@@ -17,7 +16,7 @@
         ops = '''
         [i1]
         i3 = int_add(i1, 1)
-        fail(i3)
+        finish(i3)
         '''
         bridge = self.attach_bridge(ops, loop, -2)
         self.cpu.set_future_value_int(0, 0)
@@ -30,8 +29,7 @@
         [i0]
         i1 = int_add(i0, 1)
         i2 = int_lt(i1, 20)
-        guard_true(i2)
-           fail(i1)
+        guard_true(i2) [i1]
         jump(i1)
         '''
         loop = self.interpret(ops, [0])
@@ -46,11 +44,11 @@
         i7 = int_add(i5, i4)
         i8 = int_add(i7, 1)
         i9 = int_add(i8, 1)
-        fail(i3, i4, i5, i6, i7, i8, i9)
+        finish(i3, i4, i5, i6, i7, i8, i9)
         '''
         bridge = self.attach_bridge(ops, loop, -2)
-        fail_op = loop._loop.operations[2].suboperations[0]
-        new = fail_op.descr._x86_bridge_stack_depth
+        descr = loop._loop.operations[2].descr
+        new = descr._x86_bridge_stack_depth
         assert new > previous
         self.cpu.set_future_value_int(0, 0)
         fail = self.run(loop)
@@ -65,42 +63,40 @@
         [i0, i10, i11, i12, i13, i14, i15, i16]
         i1 = int_add(i0, 1)
         i2 = int_lt(i1, 20)
-        guard_true(i2)
-           fail(i1)
+        guard_true(i2) [i1]
         jump(i1, i10, i11, i12, i13, i14, i15, i16)
         ''', [0])
         other_loop = self.interpret('''
         [i3]
-        guard_false(i3)
-           fail(i3)
+        guard_false(i3) [i3]
         jump(i3)
         ''', [1])
         ops = '''
         [i3]
         jump(i3, 1, 2, 3, 4, 5, 6, 7)
         '''
-        bridge = self.attach_bridge(ops, other_loop, 0, jump_targets=[loop])
+        bridge = self.attach_bridge(ops, other_loop, 0, jump_target=loop)
         self.cpu.set_future_value_int(0, 1)
         fail = self.run(other_loop)
-        assert fail is loop._loop.operations[2].suboperations[0].descr
+        assert fail is loop._loop.operations[2].descr
 
     def test_bridge_jumps_to_self_deeper(self):
         loop = self.interpret('''
         [i0, i1, i2, i31, i32, i33]
+        i98 = same_as(0)
+        i99 = same_as(1)
         i30 = int_add(i1, i2)
         i3 = int_add(i0, 1)
         i4 = int_and(i3, 1)
-        guard_false(i4)
-            fail(0, i3)
+        guard_false(i4) [i98, i3]
         i5 = int_lt(i3, 20)
-        guard_true(i5)
-            fail(1, i3)
+        guard_true(i5) [i99, i3]
         jump(i3, i30, 1, i30, i30, i30)
         ''', [0])
         assert self.getint(0) == 0
         assert self.getint(1) == 1
         ops = '''
-        [i3]
+        [i97, i3]
         i10 = int_mul(i3, 2)
         i8 = int_add(i3, 1)
         i6 = int_add(i8, i10)
@@ -109,10 +105,10 @@
         i11 = int_add(i12, i6)
         jump(i3, i12, i11, i10, i6, i7)
         '''
-        bridge = self.attach_bridge(ops, loop, 3, jump_targets=[loop])
-        fail_op = loop._loop.operations[3].suboperations[0]
+        bridge = self.attach_bridge(ops, loop, 5, jump_target=loop)
+        guard_op = loop._loop.operations[5]
         loop_stack_depth = loop.executable_token._x86_stack_depth
-        assert fail_op.descr._x86_bridge_stack_depth > loop_stack_depth
+        assert guard_op.descr._x86_bridge_stack_depth > loop_stack_depth
         self.cpu.set_future_value_int(0, 0)
         self.cpu.set_future_value_int(1, 0)
         self.cpu.set_future_value_int(2, 0)
@@ -123,22 +119,22 @@
     def test_bridge_jumps_to_self_shallower(self):
         loop = self.interpret('''
         [i0, i1, i2]
+        i98 = same_as(0)
+        i99 = same_as(1)
         i3 = int_add(i0, 1)
         i4 = int_and(i3, 1)
-        guard_false(i4)
-            fail(0, i3)
+        guard_false(i4) [i98, i3]
         i5 = int_lt(i3, 20)
-        guard_true(i5)
-            fail(1, i3)
+        guard_true(i5) [i99, i3]
         jump(i3, i1, i2)
         ''', [0])
         assert self.getint(0) == 0
         assert self.getint(1) == 1
         ops = '''
-        [i3]
+        [i97, i3]
         jump(i3, 0, 1)
         '''
-        bridge = self.attach_bridge(ops, loop, 2, jump_targets=[loop])
+        bridge = self.attach_bridge(ops, loop, 4, jump_target=loop)
         self.cpu.set_future_value_int(0, 0)
         self.cpu.set_future_value_int(1, 0)
         self.cpu.set_future_value_int(2, 0)

Modified: pypy/branch/remove-fail/pypy/jit/backend/x86/test/test_regalloc.py
==============================================================================
--- pypy/branch/remove-fail/pypy/jit/backend/x86/test/test_regalloc.py	(original)
+++ pypy/branch/remove-fail/pypy/jit/backend/x86/test/test_regalloc.py	Tue Sep 29 18:01:10 2009
@@ -83,14 +83,14 @@
     namespace = locals().copy()
     type_system = 'lltype'
 
-    def parse(self, s, boxkinds=None, jump_targets=None):
+    def parse(self, s, boxkinds=None, jump_target=None):
         return parse(s, self.cpu, self.namespace,
                      type_system=self.type_system,
-                     jump_targets=jump_targets,
+                     jump_target=jump_target,
                      boxkinds=boxkinds)
 
-    def interpret(self, ops, args, jump_targets=None, run=True):
-        loop = self.parse(ops, jump_targets=jump_targets)
+    def interpret(self, ops, args, jump_target=None, run=True):
+        loop = self.parse(ops, jump_target=jump_target)
         executable_token = self.cpu.compile_loop(loop.inputargs,
                                                  loop.operations)
         for i, arg in enumerate(args):
@@ -122,7 +122,7 @@
         guard_op = loop_token._loop.operations[guard_op_index]
         assert guard_op.is_guard()
         bridge = self.parse(ops, **kwds)
-        faildescr = guard_op.suboperations[0].descr
+        faildescr = guard_op.descr
         self.cpu.compile_bridge(faildescr, bridge.inputargs, bridge.operations)
         return bridge
 
@@ -135,8 +135,7 @@
         [i0]
         i1 = int_add(i0, 1)
         i2 = int_lt(i1, 20)
-        guard_true(i2)
-           fail(i1)
+        guard_true(i2) [i1]
         jump(i1)
         '''
         self.interpret(ops, [0])
@@ -147,8 +146,7 @@
         [i0, i1, i2, i3]
         i4 = int_add(i0, 1)
         i5 = int_lt(i4, 20)
-        guard_true(i5)
-           fail(i4, i1, i2, i3)
+        guard_true(i5) [i4, i1, i2, i3]
         jump(i4, i1, i2, i3)
         '''
         loop = self.interpret(ops, [0, 0, 0, 0])
@@ -158,8 +156,7 @@
         i3 = int_add(i1, 1)
         i4 = int_add(i3, 1)
         i2 = int_lt(i4, 30)
-        guard_true(i2)
-           fail(i4)
+        guard_true(i2) [i4]
         jump(i4)
         '''
         loop2 = self.interpret(ops2, [0])
@@ -167,7 +164,7 @@
         [i4]
         jump(i4, i4, i4, i4)
         '''
-        bridge = self.attach_bridge(bridge_ops, loop2, 4, jump_targets=[loop])
+        bridge = self.attach_bridge(bridge_ops, loop2, 4, jump_target=loop)
         self.cpu.set_future_value_int(0, 0)
         self.run(loop2)
         assert self.getint(0) == 31
@@ -180,8 +177,7 @@
         [i0, p0]
         i1 = int_add(i0, 1)
         i2 = int_lt(i1, 10)
-        guard_true(i2)
-            fail(p0)
+        guard_true(i2) [p0]
         jump(i1, p0)
         '''
         S = lltype.GcStruct('S')
@@ -194,20 +190,20 @@
     def test_exception_bridge_no_exception(self):
         ops = '''
         [i0]
+        i1 = same_as(1)
         call(ConstClass(raising_fptr), i0, descr=raising_calldescr)
-        guard_exception(ConstClass(zero_division_error))
-            fail(1)
-        fail(0)
+        guard_exception(ConstClass(zero_division_error)) [i1]
+        finish(0)
         '''
         bridge_ops = '''
-        []
-        guard_no_exception()
-            fail(2)
-        fail(1)
+        [i3]
+        i2 = same_as(2)
+        guard_no_exception() [i2]
+        finish(1)
         '''
         loop = self.interpret(ops, [0])
         assert self.getint(0) == 1
-        bridge = self.attach_bridge(bridge_ops, loop, 1)
+        bridge = self.attach_bridge(bridge_ops, loop, 2)
         self.cpu.set_future_value_int(0, 0)
         self.run(loop)
         assert self.getint(0) == 1
@@ -215,7 +211,7 @@
     def test_inputarg_unused(self):
         ops = '''
         [i0]
-        fail(1)
+        finish(1)
         '''
         self.interpret(ops, [0])
         # assert did not explode
@@ -223,15 +219,13 @@
     def test_nested_guards(self):
         ops = '''
         [i0, i1]
-        guard_true(i0)
-            fail(i0, i1)
-        fail(4)
+        guard_true(i0) [i0, i1]
+        finish(4)
         '''
         bridge_ops = '''
         [i0, i1]
-        guard_true(i0)
-            fail(i0, i1)
-        fail(3)
+        guard_true(i0) [i0, i1]
+        finish(3)
         '''
         loop = self.interpret(ops, [0, 10])
         assert self.getint(0) == 0
@@ -246,15 +240,14 @@
     def test_nested_unused_arg(self):
         ops = '''
         [i0, i1]
-        guard_true(i0)
-           fail(i0, i1)
-        fail(1)
+        guard_true(i0) [i0, i1]
+        finish(1)
         '''
         loop = self.interpret(ops, [0, 1])
         assert self.getint(0) == 0
         bridge_ops = '''
         [i0, i1]
-        fail(1, 2)
+        finish(1, 2)
         '''
         self.attach_bridge(bridge_ops, loop, 0)
         self.cpu.set_future_value_int(0, 0)
@@ -266,8 +259,7 @@
         [i0, i1, i2, i3]
         i4 = int_add(3, i1)
         i5 = int_lt(i4, 30)
-        guard_true(i5)
-            fail(i0, i4, i2, i3)
+        guard_true(i5) [i0, i4, i2, i3]
         jump(1, i4, 3, 4)
         '''
         self.interpret(ops, [0, 0, 0, 0])
@@ -279,8 +271,7 @@
         i4 = int_lshift(1, i1)
         i5 = int_add(1, i1)
         i6 = int_lt(i5, 30)
-        guard_true(i6)
-            fail(i4, i5, i2, i3)
+        guard_true(i6) [i4, i5, i2, i3]
         jump(i4, 3, i5, 4)
         '''
         self.interpret(ops, [0, 0, 0, 0])
@@ -290,8 +281,7 @@
         i4 = int_lshift(1, i1)
         i5 = int_add(1, i1)
         i6 = int_lt(i5, 30)
-        guard_true(i6)
-            fail(i4, i5, i2, i3)
+        guard_true(i6) [i4, i5, i2, i3]
         jump(i4, i5, 3, 4)
         '''
         self.interpret(ops, [0, 0, 0, 0])
@@ -301,8 +291,7 @@
         i4 = int_lshift(1, i1)
         i5 = int_add(1, i1)
         i6 = int_lt(i5, 30)
-        guard_true(i6)
-            fail(i4, i5, i2, i3)
+        guard_true(i6) [i4, i5, i2, i3]
         jump(i4, 4, i5, 3)
         '''
         self.interpret(ops, [0, 0, 0, 0])
@@ -314,8 +303,7 @@
         i6 = int_neg(i2)
         i7 = int_add(1, i1)
         i4 = int_lt(i7, 10)
-        guard_true(i4)
-            fail(i0, i6, i7)
+        guard_true(i4) [i0, i6, i7]
         jump(1, i7, i2, i6)
         '''
         self.interpret(ops, [0, 0, 3, 0])
@@ -327,8 +315,7 @@
         i4 = int_lt(i0, i1)
         i5 = int_add(i3, 1)
         i6 = int_lt(i5, 30)
-        guard_true(i6)
-            fail(i4)
+        guard_true(i6) [i4]
         jump(i0, i1, i4, i5)
         '''
         self.interpret(ops, [0, 10, 0, 0])
@@ -339,8 +326,7 @@
         [i0, i15, i16, i18, i1, i2, i3]
         i4 = int_add(i3, 1)
         i5 = int_lt(i4, 20)
-        guard_true(i5)
-            fail(i2, i1)
+        guard_true(i5) [i2, i1]
         jump(i0, i18, i15, i16, i2, i1, i4)
         '''
         self.interpret(ops, [0, 1, 2, 3])
@@ -349,16 +335,15 @@
         ops = '''
         [i0, i1]
         i2 = int_add(i0, i1)
-        fail(0)
+        finish(0)
         '''
         self.interpret(ops, [0, 0])
 
     def test_guard_value_two_boxes(self):
         ops = '''
         [i0, i1, i2, i3, i4, i5, i6, i7]
-        guard_value(i6, i1)
-           fail(i0, i2, i3, i4, i5, i6)
-        fail(i0, i2, i3, i4, i5, i6)
+        guard_value(i6, i1) [i0, i2, i3, i4, i5, i6]
+        finish(i0, i2, i3, i4, i5, i6)
         '''
         self.interpret(ops, [0, 0, 0, 0, 0, 0, 0, 0])
         assert self.getint(0) == 0
@@ -366,18 +351,18 @@
     def test_bug_wrong_stack_adj(self):
         ops = '''
         [i0, i1, i2, i3, i4, i5, i6, i7, i8]
-        guard_true(i0)
-            fail(0, i0, i1, i2, i3, i4, i5, i6, i7, i8)
-        fail(1, i0, i1, i2, i3, i4, i5, i6, i7, i8)
+        i9 = same_as(0)
+        guard_true(i0) [i9, i0, i1, i2, i3, i4, i5, i6, i7, i8]
+        finish(1, 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]
+        [i9, 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)
+        finish(i0, i1, i2, i3, i4, i5, i6, i7, i8)
         '''
-        self.attach_bridge(bridge_ops, loop, 0)
+        self.attach_bridge(bridge_ops, loop, 1)
         for i in range(9):
             self.cpu.set_future_value_int(i, i)
         self.run(loop)
@@ -388,10 +373,10 @@
     def test_cmp_op_0(self):
         ops = '''
         [i0, i3]
+        i1 = same_as(1)
         i2 = int_lt(i0, 100)
-        guard_true(i3)
-           fail(1, i2)
-        fail(0, i2)
+        guard_true(i3) [i1, i2]
+        finish(0, i2)
         '''
         self.interpret(ops, [0, 1])
         assert self.getint(0) == 0
@@ -419,7 +404,7 @@
         i15 = int_is_true(i5)
         i16 = int_is_true(i6)
         i17 = int_is_true(i7)
-        fail(i10, i11, i12, i13, i14, i15, i16, i17)
+        finish(i10, i11, i12, i13, i14, i15, i16, i17)
         '''
         self.interpret(ops, [0, 42, 12, 0, 13, 0, 0, 3333])
         assert self.getints(8) == [0, 1, 1, 0, 1, 0, 0, 1]
@@ -433,7 +418,7 @@
         i13 = int_eq(i5, i6)
         i14 = int_gt(i6, i2)
         i15 = int_ne(i2, i6)
-        fail(i10, i11, i12, i13, i14, i15)
+        finish(i10, i11, i12, i13, i14, i15)
         '''
         self.interpret(ops, [0, 1, 2, 3, 4, 5, 6])
         assert self.getints(6) == [1, 1, 0, 0, 1, 1]
@@ -447,7 +432,7 @@
         i13 = oononnull(i3)
         i14 = ooisnull(i6)
         i15 = ooisnull(i5)
-        fail(i10, i11, i12, i13, i14, i15)
+        finish(i10, i11, i12, i13, i14, i15)
         '''
         self.interpret(ops, [0, 1, 2, 3, 4, 5, 6])
         assert self.getints(6) == [0, 0, 1, 1, 0, 0]
@@ -456,7 +441,7 @@
         ops = '''
         [p0, i]
         strsetitem(p0, 1, i)
-        fail()
+        finish()
         '''
         llstr  = rstr.mallocstr(10)
         self.interpret(ops, [llstr, ord('a')])
@@ -466,7 +451,7 @@
         ops = '''
         [p0, i]
         setfield_gc(p0, i, descr=fielddescr)
-        fail()
+        finish()
         '''
         s = lltype.malloc(self.S)
         self.interpret(ops, [s, ord('a')])
@@ -476,7 +461,7 @@
         ops = '''
         [p0, i]
         setarrayitem_gc(p0, 1, i, descr=arraydescr)
-        fail()
+        finish()
         '''
         s = lltype.malloc(self.A, 3)
         self.interpret(ops, [s, ord('a')])

Modified: pypy/branch/remove-fail/pypy/jit/backend/x86/test/test_regalloc2.py
==============================================================================
--- pypy/branch/remove-fail/pypy/jit/backend/x86/test/test_regalloc2.py	(original)
+++ pypy/branch/remove-fail/pypy/jit/backend/x86/test/test_regalloc2.py	Tue Sep 29 18:01:10 2009
@@ -14,7 +14,7 @@
         ResOperation(rop.INT_ADD, [v1, v1], v2),
         ResOperation(rop.INT_INVERT, [v2], v3),
         ResOperation(rop.UINT_RSHIFT, [v1, ConstInt(3)], v4),
-        ResOperation(rop.FAIL, [v4, v3], None, descr=BasicFailDescr()),
+        ResOperation(rop.FINISH, [v4, v3], None, descr=BasicFailDescr()),
         ]
     cpu = CPU(None, None)
     executable_token = cpu.compile_loop(inputargs, operations)
@@ -35,7 +35,7 @@
         ResOperation(rop.INT_MUL, [v2, v1], v3),
         ResOperation(rop.INT_IS_TRUE, [v2], tmp5),
         ResOperation(rop.BOOL_NOT, [tmp5], v4),
-        ResOperation(rop.FAIL, [v4, v3, tmp5], None, descr=BasicFailDescr()),
+        ResOperation(rop.FINISH, [v4, v3, tmp5], None, descr=BasicFailDescr()),
             ]
     cpu = CPU(None, None)
     executable_token = cpu.compile_loop(inputargs, operations)
@@ -130,7 +130,7 @@
         ResOperation(rop.UINT_GT, [v33, ConstInt(-11)], v38),
         ResOperation(rop.INT_NEG, [v7], v39),
         ResOperation(rop.INT_GT, [v24, v32], v40),
-        ResOperation(rop.FAIL, [v40, v36, v37, v31, v16, v34, v35, v23, v22, v29, v14, v39, v30, v38], None, descr=BasicFailDescr()),
+        ResOperation(rop.FINISH, [v40, v36, v37, v31, v16, v34, v35, v23, v22, v29, v14, v39, v30, v38], None, descr=BasicFailDescr()),
             ]
     cpu = CPU(None, None)
     executable_token = cpu.compile_loop(inputargs, operations)
@@ -243,7 +243,7 @@
         ResOperation(rop.INT_GT, [v4, v11], v38),
         ResOperation(rop.INT_LT, [v27, v22], v39),
         ResOperation(rop.INT_NEG, [v27], v40),
-        ResOperation(rop.FAIL, [v40, v10, v36, v26, v13, v30, v21, v33, v18, v25, v31, v32, v28, v29, v35, v38, v20, v39, v34, v23, v37], None, descr=BasicFailDescr()),
+        ResOperation(rop.FINISH, [v40, v10, v36, v26, v13, v30, v21, v33, v18, v25, v31, v32, v28, v29, v35, v38, v20, v39, v34, v23, v37], None, descr=BasicFailDescr()),
             ]
     cpu = CPU(None, None)
     executable_token = cpu.compile_loop(inputargs, operations)

Modified: pypy/branch/remove-fail/pypy/jit/backend/x86/test/test_runner.py
==============================================================================
--- pypy/branch/remove-fail/pypy/jit/backend/x86/test/test_runner.py	(original)
+++ pypy/branch/remove-fail/pypy/jit/backend/x86/test/test_runner.py	Tue Sep 29 18:01:10 2009
@@ -77,12 +77,12 @@
             ResOperation(rop.INT_ADD, [x, y], z),
             ResOperation(rop.INT_SUB, [y, ConstInt(1)], t),
             ResOperation(rop.INT_EQ, [t, ConstInt(0)], u),
-            ResOperation(rop.GUARD_FALSE, [u], None),
+            ResOperation(rop.GUARD_FALSE, [u], None,
+                         descr=BasicFailDescr()),
             ResOperation(rop.JUMP, [z, t], None),
             ]
         operations[-1].jump_target = None
-        operations[-2].suboperations = [ResOperation(rop.FAIL, [t, z], None,
-                                                     descr=BasicFailDescr())]
+        operations[-2].fail_args = [t, z]
         executable_token = cpu.compile_loop([x, y], operations)
         self.cpu.set_future_value_int(0, 0)
         self.cpu.set_future_value_int(1, 10)
@@ -317,15 +317,16 @@
                     bp = BoxPtr(p)
                     n = BoxPtr(nullptr)
                 for b in (bp, n):
+                    i1 = BoxInt(1)
                     ops = [
+                        ResOperation(rop.SAME_AS, [ConstInt(1)], i1),
                         ResOperation(op, [b], f),
-                        ResOperation(guard, [f], None),
-                        ResOperation(rop.FAIL, [ConstInt(0)], None,
+                        ResOperation(guard, [f], None,
+                                     descr=BasicFailDescr()),
+                        ResOperation(rop.FINISH, [ConstInt(0)], None,
                                      descr=BasicFailDescr()),
                         ]
-                    ops[1].suboperations = [ResOperation(rop.FAIL,
-                                                        [ConstInt(1)], None,
-                                                        descr=BasicFailDescr())]
+                    ops[-2].fail_args = [i1]
                     executable_token = self.cpu.compile_loop([b], ops)
                     if op == rop.INT_IS_TRUE:
                         self.cpu.set_future_value_int(0, b.value)
@@ -362,15 +363,16 @@
             for guard in guards:
                 for op in all:
                     res = BoxInt()
+                    i1 = BoxInt(1)
                     ops = [
+                        ResOperation(rop.SAME_AS, [ConstInt(1)], i1),
                         ResOperation(op, [a, b], res),
-                        ResOperation(guard, [res], None),
-                        ResOperation(rop.FAIL, [ConstInt(0)], None,
+                        ResOperation(guard, [res], None,
+                                     descr=BasicFailDescr()),
+                        ResOperation(rop.FINISH, [ConstInt(0)], None,
                                      descr=BasicFailDescr()),
                         ]
-                    ops[1].suboperations = [ResOperation(rop.FAIL,
-                                                        [ConstInt(1)], None,
-                                                        descr=BasicFailDescr())]
+                    ops[-2].fail_args = [i1]
                     inputargs = [i for i in (a, b) if isinstance(i, Box)]
                     executable_token = self.cpu.compile_loop(inputargs, ops)
                     for i, box in enumerate(inputargs):
@@ -399,7 +401,7 @@
                 next_v = BoxInt()
                 ops.append(ResOperation(rop.INT_ADD, [v, ConstInt(1)], next_v))
                 v = next_v
-            ops.append(ResOperation(rop.FAIL, [v], None,
+            ops.append(ResOperation(rop.FINISH, [v], None,
                                     descr=BasicFailDescr()))
             executable_token = self.cpu.compile_loop([base_v], ops)
             assert self.cpu.assembler.mc != old_mc   # overflowed



More information about the Pypy-commit mailing list