Commits

Sven Hager committed a82d973

(bivab, hager):
Fixed enoying error which occurred at calls because of the backchain.

  • Participants
  • Parent commits 8e84366
  • Branches ppc-jit-backend

Comments (0)

Files changed (4)

File pypy/jit/backend/ppc/ppcgen/arch.py

 
 GPR_SAVE_AREA   = len(NONVOLATILES) * WORD
 MAX_REG_PARAMS = 8
+
+BACKCHAIN_SIZE = 2 * WORD

File pypy/jit/backend/ppc/ppcgen/ppc_assembler.py

 from pypy.jit.backend.ppc.ppcgen.symbol_lookup import lookup
 from pypy.jit.backend.ppc.ppcgen.codebuilder import PPCBuilder
 from pypy.jit.backend.ppc.ppcgen.arch import (IS_PPC_32, WORD, NONVOLATILES,
-                                              GPR_SAVE_AREA)
+                                              GPR_SAVE_AREA, BACKCHAIN_SIZE)
 from pypy.jit.backend.ppc.ppcgen.helper.assembler import (gen_emit_cmp_op, 
-                                                          encode32, decode32)
+                                                          encode32, decode32, decode32_test)
 import pypy.jit.backend.ppc.ppcgen.register as r
 import pypy.jit.backend.ppc.ppcgen.condition as c
 from pypy.jit.metainterp.history import (Const, ConstPtr, LoopToken,
     def setup_failure_recovery(self):
 
         @rgc.no_collect
-        def failure_recovery_func(mem_loc, frame_pointer, stack_pointer):
+        def failure_recovery_func(mem_loc, stack_pointer, spilling_pointer):
             """mem_loc is a structure in memory describing where the values for
             the failargs are stored.
             frame loc is the address of the frame pointer for the frame to be
             decoded frame """
-            return self.decode_registers_and_descr(mem_loc, frame_pointer, stack_pointer)
+            return self.decode_registers_and_descr(mem_loc, stack_pointer, spilling_pointer)
 
         self.failure_recovery_func = failure_recovery_func
 
             '''
         enc = rffi.cast(rffi.CCHARP, mem_loc)
         managed_size = WORD * len(r.MANAGED_REGS)
+        # XXX do some sanity considerations
         spilling_depth = spp_loc - stack_loc + managed_size
         spilling_area = rffi.cast(rffi.CCHARP, stack_loc + managed_size)
         assert spilling_depth >= 0
+        assert spp_loc > stack_loc
 
-        regs = rffi.cast(rffi.CCHARP, stack_loc)
+        regs = rffi.cast(rffi.CCHARP, stack_loc + BACKCHAIN_SIZE)
         i = -1
         fail_index = -1
         while(True):
                     self.fail_boxes_float.setitem(fail_index, value)
                     continue
                 else:
-                    value = decode32(regs, reg*WORD - 2 * WORD)
-
+                    value = decode32(regs, (reg - 3) * WORD)
+    
             if group == self.INT_TYPE:
                 self.fail_boxes_int.setitem(fail_index, value)
             elif group == self.REF_TYPE:
                 j += 4
             else: # REG_LOC
                 #loc = r.all_regs[ord(res)]
-                #import pdb; pdb.set_trace()
-                loc = r.MANAGED_REGS[ord(res) - 2]
+                loc = r.MANAGED_REGS[ord(res) - 3]
             j += 1
             locs.append(loc)
         return locs
         #
         self._save_managed_regs(mc)
         # adjust SP (r1)
-        size = WORD * len(r.MANAGED_REGS)
+        size = WORD * (len(r.MANAGED_REGS)) + BACKCHAIN_SIZE
+        # XXX do quadword alignment
+        #while size % (4 * WORD) != 0:
+        #    size += WORD
         mc.addi(r.SP.value, r.SP.value, -size)
         #
         decode_func_addr = llhelper(self.recovery_func_sign,
         addr = rffi.cast(lltype.Signed, decode_func_addr)
         #
         # load parameters into parameter registers
-        mc.lwz(r.r3.value, r.SPP.value, 0)
-        #mc.mr(r.r3.value, r.r0.value)          # address of state encoding 
+        mc.lwz(r.r3.value, r.SPP.value, 0)     # address of state encoding 
         mc.mr(r.r4.value, r.SP.value)          # load stack pointer
         mc.mr(r.r5.value, r.SPP.value)         # load spilling pointer
         #

File pypy/jit/backend/ppc/ppcgen/regalloc.py

                 box = TempInt()
             loc = self.force_allocate_reg(box, forbidden_vars=forbidden_vars)
             imm = self.rm.convert_to_imm(thing)
-            self.assembler.load_imm(loc.value, imm.value)
+            self.assembler.mc.load_imm(loc, imm.value)
         else:
             loc = self.make_sure_var_in_reg(thing,
                     forbidden_vars=forbidden_vars)

File pypy/jit/backend/ppc/ppcgen/register.py

 SP  = r1
 RES = r3
 
-MANAGED_REGS = [r2, r3, r4, r5, r6, r7, r8, r9, r10,
+MANAGED_REGS = [r3, r4, r5, r6, r7, r8, r9, r10,
                 r11, r12, r13, r14, r15, r16, r17, r18, 
                 r19, r20, r21, r22, r23, r24, r25, r26,
                 r27, r28, r29, r30]