diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-12-27 12:09:11 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-12-27 12:09:11 -0300 |
commit | 12b6f610b0f1b4157c04f0db264f1f1d0634709b (patch) | |
tree | 198881cf4ac938aa9082fe7781d575e359d9bf09 /lapi.c | |
parent | e81f586001d767c8de9b760ae2e2c3b5da1542c6 (diff) | |
download | lua-12b6f610b0f1b4157c04f0db264f1f1d0634709b.tar.gz lua-12b6f610b0f1b4157c04f0db264f1f1d0634709b.tar.bz2 lua-12b6f610b0f1b4157c04f0db264f1f1d0634709b.zip |
Several tweaks in the garbage collector
- back with step size in collectgarbage("step")
- adjustments in defaults for some GC parameters
- adjustments in 'luaO_codeparam'
Diffstat (limited to 'lapi.c')
-rw-r--r-- | lapi.c | 18 |
1 files changed, 12 insertions, 6 deletions
@@ -416,10 +416,11 @@ LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) { | |||
416 | luaC_checkGC(L); | 416 | luaC_checkGC(L); |
417 | o = index2value(L, idx); /* previous call may reallocate the stack */ | 417 | o = index2value(L, idx); /* previous call may reallocate the stack */ |
418 | } | 418 | } |
419 | if (len != NULL) | ||
420 | *len = tsslen(tsvalue(o)); | ||
421 | lua_unlock(L); | 419 | lua_unlock(L); |
422 | return getstr(tsvalue(o)); | 420 | if (len != NULL) |
421 | return getlstr(tsvalue(o), *len); | ||
422 | else | ||
423 | return getstr(tsvalue(o)); | ||
423 | } | 424 | } |
424 | 425 | ||
425 | 426 | ||
@@ -1174,11 +1175,16 @@ LUA_API int lua_gc (lua_State *L, int what, ...) { | |||
1174 | } | 1175 | } |
1175 | case LUA_GCSTEP: { | 1176 | case LUA_GCSTEP: { |
1176 | lu_byte oldstp = g->gcstp; | 1177 | lu_byte oldstp = g->gcstp; |
1178 | l_obj n = va_arg(argp, int); | ||
1179 | int work = 0; /* true if GC did some work */ | ||
1177 | g->gcstp = 0; /* allow GC to run (other bits must be zero here) */ | 1180 | g->gcstp = 0; /* allow GC to run (other bits must be zero here) */ |
1178 | luaC_step(L); /* run one basic step */ | 1181 | if (n <= 0) |
1179 | g->gcstp = oldstp; /* restore previous state */ | 1182 | n = g->GCdebt; /* force to run one basic step */ |
1180 | if (g->gcstate == GCSpause) /* end of cycle? */ | 1183 | luaE_setdebt(g, g->GCdebt - n); |
1184 | luaC_condGC(L, (void)0, work = 1); | ||
1185 | if (work && g->gcstate == GCSpause) /* end of cycle? */ | ||
1181 | res = 1; /* signal it */ | 1186 | res = 1; /* signal it */ |
1187 | g->gcstp = oldstp; /* restore previous state */ | ||
1182 | break; | 1188 | break; |
1183 | } | 1189 | } |
1184 | case LUA_GCISRUNNING: { | 1190 | case LUA_GCISRUNNING: { |