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

pedronis at codespeak.net pedronis at codespeak.net
Wed Feb 1 20:07:13 CET 2006


Author: pedronis
Date: Wed Feb  1 20:07:12 2006
New Revision: 22928

Modified:
   pypy/dist/pypy/jit/hintmodel.py
   pypy/dist/pypy/jit/test/test_hint_annotation.py
Log:
fixing across function calls arguments with simple test



Modified: pypy/dist/pypy/jit/hintmodel.py
==============================================================================
--- pypy/dist/pypy/jit/hintmodel.py	(original)
+++ pypy/dist/pypy/jit/hintmodel.py	Wed Feb  1 20:07:12 2006
@@ -193,6 +193,15 @@
                                     
         input_args_hs = list(args_hs)
         graph = desc.specialize(input_args_hs, key=key, alt_name=alt_name)
+
+        # propagate fixing of arguments in the function to the caller
+        for inp_arg_hs, arg_hs in zip(input_args_hs, args_hs):
+            if isinstance(arg_hs, SomeLLAbstractConstant):
+                assert len(inp_arg_hs.origins) == 1
+                [o] = inp_arg_hs.origins.keys()
+                if o.read_fixed():
+                    for o in arg_hs.origins:
+                        o.set_fixed()
         
         hs_res = bookkeeper.annotator.recursivecall(graph,
                                                     bookkeeper.position_key,

Modified: pypy/dist/pypy/jit/test/test_hint_annotation.py
==============================================================================
--- pypy/dist/pypy/jit/test/test_hint_annotation.py	(original)
+++ pypy/dist/pypy/jit/test/test_hint_annotation.py	Wed Feb  1 20:07:12 2006
@@ -26,7 +26,7 @@
                                                                 {OriginFlags(): True})
                                          for v in graph1.getargs()])
     t = hannotator.translator
-    t.view()
+    #t.view()
     if annotator:
         return hs, hannotator
     else:
@@ -73,12 +73,17 @@
             z = x-y
         z1 = hint(z, concrete=True)
         return z # origin of z1
-    hs = hannotate(ll_function, [bool, int, int])
+    hs, ha = hannotate(ll_function, [bool, int, int], annotator=True)
     assert isinstance(hs, SomeLLAbstractConstant)
     assert len(hs.origins) == 4
     assert hs.is_fixed()
     assert hs.concretetype == lltype.Signed
- 
+    ll_function_graph = graphof(ha.base_translator, ll_function)
+    gdesc = ha.bookkeeper.getdesc(ll_function_graph)
+    _, x_v, y_v = gdesc._cache[None].getargs()
+    assert ha.binding(x_v).is_fixed()
+    assert ha.binding(y_v).is_fixed()
+    
 def test_simple_variable():
     def ll_function(x,y):
         x = hint(x, variable=True) # special hint only for testing purposes!!!
@@ -325,7 +330,27 @@
     assert isinstance(ha.binding(v1), SomeLLConcreteValue)
     assert isinstance(ha.binding(v2), SomeLLAbstractConstant)
     assert not ha.binding(v2).is_fixed()
- 
+
+def test_propagate_fixing_across_func_arguments():
+    def ll_func2(z):
+        z = hint(z, concrete=True)
+        return z + 1
+    def ll_function(cond, x,y):
+        if cond:
+            z = x+y
+        else:
+            z = x-y
+        z = ll_func2(z)
+        return z
+    hs, ha = hannotate(ll_function, [bool, int, int], annotator=True)
+    assert isinstance(hs, SomeLLConcreteValue)
+    assert hs.concretetype == lltype.Signed
+    ll_function_graph = graphof(ha.base_translator, ll_function)
+    gdesc = ha.bookkeeper.getdesc(ll_function_graph)
+    _, x_v, y_v = gdesc._cache[None].getargs()
+    assert ha.binding(x_v).is_fixed()
+    assert ha.binding(y_v).is_fixed()
+    
 def test_hannotate_tl():
     from pypy.jit import tl
     hannotate(tl.interp, [str, int], policy=P_OOPSPEC)



More information about the Pypy-commit mailing list