Add new test case to check stack integrity on complex stack frames. - lightning.git - Portable just-in-time compiler library

index : lightning.git
Portable just-in-time compiler library
summary refs log tree commit diff
path: root/lib/jit_x86-cpu.c
diff options
context:
space:
mode:
authorpcpa <paulo.cesar.pereira.de.andrade@gmail.com>2012年12月19日 18:07:12 -0200
committerpcpa <paulo.cesar.pereira.de.andrade@gmail.com>2012年12月19日 18:07:12 -0200
commita74318a1d715a7f9ce9c99ae81c3038645efcc10 (patch)
tree5b13fe85aa14c298324b238c8e6140ee14f392b0 /lib/jit_x86-cpu.c
parentb43ea1f908866baaf14586e6d048bff4dbf6db1f (diff)
downloadlightning-a74318a1d715a7f9ce9c99ae81c3038645efcc10.tar.gz
Add new test case to check stack integrity on complex stack frames.
* check/stack.ok, check/stack.tst: New files to test data integrity on a deep chain of stack frames. * lib/jit_arm.c, lib/jit_arm-cpu.c, lib/jit_mips.c, lib/jit_mips-cpu.c, lib/jit_ppc.c, lib/jit_ppc-cpu.c, lib/jit_x86.c, lib/jit_x86-cpu.c: Calculate _jit->function->stack in the emit stage, otherwise it will calculate it wrong if need to jit_allocai space to spill registers. * lib/lightning.c: Correct wrong offset when updating the "current" jit function pointer in the code that may need to allocate stack space to spill registers. * check/lightning.c: Correct off by one data space check. * check/Makefile.am: Update for new test case.
Diffstat (limited to 'lib/jit_x86-cpu.c')
-rw-r--r--lib/jit_x86-cpu.c 12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/jit_x86-cpu.c b/lib/jit_x86-cpu.c
index ed02008..197f780 100644
--- a/lib/jit_x86-cpu.c
+++ b/lib/jit_x86-cpu.c
@@ -20,8 +20,6 @@
#if PROTO
# if __WORDSIZE == 32
-# define stack_alignment 4
-# define stack_framesize 20
# define ldi(u, v) ldi_i(u, v)
# define ldxi(u, v, w) ldxi_i(u, v, w)
# define sti(u, v) sti_i(u, v)
@@ -32,8 +30,6 @@
# define reg8_p(rn) \
((rn) >= _RAX_REGNO && (rn) <= _RBX_REGNO)
# else
-# define stack_alignment 8
-# define stack_framesize 56
# define ldi(u, v) ldi_l(u, v)
# define ldxi(u, v, w) ldxi_l(u, v, w)
# define sti(u, v) sti_l(u, v)
@@ -3070,6 +3066,14 @@ _jmpi(jit_state_t *_jit, jit_word_t i0)
static void
_prolog(jit_state_t *_jit, jit_node_t *node)
{
+#if __WORDSIZE == 32
+ _jit->function->stack = (((_jit->function->self.alen -
+ _jit->function->self.aoff) + 15) & -16) + 12;
+#else
+ _jit->function->stack = (((_jit->function->self.alen -
+ _jit->function->self.aoff) + 15) & -16) + 8;
+#endif
+
/* callee save registers */
subi(_RSP_REGNO, _RSP_REGNO, stack_framesize - sizeof(jit_word_t));
#if __WORDSIZE == 32
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月21日 07:33:12 +0000

AltStyle によって変換されたページ (->オリジナル) /