コード例 #1
0
ファイル: test_rawrefcount.py プロジェクト: mozillazg/pypy
 def entry_point(argv):
     ll_dealloc_trigger_callback = llhelper(FTYPE, dealloc_trigger)
     rawrefcount.init(ll_dealloc_trigger_callback)
     ob, p = make_p()
     if state.seen != []:
         print "OB COLLECTED REALLY TOO SOON"
         return 1
     rgc.collect()
     if state.seen != []:
         print "OB COLLECTED TOO SOON"
         return 1
     objectmodel.keepalive_until_here(p)
     p = None
     rgc.collect()
     if state.seen != [1]:
         print "OB NOT COLLECTED"
         return 1
     if rawrefcount.next_dead(PyObject) != ob:
         print "NEXT_DEAD != OB"
         return 1
     if rawrefcount.next_dead(PyObject) != lltype.nullptr(PyObjectS):
         print "NEXT_DEAD second time != NULL"
         return 1
     if rawrefcount.to_obj(W_Root, ob) is not None:
         print "to_obj(dead) is not None?"
         return 1
     rawrefcount.mark_deallocating(w_marker, ob)
     if rawrefcount.to_obj(W_Root, ob) is not w_marker:
         print "to_obj(marked-dead) is not w_marker"
         return 1
     print "OK!"
     lltype.free(ob, flavor='raw')
     return 0
コード例 #2
0
 def entry_point(argv):
     ll_dealloc_trigger_callback = llhelper(FTYPE, dealloc_trigger)
     rawrefcount.init(ll_dealloc_trigger_callback)
     ob, p = make_p()
     if state.seen != []:
         print "OB COLLECTED REALLY TOO SOON"
         return 1
     rgc.collect()
     if state.seen != []:
         print "OB COLLECTED TOO SOON"
         return 1
     objectmodel.keepalive_until_here(p)
     p = None
     rgc.collect()
     if state.seen != [1]:
         print "OB NOT COLLECTED"
         return 1
     if rawrefcount.next_dead(PyObject) != ob:
         print "NEXT_DEAD != OB"
         return 1
     if rawrefcount.next_dead(PyObject) != lltype.nullptr(PyObjectS):
         print "NEXT_DEAD second time != NULL"
         return 1
     print "OK!"
     lltype.free(ob, flavor='raw')
     return 0
コード例 #3
0
 def entry_point(argv):
     rawrefcount.create_link_pypy(prebuilt_p, prebuilt_ob)
     prebuilt_ob.c_ob_refcnt += REFCNT_FROM_PYPY
     oblist = [make_ob() for i in range(50)]
     rgc.collect()
     deadlist = []
     while True:
         ob = rawrefcount.next_dead(PyObject)
         if not ob: break
         if ob.c_ob_refcnt != 1:
             print "next_dead().ob_refcnt != 1"
             return 1
         deadlist.append(ob)
     if len(deadlist) == 0:
         print "no dead object"
         return 1
     if len(deadlist) < 30:
         print "not enough dead objects"
         return 1
     for ob in deadlist:
         if ob not in oblist:
             print "unexpected value for dead pointer"
             return 1
         oblist.remove(ob)
     print "OK!"
     lltype.free(ob, flavor='raw')
     return 0
コード例 #4
0
ファイル: state.py プロジェクト: SeraphRoy/PyPy-Functional
def _rawrefcount_perform(space):
    from pypy.module.cpyext.pyobject import PyObject, decref
    while True:
        py_obj = rawrefcount.next_dead(PyObject)
        if not py_obj:
            break
        decref(space, py_obj)
コード例 #5
0
ファイル: test_rawrefcount.py プロジェクト: wdv4758h/revdb
 def main(argv):
     rawrefcount.create_link_pypy(w1, ob1)
     w = None
     ob = lltype.nullptr(PyObjectS)
     oblist = []
     for op in argv[1:]:
         revdb.stop_point()
         w = W_Root(42)
         ob = lltype.malloc(PyObjectS, flavor='raw', zero=True)
         ob.c_ob_refcnt = rawrefcount.REFCNT_FROM_PYPY
         rawrefcount.create_link_pypy(w, ob)
         oblist.append(ob)
     del oblist[-1]
     #
     rgc.collect()
     assert rawrefcount.from_obj(PyObject, w) == ob
     assert rawrefcount.to_obj(W_Root, ob) == w
     while True:
         ob = rawrefcount.next_dead(PyObject)
         if not ob:
             break
         assert ob in oblist
         oblist.remove(ob)
     objectmodel.keepalive_until_here(w)
     revdb.stop_point()
     return 9
