예제 #1
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
예제 #2
0
    def setup_rawrefcount(self):
        space = self.space
        if not self.space.config.translating:

            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"

            rawrefcount.init(dealloc_trigger)
        else:
            if space.config.translation.gc == "boehm":
                action = BoehmPyObjDeallocAction(space)
                space.actionflag.register_periodic_action(
                    action, use_bytecode_counter=True)
            else:
                pyobj_dealloc_action = PyObjDeallocAction(space)
                self.dealloc_trigger = lambda: pyobj_dealloc_action.fire()
예제 #3
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
예제 #4
0
파일: state.py 프로젝트: abhinavthomas/pypy
    def startup(self, space):
        "This function is called when the program really starts"

        from pypy.module.cpyext.typeobject import setup_new_method_def
        from pypy.module.cpyext.api import INIT_FUNCTIONS
        from pypy.module.cpyext.api import init_static_data_translated

        if we_are_translated():
            rawrefcount.init(llhelper(rawrefcount.RAWREFCOUNT_DEALLOC_TRIGGER,
                                      self.dealloc_trigger))
            init_static_data_translated(space)

        setup_new_method_def(space)

        for func in INIT_FUNCTIONS:
            func(space)
            self.check_and_raise_exception()
예제 #5
0
파일: state.py 프로젝트: sota/pypy-old
    def startup(self, space):
        "This function is called when the program really starts"

        from pypy.module.cpyext.typeobject import setup_new_method_def
        from pypy.module.cpyext.api import INIT_FUNCTIONS
        from pypy.module.cpyext.api import init_static_data_translated

        if we_are_translated():
            rawrefcount.init(
                llhelper(rawrefcount.RAWREFCOUNT_DEALLOC_TRIGGER,
                         self.dealloc_trigger))
            init_static_data_translated(space)

        setup_new_method_def(space)

        for func in INIT_FUNCTIONS:
            func(space)
            self.check_and_raise_exception()
예제 #6
0
    def startup(self, space):
        "This function is called when the program really starts"
        from pypy.module.cpyext.typeobject import setup_new_method_def
        from pypy.module.cpyext.api import INIT_FUNCTIONS

        if we_are_translated():
            if space.config.translation.gc != "boehm":
                # This must be called in RPython, the untranslated version
                # does something different. Sigh.
                rawrefcount.init(
                    llhelper(rawrefcount.RAWREFCOUNT_DEALLOC_TRIGGER,
                             self.dealloc_trigger))
            self.builder.attach_all(space)

        setup_new_method_def(space)

        for func in INIT_FUNCTIONS:
            func(space)
            self.check_and_raise_exception()
예제 #7
0
 def test_collect_s_dies(self):
     trigger = []; rawrefcount.init(lambda: trigger.append(1))
     p = W_Root(42)
     ob = lltype.malloc(PyObjectS, flavor='raw', zero=True)
     rawrefcount.create_link_pypy(p, ob)
     ob.c_ob_refcnt += REFCNT_FROM_PYPY
     assert rawrefcount._p_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._d_list == [ob]
     assert rawrefcount._p_list == []
     assert wr_p() is None
     assert ob.c_ob_refcnt == 1       # from _d_list
     assert ob.c_ob_pypy_link == 0
     lltype.free(ob, flavor='raw')
예제 #8
0
 def test_collect_s_dies(self):
     trigger = []
     rawrefcount.init(lambda: trigger.append(1))
     p = W_Root(42)
     ob = lltype.malloc(PyObjectS, flavor='raw', zero=True)
     rawrefcount.create_link_pypy(p, ob)
     ob.c_ob_refcnt += REFCNT_FROM_PYPY
     assert rawrefcount._p_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._d_list == [ob]
     assert rawrefcount._p_list == []
     assert wr_p() is None
     assert ob.c_ob_refcnt == 1  # from _d_list
     assert ob.c_ob_pypy_link == 0
     lltype.free(ob, flavor='raw')
예제 #9
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 == 0
     assert ob.c_ob_pypy_link == 0
     lltype.free(ob, flavor="raw")
예제 #10
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
예제 #11
0
 def setup_method(self, meth):
     rawrefcount.init()
예제 #12
0
 def setup_method(self, meth):
     rawrefcount.init()