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

antocuni at codespeak.net antocuni at codespeak.net
Wed Oct 22 13:31:24 CEST 2008


Author: antocuni
Date: Wed Oct 22 13:31:22 2008
New Revision: 59309

Modified:
   pypy/branch/oo-jit/pypy/jit/codegen/cli/operation.py
   pypy/branch/oo-jit/pypy/jit/codegen/cli/rgenop.py
   pypy/branch/oo-jit/pypy/translator/cli/src/pypylib.cs
Log:
use unsigned int instead of int to store the blockid



Modified: pypy/branch/oo-jit/pypy/jit/codegen/cli/operation.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/codegen/cli/operation.py	(original)
+++ pypy/branch/oo-jit/pypy/jit/codegen/cli/operation.py	Wed Oct 22 13:31:22 2008
@@ -1,5 +1,6 @@
 import py
 from pypy.rlib.objectmodel import specialize
+from pypy.rlib.rarithmetic import intmask
 from pypy.rpython.ootypesystem import ootype
 from pypy.translator.cli.dotnet import CLR, typeof, new_array
 from pypy.translator.cli import opcodes as cli_opcodes
@@ -149,7 +150,7 @@
         graphinfo.args_manager.copy_to_inputargs(self.meth, self.args_gv)
         block_id = self.target.block_id
         #import pdb;pdb.set_trace()
-        il.Emit(OpCodes.Ldc_I4, block_id)
+        il.Emit(OpCodes.Ldc_I4, intmask(block_id))
         il.Emit(OpCodes.Ret)
 
 

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	Wed Oct 22 13:31:22 2008
@@ -3,6 +3,7 @@
 from pypy.rpython.ootypesystem import ootype
 from pypy.rpython.lltypesystem import lltype
 from pypy.rlib.objectmodel import specialize
+from pypy.rlib.rarithmetic import r_uint
 from pypy.jit.codegen.model import AbstractRGenOp, GenBuilder, GenLabel
 from pypy.jit.codegen.model import GenVarOrConst, GenVar, GenConst
 from pypy.jit.codegen.model import CodeGenSwitch
@@ -464,8 +465,12 @@
 
 class GraphInfo:
     def __init__(self):        
-        #self.blocks = [] # block_id -> (meth, label)
         self.args_manager = ArgsManager()
+        
+        # allocate space for the return variable of FlexCaseMethod
+        # XXX: it should be handled automatically :-(
+        self.args_manager.register_types([typeof(System.UInt32)])
+
 
 class MethodGenerator:
 
@@ -511,15 +516,10 @@
         return branch
 
     def newblock(self, args_gv):
-##         blocks = self.graphinfo.blocks
-##         block_id = len(blocks)
-##         result = Label(self, block_id, args_gv)
-##         blocks.append((self, result))
-        
         block_num = len(self.blocks)
         assert block_num < 2**16
         assert self.method_id >= 0
-        block_id = self.method_id << 16 | block_num
+        block_id = r_uint(self.method_id) << 16 | block_num
         lbl = Label(self, block_id, args_gv)
         self.blocks.append(lbl)
         self.graphinfo.args_manager.register(args_gv)
@@ -578,7 +578,7 @@
 
     def setup_dispatch_block(self):
         self.il_dispatch_block_label = self.il.DefineLabel()
-        self.jumpto_var = self.il.DeclareLocal(class2type(cInt32))
+        self.jumpto_var = self.il.DeclareLocal(typeof(System.UInt32))
 
     def emit_dispatch_block(self):
         # make sure we don't enter dispatch_block by mistake
@@ -885,8 +885,8 @@
     def add_case(self, gv_case):
         graph = self.graph
         name = graph.name + '_case'
-        restype = class2type(cInt32)
-        arglist = [class2type(cInt32), class2type(cObject)]
+        restype = typeof(System.UInt32)
+        arglist = [typeof(System.UInt32), class2type(cObject)]
         delegatetype = class2type(cFlexSwitchCase)
         graphinfo = graph.graphinfo
         meth = FlexCaseMethod(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	Wed Oct 22 13:31:22 2008
@@ -117,16 +117,16 @@
       public T fields;
     }
 
-    public delegate int FlexSwitchCase(int block, object args);
+    public delegate uint FlexSwitchCase(uint block, object args);
 
     public class LowLevelFlexSwitch
     {
-        public int default_blockid = -1;
+        public uint default_blockid = 0xFFFFFFFF;
         public int numcases = 0;
         public int[] values = new int[4];
         public FlexSwitchCase[] cases = new FlexSwitchCase[4];
 
-        public void set_default_blockid(int blockid)
+        public void set_default_blockid(uint blockid)
         {
             this.default_blockid = blockid;
         }
@@ -152,7 +152,7 @@
             cases = newcases;
         }
         
-        public int execute(int v, object args)
+        public uint execute(int v, object args)
         {
             for(int i=0; i<numcases; i++)
                 if (values[i] == v) {
@@ -350,7 +350,7 @@
             return obj.GetHashCode();
         }
 
-        public static void throwInvalidBlockId(int blockid)
+        public static void throwInvalidBlockId(uint blockid)
         {
             throw new Exception(string.Format("Invalid block id: {0}", blockid));
         }



More information about the Pypy-commit mailing list