Author: Armin Rigo <[email protected]>
Branch: boehm-rawrefcount
Changeset: r86923:c8bdf1398ada
Date: 2016-09-07 11:42 +0200
http://bitbucket.org/pypy/pypy/changeset/c8bdf1398ada/
Log: Stop trying to use the same test, and wrote a boehm-specific test
diff --git a/rpython/rlib/src/boehm-rawrefcount.c
b/rpython/rlib/src/boehm-rawrefcount.c
--- a/rpython/rlib/src/boehm-rawrefcount.c
+++ b/rpython/rlib/src/boehm-rawrefcount.c
@@ -206,7 +206,8 @@
pyobj_t *pyobj1 = (pyobj_t *)pyobj;
assert(pyobj1->ob_pypy_link == 0);
- assert(pyobj1->ob_refcnt >= REFCNT_FROM_PYPY);
+ /*assert(pyobj1->ob_refcnt >= REFCNT_FROM_PYPY);*/
+ /*^^^ could also be fixed just after the call to create_link_pypy()*/
hash_add_entry(gcobj1, pyobj1);
}
diff --git a/rpython/rlib/test/test_rawrefcount.py
b/rpython/rlib/test/test_rawrefcount.py
--- a/rpython/rlib/test/test_rawrefcount.py
+++ b/rpython/rlib/test/test_rawrefcount.py
@@ -214,7 +214,6 @@
class TestTranslated(StandaloneTests):
- _GC = 'incminimark'
def test_full_translation(self):
class State:
@@ -227,37 +226,29 @@
def make_p():
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
- rawrefcount.create_link_pypy(p, ob)
assert rawrefcount.from_obj(PyObject, p) == ob
assert rawrefcount.to_obj(W_Root, ob) == p
return ob, p
FTYPE = rawrefcount.RAWREFCOUNT_DEALLOC_TRIGGER
- has_callback = (self._GC != "boehm")
def entry_point(argv):
- if has_callback:
- ll_dealloc_trigger_callback = llhelper(FTYPE, dealloc_trigger)
- rawrefcount.init(ll_dealloc_trigger_callback)
+ 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
- if rawrefcount.next_dead(PyObject) != lltype.nullptr(PyObjectS):
- print "got a next_dead() really too soon"
- return 1
rgc.collect()
if state.seen != []:
print "OB COLLECTED TOO SOON"
return 1
- if rawrefcount.next_dead(PyObject) != lltype.nullptr(PyObjectS):
- print "got a next_dead() too soon"
- return 1
objectmodel.keepalive_until_here(p)
p = None
rgc.collect()
- if has_callback and state.seen != [1]:
+ if state.seen != [1]:
print "OB NOT COLLECTED"
return 1
if rawrefcount.next_dead(PyObject) != ob:
@@ -271,11 +262,50 @@
return 0
self.config = get_combined_translation_config(translating=True)
- self.config.translation.gc = self._GC
+ self.config.translation.gc = "incminimark"
t, cbuilder = self.compile(entry_point)
data = cbuilder.cmdexec('hi there')
assert data.startswith('OK!\n')
-class TestBoehm(TestTranslated):
- _GC = "boehm"
+class TestBoehmTranslated(StandaloneTests):
+
+ def test_full_translation(self):
+
+ def make_ob():
+ 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.from_obj(PyObject, p) == ob
+ assert rawrefcount.to_obj(W_Root, ob) == p
+ return ob
+
+ def entry_point(argv):
+ oblist = [make_ob() for i in range(50)]
+ rgc.collect()
+ deadlist = []
+ while True:
+ ob = rawrefcount.next_dead(PyObject)
+ if not ob: break
+ 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
+
+ self.config = get_combined_translation_config(translating=True)
+ self.config.translation.gc = "boehm"
+ t, cbuilder = self.compile(entry_point)
+ data = cbuilder.cmdexec('hi there')
+ assert data.startswith('OK!\n')
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit