mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 14:58:30 +00:00
Upgrade Lua to 5.4.3 (#217)
Based on https://github.com/lua/lua/releases/tag/v5.4.3 (commit eadd8c7).
This commit is contained in:
parent
3ac6576fe5
commit
a73e808b25
41 changed files with 464 additions and 264 deletions
40
third_party/lua/test/tracegc.lua
vendored
Normal file
40
third_party/lua/test/tracegc.lua
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
-- track collections
|
||||
|
||||
local M = {}
|
||||
|
||||
-- import list
|
||||
local setmetatable, stderr, collectgarbage =
|
||||
setmetatable, io.stderr, collectgarbage
|
||||
|
||||
_ENV = nil
|
||||
|
||||
local active = false
|
||||
|
||||
|
||||
-- each time a table is collected, remark it for finalization on next
|
||||
-- cycle
|
||||
local mt = {}
|
||||
function mt.__gc (o)
|
||||
stderr:write'.' -- mark progress
|
||||
if active then
|
||||
setmetatable(o, mt) -- remark object for finalization
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function M.start ()
|
||||
if not active then
|
||||
active = true
|
||||
setmetatable({}, mt) -- create initial object
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function M.stop ()
|
||||
if active then
|
||||
active = false
|
||||
collectgarbage() -- call finalizer for the last time
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
Loading…
Add table
Add a link
Reference in a new issue