[pypy-svn] r54777 - in pypy/branch/oo-jit/pypy: jit/codegen/cli jit/codegen/cli/test rpython/ootypesystem

antocuni at codespeak.net antocuni at codespeak.net
Fri May 16 10:07:10 CEST 2008


Author: antocuni
Date: Fri May 16 10:07:08 2008
New Revision: 54777

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/jit/codegen/cli/test/test_interpreter.py
   pypy/branch/oo-jit/pypy/rpython/ootypesystem/ootype.py
Log:
- rename builder.parent to builder.graphbuilder

- make test_compile_time_const_tuple passing



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	Fri May 16 10:07:08 2008
@@ -17,7 +17,7 @@
         if self._gv_res is None:
             restype = self.restype()
             if restype is not None:
-                loc = self.builder.parent.il.DeclareLocal(restype)
+                loc = self.builder.graphbuilder.il.DeclareLocal(restype)
                 self._gv_res = GenLocalVar(loc)
         return self._gv_res
 
@@ -41,7 +41,7 @@
 
     def emit(self):
         self.pushAllArgs()
-        self.builder.parent.il.Emit(self.getOpCode())
+        self.builder.graphbuilder.il.Emit(self.getOpCode())
         self.storeResult()
 
     def getOpCode(self):
@@ -59,7 +59,7 @@
 
     def emit(self):
         self.pushAllArgs()
-        self.builder.parent.il.Emit(self.getOpCode())
+        self.builder.graphbuilder.il.Emit(self.getOpCode())
         self.storeResult()
 
     def getOpCode(self):
@@ -82,7 +82,7 @@
         return None
 
     def emit(self):
-        self.builder.parent.il.MarkLabel(self.label)
+        self.builder.graphbuilder.il.MarkLabel(self.label)
         
 class FollowLink(Operation):
     
@@ -99,7 +99,7 @@
         for i in range(len(self.outputargs_gv)):
             self.outputargs_gv[i].load(self.builder)
             self.inputargs_gv[i].store(self.builder)
-        self.builder.parent.il.Emit(OpCodes.Br, self.label)
+        self.builder.graphbuilder.il.Emit(OpCodes.Br, self.label)
 
 
 class Branch(Operation):
@@ -116,7 +116,7 @@
     def emit(self):
         if self.gv_cond is not None:
             self.gv_cond.load(self.builder)
-        self.builder.parent.il.Emit(self.opcode, self.label)
+        self.builder.graphbuilder.il.Emit(self.opcode, self.label)
 
 class Return(Operation):
 
@@ -128,12 +128,12 @@
         return None
 
     def emit(self):
-        retvar = self.builder.parent.retvar
-        retlabel = self.builder.parent.retlabel
+        retvar = self.builder.graphbuilder.retvar
+        retlabel = self.builder.graphbuilder.retlabel
         if self.gv_x is not None:
             self.gv_x.load(self.builder)
-            self.builder.parent.il.Emit(OpCodes.Stloc, retvar)
-        self.builder.parent.il.Emit(OpCodes.Br, retlabel)
+            self.builder.graphbuilder.il.Emit(OpCodes.Stloc, retvar)
+        self.builder.graphbuilder.il.Emit(OpCodes.Br, retlabel)
 
 class Call(Operation):
 
@@ -153,10 +153,10 @@
         delegate_type = class2type(self.sigtoken.funcclass)
         meth_invoke = delegate_type.GetMethod('Invoke')
         self.gv_fnptr.load(self.builder)
-        self.builder.parent.il.Emit(OpCodes.Castclass, delegate_type)
+        self.builder.graphbuilder.il.Emit(OpCodes.Castclass, delegate_type)
         for gv_arg in self.args_gv:
             gv_arg.load(self.builder)
-        self.builder.parent.il.EmitCall(OpCodes.Callvirt, meth_invoke, None)
+        self.builder.graphbuilder.il.EmitCall(OpCodes.Callvirt, meth_invoke, None)
         self.storeResult()
 
 
@@ -230,7 +230,7 @@
             if 'call' in step:
                 return # XXX, fix this
             attrname = opcode2attrname(step)
