mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-07 22:25:46 +01:00
Customize Lua GC, add object-memory-lock API.
Add custom API to prevent Lua Objects from being garbage collected. This is intended to for Ardour LuaBridge bindings (~1MB Objects: tables, functions and userdata). The bindings are persistent and the gc can skip them in mark & sweep phases. This is a significant performance improvement for garbage collection. Note. The next version of Lua (5.4) will come with a generational-gc rather than an incremental, so extending the API at this point in time is acceptable.
This commit is contained in:
parent
2092934721
commit
f2ca0c144b
4 changed files with 16 additions and 3 deletions
|
|
@ -210,8 +210,14 @@ GCObject *luaC_newobj (lua_State *L, int tt, size_t sz) {
|
|||
GCObject *o = cast(GCObject *, luaM_newobject(L, novariant(tt), sz));
|
||||
o->marked = luaC_white(g);
|
||||
o->tt = tt;
|
||||
o->next = g->allgc;
|
||||
g->allgc = o;
|
||||
if (g->gcmlock) {
|
||||
white2gray(o); /* gray forever */
|
||||
o->next = g->fixedgc;
|
||||
g->fixedgc = o;
|
||||
} else {
|
||||
o->next = g->allgc;
|
||||
g->allgc = o;
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
|
|
@ -1175,4 +1181,7 @@ void luaC_fullgc (lua_State *L, int isemergency) {
|
|||
|
||||
/* }====================================================== */
|
||||
|
||||
|
||||
LUA_API void lua_mlock (lua_State *L, int en) {
|
||||
global_State *g = G(L);
|
||||
g->gcmlock = en;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue