[pypy-commit] pypy stmgc-c4: fix ptr_eq and add a test for it in zrpy_gc_test.py

Raemi noreply at buildbot.pypy.org
Mon Jul 29 16:55:16 CEST 2013


Author: Remi Meier <remi.meier at gmail.com>
Branch: stmgc-c4
Changeset: r65791:796f9faedadc
Date: 2013-07-29 16:54 +0200
http://bitbucket.org/pypy/pypy/changeset/796f9faedadc/

Log:	fix ptr_eq and add a test for it in zrpy_gc_test.py

diff --git a/rpython/config/translationoption.py b/rpython/config/translationoption.py
--- a/rpython/config/translationoption.py
+++ b/rpython/config/translationoption.py
@@ -74,10 +74,10 @@
                                ("translation.gctransformer", "boehm")],
                      "minimark": [("translation.gctransformer", "framework")],
                      "stmgc": [("translation.gctransformer", "framework"),
-                               ("translation.gcrootfinder", "stm")],
+                               ("translation.gcrootfinder", "stm"),
+                               ("translation.gcremovetypeptr", False)],
                      },
                  suggests = {
-                     "stmgc": [("translation.gcremovetypeptr", True)],
                      },
                   cmdline="--gc"),
     ChoiceOption("gctransformer", "GC transformer that is used - internal",
diff --git a/rpython/jit/backend/llsupport/test/zrpy_gc_test.py b/rpython/jit/backend/llsupport/test/zrpy_gc_test.py
--- a/rpython/jit/backend/llsupport/test/zrpy_gc_test.py
+++ b/rpython/jit/backend/llsupport/test/zrpy_gc_test.py
@@ -45,9 +45,11 @@
             rgc.collect()
         rgc.collect(); rgc.collect()
         freed = 0
-        for r in r_list:
+        for i, r in enumerate(r_list):
             if r() is None:
                 freed += 1
+            else:
+                print "not freed:", r(), "pos:", i
         print freed
         return 0
 
@@ -79,10 +81,11 @@
     if gcrootfinder == 'stm':
         t.config.translation.stm = True
         t.config.translation.gc = 'stmgc'
+        gc = 'stmgc'
     else:
         t.config.translation.gc = gc
     #
-    if gc != 'boehm':
+    if gc != 'boehm' and gc != 'stmgc':
         t.config.translation.gcremovetypeptr = True
     for name, value in kwds.items():
         setattr(t.config.translation, name, value)
@@ -777,3 +780,33 @@
 
     def test_compile_framework_call_assembler(self):
         self.run('compile_framework_call_assembler')
+
+    def define_compile_framework_ptr_eq(cls):
+        # test ptr_eq
+        def raiseassert(cond):
+            if not bool(cond):
+                raise AssertionError
+
+        def before(n, x):
+            x0 = X()
+            x1 = X()
+            ptrs = [None, x0, x1, X()]
+            return (n, x, x0, x1, None, None, None,
+                    None, None, None, ptrs, None)
+            
+        @unroll_safe
+        def f(n, x, x0, x1, x2, x3, x4, x5, x6, x7, ptrs, s):
+            raiseassert(x0 != ptrs[0])
+            raiseassert(x0 == ptrs[1])
+            raiseassert(x0 != ptrs[2])
+            raiseassert(x0 != ptrs[3])
+            raiseassert(x1 != ptrs[0])
+            raiseassert(x1 != ptrs[1])
+            raiseassert(x1 == ptrs[2])
+            raiseassert(x1 != ptrs[3])
+            #
+            return n - 1, x, x0, x1, x2, x3, x4, x5, x6, x7, ptrs, s
+        return before, f, None
+
+    def test_compile_framework_ptr_eq(self):
+        self.run('compile_framework_ptr_eq')
diff --git a/rpython/jit/backend/x86/assembler.py b/rpython/jit/backend/x86/assembler.py
--- a/rpython/jit/backend/x86/assembler.py
+++ b/rpython/jit/backend/x86/assembler.py
@@ -1059,7 +1059,7 @@
         if not self.cpu.gc_ll_descr.stm:
             self.genop_guard_int_eq(op, guard_op, guard_token,
                                     arglocs, result_loc)
-        assert not self.cpu.gc_ll_descr.stm
+        assert self.cpu.gc_ll_descr.stm
         guard_opnum = guard_op.getopnum()
         self._stm_ptr_eq_fastpath(self.mc, arglocs, result_loc)
         if guard_opnum == rop.GUARD_FALSE:
@@ -1072,7 +1072,7 @@
         if not self.cpu.gc_ll_descr.stm:
             self.genop_guard_int_ne(op, guard_op, guard_token,
                                     arglocs, result_loc)
-        assert not self.cpu.gc_ll_descr.stm
+        assert self.cpu.gc_ll_descr.stm
         guard_opnum = guard_op.getopnum()
         self._stm_ptr_eq_fastpath(self.mc, arglocs, result_loc)
         if guard_opnum == rop.GUARD_FALSE:
@@ -2179,7 +2179,8 @@
         mc.CMP(X86_64_SCRATCH_REG, b_base)
         mc.SET_ir(rx86.Conditions['Z'], sl.value)
         mc.MOVZX8_rr(X86_64_SCRATCH_REG.value, sl.value)
-        mc.TEST(X86_64_SCRATCH_REG, X86_64_SCRATCH_REG)
+        # mc.TEST8_rr() without movzx8
+        mc.TEST_rr(X86_64_SCRATCH_REG.value, X86_64_SCRATCH_REG.value)
         mc.J_il8(rx86.Conditions['NZ'], 0)
         j_ok1 = mc.get_relative_pos()
 
@@ -2188,7 +2189,7 @@
         mc.J_il8(rx86.Conditions['Z'], 0)
         j_ok2 = mc.get_relative_pos()
         #
-        mc.CMP(a_base, imm(0))
+        mc.CMP(b_base, imm(0))
         mc.J_il8(rx86.Conditions['Z'], 0)
         j_ok3 = mc.get_relative_pos()
         
@@ -2203,7 +2204,6 @@
         func = self.ptr_eq_slowpath
         mc.CALL(imm(func))
         # result still on stack
-        assert isinstance(result_loc, RegLoc)
         mc.POP_r(X86_64_SCRATCH_REG.value)
         # set flags:
         mc.TEST(X86_64_SCRATCH_REG, X86_64_SCRATCH_REG)


More information about the pypy-commit mailing list