[pypy-svn] r31520 - in pypy/dist/pypy: jit/llabstractinterp jit/timeshifter rpython rpython/test

arigo at codespeak.net arigo at codespeak.net
Wed Aug 23 12:09:12 CEST 2006


Author: arigo
Date: Wed Aug 23 12:09:00 2006
New Revision: 31520

Modified:
   pypy/dist/pypy/jit/llabstractinterp/llabstractinterp.py
   pypy/dist/pypy/jit/timeshifter/rtimeshift.py
   pypy/dist/pypy/rpython/rgenop.py
   pypy/dist/pypy/rpython/test/test_rgenop.py
Log:
(pedronis, arigo)

Evil plan to remove LINKPAIR and return a tuple directly from closeblock2().


Modified: pypy/dist/pypy/jit/llabstractinterp/llabstractinterp.py
==============================================================================
--- pypy/dist/pypy/jit/llabstractinterp/llabstractinterp.py	(original)
+++ pypy/dist/pypy/jit/llabstractinterp/llabstractinterp.py	Wed Aug 23 12:09:00 2006
@@ -530,8 +530,8 @@
 
         assert len(newlinkstates) == 2
 
-        exitspair = rgenop.closeblock2(b, newexitswitch.getgenvar(self))
-        false_link, true_link = exitspair.item0, exitspair.item1
+        v = newexitswitch.getgenvar(self)
+        false_link, true_link = rgenop.closeblock2(b, v)
         
         cases = {False: false_link, True: true_link}
         for ls in newlinkstates:

Modified: pypy/dist/pypy/jit/timeshifter/rtimeshift.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/rtimeshift.py	(original)
+++ pypy/dist/pypy/jit/timeshifter/rtimeshift.py	Wed Aug 23 12:09:00 2006
@@ -310,8 +310,7 @@
         self.outgoinglink = rgenop.closeblock1(self.block)
 
     def leave_block_split(self, exitgvar):
-        linkpair = rgenop.closeblock2(self.block, exitgvar)    
-        false_link, true_link = linkpair.item0, linkpair.item1
+        false_link, true_link = rgenop.closeblock2(self.block, exitgvar)    
         later_builder = ResidualGraphBuilder(link=false_link)
         self.outgoinglink = true_link
         return later_builder

Modified: pypy/dist/pypy/rpython/rgenop.py
==============================================================================
--- pypy/dist/pypy/rpython/rgenop.py	(original)
+++ pypy/dist/pypy/rpython/rgenop.py	Wed Aug 23 12:09:00 2006
@@ -126,7 +126,7 @@
     block.closeblock(link)
     return to_opaque_object(link)
 
-def closeblock2into(blockcontainer, exitswitch, linkpair):
+def closeblock2(blockcontainer, exitswitch):
     block = from_opaque_object(blockcontainer.obj)
     exitswitch = from_opaque_object(exitswitch)
     assert isinstance(exitswitch, flowmodel.Variable)
@@ -138,13 +138,19 @@
     true_link.exitcase = True
     true_link.llexitcase = True
     block.closeblock(false_link, true_link)
-    linkpair.item0 = to_opaque_object(false_link)
-    linkpair.item1 = to_opaque_object(true_link)
+    return pseudotuple(to_opaque_object(false_link),
+                       to_opaque_object(true_link))
 
-def closeblock2(blockcontainer, exitswitch):
-    linkpair = lltype.malloc(LINKPAIR)
-    closeblock2into(blockcontainer, exitswitch, linkpair) 
-    return linkpair
+class pseudotuple(object):
+    # something that looks both like a hl and a ll tuple
+    def __init__(self, *items):
+        self._TYPE = rtupletype.TUPLE_TYPE(
+            [lltype.typeOf(item) for item in items])
+        for i, item in enumerate(items):
+            setattr(self, 'item%d' % i, item)
+        self._items = items
+    def __iter__(self):
+        return iter(self._items)
 
 def _closelink(link, vars, targetblock):
     if isinstance(link, flowmodel.Link):
@@ -237,7 +243,6 @@
 BLOCKCONTAINERTYPE = blocktypeinfo.get_lltype()
 BLOCK = lltype.Ptr(BLOCKCONTAINERTYPE)
 LINK = lltype.Ptr(linktypeinfo.get_lltype())
-LINKPAIR = rtupletype.TUPLE_TYPE([LINK, LINK]).TO
 
 # support constants and types
 
@@ -280,7 +285,7 @@
 
 s_ConstOrVar = annmodel.SomePtr(CONSTORVAR)#annmodel.SomeExternalObject(flowmodel.Variable)
 s_Link = annmodel.SomePtr(LINK)#annmodel.SomeExternalObject(flowmodel.Link)
-s_LinkPair = annmodel.SomePtr(lltype.Ptr(LINKPAIR))
+s_LinkPair = annmodel.SomeTuple([s_Link, s_Link])
 
 setannotation(initblock, None)
 setannotation(geninputarg, s_ConstOrVar)

Modified: pypy/dist/pypy/rpython/test/test_rgenop.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rgenop.py	(original)
+++ pypy/dist/pypy/rpython/test/test_rgenop.py	Wed Aug 23 12:09:00 2006
@@ -52,8 +52,7 @@
     v0 = geninputarg(block, constTYPE(Signed))
     const0 = genconst(0)
     v1 = genop(block, 'int_lt', [v0, const0], constTYPE(Bool))
-    exitspair = closeblock2(block, v1)
-    false_link, true_link = exitspair.item0, exitspair.item1
+    false_link, true_link = closeblock2(block, v1)
     closereturnlink(true_link, const0)
     closereturnlink(false_link, v0)
     return block
@@ -95,8 +94,7 @@
     result1 = genop(loopblock, 'int_mul', [result0, i0], constTYPE(Signed))
     i1 = genop(loopblock, 'int_add', [i0, const1], constTYPE(Signed))
     v2 = genop(loopblock, 'int_le', [i1, v1], constTYPE(Bool))
-    exitspair = closeblock2(loopblock, v2)
-    false_link, true_link = exitspair.item0, exitspair.item1
+    false_link, true_link = closeblock2(loopblock, v2)
     closereturnlink(false_link, result1)
     closelink(true_link, [result1, i1, v1], loopblock)
     return block    



More information about the Pypy-commit mailing list