Author: Armin Rigo <[email protected]>
Branch: stmgc-c7
Changeset: r74444:b72126002e43
Date: 2014-11-11 14:47 +0100
http://bitbucket.org/pypy/pypy/changeset/b72126002e43/
Log: Light finalizers seem to be missing nothing more than being enabled.
We'll see if this theory breaks down.
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,8 +78,8 @@
if contains_weakptr: # check constant-folded
return llop.stm_allocate_weakref(llmemory.GCREF, size, typeid16)
if needs_finalizer:
- #if is_finalizer_light: XXX implement me
- # return llop.stm_allocate_f_light(llmemory.GCREF, size,
typeid16)
+ if is_finalizer_light:
+ 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/memory/gctransform/framework.py
b/rpython/memory/gctransform/framework.py
--- a/rpython/memory/gctransform/framework.py
+++ b/rpython/memory/gctransform/framework.py
@@ -1289,11 +1289,8 @@
[llmemory.Address], lltype.Void)
try:
g = destrptr._obj.graph
- if self.translator.config.translation.stm:
- light = False # XXX no working light finalizers with STM so
far
- else:
- analyzer = FinalizerAnalyzer(self.translator)
- light = not analyzer.analyze_light_finalizer(g)
+ analyzer = FinalizerAnalyzer(self.translator)
+ light = not analyzer.analyze_light_finalizer(g)
except lltype.DelayedPointer:
light = False # XXX bah, too bad
return fptr, light
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
@@ -106,7 +106,7 @@
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,))
+ 'stm_enable_light_finalizer((object_t *)%s);' % (result,))
def stm_get_from_obj(funcgen, op):
assert op.args[0].concretetype == llmemory.GCREF
diff --git a/rpython/translator/stm/src_stm/extracode.h
b/rpython/translator/stm/src_stm/extracode.h
--- a/rpython/translator/stm/src_stm/extracode.h
+++ b/rpython/translator/stm/src_stm/extracode.h
@@ -1,6 +1,7 @@
static void _stm_call_finalizer(object_t *obj)
{
+ /* this function works for both regular and light finalizers */
void *funcptr = pypy_stmcb_fetch_finalizer(((rpyobj_t *)obj)->tid);
((void(*)(object_t *))funcptr)(obj);
}
@@ -31,6 +32,7 @@
}
stmcb_finalizer = &_stm_call_finalizer;
+ stmcb_light_finalizer = &_stm_call_finalizer;
}
void pypy_stm_register_thread_local(void)
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,7 +535,6 @@
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):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit