[pypy-commit] pypy stmgc-c8: disable hashtable for now
Raemi
noreply at buildbot.pypy.org
Wed Feb 25 11:53:27 CET 2015
Author: Remi Meier <remi.meier at gmail.com>
Branch: stmgc-c8
Changeset: r76121:5c981f82e4af
Date: 2015-02-25 11:41 +0100
http://bitbucket.org/pypy/pypy/changeset/5c981f82e4af/
Log: disable hashtable for now
diff --git a/rpython/rlib/rstm.py b/rpython/rlib/rstm.py
--- a/rpython/rlib/rstm.py
+++ b/rpython/rlib/rstm.py
@@ -252,7 +252,8 @@
'freelist': _ll_hashtable_freelist,
'lookup': _ll_hashtable_lookup,
'writeobj': _ll_hashtable_writeobj})
-NULL_HASHTABLE = lltype.nullptr(_HASHTABLE_OBJ)
+# NULL_HASHTABLE = lltype.nullptr(_HASHTABLE_OBJ)
+NULL_HASHTABLE = None
def _ll_hashtable_trace(gc, obj, callback, arg):
from rpython.memory.gctransform.stmframework import get_visit_function
@@ -272,23 +273,45 @@
def create_hashtable():
if not we_are_translated():
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 = lltype.nullptr(_STM_HASHTABLE_P.TO)
- h.ll_raw_hashtable = llop.stm_hashtable_create(_STM_HASHTABLE_P, p)
- return h
+ return HashtableEmulation()
+ # 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 = 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)
+class HashtableEmulation(object):
+ def __init__(self):
+ self._content = {} # dict {integer: GCREF}
+
+ def get(self, key):
+ return self._content.get(key, NULL_GCREF)
+
+ def set(self, key, value):
+ if value:
+ self._content[key] = value
+ else:
+ try:
+ del self._content[key]
+ except KeyError:
+ pass
+
+ def len(self):
+ return len(self._content)
+
+
+
class HashtableForTest(object):
def __init__(self):
self._content = {} # dict {integer: GCREF}
More information about the pypy-commit
mailing list