[pypy-svn] r50688 - in pypy/dist/pypy: jit/codegen/llgraph jit/timeshifter/test rpython/ootypesystem

antocuni at codespeak.net antocuni at codespeak.net
Wed Jan 16 21:06:37 CET 2008


Author: antocuni
Date: Wed Jan 16 21:06:35 2008
New Revision: 50688

Added:
   pypy/dist/pypy/rpython/ootypesystem/rtupletype.py   (contents, props changed)
Modified:
   pypy/dist/pypy/jit/codegen/llgraph/llimpl.py
   pypy/dist/pypy/jit/timeshifter/test/test_timeshift.py
Log:
(antocuni, arigo)

a lot of tests passed out of the box, but test_loop_merging needed a
very weird hack to pass



Modified: pypy/dist/pypy/jit/codegen/llgraph/llimpl.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/llgraph/llimpl.py	(original)
+++ pypy/dist/pypy/jit/codegen/llgraph/llimpl.py	Wed Jan 16 21:06:35 2008
@@ -4,8 +4,8 @@
 that can be used to produce any other kind of graph.
 """
 
-from pypy.rpython.lltypesystem import lltype, llmemory, rtupletype
-from pypy.rpython.ootypesystem import ootype
+from pypy.rpython.lltypesystem import lltype, llmemory, rtupletype as llrtupletype
+from pypy.rpython.ootypesystem import ootype, rtupletype as oortupletype
 from pypy.objspace.flow import model as flowmodel
 from pypy.translator.simplify import eliminate_empty_blocks
 from pypy.translator.unsimplify import varoftype
@@ -475,11 +475,25 @@
     block.recloseblock(*exits)
     return _to_opaque(default_link)
 
+# incredible hack here; pseudotuple must pretend to be both a LL tuple
+# and an OO tuple, so we need to make the llinterpreter thinking that
+# its _TYPE is compatible both with a struct and a
+# record. TwoFacedType does exactly this.
+class TwoFacedType(ootype.BuiltinType):
+    def __init__(self, TYPE1, TYPE2):
+        self.TYPE1 = TYPE1
+        self.TYPE2 = TYPE2
+
+    def __eq__(self, other):
+        return self.TYPE1 == other or self.TYPE2 == other
+
 class pseudotuple(object):
-    # something that looks both like a hl and a ll tuple
+    # something that looks both like a hl, a ll tuple and an oo tuple
     def __init__(self, *items):
-        self._TYPE = rtupletype.TUPLE_TYPE(
-            [lltype.typeOf(item) for item in items])
+        fields = [lltype.typeOf(item) for item in items]
+        TYPE1 = llrtupletype.TUPLE_TYPE(fields)
+        TYPE2 = oortupletype.TUPLE_TYPE(fields)
+        self._TYPE = TwoFacedType(TYPE1, TYPE2)
         for i, item in enumerate(items):
             setattr(self, 'item%d' % i, item)
         self._items = items

Modified: pypy/dist/pypy/jit/timeshifter/test/test_timeshift.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/test/test_timeshift.py	(original)
+++ pypy/dist/pypy/jit/timeshifter/test/test_timeshift.py	Wed Jan 16 21:06:35 2008
@@ -1796,6 +1796,10 @@
 passing_ootype_tests = set([
     'test_very_simple',
     'test_convert_const_to_redbox',
+    'test_simple_opt_const_propagation1',
+    'test_simple_opt_const_propagation2',
+    'test_loop_folding',
+    'test_loop_merging',
     ])
 class TestOOType(BaseTestTimeshift):
     type_system = 'ootype'

Added: pypy/dist/pypy/rpython/ootypesystem/rtupletype.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/rpython/ootypesystem/rtupletype.py	Wed Jan 16 21:06:35 2008
@@ -0,0 +1,13 @@
+# Helper to build the lowleveltype corresponding to an RPython tuple.
+# This is not in rtuple.py so that it can be imported without bringing
+# the whole rtyper in.
+
+from pypy.rpython.ootypesystem import ootype
+
+
+def TUPLE_TYPE(field_lltypes):
+    if len(field_lltypes) == 0:
+        return Void      # empty tuple
+    else:
+        fields = [('item%d' % i, TYPE) for i, TYPE in enumerate(field_lltypes)]
+        return ootype.Record(dict(fields))



More information about the Pypy-commit mailing list