Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local external = {}
- function system.DebugJIT(b)
- if b then
- jit.attach(function(what, tr, func, pc, otr, oex)
- if what == "abort" then
- setlogfile("jit_trace_debug")
- -- try to translate the external function to a name
- local ext_name = external[oex]
- if not ext_name then
- -- try once if it doesn't exist, maybe it'sa module
- for k, v in pairs(_G) do
- if type(v) == "function" then
- external[v] = k
- elseif type(v) == "table" then
- for k2, v in pairs(v) do
- if type(v) == "function" then
- external[v] = k .. "." .. k2
- end
- end
- end
- end
- ext_name = external[oex] or tostring(oex)
- end
- -- try to figure out a better name for the function that couldn't be jit compiled
- local lua_name = func
- local info = debug.getinfo(func)
- if info.source then
- local lua = vfs.Read(info.source:sub(2))
- if lua then
- lua_name = lua:explode("\n")[info.linedefined]
- end
- end
- if lua_name then
- lua_name = lua_name:explode("\n")[1]
- lua_name = lua_name:trim()
- else
- lua_name = func
- end
- if not ext_name then
- ext_name = table.concat({tostringargs(what, tr, func, pc, otr, oex)}, ", ")
- end
- logf("could not jit compile %q because of the external function %s", lua_name, ext_name)
- setlogfile()
- end
- end, "trace")
- else
- -- how to disable?
- jit.attach(function() end, "trace")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment