Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lj-releng: avoid filtering Lua builtin function names inside user Lua function bodies #11

Open
agentzh opened this issue Mar 25, 2017 · 1 comment

Comments

@agentzh
Copy link
Member

agentzh commented Mar 25, 2017

Right now the lj-releng tool will ignore use of Lua global variables with the name matching one of the Lua builtin functions. This will hide those use of global variables on hot Lua code paths, as in

local function foo (msg)
    assert(type(msg) == "string")
    print(msg)
end

For this minimal Lua program, the lj-releng would fail to report the use of Lua global variables inside the foo user function, which are assert, type, and print. The "global-clean" form should be

local type = type
local assert = assert
local print = print

local function foo (msg)
    assert(type(msg) == "string")
    print(msg)
end

Under the hood, lj-releng should only filter builtin function names for bytecodes outside any Lua function bodies. This requires lj-releng to have some knowledge about the specific bytecode sequences used for Lua function prologue and epilogue during the scan.

@ladislavmacoun
Copy link
Contributor

This issue seems deprecated. I tried to run lj-releng with the above-mentioned example and it did report all use of globals as expected, or am I missing something?

openresty-devel-utils git:(master) cat test.lua
local function foo (msg)
    assert(type(msg) == "string")
    print(msg)
end
openresty-devel-utils git:(master) ./lj-releng -s test.lua
ERROR: test.lua: line 2: getting the Lua global "assert"
ERROR: test.lua: line 2: getting the Lua global "type"
ERROR: test.lua: line 3: getting the Lua global "print"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants