diff options
Diffstat (limited to 'src/lj_state.c')
-rw-r--r-- | src/lj_state.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/lj_state.c b/src/lj_state.c index dc82e260..7081a474 100644 --- a/src/lj_state.c +++ b/src/lj_state.c | |||
@@ -60,7 +60,8 @@ static void resizestack(lua_State *L, MSize n) | |||
60 | MSize oldsize = L->stacksize; | 60 | MSize oldsize = L->stacksize; |
61 | MSize realsize = n + 1 + LJ_STACK_EXTRA; | 61 | MSize realsize = n + 1 + LJ_STACK_EXTRA; |
62 | GCobj *up; | 62 | GCobj *up; |
63 | lua_assert((MSize)(tvref(L->maxstack)-oldst)==L->stacksize-LJ_STACK_EXTRA-1); | 63 | lj_assertL((MSize)(tvref(L->maxstack)-oldst) == L->stacksize-LJ_STACK_EXTRA-1, |
64 | "inconsistent stack size"); | ||
64 | st = (TValue *)lj_mem_realloc(L, tvref(L->stack), | 65 | st = (TValue *)lj_mem_realloc(L, tvref(L->stack), |
65 | (MSize)(oldsize*sizeof(TValue)), | 66 | (MSize)(oldsize*sizeof(TValue)), |
66 | (MSize)(realsize*sizeof(TValue))); | 67 | (MSize)(realsize*sizeof(TValue))); |
@@ -162,8 +163,9 @@ static void close_state(lua_State *L) | |||
162 | global_State *g = G(L); | 163 | global_State *g = G(L); |
163 | lj_func_closeuv(L, tvref(L->stack)); | 164 | lj_func_closeuv(L, tvref(L->stack)); |
164 | lj_gc_freeall(g); | 165 | lj_gc_freeall(g); |
165 | lua_assert(gcref(g->gc.root) == obj2gco(L)); | 166 | lj_assertG(gcref(g->gc.root) == obj2gco(L), |
166 | lua_assert(g->strnum == 0); | 167 | "main thread is not first GC object"); |
168 | lj_assertG(g->strnum == 0, "leaked %d strings", g->strnum); | ||
167 | lj_trace_freestate(g); | 169 | lj_trace_freestate(g); |
168 | #if LJ_HASFFI | 170 | #if LJ_HASFFI |
169 | lj_ctype_freestate(g); | 171 | lj_ctype_freestate(g); |
@@ -171,7 +173,9 @@ static void close_state(lua_State *L) | |||
171 | lj_mem_freevec(g, g->strhash, g->strmask+1, GCRef); | 173 | lj_mem_freevec(g, g->strhash, g->strmask+1, GCRef); |
172 | lj_buf_free(g, &g->tmpbuf); | 174 | lj_buf_free(g, &g->tmpbuf); |
173 | lj_mem_freevec(g, tvref(L->stack), L->stacksize, TValue); | 175 | lj_mem_freevec(g, tvref(L->stack), L->stacksize, TValue); |
174 | lua_assert(g->gc.total == sizeof(GG_State)); | 176 | lj_assertG(g->gc.total == sizeof(GG_State), |
177 | "memory leak of %lld bytes", | ||
178 | (long long)(g->gc.total - sizeof(GG_State))); | ||
175 | #ifndef LUAJIT_USE_SYSMALLOC | 179 | #ifndef LUAJIT_USE_SYSMALLOC |
176 | if (g->allocf == lj_alloc_f) | 180 | if (g->allocf == lj_alloc_f) |
177 | lj_alloc_destroy(g->allocd); | 181 | lj_alloc_destroy(g->allocd); |
@@ -283,17 +287,17 @@ lua_State *lj_state_new(lua_State *L) | |||
283 | setmrefr(L1->glref, L->glref); | 287 | setmrefr(L1->glref, L->glref); |
284 | setgcrefr(L1->env, L->env); | 288 | setgcrefr(L1->env, L->env); |
285 | stack_init(L1, L); /* init stack */ | 289 | stack_init(L1, L); /* init stack */ |
286 | lua_assert(iswhite(obj2gco(L1))); | 290 | lj_assertL(iswhite(obj2gco(L1)), "new thread object is not white"); |
287 | return L1; | 291 | return L1; |
288 | } | 292 | } |
289 | 293 | ||
290 | void LJ_FASTCALL lj_state_free(global_State *g, lua_State *L) | 294 | void LJ_FASTCALL lj_state_free(global_State *g, lua_State *L) |
291 | { | 295 | { |
292 | lua_assert(L != mainthread(g)); | 296 | lj_assertG(L != mainthread(g), "free of main thread"); |
293 | if (obj2gco(L) == gcref(g->cur_L)) | 297 | if (obj2gco(L) == gcref(g->cur_L)) |
294 | setgcrefnull(g->cur_L); | 298 | setgcrefnull(g->cur_L); |
295 | lj_func_closeuv(L, tvref(L->stack)); | 299 | lj_func_closeuv(L, tvref(L->stack)); |
296 | lua_assert(gcref(L->openupval) == NULL); | 300 | lj_assertG(gcref(L->openupval) == NULL, "stale open upvalues"); |
297 | lj_mem_freevec(g, tvref(L->stack), L->stacksize, TValue); | 301 | lj_mem_freevec(g, tvref(L->stack), L->stacksize, TValue); |
298 | lj_mem_freet(g, L); | 302 | lj_mem_freet(g, L); |
299 | } | 303 | } |