Ejemplo n.º 1
0
def _Py_Dealloc(space, obj):
    from pypy.module.cpyext.api import generic_cpy_call
    pto = obj.c_ob_type
    #print >>sys.stderr, "Calling dealloc slot", pto.c_tp_dealloc, "of", obj, \
    #      "'s type which is", rffi.charp2str(pto.c_tp_name)
    rawrefcount.mark_deallocating(w_marker_deallocating, obj)
    generic_cpy_call(space, pto.c_tp_dealloc, obj)
Ejemplo n.º 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
     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
Ejemplo n.º 3
0
def _Py_Dealloc(space, obj):
    from pypy.module.cpyext.api import generic_cpy_call
    pto = obj.c_ob_type
    #print >>sys.stderr, "Calling dealloc slot", pto.c_tp_dealloc, "of", obj, \
    #      "'s type which is", rffi.charp2str(pto.c_tp_name)
    rawrefcount.mark_deallocating(w_marker_deallocating, obj)
    generic_cpy_call(space, pto.c_tp_dealloc, obj)
Ejemplo n.º 4
0
 def test_mark_deallocating(self):
     ob = lltype.malloc(PyObjectS, flavor='raw', zero=True)
     w_marker = W_Root(42)
     rawrefcount.mark_deallocating(w_marker, ob)
     assert rawrefcount.to_obj(W_Root, ob) is w_marker
     rawrefcount._collect()
     assert rawrefcount.to_obj(W_Root, ob) is w_marker
     lltype.free(ob, flavor='raw')
Ejemplo n.º 5
0
 def test_mark_deallocating(self):
     ob = lltype.malloc(PyObjectS, flavor='raw', zero=True)
     w_marker = W_Root(42)
     rawrefcount.mark_deallocating(w_marker, ob)
     assert rawrefcount.to_obj(W_Root, ob) is w_marker
     rawrefcount._collect()
     assert rawrefcount.to_obj(W_Root, ob) is w_marker
     lltype.free(ob, flavor='raw')
Ejemplo n.º 6
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