Files
megasource/libs/LuaJIT/android/x86/jit/zone.lua
T
Miku AuahDark 44ba332ebe Rebuild LuaJIT and update LuaJIT build script.
* Clang for Windows is no longer required. Instead it requires GCC + multilib in the WSL distro.
* It will try to use Windows's installed LuaJIT, then fallback to WSL's LuaJIT. If none is found, an error will be thrown.
* Add luajit.h include file as byproducts.
2023-09-28 15:27:46 +08:00

46 lines
1002 B
Lua

----------------------------------------------------------------------------
-- LuaJIT profiler zones.
--
-- Copyright (C) 2005-2023 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
--
-- This module implements a simple hierarchical zone model.
--
-- Example usage:
--
-- local zone = require("jit.zone")
-- zone("AI")
-- ...
-- zone("A*")
-- ...
-- print(zone:get()) --> "A*"
-- ...
-- zone()
-- ...
-- print(zone:get()) --> "AI"
-- ...
-- zone()
--
----------------------------------------------------------------------------
local remove = table.remove
return setmetatable({
flush = function(t)
for i=#t,1,-1 do t[i] = nil end
end,
get = function(t)
return t[#t]
end
}, {
__call = function(t, zone)
if zone then
t[#t+1] = zone
else
return (assert(remove(t), "empty zone stack"))
end
end
})