[pypy-svn] r32531 - in pypy/branch/timeshift-refactoring/pypy/jit: hintannotator timeshifter timeshifter/test

arigo at codespeak.net arigo at codespeak.net
Wed Sep 20 17:18:25 CEST 2006


Author: arigo
Date: Wed Sep 20 17:18:22 2006
New Revision: 32531

Modified:
   pypy/branch/timeshift-refactoring/pypy/jit/hintannotator/model.py
   pypy/branch/timeshift-refactoring/pypy/jit/timeshifter/oop.py
   pypy/branch/timeshift-refactoring/pypy/jit/timeshifter/rtyper.py
   pypy/branch/timeshift-refactoring/pypy/jit/timeshifter/test/test_timeshift.py
   pypy/branch/timeshift-refactoring/pypy/jit/timeshifter/transform.py
   pypy/branch/timeshift-refactoring/pypy/jit/timeshifter/vlist.py
Log:
(arre, arigo)

'oopspec' and 'green' calls.


Modified: pypy/branch/timeshift-refactoring/pypy/jit/hintannotator/model.py
==============================================================================
--- pypy/branch/timeshift-refactoring/pypy/jit/hintannotator/model.py	(original)
+++ pypy/branch/timeshift-refactoring/pypy/jit/hintannotator/model.py	Wed Sep 20 17:18:22 2006
@@ -96,6 +96,8 @@
 ##            import pdb; pdb.set_trace()
         args_hs = [self.annotator.binding(v) for v in spaceop.args]
         hs_result = self.annotator.binding(spaceop.result)
+        if not isinstance(hs_result, SomeLLAbstractConstant):
+            return False     # was generalized, e.g. to SomeLLAbstractVariable
         hs_f1 = args_hs.pop(0)
         fnobj = hs_f1.const._obj
         if (getattr(self.annotator.policy, 'oopspec', False) and

Modified: pypy/branch/timeshift-refactoring/pypy/jit/timeshifter/oop.py
==============================================================================
--- pypy/branch/timeshift-refactoring/pypy/jit/timeshifter/oop.py	(original)
+++ pypy/branch/timeshift-refactoring/pypy/jit/timeshifter/oop.py	Wed Sep 20 17:18:22 2006
@@ -2,6 +2,7 @@
 from pypy.rpython.extregistry import ExtRegistryEntry
 from pypy.jit.timeshifter.rcontainer import cachedtype
 from pypy.jit.timeshifter import rvalue, rtimeshift
+from pypy.translator.c import exceptiontransform
 
 
 class Index:
@@ -13,7 +14,6 @@
     __metaclass__ = cachedtype
 
     def __init__(self, hrtyper, fnobj):
-        ts = hrtyper.timeshifter
         ll_func = fnobj._callable
         FUNCTYPE = lltype.typeOf(fnobj)
         nb_args = len(FUNCTYPE.ARGS)
@@ -45,7 +45,7 @@
         if FUNCTYPE.RESULT is lltype.Void:
             self.errorbox = None
         else:
-            error_value = ts.error_value(FUNCTYPE.RESULT)
+            error_value = exceptiontransform.error_value(FUNCTYPE.RESULT)
             self.errorbox = rvalue.redbox_from_prebuilt_value(RGenOp,
                                                               error_value)
         self.redboxbuilder = rvalue.ll_redboxbuilder(FUNCTYPE.RESULT)
@@ -64,8 +64,9 @@
 
         # exception handling
         graph = fnobj.graph
-        self.can_raise = ts.etrafo.raise_analyzer.analyze_direct_call(graph)
-        self.fetch_global_excdata = ts.fetch_global_excdata
+        etrafo = hrtyper.etrafo
+        self.can_raise = etrafo.raise_analyzer.analyze_direct_call(graph)
+        self.fetch_global_excdata = hrtyper.fetch_global_excdata
 
     def residual_call(self, jitstate, argboxes):
         builder = jitstate.curbuilder

Modified: pypy/branch/timeshift-refactoring/pypy/jit/timeshifter/rtyper.py
==============================================================================
--- pypy/branch/timeshift-refactoring/pypy/jit/timeshifter/rtyper.py	(original)
+++ pypy/branch/timeshift-refactoring/pypy/jit/timeshifter/rtyper.py	Wed Sep 20 17:18:22 2006
@@ -727,7 +727,7 @@
 
     # handling of the various kinds of calls
 
-    def handle_oopspec_call(self, hop):
+    def translate_op_oopspec_call(self, hop):
         # special-cased call, for things like list methods
         from pypy.jit.timeshifter.oop import OopSpecDesc, Index
 
@@ -776,9 +776,7 @@
                                       [v_jitstate,    c_oopspecdesc] + args_v,
                                       s_result)
 
