Author: Ronan Lamy <[email protected]>
Branch: exctrans
Changeset: r81594:b72c57375aa0
Date: 2016-01-05 18:40 +0100
http://bitbucket.org/pypy/pypy/changeset/b72c57375aa0/
Log: Call funcgen.patch_graph() before source generation rather than in
the middle of it
diff --git a/rpython/memory/gctransform/test/test_framework.py
b/rpython/memory/gctransform/test/test_framework.py
--- a/rpython/memory/gctransform/test/test_framework.py
+++ b/rpython/memory/gctransform/test/test_framework.py
@@ -40,7 +40,7 @@
t.config.translation.gc = "minimark"
cbuild = CStandaloneBuilder(t, entrypoint, t.config,
gcpolicy=FrameworkGcPolicy2)
- db = cbuild.generate_graphs_for_llinterp()
+ db = cbuild.generate_graphs()
entrypointptr = cbuild.getentrypointptr()
entrygraph = entrypointptr._obj.graph
@@ -69,7 +69,7 @@
return -x
t = rtype(g, [int])
gg = graphof(t, g)
- assert not CollectAnalyzer(t).analyze_direct_call(gg)
+ assert not CollectAnalyzer(t).analyze_direct_call(gg)
def test_cancollect_external():
fext1 = rffi.llexternal('fext1', [], lltype.Void, releasegil=False)
@@ -110,12 +110,12 @@
def entrypoint(argv):
return g() + 2
-
+
t = rtype(entrypoint, [s_list_of_strings])
t.config.translation.gc = "minimark"
cbuild = CStandaloneBuilder(t, entrypoint, t.config,
gcpolicy=FrameworkGcPolicy2)
- db = cbuild.generate_graphs_for_llinterp()
+ db = cbuild.generate_graphs()
def test_no_collect_detection():
from rpython.rlib import rgc
@@ -134,12 +134,13 @@
def entrypoint(argv):
return g() + 2
-
+
t = rtype(entrypoint, [s_list_of_strings])
t.config.translation.gc = "minimark"
cbuild = CStandaloneBuilder(t, entrypoint, t.config,
gcpolicy=FrameworkGcPolicy2)
- f = py.test.raises(Exception, cbuild.generate_graphs_for_llinterp)
+ with py.test.raises(Exception) as f:
+ cbuild.generate_graphs()
expected = "'no_collect' function can trigger collection: <function g at "
assert str(f.value).startswith(expected)
@@ -163,11 +164,12 @@
t.config.translation.gc = "minimark"
cbuild = CStandaloneBuilder(t, entrypoint, t.config,
gcpolicy=FrameworkGcPolicy2)
- f = py.test.raises(Exception, cbuild.generate_graphs_for_llinterp)
+ with py.test.raises(Exception) as f:
+ cbuild.generate_graphs()
assert 'can cause the GC to be called' in str(f.value)
assert 'trace_func' in str(f.value)
assert 'MyStructure' in str(f.value)
-
+
class WriteBarrierTransformer(ShadowStackFrameworkGCTransformer):
clean_sets = {}
GC_PARAMS = {}
@@ -252,7 +254,7 @@
t.config.translation.gc = "minimark"
cbuild = CStandaloneBuilder(t, g, t.config,
gcpolicy=FrameworkGcPolicy2)
- db = cbuild.generate_graphs_for_llinterp()
+ db = cbuild.generate_graphs()
ff = graphof(t, f)
#ff.show()
@@ -306,7 +308,7 @@
def test_find_clean_setarrayitems():
S = lltype.GcStruct('S')
A = lltype.GcArray(lltype.Ptr(S))
-
+
def f():
l = lltype.malloc(A, 3)
l[0] = lltype.malloc(S)
@@ -327,7 +329,7 @@
def test_find_clean_setarrayitems_2():
S = lltype.GcStruct('S')
A = lltype.GcArray(lltype.Ptr(S))
-
+
def f():
l = lltype.malloc(A, 3)
l[0] = lltype.malloc(S)
@@ -349,7 +351,7 @@
def test_find_clean_setarrayitems_3():
S = lltype.GcStruct('S')
A = lltype.GcArray(lltype.Ptr(S))
-
+
def f():
l = lltype.malloc(A, 3)
l[0] = lltype.malloc(S)
diff --git a/rpython/memory/gctransform/test/test_transform.py
b/rpython/memory/gctransform/test/test_transform.py
--- a/rpython/memory/gctransform/test/test_transform.py
+++ b/rpython/memory/gctransform/test/test_transform.py
@@ -16,7 +16,7 @@
t = rtype(f, args_s)
# XXX we shouldn't need an actual gcpolicy here.
cbuild = CStandaloneBuilder(t, f, t.config, gcpolicy=self.gcpolicy)
- cbuild.generate_graphs_for_llinterp()
+ cbuild.generate_graphs()
graph = cbuild.getentrypointptr()._obj.graph
# arguments cannot be GC objects because nobody would put a
# proper header on them
diff --git a/rpython/memory/test/test_transformed_gc.py
b/rpython/memory/test/test_transformed_gc.py
--- a/rpython/memory/test/test_transformed_gc.py
+++ b/rpython/memory/test/test_transformed_gc.py
@@ -110,7 +110,7 @@
cbuild = CStandaloneBuilder(t, entrypoint, config=t.config,
gcpolicy=cls.gcpolicy)
- db = cbuild.generate_graphs_for_llinterp()
+ db = cbuild.generate_graphs()
entrypointptr = cbuild.getentrypointptr()
entrygraph = entrypointptr._obj.graph
if option.view:
@@ -1071,7 +1071,7 @@
def test_adr_of_nursery(self):
run = self.runner("adr_of_nursery")
res = run([])
-
+
class TestGenerationalNoFullCollectGC(GCTest):
# test that nursery is doing its job and that no full collection
@@ -1131,7 +1131,7 @@
'large_object': 8*WORD,
'translated_to_c': False}
root_stack_depth = 200
-
+
def define_ref_from_rawmalloced_to_regular(cls):
import gc
S = lltype.GcStruct('S', ('x', lltype.Signed))
@@ -1182,7 +1182,7 @@
run = self.runner("write_barrier_direct")
res = run([])
assert res == 42
-
+
class TestMiniMarkGC(TestHybridGC):
gcname = "minimark"
GC_CAN_TEST_ID = True
@@ -1199,7 +1199,7 @@
'translated_to_c': False,
}
root_stack_depth = 200
-
+
def define_no_clean_setarrayitems(cls):
# The optimization find_clean_setarrayitems() in
# gctransformer/framework.py does not work with card marking.
@@ -1224,7 +1224,7 @@
run = self.runner("no_clean_setarrayitems")
res = run([])
assert res == 123
-
+
def define_nursery_hash_base(cls):
class A:
pass
@@ -1283,19 +1283,19 @@
'translated_to_c': False,
}
root_stack_depth = 200
-
+
def define_malloc_array_of_gcptr(self):
S = lltype.GcStruct('S', ('x', lltype.Signed))
A = lltype.GcArray(lltype.Ptr(S))
def f():
lst = lltype.malloc(A, 5)
- return (lst[0] == lltype.nullptr(S)
+ return (lst[0] == lltype.nullptr(S)
and lst[1] == lltype.nullptr(S)
and lst[2] == lltype.nullptr(S)
and lst[3] == lltype.nullptr(S)
and lst[4] == lltype.nullptr(S))
return f
-
+
def test_malloc_array_of_gcptr(self):
run = self.runner('malloc_array_of_gcptr')
res = run([])
@@ -1376,7 +1376,7 @@
def define_gettypeid(cls):
class A(object):
pass
-
+
def fn():
a = A()
return rgc.get_typeid(a)
diff --git a/rpython/translator/c/funcgen.py b/rpython/translator/c/funcgen.py
--- a/rpython/translator/c/funcgen.py
+++ b/rpython/translator/c/funcgen.py
@@ -2,7 +2,7 @@
from rpython.translator.c.support import cdecl
from rpython.translator.c.support import llvalue_from_constant, gen_assignments
from rpython.translator.c.support import c_string_constant, barebonearray
-from rpython.flowspace.model import Variable, Constant, copygraph
+from rpython.flowspace.model import Variable, Constant
from rpython.rtyper.lltypesystem.lltype import (Ptr, Void, Bool, Signed,
Unsigned,
SignedLongLong, Float, UnsignedLongLong, Char, UniChar, ContainerType,
Array, FixedSizeArray, ForwardReference, FuncType)
@@ -99,7 +99,6 @@
return graph
def implementation_begin(self):
- self.patch_graph()
SSI_to_SSA(self.graph)
self.collect_var_and_types()
self.blocknum = {}
diff --git a/rpython/translator/c/genc.py b/rpython/translator/c/genc.py
--- a/rpython/translator/c/genc.py
+++ b/rpython/translator/c/genc.py
@@ -195,25 +195,19 @@
DEBUG_DEFINES = {'RPY_ASSERT': 1,
'RPY_LL_ASSERT': 1}
- def generate_graphs_for_llinterp(self, db=None):
- # prepare the graphs as when the source is generated, but without
- # actually generating the source.
+ def generate_graphs(self, db=None):
+ """"Prepare the graphs."""
if db is None:
db = self.build_database()
- graphs = db.all_graphs()
- db.gctransformer.prepare_inline_helpers(graphs)
+ db.prepare_inline_helpers()
for node in db.containerlist:
- if hasattr(node, 'funcgens'):
- for funcgen in node.funcgens:
- funcgen.patch_graph()
+ if getattr(node, 'funcgen', None):
+ node.funcgen.patch_graph()
return db
def generate_source(self, db=None, defines={}, exe_name=None):
assert self.c_source_filename is None
-
- if db is None:
- db = self.build_database()
- db.prepare_inline_helpers()
+ db = self.generate_graphs(db)
pf = self.getentrypointptr()
if self.modulename is None:
self.modulename = uniquemodulename('testing')
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit