From 3cd9b56ae6002b4ef28d2467abd119606ae625d3 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 12 Jun 2019 10:31:38 -0300 Subject: Revamp around 'L->nCcalls' count The field 'L->nCcalls' now counts downwards, so that the C-stack limits do not depend on the stack size. --- testes/all.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'testes') diff --git a/testes/all.lua b/testes/all.lua index 2e6fe038..72121e8d 100644 --- a/testes/all.lua +++ b/testes/all.lua @@ -95,6 +95,8 @@ local function F (m) end end +local Cstacklevel + local showmem if not T then local max = 0 @@ -104,6 +106,7 @@ if not T then print(format(" ---- total memory: %s, max memory: %s ----\n", F(m), F(max))) end + Cstacklevel = function () return 0 end -- no info about stack level else showmem = function () T.checkmemory() @@ -117,9 +120,16 @@ else T.totalmem"string", T.totalmem"table", T.totalmem"function", T.totalmem"userdata", T.totalmem"thread")) end + + Cstacklevel = function () + local _, _, ncalls, nci = T.stacklevel() + return ncalls + nci -- number of free slots in the C stack + end end +local Cstack = Cstacklevel() + -- -- redefine dofile to run files through dump/undump -- @@ -211,6 +221,10 @@ debug.sethook(function (a) assert(type(a) == 'string') end, "cr") -- to survive outside block _G.showmem = showmem + +assert(Cstack == Cstacklevel(), + "should be at the same C-stack level it was when started the tests") + end --) local _G, showmem, print, format, clock, time, difftime, -- cgit v1.2.3-55-g6feb