[pypy-commit] pypy kill-someobject: more pyobj death

alex_gaynor noreply at buildbot.pypy.org
Sun Oct 7 20:36:30 CEST 2012


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: kill-someobject
Changeset: r57856:201d2c6d8098
Date: 2012-10-07 20:35 +0200
http://bitbucket.org/pypy/pypy/changeset/201d2c6d8098/

Log:	more pyobj death

diff --git a/pypy/rpython/memory/gctransform/test/test_boehm.py b/pypy/rpython/memory/gctransform/test/test_boehm.py
--- a/pypy/rpython/memory/gctransform/test/test_boehm.py
+++ b/pypy/rpython/memory/gctransform/test/test_boehm.py
@@ -5,8 +5,7 @@
 from pypy.translator.translator import graphof
 from pypy.translator.c.gc import BoehmGcPolicy
 from pypy.rpython.memory.gctransform.test.test_transform import LLInterpedTranformerTests
-from pypy import conftest
-import py
+
 
 class TestLLInterpedBoehm(LLInterpedTranformerTests):
     gcpolicy = BoehmGcPolicy
@@ -34,11 +33,6 @@
     f, t = make_boehm_finalizer(S)
     assert f is None
 
-def test_boehm_finalizer_pyobj():
-    S = lltype.GcStruct("S", ('x', lltype.Ptr(lltype.PyObject)))
-    f, t = make_boehm_finalizer(S)
-    assert f is not None
-
 def test_boehm_finalizer___del__():
     S = lltype.GcStruct("S", ('x', lltype.Signed), rtti=True)
     def f(s):
@@ -53,24 +47,6 @@
                                             lltype.Void),
                             "destructor_funcptr",
                             _callable=f)
-    pinf = lltype.attachRuntimeTypeInfo(S, qp, destrptr=dp)
+    lltype.attachRuntimeTypeInfo(S, qp, destrptr=dp)
     f, t = make_boehm_finalizer(S)
     assert f is not None
-
-def test_boehm_finalizer_nomix___del___and_pyobj():
-    S = lltype.GcStruct("S", ('x', lltype.Signed),
-                             ('y', lltype.Ptr(lltype.PyObject)), rtti=True)
-    def f(s):
-        s.x = 1
-    def type_info_S(p):
-        return lltype.getRuntimeTypeInfo(S)
-    qp = lltype.functionptr(lltype.FuncType([lltype.Ptr(S)],
-                                            lltype.Ptr(lltype.RuntimeTypeInfo)),
-                            "type_info_S",
-                            _callable=type_info_S)
-    dp = lltype.functionptr(lltype.FuncType([lltype.Ptr(S)],
-                                            lltype.Void),
-                            "destructor_funcptr",
-                            _callable=f)
-    pinf = lltype.attachRuntimeTypeInfo(S, qp, destrptr=dp)
-    py.test.raises(Exception, "make_boehm_finalizer(S)")
diff --git a/pypy/rpython/memory/gctransform/test/test_transform.py b/pypy/rpython/memory/gctransform/test/test_transform.py
--- a/pypy/rpython/memory/gctransform/test/test_transform.py
+++ b/pypy/rpython/memory/gctransform/test/test_transform.py
@@ -1,6 +1,5 @@
 from pypy.rpython.memory.gctransform.transform import BaseGCTransformer
 from pypy.objspace.flow.model import c_last_exception, Variable
-from pypy.rpython.memory.gctransform.support import var_ispyobj
 from pypy.translator.backendopt.support import var_needsgc
 from pypy.translator.translator import TranslationContext, graphof
 from pypy.translator.exceptiontransform import ExceptionTransformer
@@ -110,22 +109,13 @@
                                                   and not is_borrowed(v)])
     push_alives = len([op for op in block.operations
                        if op.opname == 'gc_push_alive'])
-    pyobj_push_alives = len([op for op in block.operations
-                             if op.opname == 'gc_push_alive_pyobj'])
 
-    # implicit_pyobj_pushalives included calls to things that return pyobject*
-    implicit_pyobj_pushalives = len([op for op in block.operations
-                                     if var_ispyobj(op.result)
-                                     and op.opname not in ('getfield', 'getarrayitem', 'same_as')])
-    nonpyobj_gc_returning_calls = len([op for op in block.operations
-                                       if op.opname in ('direct_call', 'indirect_call')
-                                       and var_needsgc(op.result)
-                                       and not var_ispyobj(op.result)])
+    gc_returning_calls = len([op for op in block.operations
+                              if op.opname in ('direct_call', 'indirect_call')
+                              and var_needsgc(op.result)])
 
     pop_alives = len([op for op in block.operations
                       if op.opname == 'gc_pop_alive'])
-    pyobj_pop_alives = len([op for op in block.operations
-                            if op.opname == 'gc_pop_alive_pyobj'])
     if pop_alives == len(block.operations):
         # it's a block we inserted
         return
@@ -135,9 +125,8 @@
         for v2 in link.target.inputargs:
             if var_needsgc(v2) and not is_borrowed(v2):
                 refs_out += 1
-        pyobj_pushes = pyobj_push_alives + implicit_pyobj_pushalives
-        nonpyobj_pushes = push_alives + nonpyobj_gc_returning_calls
-        assert refs_in + pyobj_pushes + nonpyobj_pushes == pop_alives + pyobj_pop_alives + refs_out
+        pushes = push_alives + gc_returning_calls
+        assert refs_in + pushes == pop_alives + refs_out
 
 def rtype(func, inputtypes, specialize=True):
     t = TranslationContext()
@@ -229,55 +218,6 @@
         return a.x + b.x
     t, transformer = rtype_and_transform(f, [int], _TestGCTransformer)
 
-def test_pyobj():
-    def f(x):
-        if x:
-            a = 1
-        else:
-            a = "1"
-        return int(a)
-    t, transformer = rtype_and_transform(f, [int], _TestGCTransformer)
-    fgraph = graphof(t, f)
-    gcops = [op for op in fgraph.startblock.exits[0].target.operations
-                 if op.opname.startswith("gc_")]
-    for op in gcops:
-        assert op.opname.endswith("_pyobj")
-
-def test_call_return_pyobj():
-    def g(factory):
-        return factory()
-    def f(factory):
-        g(factory)
-    t, transformer = rtype_and_transform(f, [object], _TestGCTransformer)
-    fgraph = graphof(t, f)
-    ops = getops(fgraph)
-    calls = ops['direct_call']
-    for call in calls:
-        if call.result.concretetype is not lltype.Bool: #RPyExceptionOccurred()
-            assert var_ispyobj(call.result)
-
-def test_getfield_pyobj():
-    class S:
-        pass
-    def f(thing):
-        s = S()
-        s.x = thing
-        return s.x
-    t, transformer = rtype_and_transform(f, [object], _TestGCTransformer)
-    fgraph = graphof(t, f)
-    pyobj_getfields = 0
-    pyobj_setfields = 0
-    for b in fgraph.iterblocks():
-        for op in b.operations:
-            if op.opname == 'getfield' and var_ispyobj(op.result):
-                pyobj_getfields += 1
-            elif op.opname == 'bare_setfield' and var_ispyobj(op.args[2]):
-                pyobj_setfields += 1
-    # although there's only one explicit getfield in the code, a
-    # setfield on a pyobj must get the old value out and decref it
-    assert pyobj_getfields >= 2
-    assert pyobj_setfields >= 1
-
 def test_pass_gc_pointer():
     S = lltype.GcStruct("S", ('x', lltype.Signed))
     def f(s):


More information about the pypy-commit mailing list