[pypy-svn] r64508 - in pypy/branch/pyjitpl5-simplify/pypy/jit: backend/llgraph metainterp metainterp/test

antocuni at codespeak.net antocuni at codespeak.net
Tue Apr 21 14:26:37 CEST 2009


Author: antocuni
Date: Tue Apr 21 14:26:36 2009
New Revision: 64508

Modified:
   pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/llimpl.py
   pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/runner.py
   pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/codewriter.py
   pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/history.py
   pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/pyjitpl.py
   pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/resoperation.py
   pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_send.py
Log:
(arigo, antocuni): implement _pure, _canraise, _noraise variants of oosend to
builtin types



Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/llimpl.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/llimpl.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/llimpl.py	Tue Apr 21 14:26:36 2009
@@ -108,6 +108,7 @@
     'arraylen_gc'     : (('ptr',), 'int'),
     'call'            : (('ptr', 'varargs'), 'intorptr'),
     'call_pure'       : (('ptr', 'varargs'), 'intorptr'),
+    'oosend'          : (('varargs',), 'intorptr'),
     'guard_true'      : (('bool',), None),
     'guard_false'     : (('bool',), None),
     'guard_value'     : (('int', 'int'), None),
@@ -654,6 +655,15 @@
 
     op_call_pure = op_call
 
+    def op_oosend(self, descr, obj, *args):
+        METH = descr.METH
+        obj = ootype.cast_from_object(METH.SELFTYPE, obj)
+        meth = getattr(obj, descr.methname)
+        res = call_maybe_on_top_of_llinterp(meth, args)
+        if isinstance(METH.RESULT, ootype.OOType):
+            return ootype.cast_to_object(res)
+        return res
+
     def op_new_array(self, arraydescr, count):
         return do_new_array(arraydescr.ofs, count)
 

Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/runner.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/runner.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/runner.py	Tue Apr 21 14:26:36 2009
@@ -511,6 +511,8 @@
 class MethDescr(OODescr):
 
     def __init__(self, METH, methname):
+        self.METH = METH
+        self.methname = methname
         SELFTYPE = METH.SELFTYPE
         RESULT = METH.RESULT
         getargs = make_getargs(METH.ARGS)

Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/codewriter.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/codewriter.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/codewriter.py	Tue Apr 21 14:26:36 2009
@@ -997,9 +997,15 @@
         SELFTYPE, methname, args_v = support.decompose_oosend(op)
         assert SELFTYPE.oopspec_name is not None
         _, meth = SELFTYPE._lookup(methname)
+        if getattr(meth, '_pure_meth', False):
+            kind = '_pure'
+        elif getattr(meth, '_can_raise', True):
+            kind = '_canraise'
+        else:
+            kind = '_noraise'
         METH = ootype.typeOf(meth)
         methdescr = self.cpu.methdescrof(METH, methname)
-        self.emit('oosend_pure')
+        self.emit('residual_oosend' + kind)
         self.emit(self.get_position(methdescr))
         self.emit_varargs(op.args[1:])
         self.register_var(op.result)

Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/history.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/history.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/history.py	Tue Apr 21 14:26:36 2009
@@ -53,6 +53,8 @@
 
 def repr_object(box):
     try:
+        if box.value.obj._TYPE is ootype.String:
+            return '(%r)' % box.value.obj._str
         return repr(box.value.obj._TYPE)
     except AttributeError:
         return box.value

Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/pyjitpl.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/pyjitpl.py	Tue Apr 21 14:26:36 2009
@@ -564,7 +564,15 @@
         self.execute(rop.NEWUNICODE, [length])
 
     @arguments("descr", "varargs")
-    def opimpl_oosend_pure(self, methdescr, boxes):
+    def opimpl_residual_oosend_canraise(self, methdescr, varargs):
+        return self.execute_with_exc(rop.OOSEND, varargs, descr=methdescr)
+
+    @arguments("descr", "varargs")
+    def opimpl_residual_oosend_noraise(self, methdescr, varargs):
+        self.execute(rop.OOSEND, varargs, descr=methdescr)
+
+    @arguments("descr", "varargs")
+    def opimpl_residual_oosend_pure(self, methdescr, boxes):
         self.execute(rop.OOSEND_PURE, boxes, descr=methdescr)
 
     @arguments("box", "box")

Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/resoperation.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/resoperation.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/resoperation.py	Tue Apr 21 14:26:36 2009
@@ -184,8 +184,9 @@
 
     _CANRAISE_FIRST = 150 # ----- start of can_raise operations -----
     CALL = 150
+    OOSEND = 151
     #
-    _OVF_FIRST = 151
+    _OVF_FIRST = 152
     INT_ADD_OVF            = 152
     INT_SUB_OVF            = 153
     INT_MUL_OVF            = 154

Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_send.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_send.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_send.py	Tue Apr 21 14:26:36 2009
@@ -44,7 +44,7 @@
         res = self.meta_interp(f, [1], policy=StopAtXPolicy(externfn))
         assert res == 2
         if self.type_system == 'ootype':
-            self.check_loops(call=1, builtin=1) # 'len' remains
+            self.check_loops(call=1, oosend=1) # 'len' remains
         else:
             # 'len' becomes a getfield('num_items') for now in lltype,
             # which is itself encoded as a 'getfield_gc'
@@ -459,7 +459,6 @@
     def skip(self):
         py.test.skip('in-progress')
 
-    test_red_builtin_send = skip
     test_send_to_single_target_method = skip
     test_red_send_to_green_receiver = skip
     test_oosend_base = skip



More information about the Pypy-commit mailing list