[pypy-commit] pypy default: merge
cfbolz
noreply at buildbot.pypy.org
Fri Oct 21 17:48:21 CEST 2011
Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch:
Changeset: r48317:9718181b5d75
Date: 2011-10-21 17:47 +0200
http://bitbucket.org/pypy/pypy/changeset/9718181b5d75/
Log: merge
diff --git a/pypy/translator/c/database.py b/pypy/translator/c/database.py
--- a/pypy/translator/c/database.py
+++ b/pypy/translator/c/database.py
@@ -176,7 +176,7 @@
# introduced by the GC transformer, or the type_info_table
return node
- def get(self, obj):
+ def get(self, obj, funcgen=None):
if isinstance(obj, CConstant):
return obj.c_name # without further checks
T = typeOf(obj)
@@ -228,6 +228,8 @@
return '((%s) %d)' % (cdecl(self.gettype(T), ''),
obj._obj)
node = self.getcontainernode(container)
+ if node._funccodegen_owner is None:
+ node._funccodegen_owner = funcgen
return node.getptrname()
else:
return '((%s) NULL)' % (cdecl(self.gettype(T), ''), )
@@ -284,14 +286,16 @@
finish_callbacks.append(('GC transformer: finished tables',
self.gctransformer.get_finish_tables()))
- def add_dependencies(newdependencies):
+ def add_dependencies(newdependencies, parent=None):
for value in newdependencies:
#if isinstance(value, _uninitialized):
# continue
if isinstance(typeOf(value), ContainerType):
- self.getcontainernode(value)
+ node = self.getcontainernode(value)
+ if parent and node._funccodegen_owner is not None:
+ node._funccodegen_owner = parent._funccodegen_owner
else:
- self.get(value)
+ self.get(value, parent and parent._funccodegen_owner)
while True:
while True:
@@ -303,7 +307,7 @@
if i == len(self.containerlist):
break
node = self.containerlist[i]
- add_dependencies(node.enum_dependencies())
+ add_dependencies(node.enum_dependencies(), node)
i += 1
self.completedcontainers = i
if i == show_i:
diff --git a/pypy/translator/c/gc.py b/pypy/translator/c/gc.py
--- a/pypy/translator/c/gc.py
+++ b/pypy/translator/c/gc.py
@@ -170,6 +170,7 @@
nodekind = 'refcnt rtti'
globalcontainer = True
typename = 'void (@)(void *)'
+ _funccodegen_owner = None
def __init__(self, db, T, obj):
assert T == RuntimeTypeInfo
@@ -266,6 +267,7 @@
nodekind = 'boehm rtti'
globalcontainer = True
typename = 'char @'
+ _funccodegen_owner = None
def __init__(self, db, T, obj):
assert T == RuntimeTypeInfo
diff --git a/pypy/translator/c/gcc/test/test_asmgcroot.py b/pypy/translator/c/gcc/test/test_asmgcroot.py
--- a/pypy/translator/c/gcc/test/test_asmgcroot.py
+++ b/pypy/translator/c/gcc/test/test_asmgcroot.py
@@ -21,6 +21,7 @@
config = get_pypy_config(translating=True)
config.translation.gc = cls.gcpolicy
config.translation.gcrootfinder = "asmgcc"
+ config.translation.taggedpointers = getattr(cls, "taggedpointers", False)
return config
@classmethod
diff --git a/pypy/translator/c/genc.py b/pypy/translator/c/genc.py
--- a/pypy/translator/c/genc.py
+++ b/pypy/translator/c/genc.py
@@ -682,8 +682,7 @@
def getbasecfilefornode(self, node, basecname):
# For FuncNode instances, use the python source filename (relative to
# the top directory):
- if hasattr(node.obj, 'graph'):
- g = node.obj.graph
+ def invent_nice_name(g):
# Lookup the filename from the function.
# However, not all FunctionGraph objs actually have a "func":
if hasattr(g, 'func'):
@@ -693,6 +692,15 @@
if pypkgpath:
relpypath = localpath.relto(pypkgpath)
return relpypath.replace('.py', '.c')
+ return None
+ if hasattr(node.obj, 'graph'):
+ name = invent_nice_name(node.obj.graph)
+ if name is not None:
+ return name
+ elif node._funccodegen_owner is not None:
+ name = invent_nice_name(node._funccodegen_owner.graph)
+ if name is not None:
+ return "data_" + name
return basecname
def splitnodesimpl(self, basecname, nodes, nextra, nbetween,
diff --git a/pypy/translator/c/node.py b/pypy/translator/c/node.py
--- a/pypy/translator/c/node.py
+++ b/pypy/translator/c/node.py
@@ -485,6 +485,7 @@
__slots__ = """db obj
typename implementationtypename
name
+ _funccodegen_owner
globalcontainer""".split()
eci_name = '_compilation_info'
@@ -509,6 +510,7 @@
if self.typename != self.implementationtypename:
if db.gettypedefnode(T).extra_union_for_varlength:
self.name += '.b'
+ self._funccodegen_owner = None
def getptrname(self):
return '(&%s)' % self.name
@@ -842,6 +844,9 @@
if self.funcgens:
argnames = self.funcgens[0].argnames() #Assume identical for all funcgens
self.implementationtypename = self.db.gettype(self.T, argnames=argnames)
+ self._funccodegen_owner = self.funcgens[0]
+ else:
+ self._funccodegen_owner = None
def basename(self):
return self.obj._name
@@ -1005,6 +1010,7 @@
globalcontainer = True
typename = 'PyObject @'
implementationtypename = 'PyObject *@'
+ _funccodegen_owner = None
def __init__(self, db, T, obj):
# obj is a _pyobject here; obj.value is the underlying CPython object
diff --git a/pypy/translator/c/primitive.py b/pypy/translator/c/primitive.py
--- a/pypy/translator/c/primitive.py
+++ b/pypy/translator/c/primitive.py
@@ -141,7 +141,12 @@
def name_gcref(value, db):
if value:
- realobj = value._obj.container
+ obj = value._obj
+ if isinstance(obj, int):
+ # a tagged pointer
+ assert obj & 1 == 1
+ return '((%s) %d)' % (cdecl("void*", ''), obj)
+ realobj = obj.container
realvalue = cast_opaque_ptr(Ptr(typeOf(realobj)), value)
return db.get(realvalue)
else:
diff --git a/pypy/translator/c/test/test_newgc.py b/pypy/translator/c/test/test_newgc.py
--- a/pypy/translator/c/test/test_newgc.py
+++ b/pypy/translator/c/test/test_newgc.py
@@ -1487,6 +1487,43 @@
res = self.run("tagged")
assert res == expected
+ def define_erased(cls):
+ from pypy.rlib import rerased
+ erase, unerase = rerased.new_erasing_pair("test")
+ class Unrelated(object):
+ pass
+
+ u = Unrelated()
+ u.tagged = True
+ u.x = rerased.erase_int(41)
+ class A(object):
+ pass
+ def fn():
+ n = 1
+ while n >= 0:
+ if u.tagged:
+ n = rerased.unerase_int(u.x)
+ a = A()
+ a.n = n - 1
+ u.x = erase(a)
+ u.tagged = False
+ else:
+ n = unerase(u.x).n
+ u.x = rerased.erase_int(n - 1)
+ u.tagged = True
+ def func():
+ rgc.collect() # check that a prebuilt erased integer doesn't explode
+ u.x = rerased.erase_int(1000)
+ u.tagged = True
+ fn()
+ return 1
+ return func
+
+ def test_erased(self):
+ expected = self.run_orig("erased")
+ res = self.run("erased")
+ assert res == expected
+
from pypy.rlib.objectmodel import UnboxedValue
class TaggedBase(object):
More information about the pypy-commit
mailing list