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

@interpreter^2 fails #228

Open
KristofferC opened this issue Mar 28, 2019 · 4 comments
Open

@interpreter^2 fails #228

KristofferC opened this issue Mar 28, 2019 · 4 comments

Comments

@KristofferC
Copy link
Member

Would be cool if this would work:

julia> f() = @interpret 1+1
f (generic function with 1 method)

julia> @interpret f()
ERROR: TypeError: in typeassert, expected JuliaInterpreter.FrameData, got Nothing
Stacktrace:
 [1] maybe_evaluate_builtin(::Frame, ::Expr, ::Bool) at C:\Users\Kristoffer\.julia\packages\JuliaInterpreter\ZrOBa\src\builtins-julia1.1.jl:162
 [2] #evaluate_call_recurse!#37(::Bool, ::Function, ::Any, ::Frame, ::Expr) at C:\Users\Kristoffer\.julia\packages\JuliaInterpreter\ZrOBa\src\interpret.jl:208
 [3] evaluate_call_recurse! at C:\Users\Kristoffer\.julia\packages\JuliaInterpreter\ZrOBa\src\interpret.jl:205 [inlined]
 [4] eval_rhs(::Any, ::Frame, ::Expr) at C:\Users\Kristoffer\.julia\packages\JuliaInterpreter\ZrOBa\src\interpret.jl:371
 [5] step_expr!(::Any, ::Frame, ::Any, ::Bool) at C:\Users\Kristoffer\.julia\packages\JuliaInterpreter\ZrOBa\src\interpret.jl:504
...

Might be problematic with our globals and so on.

@KristofferC
Copy link
Member Author

KristofferC commented Mar 31, 2019

This now works if we disable recycle:

julia> f() = @interpret 1+1
f (generic function with 1 method)

julia> @interpret f()
2

If I add it back (note that I run the check to see that we are not double adding a FrameData):

julia> JuliaInterpreter.debug_recycle[] = true;

julia> @interpret f()
ERROR: add_int: types of a and b must match
Stacktrace:
 [1] #evaluate_call_recurse!#37(::Bool, ::Function, ::Any, ::Frame, ::Expr) at C:\Users\Kristoffer\Debugging\JuliaInterpreter\src\interpret.jl:216
 [2] evaluate_call_recurse! at C:\Users\Kristoffer\Debugging\JuliaInterpreter\src\interpret.jl:205 [inlined]
 [3] eval_rhs(::Any, ::Frame, ::Expr) at C:\Users\Kristoffer\Debugging\JuliaInterpreter\src\interpret.jl:371

We have some kind of corruption because the value of a here is the frame itself which likely comes from the outer @interpret call. So I'm guessing the recycles from the other and inner interpretation are fighting with each other somehow. Cool that it is possible to do @interpret^2 now though.

Edit: Changing f() to @interpret sin(2.0) and it starts to fail.

@KristofferC
Copy link
Member Author

Here is a MWE of an error (with recycle disabled):

struct S
    a::Float64
end
f() = @interpret S(1.0)
julia> f()
S(1.0)

julia> @interpret f()
S(0.0)

@KristofferC
Copy link
Member Author

KristofferC commented Apr 2, 2019

For anyone that would like to debug the nested interpretation and want to keep your sanity. Duplicate JuliaInterpreter into a new package (JuliaInterpreter2) and do something like

f() = JuliaInterpreter2.@interpret
@interpret f()

Otherwise you don't know which print statements comes from the innner or outer interpretation etc...

@KristofferC
Copy link
Member Author

I think there might be confusion with SSAValues from the outer interpreter getting mixed with SSAValues of the inner interpreter. Presumably, we would need some "tagging" system to tag SSAVaulues from differents nesting level of interpretation.

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

1 participant