-            body.append('self.builder.parent.il.Emit(OpCodes.%s)' % attrname)
+            body.append('self.builder.graphbuilder.il.Emit(OpCodes.%s)' % attrname)
         elif isinstance(step, cli_opcodes.MapException):
             return # XXX, TODO
         else:

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	Fri May 16 10:07:08 2008
@@ -56,18 +56,18 @@
 
     def load(self, builder):
         if self.index == 0:
-            builder.parent.il.Emit(OpCodes.Ldarg_0)
+            builder.graphbuilder.il.Emit(OpCodes.Ldarg_0)
         elif self.index == 1:
-            builder.parent.il.Emit(OpCodes.Ldarg_1)
+            builder.graphbuilder.il.Emit(OpCodes.Ldarg_1)
         elif self.index == 2:
-            builder.parent.il.Emit(OpCodes.Ldarg_2)
+            builder.graphbuilder.il.Emit(OpCodes.Ldarg_2)
         elif self.index == 3:
-            builder.parent.il.Emit(OpCodes.Ldarg_3)
+            builder.graphbuilder.il.Emit(OpCodes.Ldarg_3)
         else:
-            builder.parent.il.Emit(OpCodes.Ldarg, self.index)
+            builder.graphbuilder.il.Emit(OpCodes.Ldarg, self.index)
 
     def store(self, builder):
-        builder.parent.il.Emit(OpCodes.Starg, self.index)
+        builder.graphbuilder.il.Emit(OpCodes.Starg, self.index)
 
     def __repr__(self):
         return "GenArgVar(%d)" % self.index
@@ -80,10 +80,10 @@
         return self.v.get_LocalType()
 
     def load(self, builder):
-        builder.parent.il.Emit(OpCodes.Ldloc, self.v)
+        builder.graphbuilder.il.Emit(OpCodes.Ldloc, self.v)
 
     def store(self, builder):
-        builder.parent.il.Emit(OpCodes.Stloc, self.v)
+        builder.graphbuilder.il.Emit(OpCodes.Stloc, self.v)
 
 
 class IntConst(GenConst):
@@ -107,7 +107,7 @@
         return class2type(self.cliclass)
 
     def load(self, builder):
-        builder.parent.il.Emit(OpCodes.Ldc_I4, self.value)
+        builder.graphbuilder.il.Emit(OpCodes.Ldc_I4, self.value)
 
     def __repr__(self):
         return "int const=%s" % self.value
@@ -127,7 +127,7 @@
         return typeof(System.Double)
 
     def load(self, builder):
-        builder.parent.il.Emit(OpCodes.Ldc_R8, self.value)
+        builder.graphbuilder.il.Emit(OpCodes.Ldc_R8, self.value)
 
     def __repr__(self):
         return "float const=%s" % self.value
@@ -144,10 +144,10 @@
         return index
 
     def _load_from_array(self, builder, index, clitype):
-        builder.parent.il.Emit(OpCodes.Ldarg_0)
-        builder.parent.il.Emit(OpCodes.Ldc_I4, index)
-        builder.parent.il.Emit(OpCodes.Ldelem_Ref)
-        builder.parent.il.Emit(OpCodes.Castclass, clitype)
+        builder.graphbuilder.il.Emit(OpCodes.Ldarg_0)
+        builder.graphbuilder.il.Emit(OpCodes.Ldc_I4, index)
+        builder.graphbuilder.il.Emit(OpCodes.Ldelem_Ref)
+        builder.graphbuilder.il.Emit(OpCodes.Castclass, clitype)
 
     def getobj(self):
         raise NotImplementedError
@@ -196,8 +196,8 @@
         delegatetype = self.delegatetype
         index = self._get_index(builder)
         self._load_from_array(builder, index, holdertype)
-        builder.parent.il.Emit(OpCodes.Ldfld, funcfield)
-        builder.parent.il.Emit(OpCodes.Castclass, delegatetype)
+        builder.graphbuilder.il.Emit(OpCodes.Ldfld, funcfield)
+        builder.graphbuilder.il.Emit(OpCodes.Castclass, delegatetype)
 
     @specialize.arg(1)
     def revealconst(self, T):
