[pypy-svn] r64694 - in pypy/branch/pyjitpl5/pypy/jit/backend: test x86 x86/test

arigo at codespeak.net arigo at codespeak.net
Sun Apr 26 17:01:00 CEST 2009


Author: arigo
Date: Sun Apr 26 17:01:00 2009
New Revision: 64694

Modified:
   pypy/branch/pyjitpl5/pypy/jit/backend/test/test_random.py
   pypy/branch/pyjitpl5/pypy/jit/backend/x86/runner.py
   pypy/branch/pyjitpl5/pypy/jit/backend/x86/test/test_regalloc2.py
   pypy/branch/pyjitpl5/pypy/jit/backend/x86/test/test_runner.py
Log:
Fix the x86 backend for r64691.


Modified: pypy/branch/pyjitpl5/pypy/jit/backend/test/test_random.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/test/test_random.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/test/test_random.py	Sun Apr 26 17:01:00 2009
@@ -59,12 +59,14 @@
         print >>s, '    op = cpu.execute_operations(loop, [%s])' % (
             ', '.join(['BoxInt(%d)' % v.value for v in self.loop.inputargs]))
         if self.should_fail_by is None:
-            for v in self.loop.operations[-1].args:
-                print >>s, '    assert %s.value == %d' % (names[v], v.value)
+            for i, v in enumerate(self.loop.operations[-1].args):
+                print >>s, '    assert cpu.get_latest_value_int(%d) == %d' % (
+                    i, v.value)
         else:
             print >>s, '    assert op is loop.operations[%d].suboperations[0]' % self.should_fail_by_num
-            for v in self.should_fail_by.args:
-                print >>s, '    assert %s.value == %d' % (names[v], v.value)
+            for i, v in enumerate(self.should_fail_by.args):
+                print >>s, '    assert cpu.get_latest_value_int(%d) == %d' % (
+                    i, v.value)
         self.names = names
         if demo_conftest.option.output:
             s.close()

Modified: pypy/branch/pyjitpl5/pypy/jit/backend/x86/runner.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/x86/runner.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/x86/runner.py	Sun Apr 26 17:01:00 2009
@@ -247,12 +247,6 @@
         else:
             raise ValueError('get_box_value_as_int, wrong arg')
 
-    def set_value_of_box(self, box, index, fail_boxes):
-        if isinstance(box, BoxInt):
-            box.value = fail_boxes[index]
-        elif isinstance(box, BoxPtr):
-            box.value = self.cast_int_to_gcref(fail_boxes[index])
-
     def _new_box(self, ptr):
         if ptr:
             return BoxPtr(lltype.nullptr(llmemory.GCREF.TO))
@@ -260,12 +254,7 @@
     
     def _get_loop_for_call(self, argnum, calldescr, ptr):
         try:
-            loop = self.generated_mps[calldescr]
-            box = self._new_box(ptr)
-            loop.operations[0].result = box
-            loop.operations[-1].args[0] = box
-            loop.operations[1].suboperations[0].args[0] = box
-            return loop
+            return self.generated_mps[calldescr]
         except KeyError:
             pass
         args = [BoxInt(0) for i in range(argnum + 1)]
@@ -306,11 +295,15 @@
         del self.keepalives[oldindex:]
         op = self._guard_list[guard_index]
         #print "Leaving at: %d" % self.assembler.fail_boxes[len(op.args)]
-        for i in range(len(op.args)):
-            box = op.args[i]
-            self.set_value_of_box(box, i, self.assembler.fail_boxes)
         return op
 
+    def get_latest_value_int(self, index):
+        return self.assembler.fail_boxes[index]
+
+    def get_latest_value_ptr(self, index):
+        intvalue = self.assembler.fail_boxes[index]
+        return self.cast_int_to_gcref(intvalue)
+
     def execute_call(self, loop, func, values_as_int):
         # help flow objspace
         prev_interpreter = None
@@ -568,7 +561,10 @@
         op = self.execute_operations(loop, args)
         if size == 0:
             return None
