diff --git a/VM/include/lua.h b/VM/include/lua.h index 8e7d6468..a158485a 100644 --- a/VM/include/lua.h +++ b/VM/include/lua.h @@ -358,6 +358,8 @@ struct lua_Callbacks void (*debugstep)(lua_State* L, lua_Debug* ar); /* gets called after each instruction in single step mode */ void (*debuginterrupt)(lua_State* L, lua_Debug* ar); /* gets called when thread execution is interrupted by break in another thread */ void (*debugprotectederror)(lua_State* L); /* gets called when protected call results in an error */ + + void (*gc)(lua_State* L); /* gets called when a garbage collection cycle starts */ }; LUA_API lua_Callbacks* lua_callbacks(lua_State* L); diff --git a/VM/src/lgc.cpp b/VM/src/lgc.cpp index 6553009f..501a68c3 100644 --- a/VM/src/lgc.cpp +++ b/VM/src/lgc.cpp @@ -617,6 +617,8 @@ static void markroot(lua_State* L) markvalue(g, registry(L)); markmt(g); g->gcstate = GCSpropagate; + if (g->cb.gc) + g->cb.gc(L); } static size_t remarkupvals(global_State* g)