コード例 #6
0
ファイル: state.py プロジェクト: abhinavthomas/pypy
    def perform(self, executioncontext, frame):
        from pypy.module.cpyext.pyobject import PyObject, decref

        while True:
            py_obj = rawrefcount.next_dead(PyObject)
            if not py_obj:
                break
            decref(self.space, py_obj)
コード例 #7
0
ファイル: state.py プロジェクト: sota/pypy-old
    def perform(self, executioncontext, frame):
        from pypy.module.cpyext.pyobject import PyObject, decref

        while True:
            py_obj = rawrefcount.next_dead(PyObject)
            if not py_obj:
                break
            decref(self.space, py_obj)
コード例 #8
0
ファイル: state.py プロジェクト: SeraphRoy/PyPy-Functional
 def dealloc_trigger():
     from pypy.module.cpyext.pyobject import PyObject, decref
     print 'dealloc_trigger...'
     while True:
         ob = rawrefcount.next_dead(PyObject)
         if not ob:
             break
         print 'deallocating PyObject', ob
         decref(space, ob)
     print 'dealloc_trigger DONE'
     return "RETRY"
コード例 #9
0
ファイル: test_rawrefcount.py プロジェクト: mozillazg/pypy
 def test_collect_o_dies(self):
     trigger = []; rawrefcount.init(lambda: trigger.append(1))
     p = W_Root(42)
     ob = lltype.malloc(PyObjectS, flavor='raw', zero=True)
     rawrefcount.create_link_pyobj(p, ob)
     ob.c_ob_refcnt += REFCNT_FROM_PYPY
     assert rawrefcount._o_list == [ob]
     wr_ob = weakref.ref(ob)
     wr_p = weakref.ref(p)
     del ob, p
     rawrefcount._collect()
     ob = wr_ob()
     assert ob is not None
     assert trigger == [1]
     assert rawrefcount.next_dead(PyObject) == ob
     assert rawrefcount.next_dead(PyObject) == lltype.nullptr(PyObjectS)
     assert rawrefcount.next_dead(PyObject) == lltype.nullptr(PyObjectS)
     assert rawrefcount._o_list == []
     assert wr_p() is None
     assert ob.c_ob_refcnt == 1       # from the pending list
     assert ob.c_ob_pypy_link == 0
     lltype.free(ob, flavor='raw')
コード例 #10
0
 def test_collect_o_dies(self):
     trigger = []
     rawrefcount.init(lambda: trigger.append(1))
     p = W_Root(42)
     ob = lltype.malloc(PyObjectS, flavor='raw', zero=True)
     rawrefcount.create_link_pyobj(p, ob)
     ob.c_ob_refcnt += REFCNT_FROM_PYPY
     assert rawrefcount._o_list == [ob]
     wr_ob = weakref.ref(ob)
     wr_p = weakref.ref(p)
     del ob, p
     rawrefcount._collect()
     ob = wr_ob()
     assert ob is not None
     assert trigger == [1]
     assert rawrefcount.next_dead(PyObject) == ob
     assert rawrefcount.next_dead(PyObject) == lltype.nullptr(PyObjectS)
     assert rawrefcount.next_dead(PyObject) == lltype.nullptr(PyObjectS)
     assert rawrefcount._o_list == []
     assert wr_p() is None
     assert ob.c_ob_refcnt == 1  # from the pending list
     assert ob.c_ob_pypy_link == 0
     lltype.free(ob, flavor='raw')
コード例 #11
0
 def entry_point(argv):
     ll_dealloc_trigger_callback = llhelper(FTYPE, dealloc_trigger)
     rawrefcount.init(ll_dealloc_trigger_callback)
     ob, p = make_p()
     if state.seen != []:
         print "OB COLLECTED REALLY TOO SOON"
         return 1
     rgc.collect()
     if state.seen != []:
         print "OB COLLECTED TOO SOON"
         return 1
     objectmodel.keepalive_until_here(p)
     p = None
     rgc.collect()
     if state.seen != [1]:
         print "OB NOT COLLECTED"
         return 1
     if rawrefcount.next_dead(PyObject) != ob:
         print "NEXT_DEAD != OB"
         return 1
     if ob.c_ob_refcnt != 1:
         print "next_dead().ob_refcnt != 1"
         return 1
     if rawrefcount.next_dead(PyObject) != lltype.nullptr(PyObjectS):
         print "NEXT_DEAD second time != NULL"
         return 1
     if rawrefcount.to_obj(W_Root, ob) is not None:
         print "to_obj(dead) is not None?"
         return 1
     rawrefcount.mark_deallocating(w_marker, ob)
     if rawrefcount.to_obj(W_Root, ob) is not w_marker:
         print "to_obj(marked-dead) is not w_marker"
         return 1
     print "OK!"
     lltype.free(ob, flavor='raw')
     return 0