diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-06-12 10:31:38 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-06-12 10:31:38 -0300 |
| commit | 3cd9b56ae6002b4ef28d2467abd119606ae625d3 (patch) | |
| tree | ac8d7f3986a3b318ccd4e1b6c8e7661d199c0de7 /testes | |
| parent | d2a9b4ffb86de29a201843edddfc0153a1846f96 (diff) | |
| download | lua-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.lua | 14 |
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 |
| 96 | end | 96 | end |
| 97 | 97 | ||
| 98 | local Cstacklevel | ||
| 99 | |||
| 98 | local showmem | 100 | local showmem |
| 99 | if not T then | 101 | if 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 | ||
| 107 | else | 110 | else |
| 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 | ||
| 120 | end | 128 | end |
| 121 | 129 | ||
| 122 | 130 | ||
| 131 | local 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 | |||
| 225 | assert(Cstack == Cstacklevel(), | ||
| 226 | "should be at the same C-stack level it was when started the tests") | ||
| 227 | |||
| 214 | end --) | 228 | end --) |
| 215 | 229 | ||
| 216 | local _G, showmem, print, format, clock, time, difftime, | 230 | local _G, showmem, print, format, clock, time, difftime, |