@@ -252,6 +252,11 @@
 
     @staticmethod
     @specialize.memo()
+    def methToken(TYPE, methname):
+        return methname #XXX
+
+    @staticmethod
+    @specialize.memo()
     def kindToken(T):
         if T is ootype.Void:
             return cVoid
@@ -265,7 +270,10 @@
             return cString
         elif T is ootype.Char:
             return cChar
-        elif isinstance(T, ootype.Instance):
+        elif isinstance(T, (ootype.Instance,
+                            ootype.Record,
+                            ootype.Dict,
+                            ootype.List)):
             return cObject # XXX?
         else:
             assert False
@@ -276,6 +284,11 @@
         _, FIELD = T._lookup_field(name)
         return name #, RCliGenOp.kindToken(FIELD)
 
+    @staticmethod
+    @specialize.memo()
+    def allocToken(T):
+        return RCliGenOp.kindToken(T)
+
     def check_no_open_mc(self):
         pass
 
@@ -376,12 +389,13 @@
 
 class BranchBuilder(GenBuilder):
 
-    def __init__(self, parent, label):
-        self.parent = parent
+    def __init__(self, graphbuilder, label):
+        self.graphbuilder = graphbuilder
+        self.rgenop = graphbuilder.rgenop
         self.label = label
         self.operations = []
         self.is_open = False
-        self.genconsts = parent.genconsts
+        self.genconsts = graphbuilder.genconsts
 
     def start_writing(self):
         self.is_open = True
@@ -436,16 +450,16 @@
             op = ops.SameAs(self, args_gv[i])
             self.appendop(op)
             args_gv[i] = op.gv_res()
-        label = self.parent.il.DefineLabel()
+        label = self.graphbuilder.il.DefineLabel()
         self.appendop(ops.MarkLabel(self, label))
         return Label(label, args_gv)
 
     def _jump_if(self, gv_condition, opcode):
-        label = self.parent.il.DefineLabel()
+        label = self.graphbuilder.il.DefineLabel()
         op = ops.Branch(self, gv_condition, opcode, label)
         self.appendop(op)
-        branch = BranchBuilder(self.parent, label)
-        self.parent.appendbranch(branch)
+        branch = BranchBuilder(self.graphbuilder, label)
+        self.graphbuilder.appendbranch(branch)
         return branch
 
     def jump_if_false(self, gv_condition, args_for_jump_gv):
@@ -458,11 +472,11 @@
         self.operations.append(op)
 
     def end(self):
-        self.parent.end()
+        self.graphbuilder.end()
 
     def replayops(self):
         assert not self.is_open
-        il = self.parent.il
+        il = self.graphbuilder.il
         il.MarkLabel(self.label)
         for op in self.operations:
             op.emit()

Modified: pypy/branch/oo-jit/pypy/jit/codegen/cli/test/test_interpreter.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/codegen/cli/test/test_interpreter.py	(original)
+++ pypy/branch/oo-jit/pypy/jit/codegen/cli/test/test_interpreter.py	Fri May 16 10:07:08 2008
@@ -54,7 +54,6 @@
     test_arraysize = skip
     test_setarrayitem = skip
     
-    test_compile_time_const_tuple = skip
     test_green_deepfrozen_oosend = skip
     test_direct_oosend_with_green_self = skip
     test_residual_red_call = skip

Modified: pypy/branch/oo-jit/pypy/rpython/ootypesystem/ootype.py
==============================================================================
--- pypy/branch/oo-jit/pypy/rpython/ootypesystem/ootype.py	(original)
+++ pypy/branch/oo-jit/pypy/rpython/ootypesystem/ootype.py	Fri May 16 10:07:08 2008
@@ -848,6 +848,8 @@
     def _cast_to(self, EXPECTED_TYPE):
         if self.obj is None:
             return null(EXPECTED_TYPE)
+        elif EXPECTED_TYPE is Object:
+            return self
         elif isinstance(EXPECTED_TYPE, Instance):
             return oodowncast(EXPECTED_TYPE, self.obj)
         elif isinstance(EXPECTED_TYPE, SpecializableType):



More information about the Pypy-commit mailing list