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

TailCall bug #5

Closed
SquidDev opened this issue Mar 14, 2015 · 2 comments
Closed

TailCall bug #5

SquidDev opened this issue Mar 14, 2015 · 2 comments
Labels

Comments

@SquidDev
Copy link
Member

Remove Fix TailcallVarargs

This isn't really needed, so can be removed. Most of the time .eval() is called on it straight away.

local function a() 
  return error("Um") 
end
print(select(2, xpcall(a, debug.traceback))) -- Error occurs here, when it should occur at line 2.

--[[
input:2: Um
stack traceback:
    [C]: in function 'error'
    input:2: in function <input:1>
    [C]: in function 'xpcall'
    input:4: in main chunk
]]

Fix string bug

By default encodeTo/decodeFromUtf8 should not be used and a straight new String(bytes) should be used.

@SquidDev SquidDev added this to the 0.1 milestone Mar 14, 2015
@SquidDev
Copy link
Member Author

SquidDev commented May 1, 2015

Sadly none of this can be implemented. The UTF8 code is broken but you can't change from binary to Java's String anyway. I'm going to have to think of another way to get around issues with TailCallVarargs as otherwise we will be adding to the stack, even on a varargs function.

The original Lua source is pretty confusing, though it might be worth reading through it to find how tailcalls are handled.

The opcode is executed in this function and a tail call count is stored here.

KopiLua's source is here. This might be easier as there is no messing about with pointers.

@SquidDev SquidDev added the bug label May 1, 2015
@SquidDev SquidDev changed the title Changes to LuaJ TailCall bug May 1, 2015
@SquidDev
Copy link
Member Author

SquidDev commented May 1, 2015

This occurs because the function we are calling is a c function, so tail call optimizations don't occur. If we were to implement this ourselves, then we would loose the ability to tail call Java functions. Neither method seems ideal.

@SquidDev SquidDev closed this as completed Jul 6, 2015
@SquidDev SquidDev removed this from the 0.1 milestone Mar 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant