[pypy-svn] r65121 - in pypy/branch/pyjitpl5/pypy/jit/backend/cli: . test

antocuni at codespeak.net antocuni at codespeak.net
Thu May 7 00:23:31 CEST 2009


Author: antocuni
Date: Thu May  7 00:23:28 2009
New Revision: 65121

Modified:
   pypy/branch/pyjitpl5/pypy/jit/backend/cli/method.py
   pypy/branch/pyjitpl5/pypy/jit/backend/cli/runner.py
   pypy/branch/pyjitpl5/pypy/jit/backend/cli/test/test_zrpy_send.py
Log:
implement emit_op_call and emit_op_oosend, and test_red_builtin_oosend passes



Modified: pypy/branch/pyjitpl5/pypy/jit/backend/cli/method.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/cli/method.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/cli/method.py	Thu May  7 00:23:28 2009
@@ -8,6 +8,7 @@
 from pypy.jit.metainterp.history import (AbstractValue, Const, ConstInt,
                                          ConstObj)
 from pypy.jit.metainterp.resoperation import rop, opname
+from pypy.jit.backend.cli import runner
 from pypy.jit.backend.cli.methodfactory import get_method_wrapper
 
 System = CLR.System
@@ -327,14 +328,41 @@
         raise NotImplementedError
 
     def emit_op_call(self, op):
-        raise NotImplementedError
+        calldescr = op.descr
+        assert isinstance(calldescr, runner.StaticMethDescr)
+        delegate_type = dotnet.class2type(calldescr.funcclass)
+        meth_invoke = delegate_type.GetMethod('Invoke')
+        av_sm, args_av = op.args[0], op.args[1:]
+        av_sm.load(self)
+        self.il.Emit(OpCodes.Castclass, delegate_type)
+        for av_arg in args_av:
+            av_arg.load(self)
+        self.il.EmitCall(OpCodes.Callvirt, meth_invoke, None)
+        if calldescr.has_result:
+            self.store_result(op)
 
     emit_op_call_pure = emit_op_call
 
+    def emit_op_oosend(self, op):
+        methdescr = op.descr
+        assert isinstance(methdescr, runner.MethDescr)
+        clitype = dotnet.class2type(methdescr.selfclass)
+        methinfo = clitype.GetMethod(str(methdescr.methname))
+        av_sm, args_av = op.args[0], op.args[1:]
+        av_sm.load(self)
+        self.il.Emit(OpCodes.Castclass, clitype)
+        for av_arg in args_av:
+            av_arg.load(self)
+        self.il.Emit(OpCodes.Callvirt, methinfo)
+        if methdescr.has_result:
+            self.store_result(op)
+
+    emit_op_oosend_pure = emit_op_oosend
+
+
     def not_implemented(self, op):
         raise NotImplementedError
 
-    emit_op_oosend = not_implemented
     emit_op_guard_exception = not_implemented
     emit_op_cast_int_to_ptr = not_implemented
     emit_op_guard_nonvirtualized = not_implemented
@@ -348,7 +376,6 @@
     emit_op_strgetitem = not_implemented
     emit_op_getfield_raw = not_implemented
     emit_op_setfield_gc = not_implemented
-    emit_op_oosend_pure = not_implemented
     emit_op_getarrayitem_gc_pure = not_implemented
     emit_op_arraylen_gc = not_implemented
     emit_op_unicodesetitem = not_implemented

Modified: pypy/branch/pyjitpl5/pypy/jit/backend/cli/runner.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/cli/runner.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/cli/runner.py	Thu May  7 00:23:28 2009
@@ -6,7 +6,6 @@
 from pypy.jit.backend import model
 from pypy.jit.backend.minimal.runner import cached_method
 from pypy.jit.backend.llgraph.runner import TypeDescr, FieldDescr
-from pypy.jit.backend.cli.method import Method
 from pypy.translator.cli import dotnet
 from pypy.translator.cli.dotnet import CLR
 
@@ -51,6 +50,7 @@
     # ----------------------
 
     def compile_operations(self, loop):
+        from pypy.jit.backend.cli.method import Method
         meth = Method(self, loop.name, loop)
         loop._cli_meth = meth
 
@@ -147,6 +147,7 @@
                 return boxresult(RESULT, res)
         self.callfunc = callfunc
         self.funcclass = dotnet.classof(FUNC)
+        self.has_result = (FUNC.RESULT != ootype.Void)
 
 
 class MethDescr(AbstractMethDescr):
@@ -166,7 +167,10 @@
             if METH.RESULT is not ootype.Void:
                 return boxresult(METH.RESULT, res)
         self.callmeth = callmeth
+        self.selfclass = ootype.runtimeClass(SELFTYPE)
+        self.methname = methname
 
+        self.has_result = (METH.RESULT != ootype.Void)
 
 CPU = CliCPU
 

Modified: pypy/branch/pyjitpl5/pypy/jit/backend/cli/test/test_zrpy_send.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/cli/test/test_zrpy_send.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/cli/test/test_zrpy_send.py	Thu May  7 00:23:28 2009
@@ -10,7 +10,6 @@
     def skip(self):
         py.test.skip('in-progress')
 
-    test_red_builtin_send = skip
     test_send_to_single_target_method = skip
     test_oosend_base = skip
     test_three_receivers = skip



More information about the Pypy-commit mailing list