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

arigo at codespeak.net arigo at codespeak.net
Sun Jan 29 19:36:00 CET 2006


Author: arigo
Date: Sun Jan 29 19:35:58 2006
New Revision: 22857

Modified:
   pypy/dist/pypy/jit/hintbookkeeper.py
   pypy/dist/pypy/jit/hintmodel.py
   pypy/dist/pypy/jit/test/test_hint_annotation.py
Log:
(pedronis, arre, arigo)

Make two versions of each called graph: one normal, and one identical but used
for the case where the result is then fixed in the caller.



Modified: pypy/dist/pypy/jit/hintbookkeeper.py
==============================================================================
--- pypy/dist/pypy/jit/hintbookkeeper.py	(original)
+++ pypy/dist/pypy/jit/hintbookkeeper.py	Sun Jan 29 19:35:58 2006
@@ -11,10 +11,10 @@
         self.origgraph = origgraph
         self._cache = {}
 
-    def specialize(self, input_args_hs):
+    def specialize(self, input_args_hs, key=None, alt_name=None):
         from pypy.jit import hintmodel
         # get the specialized graph -- for now, no specialization
-        graph = self.cachedgraph(None)
+        graph = self.cachedgraph(key, alt_name)
 
         # modify input_args_hs in-place to change their origin
         for i in range(len(input_args_hs)):

Modified: pypy/dist/pypy/jit/hintmodel.py
==============================================================================
--- pypy/dist/pypy/jit/hintmodel.py	(original)
+++ pypy/dist/pypy/jit/hintmodel.py	Sun Jan 29 19:35:58 2006
@@ -23,6 +23,7 @@
 class OriginFlags(object):
 
     fixed = False
+    read_positions = None
 
     def __repr__(self):
         if self.fixed:
@@ -31,6 +32,20 @@
             s = ""
         return "<%sorigin>" % (s,)
 
+    def read_fixed(self):
+        if self.read_positions is None:
+            self.read_positions = {}
+        self.read_positions[getbookkeeper().position_key] = True
+        return self.fixed
+
+    def set_fixed(self):
+        if not self.fixed:
+            self.fixed = True
+            if self.read_positions:
+                annotator = getbookkeeper().annotator
+                for p in self.read_positions:
+                    annotator.reflowfromposition(p)
+
 class SomeLLAbstractValue(annmodel.SomeObject):
 
     def __init__(self, T):
@@ -125,7 +140,7 @@
             return SomeLLAbstractVariable(hs_c1.concretetype)
         assert hs_flags.const['concrete']
         for o in hs_c1.origins:
-            o.fixed = True
+            o.set_fixed()
         return SomeLLConcreteValue(hs_c1.concretetype)
 
     def getfield(hs_c1, hs_fieldname):
@@ -165,8 +180,13 @@
         if not hasattr(fnobj, 'graph'):
             raise NotImplementedError("XXX call to externals or primitives")
         desc = bookkeeper.getdesc(fnobj.graph)
+        key = None
+        alt_name = None
+        if bookkeeper.myorigin().read_fixed():
+            key = 'fixed'
+            alt_name = fnobj.graph.name + '_HFixed'
         input_args_hs = list(args_hs)
-        graph = desc.specialize(input_args_hs)
+        graph = desc.specialize(input_args_hs, key=key, alt_name=alt_name)
         hs_res = bookkeeper.annotator.recursivecall(graph,
                                                     bookkeeper.position_key,
                                                     input_args_hs)
@@ -179,6 +199,8 @@
                     [o] = hs_inputarg.origins.keys()
                     if o in hs_res.origins:
                         deps_hs.append(hs_arg)
+            if key == 'fixed':
+                deps_hs.append(hs_res)
             hs_res = reorigin(hs_res, *deps_hs)
         return hs_res
 

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	Sun Jan 29 19:35:58 2006
@@ -285,7 +285,7 @@
     hs_n = ha.binding(g1.getargs()[0])
     assert hs_n.origins.keys()[0].fixed
 
-def INPROG_test_simple_fixed_call():
+def test_simple_fixed_call():
     def ll_help(cond, x, y):
         if cond:
             z = x+y



More information about the Pypy-commit mailing list