[pypy-svn] r32371 - in pypy/branch/kill-keepalives/pypy/translator/backendopt: . test
mwh at codespeak.net
mwh at codespeak.net
Fri Sep 15 18:26:47 CEST 2006
Author: mwh
Date: Fri Sep 15 18:26:45 2006
New Revision: 32371
Modified:
pypy/branch/kill-keepalives/pypy/translator/backendopt/malloc.py
pypy/branch/kill-keepalives/pypy/translator/backendopt/test/test_malloc.py
Log:
so i don't know how long this will be useful for, but support for removing
zero_mallocs.
Modified: pypy/branch/kill-keepalives/pypy/translator/backendopt/malloc.py
==============================================================================
--- pypy/branch/kill-keepalives/pypy/translator/backendopt/malloc.py (original)
+++ pypy/branch/kill-keepalives/pypy/translator/backendopt/malloc.py Fri Sep 15 18:26:45 2006
@@ -137,7 +137,7 @@
if cp[0] != "op":
return False
op = cp[2]
- if op.opname != "malloc":
+ if op.opname not in ("malloc", "zero_malloc"):
return False
lltypes[op.result.concretetype] = True
@@ -393,7 +393,7 @@
else:
raise AssertionError, op.opname
elif op.result in vars:
- assert op.opname == "malloc"
+ assert op.opname in ("malloc", "zero_malloc")
assert vars == {var: True}
progress = True
# drop the "malloc" operation
@@ -468,7 +468,7 @@
# look for variables created inside the block by a malloc
vars_created_here = []
for op in block.operations:
- if op.opname == "malloc" and op.result in vars:
+ if op.opname in ("malloc", "zero_malloc") and op.result in vars:
vars_created_here.append(op.result)
for var in vars_created_here:
flowin(var, newvarsmap=None)
Modified: pypy/branch/kill-keepalives/pypy/translator/backendopt/test/test_malloc.py
==============================================================================
--- pypy/branch/kill-keepalives/pypy/translator/backendopt/test/test_malloc.py (original)
+++ pypy/branch/kill-keepalives/pypy/translator/backendopt/test/test_malloc.py Fri Sep 15 18:26:45 2006
@@ -17,7 +17,7 @@
for node in flatten(graph):
if isinstance(node, Block):
for op in node.operations:
- if op.opname == 'malloc':
+ if op.opname in ('malloc', 'zero_malloc'):
S = op.args[0].value
if not union_wrapper(S): # union wrappers are fine
count1 += 1
@@ -296,3 +296,10 @@
return g.p.x
graph = check(f, [], [], 1)
assert 'flavored_free' in summary(graph)
+
+def test_remove_zero_malloc():
+ S = lltype.GcStruct("S", ("x", lltype.Signed))
+ def f():
+ s = lltype.malloc(S, zero=True)
+ return s.x
+ check(f, [], [], 0)
More information about the Pypy-commit
mailing list