[pypy-commit] pypy stmgc-c7: Fixes, and partial revert: must use _HASHTABLE_OBJ everywhere in RPython,
arigo
noreply at buildbot.pypy.org
Wed Jan 28 16:55:30 CET 2015
Author: Armin Rigo <arigo at tunes.org>
Branch: stmgc-c7
Changeset: r75564:963abcf27a42
Date: 2015-01-28 16:54 +0100
http://bitbucket.org/pypy/pypy/changeset/963abcf27a42/
Log: Fixes, and partial revert: must use _HASHTABLE_OBJ everywhere in
RPython, not the low-level _STM_HASHTABLE_P, because the latter is
not traced!
diff --git a/rpython/jit/metainterp/memmgr.py b/rpython/jit/metainterp/memmgr.py
--- a/rpython/jit/metainterp/memmgr.py
+++ b/rpython/jit/metainterp/memmgr.py
@@ -76,8 +76,8 @@
next_key = rstm.stm_count()
gcref = annlowlevel.cast_instance_to_gcref(looptoken)
if not self.stm_alive_loops:
- self.stm_alive_loops = rstm.ll_hashtable_create()
- rstm.ll_hashtable_set(self.stm_alive_loops, next_key, gcref)
+ self.stm_alive_loops = rstm.create_hashtable()
+ self.stm_alive_loops.set(next_key, gcref)
def _kill_old_loops_now(self):
debug_start("jit-mem-collect")
@@ -103,14 +103,16 @@
# all keys in 'stm_alive_loops' should be in the following range
old_count = self.stm_lowest_key
new_count = rstm.stm_count()
+ oldtotal = 0
if stm_alive_loops:
for key in range(old_count, new_count):
- gcref = rstm.ll_hashtable_get(stm_alive_loops, key)
+ gcref = stm_alive_loops.get(key)
if not gcref:
continue
# make 'stm_alive_loops' empty, and add the loops that we
# must keep in the set 'keep_loops'
- rstm.ll_hashtable_set(stm_alive_loops, key, rstm.NULL_GCREF)
+ stm_alive_loops.set(key, rstm.NULL_GCREF)
+ oldtotal += 1
looptoken = annlowlevel.cast_gcref_to_instance(JitCellToken,
gcref)
if self._must_keep_loop(looptoken):
@@ -120,7 +122,7 @@
# now re-add loops with key numbers that *end* at 'new_count'
for looptoken in keep_loops:
gcref = annlowlevel.cast_instance_to_gcref(looptoken)
- rstm.ll_hashtable_set(stm_alive_loops, new_count, gcref)
+ stm_alive_loops.set(new_count, gcref)
new_count -= 1
self.stm_lowest_key = new_count + 1 # lowest used key number
#
diff --git a/rpython/rlib/rstm.py b/rpython/rlib/rstm.py
--- a/rpython/rlib/rstm.py
+++ b/rpython/rlib/rstm.py
@@ -1,5 +1,5 @@
from rpython.rlib.objectmodel import we_are_translated, specialize
-from rpython.rlib.objectmodel import CDefinedIntSymbolic
+from rpython.rlib.objectmodel import CDefinedIntSymbolic, stm_ignored
from rpython.rlib.nonconst import NonConstant
from rpython.rlib import rgc
from rpython.rtyper.lltypesystem import lltype, rffi, rstr, llmemory
@@ -177,54 +177,38 @@
# ____________________________________________________________
_STM_HASHTABLE_P = rffi.COpaquePtr('stm_hashtable_t')
-NULL_HASHTABLE = lltype.nullptr(_STM_HASHTABLE_P.TO)
_STM_HASHTABLE_ENTRY = lltype.GcStruct('HASHTABLE_ENTRY',
('index', lltype.Unsigned),
('object', llmemory.GCREF))
@dont_look_inside
-def ll_hashtable_create():
- # Pass a null pointer to _STM_HASHTABLE_ENTRY to stm_hashtable_create().
- # Make sure we see a malloc() of it, so that its typeid is correctly
- # initialized. It can be done in a NonConstant(False) path so that
- # the C compiler will actually drop it.
- if _false:
- p = lltype.malloc(_STM_HASHTABLE_ENTRY)
- else:
- p = lltype.nullptr(_STM_HASHTABLE_ENTRY)
- return llop.stm_hashtable_create(_STM_HASHTABLE_P, p)
-
- at dont_look_inside
-def ll_hashtable_get(h, key):
+def _ll_hashtable_get(h, key):
# 'key' must be a plain integer. Returns a GCREF.
return llop.stm_hashtable_read(llmemory.GCREF, h, h.ll_raw_hashtable, key)
@dont_look_inside
-def ll_hashtable_set(h, key, value):
+def _ll_hashtable_set(h, key, value):
llop.stm_hashtable_write(lltype.Void, h, h.ll_raw_hashtable, key, value)
- at dont_look_inside
-def ll_hashtable_free(h):
- llop.stm_hashtable_free(lltype.Void, h)
-
-# -----
_HASHTABLE_OBJ = lltype.GcStruct('HASHTABLE_OBJ',
('ll_raw_hashtable', _STM_HASHTABLE_P),
rtti=True,
- adtmeths={'get': ll_hashtable_get,
- 'set': ll_hashtable_set})
+ adtmeths={'get': _ll_hashtable_get,
+ 'set': _ll_hashtable_set})
+NULL_HASHTABLE = lltype.nullptr(_HASHTABLE_OBJ)
-def ll_hashtable_trace(gc, obj, callback, arg):
+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
+lambda_hashtable_trace = lambda: _ll_hashtable_trace
-def ll_hashtable_finalizer(p):
- ll_hashtable_free(p.ll_raw_hashtable)
-lambda_hashtable_finlz = lambda: ll_hashtable_finalizer
+def _ll_hashtable_finalizer(h):
+ if h.ll_raw_hashtable:
+ llop.stm_hashtable_free(lltype.Void, h.ll_raw_hashtable)
+lambda_hashtable_finlz = lambda: _ll_hashtable_finalizer
_false = CDefinedIntSymbolic('0', default=0) # remains in the C code
@@ -234,8 +218,17 @@
return HashtableForTest() # for tests
rgc.register_custom_light_finalizer(_HASHTABLE_OBJ, lambda_hashtable_finlz)
rgc.register_custom_trace_hook(_HASHTABLE_OBJ, lambda_hashtable_trace)
+ # Pass a null pointer to _STM_HASHTABLE_ENTRY to stm_hashtable_create().
+ # Make sure we see a malloc() of it, so that its typeid is correctly
+ # initialized. It can be done in a NonConstant(False) path so that
+ # the C compiler will actually drop it.
+ if _false:
+ p = lltype.malloc(_STM_HASHTABLE_ENTRY)
+ else:
+ p = lltype.nullptr(_STM_HASHTABLE_ENTRY)
h = lltype.malloc(_HASHTABLE_OBJ)
- h.ll_raw_hashtable = ll_hashtable_create()
+ h.ll_raw_hashtable = lltype.nullptr(_STM_HASHTABLE_P.TO)
+ h.ll_raw_hashtable = llop.stm_hashtable_create(_STM_HASHTABLE_P, p)
return h
NULL_GCREF = lltype.nullptr(llmemory.GCREF.TO)
More information about the pypy-commit
mailing list