-rw-r--r-- | lib/jit_arm-cpu.c | 4 | ||||
-rw-r--r-- | lib/jit_arm.c | 3 | ||||
-rw-r--r-- | lib/jit_mips-cpu.c | 5 | ||||
-rw-r--r-- | lib/jit_mips.c | 21 | ||||
-rw-r--r-- | lib/jit_ppc-cpu.c | 3 | ||||
-rw-r--r-- | lib/jit_ppc.c | 2 | ||||
-rw-r--r-- | lib/jit_x86-cpu.c | 12 | ||||
-rw-r--r-- | lib/jit_x86.c | 13 | ||||
-rw-r--r-- | lib/lightning.c | 2 |
diff --git a/lib/jit_arm-cpu.c b/lib/jit_arm-cpu.c index 1922a6c..cf1be0f 100644 --- a/lib/jit_arm-cpu.c +++ b/lib/jit_arm-cpu.c @@ -3564,6 +3564,10 @@ _calli_p(jit_state_t *_jit, jit_word_t i0) static void _prolog(jit_state_t *_jit, jit_node_t *node) { + _jit->function->stack = ((_jit->function->self.alen - + /* align stack at 8 bytes */ + _jit->function->self.aoff) + 7) & -8; + if (jit_thumb_p()) { /* switch to thumb mode (better approach would be to * ORR 1 address being called, but no clear distinction diff --git a/lib/jit_arm.c b/lib/jit_arm.c index 1c66b22..fab42aa 100644 --- a/lib/jit_arm.c +++ b/lib/jit_arm.c @@ -322,9 +322,6 @@ void _jit_epilog(jit_state_t *_jit) { assert(_jit->function); - _jit->function->stack = ((_jit->function->self.alen - - /* align stack at 8 bytes */ - _jit->function->self.aoff) + 7) & -8; assert(_jit->function->epilog->next == NULL); jit_link(_jit->function->epilog); _jit->function = NULL; diff --git a/lib/jit_mips-cpu.c b/lib/jit_mips-cpu.c index 8749300..5e5c598 100644 --- a/lib/jit_mips-cpu.c +++ b/lib/jit_mips-cpu.c @@ -2697,6 +2697,11 @@ _calli(jit_state_t *_jit, jit_word_t i0) static void _prolog(jit_state_t *_jit, jit_node_t *node) { + _jit->function->stack = ((/* first 16 bytes must be allocated */ + (_jit->function->self.alen > 16 ? + _jit->function->self.alen : 16) - + /* align stack at 8 bytes */ + _jit->function->self.aoff) + 7) & -8; /* callee save registers */ subi(_SP_REGNO, _SP_REGNO, stack_framesize); #if __WORDSIZE == 32 diff --git a/lib/jit_mips.c b/lib/jit_mips.c index d3cca00..1773b5d 100644 --- a/lib/jit_mips.c +++ b/lib/jit_mips.c @@ -224,12 +224,6 @@ void _jit_epilog(jit_state_t *_jit) { assert(_jit->function); - - _jit->function->stack = ((/* first 16 bytes must be allocated */ - (_jit->function->self.alen > 16 ? - _jit->function->self.alen : 16) - - /* align stack at 8 bytes */ - _jit->function->self.aoff) + 7) & -8; assert(_jit->function->epilog->next == NULL); jit_link(_jit->function->epilog); _jit->function = NULL; @@ -266,13 +260,20 @@ _jit_arg_f(jit_state_t *_jit) assert(_jit->function); offset = (_jit->function->self.size - stack_framesize) >> 2; - if (offset < 4) { + if (offset < 3) { if (!_jit->function->self.argi) { offset += 4; _jit->function->self.argf += 2; + assert(!(offset & 1)); } - else + else { _jit->function->self.argi += 2; + if (offset & 1) { + ++_jit->function->self.argi; + ++offset; + _jit->function->self.size += sizeof(jit_float32_t); + } + } } else offset = _jit->function->self.size; @@ -395,7 +396,7 @@ void _jit_getarg_f(jit_state_t *_jit, jit_int32_t u, jit_int32_t v) { if (v < 4) - jit_new_node_ww(jit_code_getarg_f, u, _A0 - (v >> 1)); + jit_new_node_ww(jit_code_getarg_f, u, _A0 - v); else if (v < 8) jit_movr_f(u, _F12 - ((v - 4) >> 1)); else @@ -406,7 +407,7 @@ void _jit_getarg_d(jit_state_t *_jit, jit_int32_t u, jit_int32_t v) { if (v < 4) - jit_new_node_ww(jit_code_getarg_d, u, _A0 - (v >> 1)); + jit_new_node_ww(jit_code_getarg_d, u, _A0 - v); else if (v < 8) jit_movr_d(u, _F12 - ((v - 4) >> 1)); else diff --git a/lib/jit_ppc-cpu.c b/lib/jit_ppc-cpu.c index 05bebf2..0f9b343 100644 --- a/lib/jit_ppc-cpu.c +++ b/lib/jit_ppc-cpu.c @@ -2363,6 +2363,9 @@ _prolog(jit_state_t *_jit, jit_node_t *node) { unsigned long regno; + _jit->function->stack = ((_jit->function->self.alen - + _jit->function->self.aoff) + 15) & -16; + /* return address */ MFLR(_R0_REGNO); diff --git a/lib/jit_ppc.c b/lib/jit_ppc.c index df6007e..9fdc10d 100644 --- a/lib/jit_ppc.c +++ b/lib/jit_ppc.c @@ -230,8 +230,6 @@ void _jit_epilog(jit_state_t *_jit) { assert(_jit->function); - _jit->function->stack = ((_jit->function->self.alen - - _jit->function->self.aoff) + 15) & -16; assert(_jit->function->epilog->next == NULL); jit_link(_jit->function->epilog); _jit->function = NULL; 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 diff --git a/lib/jit_x86.c b/lib/jit_x86.c index a06bf90..dad35c4 100644 --- a/lib/jit_x86.c +++ b/lib/jit_x86.c @@ -268,8 +268,10 @@ jit_get_cpu(void) void _jit_init(jit_state_t *_jit) { +#if __WORDSIZE == 32 jit_int32_t regno; static jit_bool_t first = 1; +#endif _jit->reglen = jit_size(_rvs) - 1; #if __WORDSIZE == 32 @@ -400,13 +402,6 @@ void _jit_epilog(jit_state_t *_jit) { assert(_jit->function); -#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 assert(_jit->function->epilog->next == NULL); jit_link(_jit->function->epilog); _jit->function = NULL; @@ -448,7 +443,11 @@ _jit_arg_f(jit_state_t *_jit) return (_jit->function->self.argf++); #endif offset = _jit->function->self.size; +#if __WORDSIZE == 32 _jit->function->self.size += sizeof(jit_float32_t); +#else + _jit->function->self.size += sizeof(jit_float64_t); +#endif return (offset); } diff --git a/lib/lightning.c b/lib/lightning.c index dc9dcd9..b9db321 100644 --- a/lib/lightning.c +++ b/lib/lightning.c @@ -2298,7 +2298,7 @@ _patch_registers(jit_state_t *_jit) node->link = NULL; break; case jit_code_prolog: - _jit->function = _jit->functions.ptr + node->u.w; + _jit->function = _jit->functions.ptr + node->w.w; break; case jit_code_epilog: _jit->function = NULL; |