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

pedronis at codespeak.net pedronis at codespeak.net
Mon Oct 30 18:24:15 CET 2006


Author: pedronis
Date: Mon Oct 30 18:24:12 2006
New Revision: 33918

Modified:
   pypy/dist/pypy/jit/timeshifter/test/test_promotion.py
   pypy/dist/pypy/jit/timeshifter/test/test_timeshift.py
   pypy/dist/pypy/jit/timeshifter/transform.py
Log:
(arre, pedronis)

remove the support for the old _global_merge_points_ flag. Use the new hint style instead, also the hint put at the beginning
of a function now introduces a start global merge point. The promotion test pass after conversion.



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	Mon Oct 30 18:24:12 2006
@@ -11,10 +11,10 @@
         def ll_two(k):
             return (k+1)*2
         def ll_function(n):
+            hint(None, global_merge_point=True)
             k = hint(n, promote=True)
             k = ll_two(k)
             return hint(k, variable=True)
-        ll_function._global_merge_points_ = True
 
         # easy case: no promotion needed
         res = self.timeshift(ll_function, [20], [0])
@@ -31,12 +31,12 @@
             return k*k
         def ll_function(n, total):
             while n > 0:
+                hint(None, global_merge_point=True)
                 k = hint(n, promote=True)
                 k = ll_two(k)
                 total += hint(k, variable=True)
                 n -= 1
             return total
-        ll_function._global_merge_points_ = True
 
         res = self.timeshift(ll_function, [10, 0], [], policy=P_NOVIRTUAL)
         assert res == ll_function(10, 0)
@@ -44,13 +44,14 @@
 
     def test_multiple_portal_calls(self):
         def ll_function(n):
+            hint(None, global_merge_point=True)
             k = n
             if k > 5:
                 k //= 2
             k = hint(k, promote=True)
             k *= 17
             return hint(k, variable=True)
-        ll_function._global_merge_points_ = True
+        ll_function._dont_cache_ = True
 
         res = self.timeshift(ll_function, [4], [], policy=P_NOVIRTUAL)
         assert res == 68
@@ -68,12 +69,12 @@
             else:
                 s.x = 10
         def ll_function(n):
+            hint(None, global_merge_point=True)
             s = lltype.malloc(S)
             ll_two(n, s)
             k = hint(n, promote=True)
             k *= 17
             return hint(k, variable=True) + s.x
-        ll_function._global_merge_points_ = True
 
         res = self.timeshift(ll_function, [4], [], policy=P_NOVIRTUAL)
         assert res == 4*17 + 10
@@ -90,12 +91,12 @@
                 return 9
             
         def ll_function(n):
+            hint(None, global_merge_point=True)
             s = lltype.malloc(S)
             c = ll_two(n, s)
             k = hint(s.x, promote=True)
             k += c
             return hint(k, variable=True)
-        ll_function._global_merge_points_ = True
 
         res = self.timeshift(ll_function, [4], [], policy=P_NOVIRTUAL)
         assert res == 49
@@ -107,8 +108,8 @@
             k *= 17
             return hint(k, variable=True)
         def ll_function(n):
+            hint(None, global_merge_point=True)
             return ll_two(n + 1) - 1
-        ll_function._global_merge_points_ = True
 
         res = self.timeshift(ll_function, [10], [], policy=P_NOVIRTUAL)
         assert res == 186
@@ -116,11 +117,11 @@
 
     def test_two_promotions(self):
         def ll_function(n, m):
+            hint(None, global_merge_point=True)
             n1 = hint(n, promote=True)
             m1 = hint(m, promote=True)
             s1 = n1 + m1
             return hint(s1, variable=True)
-        ll_function._global_merge_points_ = True
 
         res = self.timeshift(ll_function, [40, 2], [], policy=P_NOVIRTUAL)
         assert res == 42
@@ -138,8 +139,8 @@
             k *= 17
             return hint(k, variable=True)
         def ll_function(n):
+            hint(None, global_merge_point=True)
             return ll_two(n)
-        ll_function._global_merge_points_ = True
 
         res = self.timeshift(ll_function, [3], [], policy=P_NOVIRTUAL)
         assert res == 340
@@ -150,12 +151,12 @@
         def ll_two(k):
             return (k+1)*2
         def ll_function(n):
+            hint(None, global_merge_point=True)
             s = lltype.malloc(S)
             s.x = n
             k = hint(n, promote=True)
             k = ll_two(k)
             return hint(k, variable=True) + s.x
-        ll_function._global_merge_points_ = True
 
         # easy case: no promotion needed
         res = self.timeshift(ll_function, [20], [0], policy=P_NOVIRTUAL)
@@ -189,6 +190,7 @@
             s.y = 0
             i = 0
             while i < n:
+                hint(None, global_merge_point=True)
                 k = ll_two(s, i, m)
                 if m & 1:
                     k *= 3
