Author: Richard Plangger <planri...@gmail.com>
Branch: s390x-backend
Changeset: r81506:25e9fedba6e8
Date: 2015-12-31 11:03 +0100
http://bitbucket.org/pypy/pypy/changeset/25e9fedba6e8/

Log:    realloc frame is nearly working, it seems though the token is not
        different from the frame?

diff --git a/rpython/jit/backend/zarch/assembler.py 
b/rpython/jit/backend/zarch/assembler.py
--- a/rpython/jit/backend/zarch/assembler.py
+++ b/rpython/jit/backend/zarch/assembler.py
@@ -321,7 +321,6 @@
         RCS2 = r.r10
         RCS3 = r.r12
 
-        # This trashes r0 and r2
         self._store_and_reset_exception(mc, RCS2, RCS3)
 
         # Do the call
@@ -344,7 +343,8 @@
             mc.store(r.r3.value, r.r5.value, -WORD)
 
         mc.restore_link()
-        self._pop_core_regs_from_jitframe(mc)
+        # do not restore r2, thus [1:]
+        self._pop_core_regs_from_jitframe(mc, r.MANAGED_REGS[1:])
         self._pop_fp_regs_from_jitframe(mc)
         mc.BCR(c.ANY, r.RETURN)
 
@@ -409,13 +409,9 @@
             self._push_fp_regs_to_jitframe(mc)
 
         # allocate a stack frame!
-        mc.STG(r.SP, l.addr(-STD_FRAME_SIZE_IN_BYTES, r.SP)) # store the 
backchain
-        mc.AGHI(r.SP, l.imm(-STD_FRAME_SIZE_IN_BYTES))
-
-        # Do the call
+        mc.push_std_frame()
         mc.raw_call(r.r12)
-
-        mc.AGHI(r.SP, l.imm(STD_FRAME_SIZE_IN_BYTES))
+        mc.pop_std_frame()
 
         # Finish
         self._reload_frame_if_necessary(mc)
@@ -437,15 +433,14 @@
         # registers).
         mc = InstrBuilder()
         #
-        mc.STG(r.r14, l.addr(14*WORD, r.SP))
+        mc.trap()
+        # mc.STG(r.r14, l.addr(14*WORD, r.SP))
         # Do the call
-        # use SP as single parameter for the call
-        mc.STG(r.SP, l.addr(0, r.SP)) # store the backchain
-        mc.AGHI(r.SP, l.imm(-STD_FRAME_SIZE_IN_BYTES))
+        mc.push_std_frame()
         mc.LGR(r.r2, r.SP)
         mc.load_imm(mc.RAW_CALL_REG, slowpathaddr)
         mc.raw_call()
-        mc.AGHI(r.SP, l.imm(STD_FRAME_SIZE_IN_BYTES))
+        mc.pop_std_frame()
         #
         # Check if it raised StackOverflow
         mc.load_imm(r.SCRATCH, self.cpu.pos_exception())
@@ -455,7 +450,7 @@
         mc.cmp_op(r.SCRATCH, 0, imm=True)
         #
         # So we return to our caller, conditionally if "EQ"
-        mc.LG(r.r14, l.addr(14*WORD, r.SP))
+        # mc.LG(r.r14, l.addr(14*WORD, r.SP))
         mc.BCR(c.EQ, r.r14)
         #
         # Else, jump to propagate_exception_path
@@ -479,6 +474,7 @@
             endaddr, lengthaddr, _ = self.cpu.insert_stack_check()
             diff = lengthaddr - endaddr
             assert check_imm_value(diff)
+            xxx
 
             mc = self.mc
             mc.load_imm(r.SCRATCH, self.stack_check_slowpath)
@@ -499,15 +495,15 @@
         mc.LG(r.r2, l.addr(ofs, r.SPP))
         patch_pos = mc.currpos()
         # placeholder for the following instructions
-        # CGRL r2, ... (6  bytes)
+        # CGFI r2, ... (6  bytes)
         # BRC  c, ...  (4  bytes)
         # LGHI r3, ... (4  bytes)
         #       sum -> (14 bytes)
         mc.write('\x00'*14)
+        self.mc.push_std_frame()
         mc.load_imm(r.RETURN, self._frame_realloc_slowpath)
         self.load_gcmap(mc, r.r2, gcmap)
-        self.mc.push_std_frame()
-        mc.BCR(c.ANY, r.RETURN)
+        mc.raw_call()
         self.mc.pop_std_frame()
 
         self.frame_depth_to_patch.append((patch_pos, mc.currpos()))
@@ -852,9 +848,9 @@
         for traps_pos, jmp_target in self.frame_depth_to_patch:
             pmc = OverwritingBuilder(self.mc, traps_pos, 3)
             # three traps, so exactly three instructions to patch here
-            pmc.CGRL(r.r2, l.imm(frame_depth))
-            pmc.BRC(c.EQ, jmp_target - (traps_pos + 6))
-            pmc.LGHI(r.r3, frame_depth)
+            pmc.CGFI(r.r2, l.imm(frame_depth))
+            pmc.BRC(c.EQ, l.imm(jmp_target - (traps_pos + 6)))
+            pmc.LGHI(r.r3, l.imm(frame_depth))
             pmc.overwrite()
 
     def materialize_loop(self, looptoken):
@@ -910,11 +906,6 @@
                                                  relative_target))
 
     def _call_header(self):
-        # Reserve space for a function descriptor, 3 words
-        #self.mc.write64(0)
-        #self.mc.write64(0)
-        #self.mc.write64(0)
-
         # Build a new stackframe of size STD_FRAME_SIZE_IN_BYTES
         self.mc.STMG(r.r6, r.r15, l.addr(6*WORD, r.SP))
         # save the back chain
diff --git a/rpython/jit/backend/zarch/codebuilder.py 
b/rpython/jit/backend/zarch/codebuilder.py
--- a/rpython/jit/backend/zarch/codebuilder.py
+++ b/rpython/jit/backend/zarch/codebuilder.py
@@ -206,10 +206,10 @@
 
     def push_std_frame(self):
         self.STG(r.SP, l.addr(-STD_FRAME_SIZE_IN_BYTES, r.SP))
-        self.AGHI(r.SP, l.imm(-STD_FRAME_SIZE_IN_BYTES))
+        self.LAY(r.SP, l.addr(-STD_FRAME_SIZE_IN_BYTES, r.SP))
 
     def pop_std_frame(self):
-        self.AGHI(r.SP, l.imm(STD_FRAME_SIZE_IN_BYTES))
+        self.LAY(r.SP, l.addr(STD_FRAME_SIZE_IN_BYTES, r.SP))
 
 class OverwritingBuilder(BlockBuilderMixin, AbstractZARCHBuilder):
     def __init__(self, mc, start, num_insts=0):
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to