[pypy-commit] pypy stmgc-c7: Hopefully finish the RPython interfacing with stm hashtables.
arigo
noreply at buildbot.pypy.org
Wed Nov 12 11:32:01 CET 2014
Author: Armin Rigo <arigo at tunes.org>
Branch: stmgc-c7
Changeset: r74475:34d87a99d19a
Date: 2014-11-12 11:31 +0100
http://bitbucket.org/pypy/pypy/changeset/34d87a99d19a/
Log: Hopefully finish the RPython interfacing with stm hashtables.
diff --git a/rpython/memory/gctransform/stmframework.py b/rpython/memory/gctransform/stmframework.py
--- a/rpython/memory/gctransform/stmframework.py
+++ b/rpython/memory/gctransform/stmframework.py
@@ -7,6 +7,7 @@
from rpython.memory.gctypelayout import WEAKREF, WEAKREFPTR
from rpython.memory.gc.stmgc import StmGC
from rpython.rtyper import rmodel, llannotation
+from rpython.rtyper.annlowlevel import llhelper
from rpython.translator.backendopt.support import var_needsgc
from rpython.rlib.objectmodel import specialize
from rpython.rlib import rstm
diff --git a/rpython/rlib/rstm.py b/rpython/rlib/rstm.py
--- a/rpython/rlib/rstm.py
+++ b/rpython/rlib/rstm.py
@@ -193,7 +193,12 @@
adtmeths={'get': ll_hashtable_get,
'set': ll_hashtable_set})
-#def ll_hashtable_trace(...)
+def ll_hashtable_trace(gc, obj, callback, arg):
+ from rpython.memory.gctransform.stmframework import get_visit_function
+ visit_fn = get_visit_function(callback, arg)
+ addr = obj + llmemory.offsetof(_HASHTABLE_OBJ, 'll_raw_hashtable')
+ llop.stm_hashtable_tracefn(lltype.Void, addr.address[0], visit_fn)
+lambda_hashtable_trace = lambda: ll_hashtable_trace
def create_hashtable():
if not we_are_translated():
@@ -206,6 +211,7 @@
p = lltype.malloc(_STM_HASHTABLE_ENTRY)
else:
p = lltype.nullptr(_STM_HASHTABLE_ENTRY)
+ rgc.register_custom_trace_hook(_HASHTABLE_OBJ, lambda_hashtable_trace)
h = lltype.malloc(_HASHTABLE_OBJ)
h.ll_raw_hashtable = llop.stm_hashtable_create(_STM_HASHTABLE_P, p)
return h
diff --git a/rpython/rtyper/annlowlevel.py b/rpython/rtyper/annlowlevel.py
--- a/rpython/rtyper/annlowlevel.py
+++ b/rpython/rtyper/annlowlevel.py
@@ -516,7 +516,7 @@
@specialize.arg(0)
def cast_gcref_to_instance(Class, ptr):
"""Reverse the hacking done in cast_instance_to_gcref()."""
- from rpython.rtyper.lltypesystem.rclass import OBJECTPTR
+ from rpython.rtyper.rclass import OBJECTPTR
ptr = lltype.cast_opaque_ptr(OBJECTPTR, ptr)
return cast_base_ptr_to_instance(Class, ptr)
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
@@ -464,6 +464,7 @@
'stm_hashtable_free': LLOp(),
'stm_hashtable_read': LLOp(),
'stm_hashtable_write': LLOp(),
+ 'stm_hashtable_tracefn': LLOp(),
# __________ address operations __________
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
@@ -311,3 +311,8 @@
arg3 = funcgen.expr(op.args[3])
return ('stm_hashtable_write((object_t *)%s, %s, %s, (object_t *)%s, '
'&stm_thread_local);' % (arg0, arg1, arg2, arg3))
+
+def stm_hashtable_tracefn(funcgen, op):
+ arg0 = funcgen.expr(op.args[0])
+ arg1 = funcgen.expr(op.args[1])
+ return 'stm_hashtable_tracefn((stm_hashtable_t *)%s, %s);' % (arg0, arg1)
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
@@ -553,8 +553,6 @@
assert '<del>' in err
def test_hashtable(self):
- py.test.skip("missing: custom tracer on Hashtable")
-
class X(object):
pass
More information about the pypy-commit
mailing list