[pypy-svn] r49805 - in pypy/dist/pypy: rpython/memory/gctransform translator/c
arigo at codespeak.net
arigo at codespeak.net
Fri Dec 14 19:56:16 CET 2007
Author: arigo
Date: Fri Dec 14 19:56:16 2007
New Revision: 49805
Modified:
pypy/dist/pypy/rpython/memory/gctransform/framework.py
pypy/dist/pypy/translator/c/database.py
Log:
Use a delayed pointer for the type_info_table. Requires a bit of
further hacking in c/database.py, but otherwise it's a much cleaner
approach and it gives better performance because the type_info_table
attribute can now be considered as a constant.
Modified: pypy/dist/pypy/rpython/memory/gctransform/framework.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/gctransform/framework.py (original)
+++ pypy/dist/pypy/rpython/memory/gctransform/framework.py Fri Dec 14 19:56:16 2007
@@ -418,9 +418,10 @@
# replace the type_info_table pointer in gcdata -- at this point,
# the database is in principle complete, so it has already seen
- # the old (empty) array. We need to force it to consider the new
- # array now. It's a bit hackish as the old empty array will also
- # be generated in the C source, but that's a rather minor problem.
+ # the delayed pointer, but it still remembers it and will look
+ # again after we "resolve" it to a real pointer.
+
+ self.gcdata.type_info_table._become(table)
# XXX because we call inputconst already in replace_malloc, we can't
# modify the instance, we have to modify the 'rtyped instance'
@@ -430,8 +431,6 @@
self.gcdata)
r_gcdata = self.translator.rtyper.getrepr(s_gcdata)
ll_instance = rmodel.inputconst(r_gcdata, self.gcdata).value
- ll_instance.inst_type_info_table = table
- #self.gcdata.type_info_table = table
addresses_of_static_ptrs = (
self.layoutbuilder.addresses_of_static_ptrs +
@@ -447,7 +446,6 @@
ll_instance.inst_static_root_end = ll_instance.inst_static_root_start + llmemory.sizeof(llmemory.Address) * len(ll_static_roots_inside)
newgcdependencies = []
- newgcdependencies.append(table)
newgcdependencies.append(ll_static_roots_inside)
self.write_typeid_list()
return newgcdependencies
Modified: pypy/dist/pypy/translator/c/database.py
==============================================================================
--- pypy/dist/pypy/translator/c/database.py (original)
+++ pypy/dist/pypy/translator/c/database.py Fri Dec 14 19:56:16 2007
@@ -195,11 +195,15 @@
n = len('delayed!')
if len(name) == n:
raise
- if id(obj) in self.delayedfunctionnames:
- return self.delayedfunctionnames[id(obj)][0]
- funcname = name[n:]
- funcname = self.namespace.uniquename('g_' + funcname)
- self.delayedfunctionnames[id(obj)] = funcname, obj
+ if isinstance(lltype.typeOf(obj).TO, lltype.FuncType):
+ if id(obj) in self.delayedfunctionnames:
+ return self.delayedfunctionnames[id(obj)][0]
+ funcname = name[n:]
+ funcname = self.namespace.uniquename('g_'+funcname)
+ self.delayedfunctionnames[id(obj)] = funcname, obj
+ else:
+ funcname = None # can't use the name of a
+ # delayed non-function ptr
self.delayedfunctionptrs.append(obj)
return funcname
# /hack hack hack
More information about the Pypy-commit
mailing list