[pypy-svn] r56775 - in pypy/branch/oo-jit/pypy: jit/codegen/cli translator/cli/src

antocuni at codespeak.net antocuni at codespeak.net
Thu Jul 24 17:29:51 CEST 2008


Author: antocuni
Date: Thu Jul 24 17:29:51 2008
New Revision: 56775

Modified:
   pypy/branch/oo-jit/pypy/jit/codegen/cli/rgenop.py
   pypy/branch/oo-jit/pypy/translator/cli/src/pypylib.cs
Log:
pass object and do a cast inside cases instead of passing directly
InputArgs; this will allow us to choose the exact class to use for
inputargs depending on which field we need



Modified: pypy/branch/oo-jit/pypy/jit/codegen/cli/rgenop.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/codegen/cli/rgenop.py	(original)
+++ pypy/branch/oo-jit/pypy/jit/codegen/cli/rgenop.py	Thu Jul 24 17:29:51 2008
@@ -370,6 +370,7 @@
         self.graphinfo = graphinfo
 
         self.gv_entrypoint = FunctionConst(delegatetype)
+        self.gv_inputargs = None
         self.genconsts = {}
         self.branches = []
         self.newbranch()
@@ -452,7 +453,6 @@
             return
         self.graphinfo.has_flexswitches = True
         self.il_dispatch_jump_label = self.il.DefineLabel()
-        self.gv_inputargs = self.newlocalvar(class2type(cInputArgs))
         self.jumpto_var = self.il.DeclareLocal(class2type(cInt32))
 
     def get_op_Return(self, gv_returnvar):
@@ -468,8 +468,10 @@
 
     def emit_preamble(self):
         if not self.graphinfo.has_flexswitches:
-            return        
-        # InputArgs inputargs_var = new InputArgs()
+            return
+        
+        # InputArgs inputargs = new InputArgs()
+        self.gv_inputargs = self.newlocalvar(class2type(cInputArgs))
         clitype = self.gv_inputargs.getCliType()
         ctor = clitype.GetConstructor(new_array(System.Type, 0))
         self.il.Emit(OpCodes.Newobj, ctor)
@@ -522,8 +524,6 @@
             gv_local = self.newlocalvar(gv_arg.getCliType())
             self.linkargs_gv_map[gv_arg] = gv_local
 
-        self.gv_inputargs = self.inputargs_gv[1] # InputArgs is always the 2nd argument
-
     def map_genvar(self, gv_var):
         return self.linkargs_gv_map.get(gv_var, gv_var)
 
@@ -538,6 +538,14 @@
 
     def emit_preamble(self):
         from pypy.jit.codegen.cli.operation import InputArgsManager
+
+        # InputArgs inputargs = (InputArgs)obj // obj is the 2nd arg
+        clitype = class2type(cInputArgs)
+        self.gv_inputargs = self.newlocalvar(clitype)
+        self.inputargs_gv[1].load(self)
+        self.il.Emit(OpCodes.Castclass, clitype)
+        self.gv_inputargs.store(self)
+
         linkargs_out_gv = []
         for gv_linkarg in self.linkargs_gv:
             gv_var = self.linkargs_gv_map[gv_linkarg]
@@ -677,7 +685,7 @@
         graph = self.graph
         name = graph.name + '_case'
         restype = class2type(cInt32)
-        arglist = [class2type(cInt32), class2type(cInputArgs)]
+        arglist = [class2type(cInt32), class2type(cObject)]
         delegatetype = class2type(cFlexSwitchCase)
         graphinfo = graph.graphinfo
         meth = FlexSwitchCaseGenerator(graph.rgenop, name, restype,

Modified: pypy/branch/oo-jit/pypy/translator/cli/src/pypylib.cs
==============================================================================
--- pypy/branch/oo-jit/pypy/translator/cli/src/pypylib.cs	(original)
+++ pypy/branch/oo-jit/pypy/translator/cli/src/pypylib.cs	Thu Jul 24 17:29:51 2008
@@ -106,7 +106,7 @@
 {
 
     // XXX: these classes should be automatically generated by the JIT backend
-    public delegate int FlexSwitchCase(int block, InputArgs args);
+    public delegate int FlexSwitchCase(int block, object args);
     public class InputArgs {
         public int Int32_0;
         public int Int32_1;
@@ -145,7 +145,7 @@
             cases = newcases;
         }
         
-        public int execute(int v, InputArgs args)
+        public int execute(int v, object args)
         {
             for(int i=0; i<numcases; i++)
                 if (values[i] == v) {



More information about the Pypy-commit mailing list