Author: Brian Kearns <bdkea...@gmail.com> Branch: Changeset: r62613:b1a1549418d9 Date: 2013-03-21 15:05 -0400 http://bitbucket.org/pypy/pypy/changeset/b1a1549418d9/
Log: merge heads diff --git a/rpython/jit/backend/arm/assembler.py b/rpython/jit/backend/arm/assembler.py --- a/rpython/jit/backend/arm/assembler.py +++ b/rpython/jit/backend/arm/assembler.py @@ -242,7 +242,7 @@ # mc = ARMv7Builder() # save argument registers and return address - mc.PUSH([reg.value for reg in r.argument_regs] + [r.lr.value]) + mc.PUSH([reg.value for reg in r.argument_regs] + [r.ip.value, r.lr.value]) # stack is aligned here # Pass current stack pointer as argument to the call mc.MOV_rr(r.r0.value, r.sp.value) @@ -253,21 +253,13 @@ mc.gen_load_int(r.r0.value, self.cpu.pos_exception()) mc.LDR_ri(r.r0.value, r.r0.value) mc.TST_rr(r.r0.value, r.r0.value) + # # restore registers and return # We check for c.EQ here, meaning all bits zero in this case - mc.POP([reg.value for reg in r.argument_regs] + [r.pc.value], cond=c.EQ) - # - # Call the helper, which will return a dead frame object with - # the correct exception set, or MemoryError by default - addr = rffi.cast(lltype.Signed, self.cpu.get_propagate_exception()) - mc.BL(addr) - # - # footer -- note the ADD, which skips the return address of this - # function, and will instead return to the caller's caller. Note - # also that we completely ignore the saved arguments, because we - # are interrupting the function. - mc.ADD_ri(r.sp.value, r.sp.value, (len(r.argument_regs) + 1) * WORD) - mc.POP([r.pc.value]) + mc.POP([reg.value for reg in r.argument_regs] + [r.ip.value, r.pc.value], cond=c.EQ) + # restore sp + mc.ADD_ri(r.sp.value, r.sp.value, (len(r.argument_regs) + 2) * WORD) + mc.B(self.propagate_exception_path) # rawstart = mc.materialize(self.cpu.asmmemmgr, []) self.stack_check_slowpath = rawstart @@ -311,6 +303,8 @@ else: self._restore_exception(mc, exc0, exc1) mc.VPOP([vfpr.value for vfpr in r.caller_vfp_resp]) + assert exc0 is not None + assert exc1 is not None mc.POP([gpr.value for gpr in r.caller_resp] + [exc0.value, exc1.value]) # @@ -505,7 +499,7 @@ if self.cpu.supports_floats: mc.VPOP([reg.value for reg in r.callee_saved_vfp_registers], cond=cond) - # push all callee saved registers and IP to keep the alignment + # pop all callee saved registers and IP to keep the alignment mc.POP([reg.value for reg in r.callee_restored_registers] + [r.ip.value], cond=cond) mc.BKPT() @@ -564,11 +558,11 @@ self.gen_func_prolog() def _call_header_with_stack_check(self): + self._call_header() if self.stack_check_slowpath == 0: pass # no stack check (e.g. not translated) else: endaddr, lengthaddr, _ = self.cpu.insert_stack_check() - self.mc.PUSH([r.lr.value]) # load stack end self.mc.gen_load_int(r.ip.value, endaddr) # load ip, [end] self.mc.LDR_ri(r.ip.value, r.ip.value) # LDR ip, ip @@ -580,9 +574,6 @@ # if ofs self.mc.CMP_rr(r.ip.value, r.lr.value) # CMP ip, lr self.mc.BL(self.stack_check_slowpath, c=c.HI) # call if ip > lr - # - self.mc.POP([r.lr.value]) - self._call_header() # cpu interface def assemble_loop(self, loopname, inputargs, operations, looptoken, log): diff --git a/rpython/jit/backend/arm/test/test_calling_convention.py b/rpython/jit/backend/arm/test/test_calling_convention.py --- a/rpython/jit/backend/arm/test/test_calling_convention.py +++ b/rpython/jit/backend/arm/test/test_calling_convention.py @@ -4,12 +4,23 @@ from rpython.rtyper.lltypesystem import lltype from rpython.jit.codewriter.effectinfo import EffectInfo +from rpython.jit.backend.arm.codebuilder import ARMv7Builder +from rpython.jit.backend.arm import registers as r from rpython.jit.backend.arm.test.support import skip_unless_run_slow_tests skip_unless_run_slow_tests() class TestARMCallingConvention(CallingConvTests): # ../../test/calling_convention_test.py + def make_function_returning_stack_pointer(self): + mc = ARMv7Builder() + mc.MOV_rr(r.r0.value, r.sp.value) + mc.MOV_rr(r.pc.value, r.lr.value) + return mc.materialize(self.cpu.asmmemmgr, []) + + def get_alignment_requirements(self): + return 8 + def test_call_argument_spilling(self): # bug when we have a value in r0, that is overwritten by an argument # and needed after the call, so that the register gets spilled after it @@ -28,12 +39,24 @@ ops = """ [%s] i99 = call(ConstClass(func_ptr), 22, descr=calldescr) - finish(%s, i99)""" % (args, args) + force_spill(i0) + force_spill(i1) + force_spill(i2) + force_spill(i3) + force_spill(i4) + force_spill(i5) + force_spill(i6) + force_spill(i7) + force_spill(i8) + force_spill(i9) + force_spill(i10) + guard_true(i0) [%s, i99] + finish()""" % (args, args) loop = parse(ops, namespace=locals()) looptoken = JitCellToken() self.cpu.compile_loop(loop.inputargs, loop.operations, looptoken) args = [x for x in range(11)] - self.cpu.execute_token(looptoken, *args) + deadframe = self.cpu.execute_token(looptoken, *args) for x in range(11): - assert self.cpu.get_latest_value_int(x) == x - assert self.cpu.get_latest_value_int(11) == 38 + assert self.cpu.get_int_value(deadframe, x) == x + assert self.cpu.get_int_value(deadframe, 11) == 38 diff --git a/rpython/jit/backend/test/calling_convention_test.py b/rpython/jit/backend/test/calling_convention_test.py --- a/rpython/jit/backend/test/calling_convention_test.py +++ b/rpython/jit/backend/test/calling_convention_test.py @@ -11,6 +11,7 @@ from rpython.jit.backend.test.runner_test import Runner import py import sys +import platform def boxfloat(x): return BoxFloat(longlong.getfloatstorage(x)) @@ -382,7 +383,8 @@ raise NotImplementedError def test_call_aligned_explicit_check(self): - if sys.maxint == 2 ** 31 - 1: + if (not platform.machine().startswith('arm') and + sys.maxint == 2 ** 31 - 1): # XXX is still necessary on x86? py.test.skip("libffi on 32bit is broken") cpu = self.cpu if not cpu.supports_floats: _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit