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

v1.12: JuliaInterpreter optimization seems to badly interact with new compressed linetable format #622

Closed
aviatesk opened this issue Mar 26, 2024 · 5 comments

Comments

@aviatesk
Copy link
Member

It looks like this "optimization" introduces a very bad interaction with the new lineinfo format:

# TODO: because of builtins.jl, for CodeInfos like
# %1 = Core.apply_type
# %2 = (%1)(args...)
# it would be best to *not* resolve the GlobalRef at %1
## Replace GlobalRefs with QuoteNodes
for (i, stmt) in enumerate(code.code)
if isa(stmt, GlobalRef)
code.code[i] = lookup_global_ref(stmt)
elseif isa(stmt, Expr)
if stmt.head === :call && stmt.args[1] === :cglobal # cglobal requires literals
continue
else
lookup_global_refs!(stmt)
code.code[i] = lookup_getproperties(code.code, stmt)
end
end
end

julia> using JuliaInterpreter

julia> fnone1() = nothing;

julia> let m = only(methods(fnone1))
           JuliaInterpreter.FrameCode(m, JuliaInterpreter.get_source(m); optimize=true).src.debuginfo
       end
Core.DebugInfo(Symbol("REPL[2]"), nothing, svec(), "\x01\0\0\0\0\0\0\0\0\0\0\0\x01\x01\0")

julia> fnone2() = nothing;

julia> let m = only(methods(fnone2))
           JuliaInterpreter.FrameCode(m, JuliaInterpreter.get_source(m); optimize=true).src.debuginfo
       end
Core.DebugInfo(Symbol("REPL[4]"), nothing, svec(), "")

Originally posted by @aviatesk in #606 (comment)

@timholy
Copy link
Member

timholy commented Jul 18, 2024

Is this still relevant? I get the same output in both cases. And it doesn't depend on the value of optimize.

@simeonschaub

This comment was marked as outdated.

@simeonschaub
Copy link
Collaborator

A better reproducer:

julia> using JuliaInterpreter

julia> fnone1() = nothing;

julia> let m = only(methods(fnone1))
           JuliaInterpreter.FrameCode(m, JuliaInterpreter.get_source(m); optimize=true).src.debuginfo
       end
Core.DebugInfo(Symbol("REPL[2]"), nothing, svec(), "\x01\0\0\0\0\0\0\0\0\0\0\0\x01\x01\0")

julia> @interpret (() -> nothing)()

julia> fnone2() = nothing;

julia> let m = only(methods(fnone2))
           JuliaInterpreter.FrameCode(m, JuliaInterpreter.get_source(m); optimize=true).src.debuginfo
       end
Core.DebugInfo(Symbol("REPL[5]"), nothing, svec(), "")

Note that if the nothing @interpret (() -> nothing)() is replaced with anything else (e.g. @interpret (() -> 7)()) this behavior disappears.

@simeonschaub
Copy link
Collaborator

It also doesn't seem to have anything to do with those particular optimizations since it still happens with optimize=false:

julia> using JuliaInterpreter

julia> fnone1() = nothing;

julia> let m = only(methods(fnone1))
           global fc = JuliaInterpreter.FrameCode(m, JuliaInterpreter.get_source(m); optimize=false)
           fc.src.debuginfo
       end
Core.DebugInfo(Symbol("REPL[2]"), nothing, svec(), "\x01\0\0\0\0\0\0\0\0\0\0\0\x01\x01\0")

julia> let fr = JuliaInterpreter.prepare_frame(fc, [], Core.svec())
           JuliaInterpreter.finish_and_return!(fr)
       end

julia> fnone2() = nothing;

julia> let m = only(methods(fnone2))
           JuliaInterpreter.FrameCode(m, JuliaInterpreter.get_source(m); optimize=false).src.debuginfo
       end
Core.DebugInfo(Symbol("REPL[5]"), nothing, svec(), "")

@simeonschaub
Copy link
Collaborator

Reported upstream as JuliaLang/julia#55688 with a non-JuliaInterpreter reproducer. Seems like we can close this issue here

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

3 participants