Author: Richard Plangger <planri...@gmail.com> Branch: s390x-backend Changeset: r81993:394d3ce64a00 Date: 2016-01-28 14:12 +0100 http://bitbucket.org/pypy/pypy/changeset/394d3ce64a00/
Log: added SGRK instruction, now the stack overflow is correctly detected and the exception is thrown! 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 @@ -562,20 +562,18 @@ assert check_imm_value(diff) mc = self.mc - mc.load_imm(r.SCRATCH, endaddr) # li r0, endaddr - mc.load(r.r14, r.SCRATCH, 0) # lg r14, [end] - mc.load(r.SCRATCH, r.SCRATCH, diff) # lg r0, [length] - mc.LGR(r.SCRATCH2, r.SP) - mc.SGR(r.SCRATCH2, r.r14) # sub r1, (SP - r14) - jmp_pos = self.mc.currpos() - self.mc.reserve_cond_jump() - + mc.load_imm(r.r1, endaddr) + mc.load(r.r0, r.r1, 0) # ld r0, [end] + mc.load(r.r1, r.r1, diff) # ld r1, [length] + mc.SGRK(r.r0, r.SP, r.r0) + jmp_pos = self.mc.get_relative_pos() + mc.reserve_cond_jump() mc.load_imm(r.r14, self.stack_check_slowpath) mc.BASR(r.r14, r.r14) currpos = self.mc.currpos() - pmc = OverwritingBuilder(mc, jmp_pos, 1) - pmc.CLGRJ(r.SCRATCH2, r.SCRATCH, c.GT, l.imm(currpos - jmp_pos)) + pmc = OverwritingBuilder(self.mc, jmp_pos, 1) + pmc.CLGRJ(r.r0, r.r1, c.LE, l.imm(currpos - jmp_pos)) pmc.overwrite() def _check_frame_depth(self, mc, gcmap): diff --git a/rpython/jit/backend/zarch/instruction_builder.py b/rpython/jit/backend/zarch/instruction_builder.py --- a/rpython/jit/backend/zarch/instruction_builder.py +++ b/rpython/jit/backend/zarch/instruction_builder.py @@ -388,6 +388,12 @@ byte = (r1 & BIT_MASK_4) << 4 | (r2 & BIT_MASK_4) self.writechar(chr(byte)) +def build_rrf_a(mnemonic, (opcode1,opcode2), argtypes='r,r,r'): + @builder.arguments(argtypes) + def encode_rrf_a(self, r1, r2, r3): + _encode_rrf(self, opcode1, opcode2, r1, r2, r3, 0) + return encode_rrf_a + def build_rrf_c(mnemonic, (opcode1,opcode2), argtypes='r,r,r/m,-'): @builder.arguments(argtypes) def encode_rrf_b(self, r1, r2, rm3, rm4): diff --git a/rpython/jit/backend/zarch/instructions.py b/rpython/jit/backend/zarch/instructions.py --- a/rpython/jit/backend/zarch/instructions.py +++ b/rpython/jit/backend/zarch/instructions.py @@ -21,6 +21,7 @@ 'SR': ('rr', ['\x1B']), 'SG': ('rxy', ['\xE3','\x09']), 'SGR': ('rre', ['\xB9','\x09']), + 'SGRK': ('rrf_a', ['\xB9','\xE9']), # mul 'MSGR': ('rre', ['\xB9','\x0C']), 'MSG': ('rxy', ['\xE3','\x0C']), @@ -287,3 +288,9 @@ all_mnemonic_codes.update(memory_mnemonic_codes) all_mnemonic_codes.update(floatingpoint_mnemonic_codes) all_mnemonic_codes.update(branch_mnemonic_codes) + + +if __name__ == "__main__": + print("%d instructions:" % len(all_mnemonic_codes)) + for name, (typeinstr, _) in all_mnemonic_codes.items(): + print(" %s\t(type: %s)" % (name, typeinstr)) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit