mirror of https://github.com/rusefi/lua.git
first version of control for the generational collector
This commit is contained in:
parent
a45945b6d5
commit
c7bdc0e0e8
6
lapi.c
6
lapi.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lapi.c,v 2.261 2017/04/06 13:08:56 roberto Exp roberto $
|
** $Id: lapi.c,v 2.262 2017/04/11 18:41:09 roberto Exp roberto $
|
||||||
** Lua API
|
** Lua API
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -1098,6 +1098,10 @@ LUA_API int lua_gc (lua_State *L, int what, int data) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LUA_GCGEN: {
|
case LUA_GCGEN: {
|
||||||
|
lu_byte aux = data & 0xff;
|
||||||
|
g->genminormul = (aux == 0) ? 20 : aux;
|
||||||
|
aux = (data >> 8) & 0xff;
|
||||||
|
g->genmajormul = (aux == 0) ? 100 : aux;
|
||||||
luaC_changemode(L, KGC_GEN);
|
luaC_changemode(L, KGC_GEN);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
12
lgc.c
12
lgc.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lgc.c,v 2.221 2017/04/11 19:00:27 roberto Exp roberto $
|
** $Id: lgc.c,v 2.222 2017/04/12 18:01:40 roberto Exp roberto $
|
||||||
** Garbage Collector
|
** Garbage Collector
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -1158,6 +1158,7 @@ static void entergen (lua_State *L, global_State *g) {
|
||||||
|
|
||||||
finishgencycle(L, g);
|
finishgencycle(L, g);
|
||||||
g->gckind = KGC_GEN;
|
g->gckind = KGC_GEN;
|
||||||
|
g->GCestimate = gettotalbytes(g); /* base for memory control */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1205,10 +1206,17 @@ static void fullgen (lua_State *L, global_State *g) {
|
||||||
** collection. (We still has to implement the full control.)
|
** collection. (We still has to implement the full control.)
|
||||||
*/
|
*/
|
||||||
static void genstep (lua_State *L, global_State *g) {
|
static void genstep (lua_State *L, global_State *g) {
|
||||||
|
lu_mem majorbase = g->GCestimate;
|
||||||
|
lua_checkmemory(L);
|
||||||
|
if (gettotalbytes(g) > (majorbase / 100) * (100 + g->genmajormul))
|
||||||
|
fullgen(L, g);
|
||||||
|
else {
|
||||||
lu_mem mem;
|
lu_mem mem;
|
||||||
youngcollection(L, g);
|
youngcollection(L, g);
|
||||||
mem = gettotalbytes(g);
|
mem = gettotalbytes(g);
|
||||||
luaE_setdebt(g, -((mem / 100) * 20));
|
luaE_setdebt(g, -((mem / 100) * g->genminormul));
|
||||||
|
g->GCestimate = mem;
|
||||||
|
}
|
||||||
lua_checkmemory(L);
|
lua_checkmemory(L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
4
lstate.h
4
lstate.h
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lstate.h,v 2.136 2017/04/05 16:50:51 roberto Exp roberto $
|
** $Id: lstate.h,v 2.137 2017/04/11 18:41:09 roberto Exp roberto $
|
||||||
** Global State
|
** Global State
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -148,6 +148,8 @@ typedef struct global_State {
|
||||||
lu_byte currentwhite;
|
lu_byte currentwhite;
|
||||||
lu_byte gcstate; /* state of garbage collector */
|
lu_byte gcstate; /* state of garbage collector */
|
||||||
lu_byte gckind; /* kind of GC running */
|
lu_byte gckind; /* kind of GC running */
|
||||||
|
lu_byte genminormul; /* control for minor generational collections */
|
||||||
|
lu_byte genmajormul; /* control for major generational collections */
|
||||||
lu_byte gcrunning; /* true if GC is running */
|
lu_byte gcrunning; /* true if GC is running */
|
||||||
GCObject *allgc; /* list of all collectable objects */
|
GCObject *allgc; /* list of all collectable objects */
|
||||||
GCObject **sweepgc; /* current position of sweep in list */
|
GCObject **sweepgc; /* current position of sweep in list */
|
||||||
|
|
Loading…
Reference in New Issue