[pypy-commit] pypy stmgc-c7: Generate prebuilt objects with the expected hashes.
arigo
noreply at buildbot.pypy.org
Mon Mar 10 18:40:50 CET 2014
Author: Armin Rigo <arigo at tunes.org>
Branch: stmgc-c7
Changeset: r69837:27a3cd675ae1
Date: 2014-03-10 18:39 +0100
http://bitbucket.org/pypy/pypy/changeset/27a3cd675ae1/
Log: Generate prebuilt objects with the expected hashes.
diff --git a/rpython/translator/c/gc.py b/rpython/translator/c/gc.py
--- a/rpython/translator/c/gc.py
+++ b/rpython/translator/c/gc.py
@@ -468,6 +468,12 @@
def get_prebuilt_hash(self, obj):
return None # done differently with the stmgc
+ def get_stm_prebuilt_hash(self, obj):
+ h = BasicFrameworkGcPolicy.get_prebuilt_hash(self, obj)
+ if h is None:
+ h = object.__hash__(obj) # a "random enough" number
+ return h
+
name_to_gcpolicy = {
'boehm': BoehmGcPolicy,
diff --git a/rpython/translator/c/genc.py b/rpython/translator/c/genc.py
--- a/rpython/translator/c/genc.py
+++ b/rpython/translator/c/genc.py
@@ -799,7 +799,6 @@
if database.with_stm:
print >> f
print >> f, 'extern object_t *rpy_prebuilt[];'
- print >> f, 'extern long rpy_prebuilt_hashes[];'
print >> f
for node in database.globalcontainers():
for line in node.forward_declaration():
@@ -845,6 +844,8 @@
print >> f, '}'
def gen_stm_prebuilt(f, database):
+ from rpython.translator.c.primitive import name_signed
+ #
print >> f, '#include "common_header.h"'
print >> f, '#include "structdef.h"'
print >> f, '#include "forwarddecl.h"'
@@ -858,15 +859,21 @@
print >> f, '\t(object_t *)&%s,' % node.name
print >> f, '\tNULL'
print >> f, '};'
- print >> f, '/* long rpy_prebuilt_hashes[] = { ... }; */' # XXX
+ print >> f, 'static long rpy_prebuilt_hashes[] = {'
+ for _, node in gclist:
+ h = database.gcpolicy.get_stm_prebuilt_hash(node.obj)
+ print >> f, '\t%s,' % (name_signed(h, database),)
+ print >> f, '};'
print >> f, '''
void pypy_stm_setup(void)
{
stm_setup();
- object_t **pp;
- for (pp = rpy_prebuilt; *pp; pp++) {
+ object_t **pp = rpy_prebuilt;
+ long *ph = rpy_prebuilt_hashes;
+ for ( ; *pp; pp++, ph++) {
*pp = stm_setup_prebuilt(*pp);
+ stm_set_prebuilt_identityhash(*pp, *ph);
}
stm_register_thread_local(&stm_thread_local);
More information about the pypy-commit
mailing list