-        return op.args[0]
+        elif ptr:
+            return BoxPtr(self.get_latest_value_ptr(0))
+        else:
+            return BoxInt(self.get_latest_value_int(0))
 
     def do_cast_ptr_to_int(self, args, descr=None):
         return BoxInt(self.cast_gcref_to_int(args[0].getptr_base()))

Modified: pypy/branch/pyjitpl5/pypy/jit/backend/x86/test/test_regalloc2.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/x86/test/test_regalloc2.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/x86/test/test_regalloc2.py	Sun Apr 26 17:01:00 2009
@@ -20,8 +20,8 @@
     cpu = CPU(None, None)
     cpu.compile_operations(loop)
     cpu.execute_operations(loop, [BoxInt(9)])
-    assert v4.value == (9 >> 3)
-    assert v3.value == (~18)
+    assert cpu.get_latest_value_int(0) == (9 >> 3)
+    assert cpu.get_latest_value_int(1) == (~18)
 
 def test_bug_int_is_true_1():
     v1 = BoxInt()
@@ -41,9 +41,9 @@
     cpu = CPU(None, None)
     cpu.compile_operations(loop)
     cpu.execute_operations(loop, [BoxInt(-10)])
-    assert tmp5.value == 1
-    assert v4.value == 0
-    assert v3.value == -1000
+    assert cpu.get_latest_value_int(0) == 0
+    assert cpu.get_latest_value_int(1) == -1000
+    assert cpu.get_latest_value_int(2) == 1
 
 def test_bug_0():
     v1 = BoxInt()
@@ -136,20 +136,20 @@
     cpu = CPU(None, None)
     cpu.compile_operations(loop)
     cpu.execute_operations(loop, [BoxInt(-13), BoxInt(10), BoxInt(10), BoxInt(8), BoxInt(-8), BoxInt(-16), BoxInt(-18), BoxInt(46), BoxInt(-12), BoxInt(26)])
-    assert v40.value == 0
-    assert v36.value == 0
-    assert v37.value == 0
-    assert v31.value == 0
-    assert v16.value == 1
-    assert v34.value == -7
-    assert v35.value == 1
-    assert v23.value == 0
-    assert v22.value == -2
-    assert v29.value == 18
-    assert v14.value == 1
-    assert v39.value == 18
-    assert v30.value == -1
-    assert v38.value == 0
+    assert cpu.get_latest_value_int(0) == 0
+    assert cpu.get_latest_value_int(1) == 0
+    assert cpu.get_latest_value_int(2) == 0
+    assert cpu.get_latest_value_int(3) == 0
+    assert cpu.get_latest_value_int(4) == 1
+    assert cpu.get_latest_value_int(5) == -7
+    assert cpu.get_latest_value_int(6) == 1
+    assert cpu.get_latest_value_int(7) == 0
+    assert cpu.get_latest_value_int(8) == -2
+    assert cpu.get_latest_value_int(9) == 18
+    assert cpu.get_latest_value_int(10) == 1
+    assert cpu.get_latest_value_int(11) == 18
+    assert cpu.get_latest_value_int(12) == -1
+    assert cpu.get_latest_value_int(13) == 0
 
 def test_bug_1():
     v1 = BoxInt()
@@ -240,24 +240,24 @@
     cpu = CPU(None, None)
     cpu.compile_operations(loop)
     cpu.execute_operations(loop, [BoxInt(17), BoxInt(-20), BoxInt(-6), BoxInt(6), BoxInt(1), BoxInt(13), BoxInt(13), BoxInt(9), BoxInt(49), BoxInt(8)])
