[pypy-svn] r25835 - in pypy/dist/pypy: rpython/memory translator/c/test
cfbolz at codespeak.net
cfbolz at codespeak.net
Fri Apr 14 21:55:09 CEST 2006
Author: cfbolz
Date: Fri Apr 14 21:55:06 2006
New Revision: 25835
Modified:
pypy/dist/pypy/rpython/memory/gctransform.py
pypy/dist/pypy/translator/c/test/test_boehm.py
pypy/dist/pypy/translator/c/test/test_newgc.py
Log:
only protect calls that actually can collect in the framework
Modified: pypy/dist/pypy/rpython/memory/gctransform.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/gctransform.py (original)
+++ pypy/dist/pypy/rpython/memory/gctransform.py Fri Apr 14 21:55:06 2006
@@ -6,6 +6,7 @@
from pypy.translator.unsimplify import insert_empty_block
from pypy.translator.translator import graphof
from pypy.translator.backendopt.support import var_needsgc, needs_conservative_livevar_calculation
+from pypy.translator.backendopt import graphanalyze
from pypy.annotation import model as annmodel
from pypy.rpython import rmodel, rptr, annlowlevel
from pypy.rpython.memory import gc, lladdress
@@ -664,6 +665,10 @@
yield a
+class CollectAnalyzer(graphanalyze.GraphAnalyzer):
+ def operation_is_true(self, op):
+ return op.opname in ("malloc", "malloc_varsize")
+
class FrameworkGCTransformer(GCTransformer):
def __init__(self, translator):
@@ -822,6 +827,9 @@
self.malloc_varsize_ptr = self.graph2funcptr(malloc_varsize_graph)
self.graphs_to_inline[malloc_fixedsize_graph] = True
+ self.collect_analyzer = CollectAnalyzer(self.translator)
+ self.collect_analyzer.analyze_all()
+
def graph2funcptr(self, graph):
self.need_minimal_transform(graph)
return const_funcptr_fromgraph(graph)
@@ -971,8 +979,13 @@
newops.extend(self.pop_roots(livevars))
return newops, index
- replace_direct_call = protect_roots
- replace_indirect_call = protect_roots
+ def replace_direct_call(self, op, livevars, block):
+ if self.collect_analyzer.analyze(op):
+ return self.protect_roots(op, livevars, block)
+ else:
+ return [op], 0
+
+ replace_indirect_call = replace_direct_call
def replace_malloc(self, op, livevars, block):
TYPE = op.args[0].value
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 Fri Apr 14 21:55:06 2006
@@ -20,6 +20,7 @@
def getcompiled(self, func):
t = TranslationContext(simplifying=True)
+ self.t = t
# builds starting-types from func_defs
argstypelist = []
if func.func_defaults:
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 Fri Apr 14 21:55:06 2006
@@ -4,6 +4,7 @@
from py.test import raises
from pypy.translator.translator import TranslationContext
+from pypy.translator.backendopt.stat import print_statistics
from pypy.translator.c import genc, gc
from pypy.rpython.lltypesystem import lltype
@@ -193,7 +194,7 @@
from pypy.translator.c.gc import FrameworkGcPolicy as gcpolicy
def test_framework_simple(self):
- def g(x):
+ def g(x): # cannot cause a collect
return x + 1
class A(object):
pass
@@ -208,6 +209,7 @@
fn = self.getcompiled(f)
res = fn()
assert res == 2
+ assert len(self.t.graphs[0].startblock.exits[False].target.operations) == 10
def test_framework_varsized(self):
S = lltype.GcStruct("S", ('x', lltype.Signed))
More information about the Pypy-commit
mailing list