[pypy-svn] r36576 - pypy/dist/pypy/translator/backendopt
antocuni at codespeak.net
antocuni at codespeak.net
Fri Jan 12 15:47:38 CET 2007
Author: antocuni
Date: Fri Jan 12 15:47:29 2007
New Revision: 36576
Modified:
pypy/dist/pypy/translator/backendopt/malloc.py
Log:
Use the right TYPE for the key in newvarsmap; don't remove malloc of BuiltinType
Modified: pypy/dist/pypy/translator/backendopt/malloc.py
==============================================================================
--- pypy/dist/pypy/translator/backendopt/malloc.py (original)
+++ pypy/dist/pypy/translator/backendopt/malloc.py Fri Jan 12 15:47:29 2007
@@ -49,6 +49,9 @@
def key_for_field_access(self, S, fldname):
raise NotImplementedError
+ def inline_type(self, TYPE):
+ raise NotImplementedError
+
def flowin(self, block, count, var, newvarsmap):
# in this 'block', follow where the 'var' goes to and replace
# it by a flattened-out family of variables. This family is given
@@ -186,6 +189,9 @@
op = cp[2]
if op.opname != self.MALLOC_OP:
return False
+ if not self.inline_type(op.args[0].value):
+ return False
+
lltypes[op.result.concretetype] = True
# there must be a single largest malloced GcStruct;
@@ -340,6 +346,9 @@
name = 'item%d' % (name,)
self.accessed_substructs[S, name] = True
+ def inline_type(self, TYPE):
+ return True
+
def equivalent_substruct(self, S, fieldname):
# we consider a pointer to a GcStruct S as equivalent to a
# pointer to a substructure 'S.fieldname' if it's the first
@@ -527,6 +536,9 @@
def RTTI_dtor(self, STRUCT):
return False
+ def inline_type(self, TYPE):
+ return isinstance(TYPE, (ootype.Record, ootype.Instance))
+
def _get_fields(self, TYPE):
if isinstance(TYPE, ootype.Record):
return TYPE._fields
@@ -537,7 +549,7 @@
def flatten(self, TYPE):
for name, (FIELDTYPE, default) in self._get_fields(TYPE).iteritems():
- key = TYPE, name
+ key = self.key_for_field_access(TYPE, name)
example = FIELDTYPE._defl()
constant = Constant(example)
constant.concretetype = FIELDTYPE
@@ -546,7 +558,8 @@
self.newvarstype[key] = FIELDTYPE
def key_for_field_access(self, S, fldname):
- return S, fldname
+ CLS, TYPE = S._lookup_field(fldname)
+ return CLS, fldname
def flowin_op(self, op, vars, newvarsmap):
if op.opname == "oogetfield":
More information about the Pypy-commit
mailing list