-    assert v40.value == 0
-    assert v10.value == 8
-    assert v36.value == 1
-    assert v26.value == 131072
-    assert v13.value == 20
-    assert v30.value == 1
-    assert v21.value == 0
-    assert v33.value == -19
-    assert v18.value == 6
-    assert v25.value == 26
-    assert v31.value == 12
-    assert v32.value == 0
-    assert v28.value == 0
-    assert v29.value == 2
-    assert v35.value == 2
-    assert v38.value == 1
-    assert v20.value == 57344
-    assert v39.value == 1
-    assert v34.value == 1
-    assert v23.value == -2147483648
-    assert v37.value == 49
+    assert cpu.get_latest_value_int(0) == 0
+    assert cpu.get_latest_value_int(1) == 8
+    assert cpu.get_latest_value_int(2) == 1
+    assert cpu.get_latest_value_int(3) == 131072
+    assert cpu.get_latest_value_int(4) == 20
+    assert cpu.get_latest_value_int(5) == 1
+    assert cpu.get_latest_value_int(6) == 0
+    assert cpu.get_latest_value_int(7) == -19
+    assert cpu.get_latest_value_int(8) == 6
+    assert cpu.get_latest_value_int(9) == 26
+    assert cpu.get_latest_value_int(10) == 12
+    assert cpu.get_latest_value_int(11) == 0
+    assert cpu.get_latest_value_int(12) == 0
+    assert cpu.get_latest_value_int(13) == 2
+    assert cpu.get_latest_value_int(14) == 2
+    assert cpu.get_latest_value_int(15) == 1
+    assert cpu.get_latest_value_int(16) == 57344
+    assert cpu.get_latest_value_int(17) == 1
+    assert cpu.get_latest_value_int(18) == 1
+    assert cpu.get_latest_value_int(19) == -2147483648
+    assert cpu.get_latest_value_int(20) == 49

Modified: pypy/branch/pyjitpl5/pypy/jit/backend/x86/test/test_runner.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/x86/test/test_runner.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/x86/test/test_runner.py	Sun Apr 26 17:01:00 2009
@@ -89,7 +89,8 @@
         operations[-2].suboperations = [ResOperation(rop.FAIL, [t, z], None)]
         cpu.compile_operations(loop)
         res = self.cpu.execute_operations(loop, [BoxInt(0), BoxInt(10)])
-        assert [arg.value for arg in res.args] == [0, 55]
+        assert self.cpu.get_latest_value_int(0) == 0
+        assert self.cpu.get_latest_value_int(1) == 55
 
     def test_misc_int_ops(self):
         for op, args, res in [
@@ -464,10 +465,11 @@
                     loop.inputargs = [b]
                     self.cpu.compile_operations(loop)
                     r = self.cpu.execute_operations(loop, [b])
+                    result = self.cpu.get_latest_value_int(0)
                     if guard == rop.GUARD_FALSE:
-                        assert r.args[0].value == execute(self.cpu, op, [b]).value
+                        assert result == execute(self.cpu, op, [b]).value
                     else:
-                        assert r.args[0].value != execute(self.cpu, op, [b]).value
+                        assert result != execute(self.cpu, op, [b]).value
                     
 
     def test_stuff_followed_by_guard(self):
@@ -504,10 +506,11 @@
                     loop.inputargs = [i for i in (a, b) if isinstance(i, Box)]
                     self.cpu.compile_operations(loop)
                     r = self.cpu.execute_operations(loop, loop.inputargs)
+                    result = self.cpu.get_latest_value_int(0)
                     if guard == rop.GUARD_FALSE:
-                        assert r.args[0].value == execute(self.cpu, op, (a, b)).value
+                        assert result == execute(self.cpu, op, (a, b)).value
                     else:
-                        assert r.args[0].value != execute(self.cpu, op, (a, b)).value
+                        assert result != execute(self.cpu, op, (a, b)).value
 
     def test_overflow_mc(self):
         from pypy.jit.backend.x86.assembler import MachineCodeBlockWrapper
@@ -531,7 +534,7 @@
             loop.inputargs = [base_v]
             self.cpu.compile_operations(loop)
             op = self.cpu.execute_operations(loop, [base_v])
-            assert op.args[0].value == 1024
+            assert self.cpu.get_latest_value_int(0) == 1024
         finally:
             MachineCodeBlockWrapper.MC_SIZE = orig_size
             self.cpu.assembler.mc = old_mc



More information about the Pypy-commit mailing list