[pypy-svn] r26926 - in pypy/dist/pypy: rpython/memory translator/c/test
cfbolz at codespeak.net
cfbolz at codespeak.net
Sun May 7 12:40:22 CEST 2006
Author: cfbolz
Date: Sun May 7 12:40:20 2006
New Revision: 26926
Modified:
pypy/dist/pypy/rpython/memory/gctransform.py
pypy/dist/pypy/translator/c/test/test_newgc.py
Log:
make the llop gc__collect work for the framework too
Modified: pypy/dist/pypy/rpython/memory/gctransform.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/gctransform.py (original)
+++ pypy/dist/pypy/rpython/memory/gctransform.py Sun May 7 12:40:20 2006
@@ -720,7 +720,7 @@
class CollectAnalyzer(graphanalyze.GraphAnalyzer):
def operation_is_true(self, op):
- return op.opname in ("malloc", "malloc_varsize")
+ return op.opname in ("malloc", "malloc_varsize", "gc__collect")
class FrameworkGCTransformer(GCTransformer):
@@ -875,6 +875,8 @@
GCData.GCClass.malloc_varsize.im_func,
[s_gcdata] + [annmodel.SomeInteger(nonneg=True) for i in range(5)],
annmodel.SomeAddress())
+ collect_graph = annhelper.getgraph(GCData.GCClass.collect.im_func,
+ [s_gcdata], annmodel.s_None)
annhelper.finish() # at this point, annotate all mix-level helpers
self.frameworkgc_setup_ptr = self.graph2funcptr(frameworkgc_setup_graph)
self.push_root_ptr = self.graph2funcptr(push_root_graph)
@@ -883,8 +885,8 @@
self.graphs_to_inline[pop_root_graph] = True
self.malloc_fixedsize_ptr = self.graph2funcptr(malloc_fixedsize_graph)
self.malloc_varsize_ptr = self.graph2funcptr(malloc_varsize_graph)
+ self.collect_ptr = self.graph2funcptr(collect_graph)
self.graphs_to_inline[malloc_fixedsize_graph] = True
-
self.collect_analyzer = CollectAnalyzer(self.translator)
self.collect_analyzer.analyze_all()
@@ -1061,6 +1063,14 @@
replace_malloc_varsize = replace_malloc
+ def replace_gc__collect(self, op, livevars, block):
+ # surely there's a better way of doing this?
+ s_gc = self.translator.annotator.bookkeeper.valueoftype(self.gcdata.GCClass)
+ r_gc = self.translator.rtyper.getrepr(s_gc)
+ const_gc = rmodel.inputconst(r_gc, self.gcdata.gc)
+ return [SpaceOperation(
+ "direct_call", [self.collect_ptr, const_gc], op.result)]
+
def push_alive_nopyobj(self, var):
return []
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 Sun May 7 12:40:20 2006
@@ -7,6 +7,7 @@
from pypy.translator.backendopt.stat import print_statistics
from pypy.translator.c import genc, gc
from pypy.rpython.lltypesystem import lltype
+from pypy.rpython.lltypesystem.lloperation import llop
from pypy.rpython.objectmodel import cast_address_to_object, cast_object_to_address
from pypy.rpython.memory.gctransform import GCTransformer
@@ -323,9 +324,9 @@
a = A()
a.b = g(1)
# this should trigger a couple of collections
- # XXX make sure it triggers at least one somehow!
for i in range(1000):
[A() for j in range(1000)]
+ llop.gc__collect(lltype.Void)
return a.b
fn = self.getcompiled(f)
res = fn()
@@ -353,10 +354,9 @@
g(1)
b0 = a.b
b0.c = b.c = 42
- # this should trigger a couple of collections
- # XXX make sure it triggers at least one somehow!
for i in range(1000):
[A() for j in range(1000)]
+ llop.gc__collect(lltype.Void)
return global_a.b.a.b.c
fn = self.getcompiled(f)
startblock = self.t.graphs[0].startblock
@@ -378,6 +378,9 @@
# this should trigger 3 collections
for i in range(1000000):
prepare(B(), -1)
+ llop.gc__collect(lltype.Void)
+ llop.gc__collect(lltype.Void)
+ llop.gc__collect(lltype.Void)
# we need to prevent it getting inlined
if not a:
g(A())
@@ -445,8 +448,7 @@
a.x = None
def f():
a.x = A(42)
- for i in range(1000000):
- A(i)
+ llop.gc__collect(lltype.Void)
return a.x.y
fn = self.getcompiled(f)
res = fn()
More information about the Pypy-commit
mailing list