[pypy-svn] r36831 - in pypy/dist/pypy/jit/codegen/i386: . test

arigo at codespeak.net arigo at codespeak.net
Tue Jan 16 18:26:23 CET 2007


Author: arigo
Date: Tue Jan 16 18:26:21 2007
New Revision: 36831

Modified:
   pypy/dist/pypy/jit/codegen/i386/rgenop.py
   pypy/dist/pypy/jit/codegen/i386/test/test_genc_ts.py
   pypy/dist/pypy/jit/codegen/i386/test/test_operation.py
Log:
Finally, with good debugging tools (here the dump backend) it is very
easy to find and fix this kind of bug.


Modified: pypy/dist/pypy/jit/codegen/i386/rgenop.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/i386/rgenop.py	(original)
+++ pypy/dist/pypy/jit/codegen/i386/rgenop.py	Tue Jan 16 18:26:21 2007
@@ -1125,8 +1125,8 @@
         self.required_frame_depth = stackn
 
     def get_operand(self, gv_source):
-        if isinstance(gv_source, IntConst):
-            return imm(gv_source.value)
+        if gv_source.is_const:
+            return imm(gv_source.revealconst(lltype.Signed))
         else:
             loc = self.var2loc[gv_source]
             return self.operands[loc]

Modified: pypy/dist/pypy/jit/codegen/i386/test/test_genc_ts.py
==============================================================================

Modified: pypy/dist/pypy/jit/codegen/i386/test/test_operation.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/i386/test/test_operation.py	(original)
+++ pypy/dist/pypy/jit/codegen/i386/test/test_operation.py	Tue Jan 16 18:26:21 2007
@@ -1,4 +1,5 @@
 from pypy.rlib.objectmodel import specialize
+from pypy.rpython.lltypesystem import lltype
 from pypy.jit.codegen.test.operation_tests import OperationTests
 from pypy.jit.codegen.i386.rgenop import RI386GenOp
 from pypy.rpython.memory.lltypelayout import convert_offset_to_int
@@ -47,3 +48,31 @@
 
     # for the individual tests see
     # ====> ../../test/operation_tests.py
+
+    def test_specific_bug(self):
+        rgenop = self.RGenOp()
+        FUNC0 = lltype.FuncType([], lltype.Signed)
+        A = lltype.GcArray(lltype.Signed)
+        a = lltype.malloc(A, 2, immortal=True)
+        gv_a = rgenop.genconst(a)
+        signed_kind = rgenop.kindToken(lltype.Signed)
+        arraytoken = rgenop.arrayToken(A)
+        builder0, gv_callable, _ = rgenop.newgraph(rgenop.sigToken(FUNC0),
+                                                   'generated')
+        builder0.genop_setarrayitem(arraytoken, gv_a, rgenop.genconst(0),
+                                    rgenop.genconst(1))
+        builder0.genop_setarrayitem(arraytoken, gv_a, rgenop.genconst(1),
+                                    rgenop.genconst(2))
+        v0 = builder0.genop_getarrayitem(arraytoken, gv_a, rgenop.genconst(0))
+        v1 = builder0.genop_getarrayitem(arraytoken, gv_a, rgenop.genconst(1))
+        v2 = builder0.genop2('int_add', v0, v1)
+        builder1 = builder0.pause_writing([v2])
+        builder1.start_writing()
+        args_gv = [v2]
+        label0 = builder1.enter_next_block([signed_kind], args_gv)
+        [v3] = args_gv
+        args_gv = [v3]
+        label1 = builder1.enter_next_block([signed_kind], args_gv)
+        [v4] = args_gv
+        builder1.finish_and_return(rgenop.sigToken(FUNC0), v4)
+        builder0.end()



More information about the Pypy-commit mailing list