@@ -198,7 +200,6 @@
                 j = hint(j, variable=True)
                 i += j
             return s.x + s.y * 17
-        ll_function._global_merge_points_ = True
 
         res = self.timeshift(ll_function, [100, 2], [], policy=P_NOVIRTUAL)
         assert res == ll_function(100, 2)
@@ -266,10 +267,11 @@
                 return Str('123')
 
         def ll_function(n):
+            hint(None, global_merge_point=True)
             o = ll_make(n)
             hint(o.__class__, promote=True)
             return o.double().get()
-        ll_function._global_merge_points_ = True
+        ll_function._dont_cache_ = True
 
         res = self.timeshift(ll_function, [5], [], policy=P_NOVIRTUAL)
         assert res == 10
@@ -279,18 +281,3 @@
         assert res == ord('2')
         self.check_insns(indirect_call=0)
 
-    def test_explicit_global_merge(self):
-        def ll_two(k):
-            return k*k
-        def ll_function(n, total):
-            while n > 0:
-                hint(None, global_merge_point=True)
-                k = hint(n, promote=True)
-                k = ll_two(k)
-                total += hint(k, variable=True)
-                n -= 1
-            return total
-
-        res = self.timeshift(ll_function, [10, 0], [], policy=P_NOVIRTUAL)
-        assert res == ll_function(10, 0)
-        self.check_insns(int_add=10, int_mul=0)

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	Mon Oct 30 18:24:12 2006
@@ -222,7 +222,7 @@
             from pypy.translator.tool.graphpage import FlowGraphPage
             FlowGraphPage(t, ha.translator.graphs).display()
 
-        if getattr(ll_function, '_global_merge_points_', False):
+        if getattr(ll_function, '_dont_cache_', False):
             # XXX TEMPORARY: for now, caching doesn't work in the presence
             # of global caches
             pass

Modified: pypy/dist/pypy/jit/timeshifter/transform.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/transform.py	(original)
+++ pypy/dist/pypy/jit/timeshifter/transform.py	Mon Oct 30 18:24:12 2006
@@ -61,6 +61,7 @@
 
     def compute_merge_points(self):
         entrymap = mkentrymap(self.graph)
+        startblock = self.graph.startblock
         global_merge_blocks = {}
         for block in self.graph.iterblocks():
             if not block.operations:
@@ -71,7 +72,7 @@
             if (op.opname == 'hint' and
                 op.args[1].value == {'global_merge_point': True}):
                 hashint = True
-                if len(entrymap[block]) > 1:
+                if block is startblock or len(entrymap[block]) > 1:
                     global_merge_blocks[block] = True
                     cand += 1
                 else:
@@ -90,18 +91,14 @@
             assert not hashint or cand==1, (
                 "ambigous global merge point hint: %r" % block)
                 
-        if self.graph_global_mps(self.graph):
-            kind = 'global'
-        else:
-            kind = 'local'
         for block, links in entrymap.items():
             if len(links) > 1 and block is not self.graph.returnblock:
                 if block in global_merge_blocks:
                     self.mergepoint_set[block] = 'global'
                 else:
-                    self.mergepoint_set[block] = kind
-        if kind == 'global':
-            self.mergepoint_set[self.graph.startblock] = 'global'
+                    self.mergepoint_set[block] = 'local'
+        if startblock in global_merge_blocks:
+            self.mergepoint_set[startblock] = 'global'
 
     def graph_calling_color(self, tsgraph):
         args_hs, hs_res = self.hannotator.bookkeeper.tsgraphsigs[tsgraph]
@@ -112,12 +109,6 @@
         else:
             return 'red'
 
-    def graph_global_mps(self, tsgraph):
-        try:
-            return tsgraph.func._global_merge_points_
-        except AttributeError:
-            return False
-
     def timeshifted_graph_of(self, graph, args_v):
         bk = self.hannotator.bookkeeper
         args_hs = [self.hannotator.binding(v) for v in args_v]
@@ -472,11 +463,13 @@
         # alive local variables into the current JITState
         self.genop(block, 'save_locals', save_locals_vars)
         targets = dict(self.graphs_from(op))
-        for tsgraph in targets.values():
-            if self.graph_global_mps(tsgraph):
-                # make sure jitstate.resumepoint is set to zero
-                self.genop(block, 'resetresumepoint', [])
-                break
+        #for tsgraph in targets.values():
+        #    if self.graph_global_mps(tsgraph):
+        #        # make sure jitstate.resumepoint is set to zero
+        #        self.genop(block, 'resetresumepoint', [])
+        #        break
+        #  XXX do the right thing for call to portals
+        #
         args_v = op.args[1:]
         if op.opname == 'indirect_call':
             del args_v[-1]



More information about the Pypy-commit mailing list