[pypy-commit] pypy kill-ootype: Clean up rpython/translator/backendopt/

rlamy noreply at buildbot.pypy.org
Tue Jul 23 18:50:18 CEST 2013


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: kill-ootype
Changeset: r65562:feed2f2df76b
Date: 2013-07-23 18:49 +0200
http://bitbucket.org/pypy/pypy/changeset/feed2f2df76b/

Log:	Clean up rpython/translator/backendopt/

diff --git a/rpython/translator/backendopt/malloc.py b/rpython/translator/backendopt/malloc.py
--- a/rpython/translator/backendopt/malloc.py
+++ b/rpython/translator/backendopt/malloc.py
@@ -1,7 +1,6 @@
 from rpython.flowspace.model import Variable, Constant, SpaceOperation
 from rpython.tool.algo.unionfind import UnionFind
 from rpython.rtyper.lltypesystem import lltype
-from rpython.rtyper.ootypesystem import ootype
 from rpython.translator import simplify
 from rpython.translator.backendopt import removenoops
 from rpython.translator.backendopt.support import log
@@ -538,10 +537,7 @@
 
 
 def remove_simple_mallocs(graph, type_system='lltypesystem', verbose=True):
-    if type_system == 'lltypesystem':
-        remover = LLTypeMallocRemover(verbose)
-    else:
-        remover = OOTypeMallocRemover(verbose)
+    remover = LLTypeMallocRemover(verbose)
     return remover.remove_simple_mallocs(graph)
 
 
diff --git a/rpython/translator/backendopt/test/test_mallocv.py b/rpython/translator/backendopt/test/test_mallocv.py
--- a/rpython/translator/backendopt/test/test_mallocv.py
+++ b/rpython/translator/backendopt/test/test_mallocv.py
@@ -1,17 +1,11 @@
 import py
 import sys
 from rpython.translator.backendopt.mallocv import MallocVirtualizer
-from rpython.translator.backendopt.inline import inline_function
-from rpython.translator.backendopt.all import backend_optimizations
 from rpython.translator.translator import TranslationContext, graphof
-from rpython.translator import simplify
-from rpython.flowspace.model import checkgraph, Block, mkentrymap
 from rpython.flowspace.model import summary
 from rpython.rtyper.llinterp import LLInterpreter, LLException
-from rpython.rtyper.lltypesystem import lltype, llmemory, lloperation
-from rpython.rtyper.ootypesystem import ootype
+from rpython.rtyper.lltypesystem import lltype, lloperation
 from rpython.rtyper.annlowlevel import llhelper
-from rpython.rlib import objectmodel
 from rpython.rlib.rarithmetic import ovfcheck
 from rpython.conftest import option
 
@@ -22,13 +16,8 @@
         self.excname = excname
 
 
-class BaseMallocRemovalTest(object):
-    type_system = None
-    MallocRemover = None
-
-    def _skip_oo(self, msg):
-        if self.type_system == 'ootype':
-            py.test.skip(msg)
+class TestMallocRemoval(object):
+    type_system = 'lltype'
 
     def check_malloc_removed(cls, graph, expected_mallocs, expected_calls):
         count_mallocs = 0
@@ -59,7 +48,6 @@
         mallocv = MallocVirtualizer(t.graphs, t.rtyper, verbose=True)
         while True:
             progress = mallocv.remove_mallocs_once()
-            #simplify.transform_dead_op_vars_in_blocks(list(graph.iterblocks()))
             if progress and option.view:
                 t.view()
             t.checkgraphs()
@@ -552,10 +540,6 @@
                                      # g(Virtual, Virtual)
 
 
-class TestLLTypeMallocRemoval(BaseMallocRemovalTest):
-    type_system = 'lltype'
-    #MallocRemover = LLTypeMallocRemover
-
     def test_getsubstruct(self):
         SMALL = lltype.Struct('SMALL', ('x', lltype.Signed))
         BIG = lltype.GcStruct('BIG', ('z', lltype.Signed), ('s', SMALL))
