[pypy-commit] pypy stmgc-c8-dictstrategy: fix the hack with another more official-looking hack

arigo noreply at buildbot.pypy.org
Wed Nov 25 11:54:19 EST 2015


Author: Armin Rigo <arigo at tunes.org>
Branch: stmgc-c8-dictstrategy
Changeset: r80962:29cd05d512d4
Date: 2015-11-25 17:54 +0100
http://bitbucket.org/pypy/pypy/changeset/29cd05d512d4/

Log:	fix the hack with another more official-looking hack

diff --git a/rpython/rlib/rstm.py b/rpython/rlib/rstm.py
--- a/rpython/rlib/rstm.py
+++ b/rpython/rlib/rstm.py
@@ -320,7 +320,9 @@
     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, obj, addr.address[0], visit_fn)
+    ht = addr.address[0]
+    if ht:
+        llop.stm_hashtable_tracefn(lltype.Void, obj, ht, visit_fn)
 lambda_hashtable_trace = lambda: _ll_hashtable_trace
 
 def _ll_hashtable_finalizer(h):
diff --git a/rpython/translator/stm/hashtable.py b/rpython/translator/stm/hashtable.py
--- a/rpython/translator/stm/hashtable.py
+++ b/rpython/translator/stm/hashtable.py
@@ -18,7 +18,12 @@
         for entry in hashtable._content.values():
             if entry._obj:
                 bookkeeper.immutablevalue(entry._obj)
-        bookkeeper.immutablevalue(lltype.nullptr(rstm._STM_HASHTABLE_ENTRY))
+        #
+        # When we have a prebuilt hashtable but no calls to create_hashtable()
+        # in the final RPython program, the translation state is incomplete.
+        # Fix it by emulating a call to create_hashtable().
+        s_create_hashtable = bookkeeper.immutablevalue(rstm.create_hashtable)
+        bookkeeper.emulate_pbc_call("create_hashtable", s_create_hashtable, [])
         #
     return lltype_to_annotation(lltype.Ptr(rstm._HASHTABLE_OBJ))
 


More information about the pypy-commit mailing list