aboutsummaryrefslogtreecommitdiff
path: root/src/lj_state.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lj_state.c')
-rw-r--r--src/lj_state.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/lj_state.c b/src/lj_state.c
index 604ff886..486e66e3 100644
--- a/src/lj_state.c
+++ b/src/lj_state.c
@@ -60,7 +60,7 @@ static void resizestack(lua_State *L, MSize n)
60 GCobj *up; 60 GCobj *up;
61 lua_assert((MSize)(tvref(L->maxstack)-oldst)==L->stacksize-LJ_STACK_EXTRA-1); 61 lua_assert((MSize)(tvref(L->maxstack)-oldst)==L->stacksize-LJ_STACK_EXTRA-1);
62 st = (TValue *)lj_mem_realloc(L, tvref(L->stack), 62 st = (TValue *)lj_mem_realloc(L, tvref(L->stack),
63 (MSize)(L->stacksize*sizeof(TValue)), 63 (MSize)(oldsize*sizeof(TValue)),
64 (MSize)(realsize*sizeof(TValue))); 64 (MSize)(realsize*sizeof(TValue)));
65 setmref(L->stack, st); 65 setmref(L->stack, st);
66 delta = (char *)st - (char *)oldst; 66 delta = (char *)st - (char *)oldst;
@@ -68,12 +68,12 @@ static void resizestack(lua_State *L, MSize n)
68 while (oldsize < realsize) /* Clear new slots. */ 68 while (oldsize < realsize) /* Clear new slots. */
69 setnilV(st + oldsize++); 69 setnilV(st + oldsize++);
70 L->stacksize = realsize; 70 L->stacksize = realsize;
71 if ((size_t)(mref(G(L)->jit_base, char) - (char *)oldst) < oldsize)
72 setmref(G(L)->jit_base, mref(G(L)->jit_base, char) + delta);
71 L->base = (TValue *)((char *)L->base + delta); 73 L->base = (TValue *)((char *)L->base + delta);
72 L->top = (TValue *)((char *)L->top + delta); 74 L->top = (TValue *)((char *)L->top + delta);
73 for (up = gcref(L->openupval); up != NULL; up = gcnext(up)) 75 for (up = gcref(L->openupval); up != NULL; up = gcnext(up))
74 setmref(gco2uv(up)->v, (TValue *)((char *)uvval(gco2uv(up)) + delta)); 76 setmref(gco2uv(up)->v, (TValue *)((char *)uvval(gco2uv(up)) + delta));
75 if (obj2gco(L) == gcref(G(L)->jit_L))
76 setmref(G(L)->jit_base, mref(G(L)->jit_base, char) + delta);
77} 77}
78 78
79/* Relimit stack after error, in case the limit was overdrawn. */ 79/* Relimit stack after error, in case the limit was overdrawn. */
@@ -90,7 +90,8 @@ void lj_state_shrinkstack(lua_State *L, MSize used)
90 return; /* Avoid stack shrinking while handling stack overflow. */ 90 return; /* Avoid stack shrinking while handling stack overflow. */
91 if (4*used < L->stacksize && 91 if (4*used < L->stacksize &&
92 2*(LJ_STACK_START+LJ_STACK_EXTRA) < L->stacksize && 92 2*(LJ_STACK_START+LJ_STACK_EXTRA) < L->stacksize &&
93 obj2gco(L) != gcref(G(L)->jit_L)) /* Don't shrink stack of live trace. */ 93 /* Don't shrink stack of live trace. */
94 (tvref(G(L)->jit_base) == NULL || obj2gco(L) != gcref(G(L)->jit_L)))
94 resizestack(L, L->stacksize >> 1); 95 resizestack(L, L->stacksize >> 1);
95} 96}
96 97