[pypy-svn] r35235 - in pypy/branch/jit-real-world/pypy/jit: codegen/i386 codegen/llgraph timeshifter

arigo at codespeak.net arigo at codespeak.net
Sun Dec 3 23:23:10 CET 2006


Author: arigo
Date: Sun Dec  3 23:23:07 2006
New Revision: 35235

Modified:
   pypy/branch/jit-real-world/pypy/jit/codegen/i386/rgenop.py
   pypy/branch/jit-real-world/pypy/jit/codegen/llgraph/rgenop.py
   pypy/branch/jit-real-world/pypy/jit/timeshifter/hrtyper.py
   pypy/branch/jit-real-world/pypy/jit/timeshifter/transform.py
Log:
(pedronis, arigo)

Change the policy for Void arguments in genop_call().
Now they are never present at all.  The only back-end
that cares is llgraph, which can hack them back.


Modified: pypy/branch/jit-real-world/pypy/jit/codegen/i386/rgenop.py
==============================================================================
--- pypy/branch/jit-real-world/pypy/jit/codegen/i386/rgenop.py	(original)
+++ pypy/branch/jit-real-world/pypy/jit/codegen/i386/rgenop.py	Sun Dec  3 23:23:07 2006
@@ -346,20 +346,17 @@
         return self.returnvar(eax)
         
     def genop_call(self, sigtoken, gv_fnptr, args_gv):
+        numargs = sigtoken      # for now
         MASK = CALL_ALIGN-1
         if MASK:
-            final_depth = self.stackdepth
-            for gv_arg in args_gv:
-                if gv_arg is not None:
-                    final_depth += 1
+            final_depth = self.stackdepth + numargs
             delta = (final_depth+MASK)&~MASK-final_depth
             if delta:
                 self.mc.SUB(esp, imm(delta*WORD))
                 self.stackdepth += delta
-        for i in range(len(args_gv)-1, -1, -1):
+        for i in range(numargs-1, -1, -1):
             gv_arg = args_gv[i]
-            if gv_arg is not None:
-                self.push(gv_arg.operand(self))
+            self.push(gv_arg.operand(self))
         if gv_fnptr.is_const:
             target = gv_fnptr.revealconst(lltype.Signed)
             self.mc.CALL(rel32(target))

Modified: pypy/branch/jit-real-world/pypy/jit/codegen/llgraph/rgenop.py
==============================================================================
--- pypy/branch/jit-real-world/pypy/jit/codegen/llgraph/rgenop.py	(original)
+++ pypy/branch/jit-real-world/pypy/jit/codegen/llgraph/rgenop.py	Sun Dec  3 23:23:07 2006
@@ -25,7 +25,18 @@
     def __repr__(self):
         return repr(RGenOp.reveal(self))
 
-gv_Void = LLConst(llimpl.constTYPE(lltype.Void))
+
+_gv_TYPE_cache = {}
+def gv_TYPE(TYPE):
+    try:
+        return _gv_TYPE_cache[TYPE]
+    except KeyError:
+        gv = LLConst(llimpl.constTYPE(TYPE))
+        _gv_TYPE_cache[TYPE] = gv
+        return gv
+
+gv_Void = gv_TYPE(lltype.Void)
+gv_Signed = gv_TYPE(lltype.Signed)
 gv_dummy_placeholder = LLConst(llimpl.dummy_placeholder)
 
 
@@ -75,10 +86,13 @@
 
     def genop_call(self, (ARGS_gv, gv_RESULT, _), gv_callable, args_gv):
         vars_gv = [gv_callable]
+        j = 0
         for i in range(len(ARGS_gv)):
-            gv_arg = args_gv[i]
-            if gv_arg is not None:
-                gv_arg = LLVar(llimpl.cast(self.b, ARGS_gv[i].v, gv_arg.v))
+            if ARGS_gv[i] is gv_Void:
+                gv_arg = gv_dummy_placeholder
+            else:
+                gv_arg = LLVar(llimpl.cast(self.b, ARGS_gv[i].v, args_gv[j]))
+                j += 1
             vars_gv.append(gv_arg)
         if gv_callable.is_const:
             v = llimpl.genop(self.b, 'direct_call', vars_gv, gv_RESULT.v)
@@ -122,7 +136,7 @@
 
     def genop_getarraysize(self, gv_ITEMTYPE, gv_ptr):
         return LLVar(llimpl.genop(self.b, 'getarraysize', [gv_ptr.v],
-                                  llimpl.constTYPE(lltype.Signed)))
+                                  gv_Signed.v))
 
     def genop_malloc_fixedsize(self, (gv_TYPE, gv_PTRTYPE)):
         vars_gv = [gv_TYPE.v]
@@ -212,7 +226,7 @@
     @staticmethod
     @specialize.memo()
     def kindToken(T):
-        return LLConst(llimpl.constTYPE(T))        
+        return gv_TYPE(T)
 
     @staticmethod
     @specialize.memo()
@@ -222,14 +236,14 @@
         if isinstance(FIELDTYPE, lltype.ContainerType):
             FIELDTYPE = lltype.Ptr(FIELDTYPE)
         return (LLConst(llimpl.constFieldName(name)),
-                LLConst(llimpl.constTYPE(lltype.Ptr(T))),
-                LLConst(llimpl.constTYPE(FIELDTYPE)))
+                gv_TYPE(lltype.Ptr(T)),
+                gv_TYPE(FIELDTYPE))
 
     @staticmethod
     @specialize.memo()
     def allocToken(TYPE):
-        return (LLConst(llimpl.constTYPE(TYPE)),
-                LLConst(llimpl.constTYPE(lltype.Ptr(TYPE))))
+        return (gv_TYPE(TYPE),
+                gv_TYPE(lltype.Ptr(TYPE)))
 
     varsizeAllocToken = allocToken
 
@@ -239,14 +253,14 @@
         ITEMTYPE = A.OF
         if isinstance(ITEMTYPE, lltype.ContainerType):
             ITEMTYPE = lltype.Ptr(ITEMTYPE)
-        return LLConst(llimpl.constTYPE(ITEMTYPE))
+        return gv_TYPE(ITEMTYPE)
 
     @staticmethod
     @specialize.memo()
     def sigToken(FUNCTYPE):
-        return ([LLConst(llimpl.constTYPE(A)) for A in FUNCTYPE.ARGS],
-                LLConst(llimpl.constTYPE(FUNCTYPE.RESULT)),
-                LLConst(llimpl.constTYPE(FUNCTYPE)))
+        return ([gv_TYPE(A) for A in FUNCTYPE.ARGS],
+                gv_TYPE(FUNCTYPE.RESULT),
+                gv_TYPE(FUNCTYPE))
 
     constPrebuiltGlobal = genconst
 

Modified: pypy/branch/jit-real-world/pypy/jit/timeshifter/hrtyper.py
==============================================================================
--- pypy/branch/jit-real-world/pypy/jit/timeshifter/hrtyper.py	(original)
+++ pypy/branch/jit-real-world/pypy/jit/timeshifter/hrtyper.py	Sun Dec  3 23:23:07 2006
@@ -146,7 +146,7 @@
         self.ll_finish_jitstate = ll_finish_jitstate
 
         self.v_queue = varoftype(self.r_Queue.lowleveltype, 'queue')
-        self.void_red_repr = VoidRedRepr(self)
+        #self.void_red_repr = VoidRedRepr(self)
 
     def specialize(self, origportalgraph=None, view=False):
         """
@@ -184,6 +184,7 @@
             self.annotator.translator.view()     # in the middle
         for graph in seen:
             self.timeshift_graph(graph)
+        self.log.event("Timeshifted %d graphs." % (len(seen),))
 
         if origportalgraph:
             self.rewire_portal()
@@ -490,11 +491,11 @@
             self.red_reprs[lowleveltype] = r
             return r
 
-    def getredrepr_or_none(self, lowleveltype):
-        if lowleveltype is lltype.Void:
-            return self.void_red_repr
-        else:
-            return self.getredrepr(lowleveltype)
+##    def getredrepr_or_none(self, lowleveltype):
+##        if lowleveltype is lltype.Void:
+##            return self.void_red_repr
+##        else:
+##            return self.getredrepr(lowleveltype)
 
 ##    def gethscolor(self, hs):
 ##        try:
@@ -613,7 +614,7 @@
             hop.llops.append(hop.spaceop)
             return hop.spaceop.result
         else:
-            print "RED op", hop.spaceop
+            #print "RED op", hop.spaceop
             return None
 
     def default_translate_operation(self, hop):
@@ -930,7 +931,7 @@
 
     def translate_op_save_locals(self, hop):
         v_jitstate = hop.llops.getjitstate()
-        boxes_r = [self.getredrepr_or_none(originalconcretetype(hs))
+        boxes_r = [self.getredrepr(originalconcretetype(hs))
                    for hs in hop.args_s]
         boxes_v = hop.inputargs(*boxes_r)
         boxes_s = [self.s_RedBox] * len(hop.args_v)
@@ -1454,12 +1455,12 @@
         return hop.llops.as_redbox(v_ptrbox)
 
 
-class VoidRedRepr(Repr):
-    def __init__(self, hrtyper):
-        self.lowleveltype = hrtyper.r_RedBox.lowleveltype
+##class VoidRedRepr(Repr):
+##    def __init__(self, hrtyper):
+##        self.lowleveltype = hrtyper.r_RedBox.lowleveltype
 
-    def convert_const(self, ll_value):
-        return lltype.nullptr(self.lowleveltype.TO)
+##    def convert_const(self, ll_value):
+##        return lltype.nullptr(self.lowleveltype.TO)
 
 
 class BlueRepr(Repr):

Modified: pypy/branch/jit-real-world/pypy/jit/timeshifter/transform.py
==============================================================================
--- pypy/branch/jit-real-world/pypy/jit/timeshifter/transform.py	(original)
+++ pypy/branch/jit-real-world/pypy/jit/timeshifter/transform.py	Sun Dec  3 23:23:07 2006
@@ -576,6 +576,7 @@
             if op.opname == 'indirect_call':
                 del args_v[-1]
             # pseudo-obscure: the arguments for the call go in save_locals
+            args_v = [v for v in args_v if v.concretetype is not lltype.Void]
             self.genop(nonconstantblock, 'save_locals', args_v)
             v_res = self.genop(nonconstantblock, 'residual_%s_call' % (color,),
                                [op.args[0]], result_like = op.result)
@@ -665,6 +666,7 @@
             color = 'red'
         newops = []
         # pseudo-obscure: the arguments for the call go in save_locals
+        args_v = [v for v in args_v if v.concretetype is not lltype.Void]
         self.genop(newops, 'save_locals', args_v)
         self.genop(newops, 'residual_%s_call' % (color,),
                    [op.args[0]], result_like = op.result)



More information about the Pypy-commit mailing list