[pypy-svn] r40731 - in pypy/dist/pypy: interpreter jit/goal jit/hintannotator module/pypyjit

arigo at codespeak.net arigo at codespeak.net
Sun Mar 18 22:29:30 CET 2007


Author: arigo
Date: Sun Mar 18 22:29:27 2007
New Revision: 40731

Modified:
   pypy/dist/pypy/interpreter/pyframe.py
   pypy/dist/pypy/interpreter/pyopcode.py
   pypy/dist/pypy/jit/goal/jitstep.py
   pypy/dist/pypy/jit/hintannotator/model.py
   pypy/dist/pypy/module/pypyjit/interp_jit.py
Log:
(pedronis, arigo)

Use the 'access_directly' hint in PyPy:
    
    - in PyFrame.__init__(), when initializing all the fields;

    - in PyFrame.dispatch(), the version which is *not* timeshifted.
      For this one the flag propagates through most of the code of
      pyopcode.py.

The goal is that if a frame is run by the non-jitting copy of the
main loop, we know that it is not a virtualized frame, so we can
save all the checks and access the fields directly.



Modified: pypy/dist/pypy/interpreter/pyframe.py
==============================================================================
--- pypy/dist/pypy/interpreter/pyframe.py	(original)
+++ pypy/dist/pypy/interpreter/pyframe.py	Sun Mar 18 22:29:27 2007
@@ -46,6 +46,7 @@
     instr_prev               = -1
 
     def __init__(self, space, code, w_globals, closure):
+        self = hint(self, access_directly=True)
         assert isinstance(code, pycode.PyCode)
         self.pycode = code
         eval.Frame.__init__(self, space, w_globals, code.co_nlocals)
@@ -320,8 +321,8 @@
         return self.pycode.hidden_applevel
 
     def getcode(self):
-        return self.pycode
-        
+        return hint(hint(self.pycode, promote=True), deepfreeze=True)
+
     def getfastscope(self):
         "Get the fast locals as a list."
         return self.fastlocals_w

Modified: pypy/dist/pypy/interpreter/pyopcode.py
==============================================================================
--- pypy/dist/pypy/interpreter/pyopcode.py	(original)
+++ pypy/dist/pypy/interpreter/pyopcode.py	Sun Mar 18 22:29:27 2007
@@ -234,9 +234,6 @@
 
     ### accessor functions ###
 
-    def getcode(self):
-        return hint(hint(self.pycode, promote=True), deepfreeze=True)
-
     def getlocalvarname(self, index):
         return self.getcode().co_varnames[index]
 

Modified: pypy/dist/pypy/jit/goal/jitstep.py
==============================================================================
--- pypy/dist/pypy/jit/goal/jitstep.py	(original)
+++ pypy/dist/pypy/jit/goal/jitstep.py	Sun Mar 18 22:29:27 2007
@@ -3,6 +3,7 @@
 
 from pypy.objspace.flow.model import checkgraph
 from pypy.translator.translator import graphof
+from pypy.annotation.specialize import getuniquenondirectgraph
 from pypy.jit.hintannotator.annotator import HintAnnotator, HintAnnotatorPolicy
 from pypy.jit.hintannotator.model import OriginFlags, SomeLLAbstractConstant
 
@@ -26,6 +27,12 @@
         mod = func.__module__ or '?'
         if mod.startswith('pypy.objspace'):
             return False
+        if mod.startswith('pypy._cache'):
+            return False
+        if mod.startswith('pypy.interpreter.astcompiler'):
+            return False
+        if mod.startswith('pypy.interpreter.pyparser'):
+            return False
         if mod.startswith('pypy.module.'):
             if not mod.startswith('pypy.module.pypyjit.'):
                 return False
@@ -87,19 +94,25 @@
         targetgraphs.keys(),))
 
 
-def timeshift_graphs(t, portal_graph):
+def timeshift_graphs(t, portal_graph, log):
     result_graphs = {}
 
+    bk = t.annotator.bookkeeper
+
     def _graph(func):
         func = getattr(func, 'im_func', func)
-        return graphof(t, func)
+        desc = bk.getdesc(func)
+        return getuniquenondirectgraph(desc)
 
     def seefunc(fromfunc, *tofuncs):
         targetgraphs = {}
         for tofunc in tofuncs:
             targetgraphs[_graph(tofunc)] = True
         graphs = graphs_on_the_path_to(t, _graph(fromfunc), targetgraphs)
-        result_graphs.update(graphs)
+        for graph in graphs:
+            if graph not in result_graphs:
+                log('including graph %s' % (graph,))
+            result_graphs[graph] = True
 
     def seepath(*path):
         for i in range(1, len(path)):
@@ -173,14 +186,15 @@
     t = drv.translator
     portal_graph = graphof(t, PORTAL)
 
-    POLICY = PyPyHintAnnotatorPolicy(timeshift_graphs(t, portal_graph))
+    POLICY = PyPyHintAnnotatorPolicy(timeshift_graphs(t, portal_graph,
+                                                      drv.log))
 
-    graphnames = [str(_g) for _g in POLICY.timeshift_graphs]
-    graphnames.sort()
-    print '-' * 20
-    for graphname in graphnames:
-        print graphname
-    print '-' * 20
+##    graphnames = [str(_g) for _g in POLICY.timeshift_graphs]
+##    graphnames.sort()
+##    print '-' * 20
+##    for graphname in graphnames:
+##        print graphname
+##    print '-' * 20
 
     hannotator = HintAnnotator(base_translator=t, policy=POLICY)
     hs = hannotator.build_types(portal_graph,

Modified: pypy/dist/pypy/jit/hintannotator/model.py
==============================================================================
--- pypy/dist/pypy/jit/hintannotator/model.py	(original)
+++ pypy/dist/pypy/jit/hintannotator/model.py	Sun Mar 18 22:29:27 2007
@@ -322,7 +322,8 @@
             hs_clone = hs_v1.clone()
             hs_clone.deepfrozen = True
             return hs_clone
-        for name in ["reverse_split_queue", "global_merge_point"]:
+        for name in ["reverse_split_queue", "global_merge_point",
+                     "access_directly"]:
             if hs_flags.const.get(name, False):
                 return
 

Modified: pypy/dist/pypy/module/pypyjit/interp_jit.py
==============================================================================
--- pypy/dist/pypy/module/pypyjit/interp_jit.py	(original)
+++ pypy/dist/pypy/module/pypyjit/interp_jit.py	Sun Mar 18 22:29:27 2007
@@ -29,6 +29,7 @@
         if pycode.jit_enable:
             return self.dispatch_jit(pycode, next_instr, ec)
         else:
+            self = hint(self, access_directly=True)
             return super_dispatch(self, pycode, next_instr, ec)
             
     def dispatch_jit(self, pycode, next_instr, ec):



More information about the Pypy-commit mailing list