aboutsummaryrefslogtreecommitdiff
path: root/testes
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-06-12 10:31:38 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-06-12 10:31:38 -0300
commit3cd9b56ae6002b4ef28d2467abd119606ae625d3 (patch)
treeac8d7f3986a3b318ccd4e1b6c8e7661d199c0de7 /testes
parentd2a9b4ffb86de29a201843edddfc0153a1846f96 (diff)
downloadlua-3cd9b56ae6002b4ef28d2467abd119606ae625d3.tar.gz
lua-3cd9b56ae6002b4ef28d2467abd119606ae625d3.tar.bz2
lua-3cd9b56ae6002b4ef28d2467abd119606ae625d3.zip
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.
Diffstat (limited to 'testes')
-rw-r--r--testes/all.lua14
1 files changed, 14 insertions, 0 deletions
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)
95 end 95 end
96end 96end
97 97
98local Cstacklevel
99
98local showmem 100local showmem
99if not T then 101if not T then
100 local max = 0 102 local max = 0
@@ -104,6 +106,7 @@ if not T then
104 print(format(" ---- total memory: %s, max memory: %s ----\n", 106 print(format(" ---- total memory: %s, max memory: %s ----\n",
105 F(m), F(max))) 107 F(m), F(max)))
106 end 108 end
109 Cstacklevel = function () return 0 end -- no info about stack level
107else 110else
108 showmem = function () 111 showmem = function ()
109 T.checkmemory() 112 T.checkmemory()
@@ -117,9 +120,16 @@ else
117 T.totalmem"string", T.totalmem"table", T.totalmem"function", 120 T.totalmem"string", T.totalmem"table", T.totalmem"function",
118 T.totalmem"userdata", T.totalmem"thread")) 121 T.totalmem"userdata", T.totalmem"thread"))
119 end 122 end
123
124 Cstacklevel = function ()
125 local _, _, ncalls, nci = T.stacklevel()
126 return ncalls + nci -- number of free slots in the C stack
127 end
120end 128end
121 129
122 130
131local Cstack = Cstacklevel()
132
123-- 133--
124-- redefine dofile to run files through dump/undump 134-- redefine dofile to run files through dump/undump
125-- 135--
@@ -211,6 +221,10 @@ debug.sethook(function (a) assert(type(a) == 'string') end, "cr")
211-- to survive outside block 221-- to survive outside block
212_G.showmem = showmem 222_G.showmem = showmem
213 223
224
225assert(Cstack == Cstacklevel(),
226 "should be at the same C-stack level it was when started the tests")
227
214end --) 228end --)
215 229
216local _G, showmem, print, format, clock, time, difftime, 230local _G, showmem, print, format, clock, time, difftime,