Author: Armin Rigo <[email protected]>
Branch: use-gc-del-3
Changeset: r84262:070d35dbb069
Date: 2016-05-06 13:52 +0200
http://bitbucket.org/pypy/pypy/changeset/070d35dbb069/
Log: Ignore the register_finalizer() calls on top of Boehm
diff --git a/pypy/doc/discussion/finalizer-order.rst
b/pypy/doc/discussion/finalizer-order.rst
--- a/pypy/doc/discussion/finalizer-order.rst
+++ b/pypy/doc/discussion/finalizer-order.rst
@@ -102,6 +102,9 @@
For now the untranslated emulation does not support registering the
same object several times.
+Note that the Boehm garbage collector, used in ``rpython -O0``,
+completely ignores ``register_finalizer()``.
+
Ordering of finalizers
----------------------
diff --git a/rpython/translator/c/src/mem.h b/rpython/translator/c/src/mem.h
--- a/rpython/translator/c/src/mem.h
+++ b/rpython/translator/c/src/mem.h
@@ -109,6 +109,9 @@
#define OP_GC__ENABLE_FINALIZERS(r) (boehm_gc_finalizer_lock--, \
boehm_gc_finalizer_notifier())
+#define OP_GC_FQ_REGISTER(tag, obj, r) /* ignored so far */
+#define OP_GC_FQ_NEXT_DEAD(tag, r) (r = NULL)
+
#endif /* PYPY_USING_BOEHM_GC */
@@ -121,6 +124,8 @@
#define GC_REGISTER_FINALIZER(a, b, c, d, e) /* nothing */
#define GC_gcollect() /* nothing */
#define GC_set_max_heap_size(a) /* nothing */
+#define OP_GC_FQ_REGISTER(tag, obj, r) /* nothing */
+#define OP_GC_FQ_NEXT_DEAD(tag, r) (r = NULL)
#endif
/************************************************************/
diff --git a/rpython/translator/c/test/test_boehm.py
b/rpython/translator/c/test/test_boehm.py
--- a/rpython/translator/c/test/test_boehm.py
+++ b/rpython/translator/c/test/test_boehm.py
@@ -2,7 +2,7 @@
import py
-from rpython.rlib import rgc
+from rpython.rlib import rgc, debug
from rpython.rlib.objectmodel import (keepalive_until_here, compute_unique_id,
compute_hash, current_object_addr_as_int)
from rpython.rtyper.lltypesystem import lltype, llmemory
@@ -392,3 +392,23 @@
assert res[2] != compute_hash(c) # likely
assert res[3] == compute_hash(d)
assert res[4] == compute_hash(("Hi", None, (7.5, 2, d)))
+
+ def test_finalizer_queue_is_at_least_ignored(self):
+ class A(object):
+ pass
+ class FQ(rgc.FinalizerQueue):
+ Class = A
+ def finalizer_trigger(self):
+ debug.debug_print("hello!") # not called so far
+ fq = FQ()
+ #
+ def fn():
+ fq.register_finalizer(A())
+ rgc.collect()
+ rgc.collect()
+ fq.next_dead()
+ return 42
+
+ f = self.getcompiled(fn)
+ res = f()
+ assert res == 42
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit