Commits

Maciej Fijalkowski committed 88ab83e

argument passing to call_assembler

Comments (0)

Files changed (3)

pypy/jit/backend/llsupport/gc.py

                                                   'jfi_frame_depth')
         return descrs
 
+    def getarraydescr_for_frame(self, type, index):
+        """ This function returns a tuple (descr, index) for storing
+        index inside a frame array. It's a little bit delicate, because on
+        say x86 32bit, we can't express all indexes of floats.
+        """
+        raise NotImplementedError # cpu specific
+
 class JitFrameDescrs:
     def _freeze_(self):
         return True

pypy/jit/backend/llsupport/rewrite.py

         op0 = ResOperation(rop.GETFIELD_GC, [history.ConstPtr(llref)], lgt_box,
                            descr=descrs.jfi_frame_depth)
         self.newops.append(op0)
+        # XXX for now it generates call_malloc_gc, instead of
+        # call_malloc_nursery, because the array is strange
         op1 = ResOperation(rop.NEW_ARRAY, [lgt_box], frame,
                            descr=descrs.arraydescr)
         self.handle_new_array(descrs.arraydescr, op1)
         op2 = ResOperation(rop.SETFIELD_GC, [frame, history.ConstPtr(llref)],
                            None, descr=descrs.jf_frame_info)
         self.newops.append(op2)
-        lst = op.getarglist()
-        self.newops.append(ResOperation(rop.CALL_ASSEMBLER, [frame] + lst,
+        for i, arg in enumerate(op.getarglist()):
+            descr = self.cpu.getarraydescr_for_frame(arg.type, i)
+            self.newops.append(ResOperation(rop.SETARRAYITEM_GC,
+                                            [frame, ConstInt(i), arg],
+                                            None, descr))
+        self.newops.append(ResOperation(rop.CALL_ASSEMBLER, [frame],
                                         op.result, op.getdescr()))
 
     # ----------

pypy/jit/backend/llsupport/test/test_rewrite.py

         framedescrs = self.gc_ll_descr.getframedescrs(self.cpu)
         jfi_frame_depth = framedescrs.jfi_frame_depth
         jf_frame_info = framedescrs.jf_frame_info
+        signedframedescr = self.cpu.signedframedescr
+        floatframedescr = self.cpu.floatframedescr
         casmdescr.compiled_loop_token = clt
         #
         namespace.update(locals())
 class BaseFakeCPU(object):
     def __init__(self):
         self._cache = {}
+        self.signedframedescr = ArrayDescr(3, 8, FieldDescr('len', 0, 0, 0), 0)
+        self.floatframedescr = ArrayDescr(5, 8, FieldDescr('len', 0, 0, 0), 0)
+
+    def getarraydescr_for_frame(self, tp, index):
+        if tp == history.FLOAT:
+            return self.floatframedescr
+        return self.signedframedescr
     
     def arraydescrof(self, ARRAY):
         try:
             r = ArrayDescr(1, 2, FieldDescr('len', 0, 0, 0), 0)
             self._cache[ARRAY] = r
             return r
+        
     def fielddescrof(self, STRUCT, fname):
         key = (STRUCT, fname)
         try:
 
     def test_rewrite_call_assembler(self):
         self.check_rewrite("""
-        [i0]
-        i1 = call_assembler(i0, descr=casmdescr)
+        [i0, f0]
+        i2 = call_assembler(i0, f0, descr=casmdescr)
         """, """
-        [i0]
+        [i0, f0]
         i1 = getfield_gc(ConstPtr(ll_frame_info), descr=jfi_frame_depth)
         p1 = call_malloc_gc(ConstClass(malloc_array_nonstandard), 1, 2, 0, 0, i1, descr=malloc_array_nonstandard_descr)
         setfield_gc(p1, ConstPtr(ll_frame_info), descr=jf_frame_info)
-        i2 = call_assembler(p1, i0, descr=casmdescr)
+        setarrayitem_gc(p1, 0, i0, descr=signedframedescr)
+        setarrayitem_gc(p1, 1, f0, descr=floatframedescr)
+        i2 = call_assembler(p1, descr=casmdescr)
         """)
         # XXX we want call_malloc_nursery actually, but let's not care
         # for now, the array is a bit non-standard