@@ -802,32 +786,3 @@
                 t.y += 1
             return s.x
         graph = self.check(f, [int], [5], 123)
-
-
-class DISABLED_TestOOTypeMallocRemoval(BaseMallocRemovalTest):
-    type_system = 'ootype'
-    #MallocRemover = OOTypeMallocRemover
-
-    def test_oononnull(self):
-        FOO = ootype.Instance('Foo', ootype.ROOT)
-        def fn():
-            s = ootype.new(FOO)
-            return bool(s)
-        self.check(fn, [], [], True)
-
-    def test_classattr_as_defaults(self):
-        class Bar:
-            foo = 41
-        
-        def fn():
-            x = Bar()
-            x.foo += 1
-            return x.foo
-        self.check(fn, [], [], 42)
-
-    def test_fn5(self):
-        # don't test this in ootype because the class attribute access
-        # is turned into an oosend which prevents malloc removal to
-        # work unless we inline first. See test_classattr in
-        # test_inline.py
-        pass
diff --git a/rpython/translator/backendopt/test/test_storesink.py b/rpython/translator/backendopt/test/test_storesink.py
--- a/rpython/translator/backendopt/test/test_storesink.py
+++ b/rpython/translator/backendopt/test/test_storesink.py
@@ -3,13 +3,12 @@
 from rpython.translator.translator import TranslationContext, graphof
 from rpython.translator.backendopt.storesink import storesink_graph
 from rpython.translator.backendopt import removenoops
-from rpython.flowspace.model import last_exception, checkgraph
+from rpython.flowspace.model import checkgraph
 from rpython.conftest import option
 
 class TestStoreSink(object):
-    # not sure if it makes any sense on ootype, maybe worth trying
     type_system = 'lltype'
-    
+
     def translate(self, func, argtypes):
         t = TranslationContext()
         t.buildannotator().build_types(func, argtypes)
@@ -37,7 +36,7 @@
     def test_infrastructure(self):
         class A(object):
             pass
-        
+
         def f(i):
             a = A()
             a.x = i
@@ -55,7 +54,7 @@
             return a.x + a.x
 
         self.check(f, [int], 1)
-                
+
     def test_irrelevant_setfield(self):
         class A(object):
             pass
diff --git a/rpython/translator/backendopt/writeanalyze.py b/rpython/translator/backendopt/writeanalyze.py
--- a/rpython/translator/backendopt/writeanalyze.py
+++ b/rpython/translator/backendopt/writeanalyze.py
@@ -1,6 +1,5 @@
 from rpython.flowspace.model import Variable
 from rpython.translator.backendopt import graphanalyze
-from rpython.rtyper.ootypesystem import ootype
 
 top_set = object()
 empty_set = frozenset()
@@ -36,7 +35,7 @@
         return result1.union(result2)
 
     def analyze_simple_operation(self, op, graphinfo):
-        if op.opname in ("setfield", "oosetfield"):
+        if op.opname == "setfield":
             if graphinfo is None or not graphinfo.is_fresh_malloc(op.args[0]):
                 return frozenset([
                     ("struct", op.args[0].concretetype, op.args[1].value)])
@@ -48,15 +47,6 @@
     def _array_result(self, TYPE):
         return frozenset([("array", TYPE)])
 
-    def analyze_external_method(self, op, TYPE, meth):
-        if isinstance(TYPE, ootype.Array):
-            methname = op.args[0].value
-            if methname == 'll_setitem_fast':
-                return self._array_result(op.args[1].concretetype)
-            elif methname in ('ll_getitem_fast', 'll_length'):
-                return self.bottom_result()
-        return graphanalyze.GraphAnalyzer.analyze_external_method(self, op, TYPE, meth)
-
     def compute_graph_info(self, graph):
         return FreshMallocs(graph)
 


More information about the pypy-commit mailing list