-    def handle_green_call(self, hop):
-        # green-returning call, for now (XXX) we assume it's an
-        # all-green function that we can just call
+    def translate_op_green_call(self, hop):
         for r_arg in hop.args_r:
             assert isinstance(r_arg, GreenRepr)
         v = hop.genop('direct_call', hop.args_v, hop.r_result.lowleveltype)

Modified: pypy/branch/timeshift-refactoring/pypy/jit/timeshifter/test/test_timeshift.py
==============================================================================
--- pypy/branch/timeshift-refactoring/pypy/jit/timeshifter/test/test_timeshift.py	(original)
+++ pypy/branch/timeshift-refactoring/pypy/jit/timeshifter/test/test_timeshift.py	Wed Sep 20 17:18:22 2006
@@ -887,6 +887,18 @@
         res = self.timeshift(ll_function, [3], [], policy=P_NOVIRTUAL)
         assert res == 3
 
+    def test_green_call(self):
+        def ll_add_one(x):
+            return x+1
+        def ll_function(y):
+            z = ll_add_one(y)
+            z = hint(z, concrete=True)
+            return hint(z, variable=True)
+
+        res = self.timeshift(ll_function, [3], [0], policy=P_NOVIRTUAL)
+        assert res == 4
+        self.check_insns({})
+
     def test_split_on_green_return(self):
         py.test.skip("in-progress")
         def ll_two(x):

Modified: pypy/branch/timeshift-refactoring/pypy/jit/timeshifter/transform.py
==============================================================================
--- pypy/branch/timeshift-refactoring/pypy/jit/timeshifter/transform.py	(original)
+++ pypy/branch/timeshift-refactoring/pypy/jit/timeshifter/transform.py	Wed Sep 20 17:18:22 2006
@@ -347,3 +347,15 @@
         block.renamevariables(mapping)
         block.inputargs = saved
         block.operations[:0] = beforeops + newops
+
+    def handle_oopspec_call(self, block, pos):
+        op = block.operations[pos]
+        assert op.opname == 'direct_call'
+        op.opname = 'oopspec_call'
+
+    def handle_green_call(self, block, pos):
+        # green-returning call, for now (XXX) we assume it's an
+        # all-green function that we can just call
+        op = block.operations[pos]
+        assert op.opname == 'direct_call'
+        op.opname = 'green_call'

Modified: pypy/branch/timeshift-refactoring/pypy/jit/timeshifter/vlist.py
==============================================================================
--- pypy/branch/timeshift-refactoring/pypy/jit/timeshifter/vlist.py	(original)
+++ pypy/branch/timeshift-refactoring/pypy/jit/timeshifter/vlist.py	Wed Sep 20 17:18:22 2006
@@ -8,7 +8,7 @@
 
     def __init__(self, hrtyper, LIST):
         RGenOp = hrtyper.RGenOp
-        rtyper = hrtyper.timeshifter.rtyper
+        rtyper = hrtyper.rtyper
         self.LIST = LIST
         self.LISTPTR = lltype.Ptr(LIST)
         self.ptrkind = RGenOp.kindToken(self.LISTPTR)



More information about the Pypy-commit mailing list