[pypy-svn] r62121 - in pypy/branch/pyjitpl5/pypy/jit: backend/llgraph metainterp

arigo at codespeak.net arigo at codespeak.net
Tue Feb 24 18:05:57 CET 2009


Author: arigo
Date: Tue Feb 24 18:05:56 2009
New Revision: 62121

Removed:
   pypy/branch/pyjitpl5/pypy/jit/metainterp/rpyjitpl.py
Modified:
   pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py
   pypy/branch/pyjitpl5/pypy/jit/metainterp/history.py
   pypy/branch/pyjitpl5/pypy/jit/metainterp/optimize.py
   pypy/branch/pyjitpl5/pypy/jit/metainterp/support.py
   pypy/branch/pyjitpl5/pypy/jit/metainterp/warmspot.py
Log:
The first translation test passes.


Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py	Tue Feb 24 18:05:56 2009
@@ -139,7 +139,6 @@
             return history.BoxPtr(llimpl.frame_ptr_getresult(frame))
         else:
             return None
-    execute_operation._annspecialcase_ = 'specialize:arg(3)'
 
     def get_compiled_single_op(self, opname, valueboxes, result_type):
         keylist = self.compiled_single_ops.setdefault((opname, result_type),

Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/history.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/history.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/history.py	Tue Feb 24 18:05:56 2009
@@ -441,9 +441,16 @@
     execute_and_record._annspecialcase_ = 'specialize:arg(3, 4)'
 
     def record(self, opname, argboxes, resboxes, opcls=ResOperation):
+        # xxx the indirection from record to _record is to work
+        # around a limitation of the annotator (normalizecalls.py)
+        return self._record(opname, argboxes, resboxes, opcls)
+    record._annspecialcase_ = 'specialize:arg(4)'
+
+    def _record(self, opname, argboxes, resboxes, opcls):
         op = opcls(opname, argboxes, resboxes)
         self.operations.append(op)
         return op
+    _record._annspecialcase_ = 'specialize:arg(4)'
 
     def generate_anything_since(self, old_index):
         return len(self.operations) > old_index
@@ -452,8 +459,9 @@
     pass
 
 class BlackHole(RunningMatcher):
-    def record(self, step, argboxes, resboxes, opcls=ResOperation):
+    def _record(self, step, argboxes, resboxes, opcls):
         return None
+    _record._annspecialcase_ = 'specialize:arg(4)'
 
     def generate_anything_since(self, old_index):
         return True

Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/optimize.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/optimize.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/optimize.py	Tue Feb 24 18:05:56 2009
@@ -297,9 +297,13 @@
         for box in self.loop.operations[0].args:
             self.nodes[box] = InstanceNode(box, escaped=False, startbox=True,
                                            const=isinstance(box, Const))
-        for op in self.loop.operations[1:-1]:
+        for op in self.loop.operations:
             opname = op.opname
-            if opname == 'new_with_vtable':
+            if (opname == 'merge_point' or
+                opname == 'catch' or
+                opname == 'jump'):
+                continue
+            elif opname == 'new_with_vtable':
                 box = op.results[0]
                 instnode = InstanceNode(box, escaped=False)
                 instnode.cls = InstanceNode(op.args[1], const=True)

Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/support.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/support.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/support.py	Tue Feb 24 18:05:56 2009
@@ -3,6 +3,7 @@
 from pypy.rpython import rlist
 from pypy.rpython.lltypesystem import rdict, rstr
 from pypy.rpython.llinterp import LLInterpreter
+from pypy.rpython.extregistry import ExtRegistryEntry
 from pypy.translator.simplify import get_funcobj
 from pypy.translator.unsimplify import split_block
 from pypy.objspace.flow.model import Constant
@@ -80,6 +81,14 @@
             return fnptr._callable(*args)
     return on_top_of_llinterp
 
+class Entry(ExtRegistryEntry):
+    _about_ = maybe_on_top_of_llinterp
+    def compute_result_annotation(self, s_rtyper, s_fnptr):
+        return s_fnptr
+    def specialize_call(self, hop):
+        hop.exception_cannot_occur()
+        return hop.inputarg(hop.args_r[1], arg=1)
+
 # ____________________________________________________________
 #
 # Manually map oopspec'ed operations back to their ll implementation

Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/warmspot.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/warmspot.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/warmspot.py	Tue Feb 24 18:05:56 2009
@@ -29,17 +29,10 @@
     warmrunnerdesc.state.set_param_trace_eagerness(2)    # for tests
     return interp.eval_graph(graph, args)
 
-def rpython_ll_meta_interp(function, args, loops=None, **kwds):
-    kwds['translate_support_code'] = True
-    interp, graph = get_interpreter(function, args, backendopt=True,
-                                    inline_threshold=0)
-    clear_tcache()
-    translator = interp.typer.annotator.translator
-    warmrunnerdesc = WarmRunnerDesc(translator, **kwds)
-    warmrunnerdesc.state.set_param_threshold(3)          # for tests
-    warmrunnerdesc.state.set_param_trace_eagerness(2)    # for tests
-    xxx
-    interp.eval_graph(boot, args)
+def rpython_ll_meta_interp(function, args, loops='not used right now', **kwds):
+    return ll_meta_interp(function, args,
+                          translate_support_code=True, backendopt=True,
+                          **kwds)
 
 def find_can_enter_jit(graphs):
     results = []
@@ -93,6 +86,8 @@
         self.rewrite_jit_merge_point()
         self.metainterp.num_green_args = self.num_green_args
         self.metainterp.state = self.state
+        if self.cpu.translate_support_code:
+            self.annhelper.finish()
 
     def _freeze_(self):
         return True
@@ -250,42 +245,45 @@
         self.metainterp.ExitFrameWithException = ExitFrameWithException
         self.metainterp.ContinueRunningNormally = ContinueRunningNormally
         rtyper = self.translator.rtyper
+        portalfunc_ARGS = unrolling_iterable(list(enumerate(PORTALFUNC.ARGS)))
+        RESULT = PORTALFUNC.RESULT
 
-        if not self.cpu.translate_support_code:
-            def ll_portal_runner(*args):
-                while 1:
-                    try:
-                        return support.maybe_on_top_of_llinterp(rtyper,
-                                                          portal_ptr)(*args)
-                    except ContinueRunningNormally, e:
-                        args = []
-                        for i, arg in enumerate(e.args):
-                            v = arg.value
-                            # HACK for x86 backend always returning int
-                            if (isinstance(PORTALFUNC.ARGS[i], lltype.Ptr) and
-                                isinstance(v, int)):
-                                v = self.metainterp.cpu.cast_int_to_gcref(v)
-                            if lltype.typeOf(v) == llmemory.GCREF:
-                                v = lltype.cast_opaque_ptr(PORTALFUNC.ARGS[i],
-                                                           v)
-                            args.append(v)
-                    except DoneWithThisFrame, e:
-                        if e.resultbox is not None:
-                            return e.resultbox.value
-                        return
-                    except ExitFrameWithException, e:
+        def unwrap(TYPE, box):
+            if TYPE is lltype.Void:
+                return None
+            if isinstance(TYPE, lltype.Ptr):
+                return box.getptr(TYPE)
+            else:
+                return box.getint()
+        unwrap._annspecialcase_ = 'specialize:arg(0)'
+
+        def ll_portal_runner(*args):
+            while 1:
+                try:
+                    return support.maybe_on_top_of_llinterp(rtyper,
+                                                      portal_ptr)(*args)
+                except ContinueRunningNormally, e:
+                    args = ()
+                    for i, ARG in portalfunc_ARGS:
+                        v = unwrap(ARG, e.args[i])
+                        # HACK for x86 backend always returning int
+                        #if isinstance(ARG, lltype.Ptr) and type(v) is int:
+                        #    v = self.metainterp.cpu.cast_int_to_gcref(v)
+                        #if lltype.typeOf(v) == llmemory.GCREF:
+                        #    v = lltype.cast_opaque_ptr(ARG, v)
+                        args = args + (v,)
+                except DoneWithThisFrame, e:
+                    return unwrap(RESULT, e.resultbox)
+                except ExitFrameWithException, e:
+                    value = e.valuebox.getptr(lltype.Ptr(rclass.OBJECT))
+                    if we_are_translated():
+                        # re-raise the exception as it is
+                        raise Exception, value
+                    else:
                         type = e.typebox.getaddr(self.metainterp.cpu)
                         type = llmemory.cast_adr_to_ptr(type, rclass.CLASSTYPE)
-                        value = e.valuebox.getptr(lltype.Ptr(rclass.OBJECT))
                         raise LLException(type, value)
 
-        else:
-            def ll_portal_runner(*args):
-                while 1:
-                    #try:
-                    portal_ptr(*args)
-                    #xexcept DoneWi
-
         portal_runner_ptr = self.helper_func(lltype.Ptr(PORTALFUNC),
                                              ll_portal_runner)
 
@@ -308,8 +306,6 @@
         origblock.exitswitch = None
         origblock.recloseblock(Link([v_result], origportalgraph.returnblock))
         checkgraph(origportalgraph)
-        if self.cpu.translate_support_code:
-            self.annhelper.finish()
 
 
 def decode_hp_hint_args(op):



More information about the Pypy-commit mailing list