[pypy-svn] r33958 - in pypy/dist/pypy/jit/timeshifter: . test

pedronis at codespeak.net pedronis at codespeak.net
Tue Oct 31 15:44:28 CET 2006


Author: pedronis
Date: Tue Oct 31 15:44:26 2006
New Revision: 33958

Modified:
   pypy/dist/pypy/jit/timeshifter/rtimeshift.py
   pypy/dist/pypy/jit/timeshifter/rtyper.py
   pypy/dist/pypy/jit/timeshifter/test/test_promotion.py
   pypy/dist/pypy/jit/timeshifter/transform.py
Log:
(arre, pedronis, arigo around)

test that shows that our global merge caches logic needs to be sure nothing is pending on the split queue.



Modified: pypy/dist/pypy/jit/timeshifter/rtimeshift.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/rtimeshift.py	(original)
+++ pypy/dist/pypy/jit/timeshifter/rtimeshift.py	Tue Oct 31 15:44:26 2006
@@ -194,6 +194,7 @@
                                  frozen, newblock,
                                  global_resumer)
         jitstate.promotion_path = PromotionPathMergesToSee(node, 0)
+        #debug_print(lltype.Void, "PROMOTION ROOT")
 start_new_block._annspecialcase_ = "specialize:arglltype(2)"
 
 def retrieve_jitstate_for_merge(states_dic, jitstate, key, global_resumer):
@@ -236,6 +237,7 @@
         count = dispatchqueue.mergecounter + 1
         dispatchqueue.mergecounter = count
         node = PromotionPathMergesToSee(node, count)
+        #debug_print(lltype.Void, "MERGE", count)
         jitstate.promotion_path = node
     else:
         if resuming.mergesleft != MC_IGNORE_UNTIL_RETURN:
@@ -300,6 +302,15 @@
     return jitstate_chain
     # XXX obscurity++ above
 
+def reverse_split_queue(dispatchqueue):
+    newchain = None
+    while dispatchqueue.split_chain:
+        jitstate = dispatchqueue.split_chain
+        dispatchqueue.split_chain = jitstate.next
+        jitstate.next = newchain
+        newchain = jitstate
+    dispatchqueue.split_chain = newchain
+
 def dispatch_next(oldjitstate, dispatchqueue):
     if dispatchqueue.split_chain is not None:
         jitstate = dispatchqueue.split_chain
@@ -549,6 +560,7 @@
             enter_block(jitstate)
             pm = PromotionPoint(flexswitch, incoming_gv,
                                 jitstate.promotion_path)
+            #debug_print(lltype.Void, "PROMOTE")
             ll_pm = cast_instance_to_base_ptr(pm)
             gv_pm = default_builder.rgenop.genconst(ll_pm)
             gv_switchvar = promotebox.genvar

Modified: pypy/dist/pypy/jit/timeshifter/rtyper.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/rtyper.py	(original)
+++ pypy/dist/pypy/jit/timeshifter/rtyper.py	Tue Oct 31 15:44:26 2006
@@ -1108,6 +1108,12 @@
     def translate_op_residual_gray_call(self, hop):
         self.translate_op_residual_red_call(hop, color='gray')
 
+    def translate_op_reverse_split_queue(self, hop):
+        hop.llops.genmixlevelhelpercall(rtimeshift.reverse_split_queue,
+                                        [self.s_Queue],
+                                        [self.v_queue],
+                                        annmodel.s_None)
+
 
 class HintLowLevelOpList(LowLevelOpList):
     """Warning: the HintLowLevelOpList's rtyper is the *original*

Modified: pypy/dist/pypy/jit/timeshifter/test/test_promotion.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/test/test_promotion.py	(original)
+++ pypy/dist/pypy/jit/timeshifter/test/test_promotion.py	Tue Oct 31 15:44:26 2006
@@ -262,3 +262,32 @@
         assert res == ord('2')
         self.check_insns(indirect_call=0)
 
+    def test_mixed_merges(self):
+        py.test.skip("in-progress")
+        def ll_function(x, y, z, k):
+            if x:
+               while x > 0:
+                   hint(None, global_merge_point=True)
+                   if y < 0:
+                       y = -y
+                       hint(None, reverse_split_queue=True)
+                       return y
+                   else:
+                       n = 10
+                       while n:
+                           n -= 1
+                       y = hint(y, promote=True)
+                       y *= 2
+                       y = hint(y, variable=True)
+                   x -= 1
+            else:
+                if z < 0:
+                    z = -z
+                else:
+                    k = 3
+                y = y + z*k
+            return y
+
+        res = self.timeshift(ll_function, [6, 3, 2, 2], [3], policy=P_NOVIRTUAL)
+
+        assert res == ll_function(6, 3, 2, 2)

Modified: pypy/dist/pypy/jit/timeshifter/transform.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/transform.py	(original)
+++ pypy/dist/pypy/jit/timeshifter/transform.py	Tue Oct 31 15:44:26 2006
@@ -663,6 +663,11 @@
         newop = SpaceOperation('same_as', [op.args[0]], op.result)
         block.operations[i] = newop
 
+    def handle_reverse_split_queue_hint(self, block, i):
+        op = block.operations[i]
+        newop = SpaceOperation('reverse_split_queue', [], op.result)
+        block.operations[i] = newop
+
     def handle_forget_hint(self, block, i):
         # a hint for testing only
         op = block.operations[i]



More information about the Pypy-commit mailing list