[pypy-commit] pypy stmgc-c7: Light finalizers: still a problem if they call some function like close(),
arigo
noreply at buildbot.pypy.org
Sat Oct 18 09:16:44 CEST 2014
Author: Armin Rigo <arigo at tunes.org>
Branch: stmgc-c7
Changeset: r74011:6355617bf9a2
Date: 2014-10-18 09:14 +0200
http://bitbucket.org/pypy/pypy/changeset/6355617bf9a2/
Log: Light finalizers: still a problem if they call some function like
close(), because that triggers stm_become_inevitable(), which can
pause and run gc collections --- not supported in light finalizers.
diff --git a/rpython/memory/gc/stmgc.py b/rpython/memory/gc/stmgc.py
--- a/rpython/memory/gc/stmgc.py
+++ b/rpython/memory/gc/stmgc.py
@@ -78,7 +78,8 @@
if contains_weakptr: # check constant-folded
return llop.stm_allocate_weakref(llmemory.GCREF, size, typeid16)
if needs_finalizer:
- #is_finalizer_light XXX ignored now
+ #if is_finalizer_light: XXX implement me
+ # return llop.stm_allocate_f_light(llmemory.GCREF, size, typeid16)
return llop.stm_allocate_finalizer(llmemory.GCREF, size, typeid16)
return llop.stm_allocate_tid(llmemory.GCREF, size, typeid16)
diff --git a/rpython/rtyper/lltypesystem/lloperation.py b/rpython/rtyper/lltypesystem/lloperation.py
--- a/rpython/rtyper/lltypesystem/lloperation.py
+++ b/rpython/rtyper/lltypesystem/lloperation.py
@@ -418,6 +418,7 @@
'stm_allocate_tid': LLOp(sideeffects=False, canmallocgc=True),
'stm_allocate_weakref': LLOp(sideeffects=False, canmallocgc=True),
'stm_allocate_finalizer': LLOp(sideeffects=False, canmallocgc=True),
+ 'stm_allocate_f_light': LLOp(sideeffects=False, canmallocgc=True),
'stm_get_from_obj': LLOp(sideeffects=False),
'stm_get_from_obj_const': LLOp(canfold=True),
'stm_set_into_obj': LLOp(),
diff --git a/rpython/translator/stm/funcgen.py b/rpython/translator/stm/funcgen.py
--- a/rpython/translator/stm/funcgen.py
+++ b/rpython/translator/stm/funcgen.py
@@ -98,6 +98,16 @@
result, arg_size) +
'((rpyobj_t *)%s)->tid = %s;' % (result, arg_type_id))
+def stm_allocate_f_light(funcgen, op):
+ arg_size = funcgen.expr(op.args[0])
+ arg_type_id = funcgen.expr(op.args[1])
+ result = funcgen.expr(op.result)
+ # XXX NULL returns?
+ return ('%s = (rpygcchar_t *)stm_allocate(%s); ' % (
+ result, arg_size) +
+ '((rpyobj_t *)%s)->tid = %s;\n' % (result, arg_type_id) +
+ 'stm_enable_light_finalizer(%s);' % (result,))
+
def stm_get_from_obj(funcgen, op):
assert op.args[0].concretetype == llmemory.GCREF
arg_obj = funcgen.expr(op.args[0])
diff --git a/rpython/translator/stm/test/test_ztranslated.py b/rpython/translator/stm/test/test_ztranslated.py
--- a/rpython/translator/stm/test/test_ztranslated.py
+++ b/rpython/translator/stm/test/test_ztranslated.py
@@ -535,6 +535,7 @@
assert 'destructors called: 1\n' in data
def test_light_finalizer(self):
+ py.test.skip("XXX implement me")
class X:
@rgc.must_be_light_finalizer
def __del__(self):
More information about the pypy-commit
mailing list