[pypy-commit] pypy jitframe-on-heap: (fijal, alex, hodgestar, arigo)
arigo
noreply at buildbot.pypy.org
Thu Mar 14 02:14:25 CET 2013
Author: Armin Rigo <arigo at tunes.org>
Branch: jitframe-on-heap
Changeset: r62334:b8d923271ff2
Date: 2013-03-14 02:13 +0100
http://bitbucket.org/pypy/pypy/changeset/b8d923271ff2/
Log: (fijal, alex, hodgestar, arigo) A test for alignment of x86 stack
across a CALL operation.
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
@@ -19,7 +19,8 @@
class FakeStats(object):
pass
-class TestCallingConv(Runner):
+
+class CallingConvTests(Runner):
type_system = 'lltype'
Ptr = lltype.Ptr
FuncType = lltype.FuncType
@@ -371,3 +372,57 @@
'float', descr=calldescr)
expected = func(*argvalues)
assert abs(res.getfloat() - expected) < 0.0001
+
+
+ def make_function_returning_stack_pointer(self):
+ raise NotImplementedError
+
+ def get_alignment_requirements(self):
+ raise NotImplementedError
+
+ def test_call_aligned_explicit_check(self):
+ cpu = self.cpu
+ if not cpu.supports_floats:
+ py.test.skip('requires floats')
+
+ func_addr = self.make_function_returning_stack_pointer()
+
+ F = lltype.Float
+ I = lltype.Signed
+ floats = [0.7, 5.8, 0.1, 0.3, 0.9, -2.34, -3.45, -4.56]
+ ints = [7, 11, 23, 13, -42, 1111, 95, 1]
+ for case in range(256):
+ args = []
+ funcargs = []
+ float_count = 0
+ int_count = 0
+ for i in range(8):
+ if case & (1<<i):
+ args.append('f%d' % float_count)
+ float_count += 1
+ funcargs.append(F)
+ else:
+ args.append('i%d' % int_count)
+ int_count += 1
+ funcargs.append(I)
+
+ arguments = ', '.join(args)
+
+ FUNC = self.FuncType(funcargs, I)
+ calldescr = cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT,
+ EffectInfo.MOST_GENERAL)
+
+ ops = '[%s]\n' % arguments
+ ops += 'i99 = call(%d, %s, descr=calldescr)\n' % (func_addr,
+ arguments)
+ ops += 'finish(i99)\n'
+
+ loop = parse(ops, namespace=locals())
+ looptoken = JitCellToken()
+ self.cpu.compile_loop(loop.inputargs, loop.operations, looptoken)
+ argvals, expected_result = self._prepare_args(args, floats, ints)
+
+ deadframe = self.cpu.execute_token(looptoken, *argvals)
+ x = cpu.get_int_value(deadframe, 0)
+ align_req = self.get_alignment_requirements()
+ assert x % align_req == 0
diff --git a/rpython/jit/backend/x86/rx86.py b/rpython/jit/backend/x86/rx86.py
--- a/rpython/jit/backend/x86/rx86.py
+++ b/rpython/jit/backend/x86/rx86.py
@@ -599,6 +599,9 @@
# reserved as an illegal instruction
UD2 = insn('\x0F\x0B')
+ # a breakpoint
+ INT3 = insn('\xCC')
+
# ------------------------------ SSE2 ------------------------------
# Conversion
diff --git a/rpython/jit/backend/x86/test/test_calling_convention.py b/rpython/jit/backend/x86/test/test_calling_convention.py
--- a/rpython/jit/backend/x86/test/test_calling_convention.py
+++ b/rpython/jit/backend/x86/test/test_calling_convention.py
@@ -1,1 +1,16 @@
-from rpython.jit.backend.test.calling_convention_test import TestCallingConv
+from rpython.jit.backend.test.calling_convention_test import CallingConvTests
+from rpython.jit.backend.x86 import codebuf
+from rpython.jit.backend.x86.arch import WORD
+from rpython.jit.backend.x86.regloc import eax, esp
+
+class TestCallingConv(CallingConvTests):
+
+ def make_function_returning_stack_pointer(self):
+ mc = codebuf.MachineCodeBlockWrapper()
+ mc.MOV(eax, esp)
+ mc.ADD_ri(eax.value, WORD)
+ mc.RET()
+ return mc.materialize(self.cpu.asmmemmgr, [])
+
+ def get_alignment_requirements(self):
+ return 16
More information about the pypy-commit
mailing list