Lua処理系コード読み(7) luaC_checkGC
lgc.h
#define luaC_checkGC(L) { \ condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); \ if (G(L)->totalbytes >= G(L)->GCthreshold) \ luaC_step(L); }
総アロケート量が閾値を超えているときにGCステップの呼び出し。超えてなければ通常何もしない。
llimits.h
/* ** macro to control inclusion of some hard tests on stack reallocation */ #ifndef HARDSTACKTESTS #define condhardstacktests(x) ((void)0) #else #define condhardstacktests(x) x #endif
condhardstacktestsは、普段は何もしないマクロ。スタック領域のreallocを毎度毎度厳密にやりたいときだけマクロをオンにしてコンパイルする。