[pypy-svn] r46548 - in pypy/dist/pypy/translator/c: . test
arigo at codespeak.net
arigo at codespeak.net
Thu Sep 13 19:09:08 CEST 2007
Author: arigo
Date: Thu Sep 13 19:09:06 2007
New Revision: 46548
Modified:
pypy/dist/pypy/translator/c/database.py
pypy/dist/pypy/translator/c/gc.py
pypy/dist/pypy/translator/c/genc.py
pypy/dist/pypy/translator/c/node.py
pypy/dist/pypy/translator/c/test/test_boehm.py
pypy/dist/pypy/translator/c/test/test_newgc.py
Log:
The (one?) framework weakref bug is that prebuilt weakrefs
had their typeid not initialized - always 0.
- improve the tests to expose the problem
- fix
The issue was caused by cfbolz being hit by a hack of mine...
Replace it with a slightly more solid-looking hack.
Modified: pypy/dist/pypy/translator/c/database.py
==============================================================================
--- pypy/dist/pypy/translator/c/database.py (original)
+++ pypy/dist/pypy/translator/c/database.py Thu Sep 13 19:09:06 2007
@@ -146,7 +146,7 @@
else:
raise Exception("don't know about type %r" % (T,))
- def getcontainernode(self, container, **buildkwds):
+ def getcontainernode(self, container, _cached=True, **buildkwds):
try:
node = self.containernodes[container]
except KeyError:
@@ -156,6 +156,9 @@
self.gctransformer.consider_constant(T, container)
nodefactory = ContainerNodeFactory[T.__class__]
node = nodefactory(self, T, container, **buildkwds)
+ # _cached should only be False for a hack in weakrefnode_factory()
+ if not _cached:
+ return node
self.containernodes[container] = node
self.containerlist.append(node)
kind = getattr(node, 'nodekind', '?')
Modified: pypy/dist/pypy/translator/c/gc.py
==============================================================================
--- pypy/dist/pypy/translator/c/gc.py (original)
+++ pypy/dist/pypy/translator/c/gc.py Thu Sep 13 19:09:06 2007
@@ -362,11 +362,7 @@
return framework.WEAKREF
def convert_weakref_to(self, ptarget):
- result = framework.convert_weakref_to(ptarget)
- # XXX whack
- gct = self.db.gctransformer
- gct.gcdata.gc.gcheaderbuilder.new_header(result)
- return result
+ return framework.convert_weakref_to(ptarget)
def OP_GC_RELOAD_POSSIBLY_MOVED(self, funcgen, op):
args = [funcgen.expr(v) for v in op.args]
Modified: pypy/dist/pypy/translator/c/genc.py
==============================================================================
--- pypy/dist/pypy/translator/c/genc.py (original)
+++ pypy/dist/pypy/translator/c/genc.py Thu Sep 13 19:09:06 2007
@@ -110,6 +110,11 @@
return gc.name_to_gcpolicy[self.config.translation.gc]
return self.gcpolicy
+ # use generate_source(defines=DEBUG_DEFINES) to force the #definition
+ # of the macros that enable debugging assertions
+ DEBUG_DEFINES = {'RPY_ASSERT': 1,
+ 'RPY_LL_ASSERT': 1}
+
def generate_source(self, db=None, defines={}):
assert self.c_source_filename is None
translator = self.translator
Modified: pypy/dist/pypy/translator/c/node.py
==============================================================================
--- pypy/dist/pypy/translator/c/node.py (original)
+++ pypy/dist/pypy/translator/c/node.py Thu Sep 13 19:09:06 2007
@@ -865,9 +865,7 @@
ptarget = obj._dereference()
wrapper = db.gcpolicy.convert_weakref_to(ptarget)
container = wrapper._obj
- T = typeOf(container)
- nodefactory = ContainerNodeFactory[T.__class__]
- return nodefactory(db, T, container)
+ return db.getcontainernode(container, _cached=False)
ContainerNodeFactory = {
Modified: pypy/dist/pypy/translator/c/test/test_boehm.py
==============================================================================
--- pypy/dist/pypy/translator/c/test/test_boehm.py (original)
+++ pypy/dist/pypy/translator/c/test/test_boehm.py Thu Sep 13 19:09:06 2007
@@ -34,7 +34,8 @@
t.checkgraphs()
def compile():
cbuilder = CExtModuleBuilder(t, func, config=config)
- c_source_filename = cbuilder.generate_source()
+ c_source_filename = cbuilder.generate_source(
+ defines = cbuilder.DEBUG_DEFINES)
if conftest.option.view:
t.view()
cbuilder.compile()
@@ -303,6 +304,7 @@
else:
r = r2
a = r()
+ rgc.collect()
if a is None:
return -5
else:
Modified: pypy/dist/pypy/translator/c/test/test_newgc.py
==============================================================================
--- pypy/dist/pypy/translator/c/test/test_newgc.py (original)
+++ pypy/dist/pypy/translator/c/test/test_newgc.py Thu Sep 13 19:09:06 2007
@@ -614,10 +614,11 @@
result = 0
for i in range(2):
a = refs[i]()
+ rgc.collect()
if a is None:
- result += i
+ result += (i+1)
else:
- result += a.hello * i
+ result += a.hello * (i+1)
return result
c_fn = self.getcompiled(fn)
res = c_fn()
More information about the Pypy-commit
mailing list