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

concretization of :foreigncall #277

Closed
goerch opened this issue Dec 3, 2021 · 3 comments · Fixed by #280
Closed

concretization of :foreigncall #277

goerch opened this issue Dec 3, 2021 · 3 comments · Fixed by #280

Comments

@goerch
Copy link
Contributor

goerch commented Dec 3, 2021

Testing with a reduced MWE from #224

using Libdl

let
    llvmpaths = filter(lib -> occursin(r"LLVM\b", basename(lib)), Libdl.dllist())
    if length(llvmpaths) != 1
        throw(ArgumentError("Found one or multiple LLVM libraries"))
    end
    libllvm = Libdl.dlopen(llvmpaths[1])
    gethostcpufeatures = Libdl.dlsym(libllvm, :LLVMGetHostCPUFeatures)
    features_cstring = ccall(gethostcpufeatures, Cstring, ())
    features = split(unsafe_string(features_cstring), ',')
    Libc.free(features_cstring)
    features
end

reveals

ERROR: BoundsError: attempt to access 31-element Vector{Bool} at index [32]
Stacktrace:
  [1] getindex
    @ .\array.jl:921 [inlined]
  [2] selective_eval!(recurse::Any, frame::JuliaInterpreter.Frame, isrequired::Vector{Bool}, istoplevel::Bool)
    @ LoweredCodeUtils C:\Users\Win10\.julia\packages\LoweredCodeUtils\jZY56\src\codeedges.jl:848
  [3] selective_eval_fromstart!
    @ C:\Users\Win10\.julia\packages\LoweredCodeUtils\jZY56\src\codeedges.jl:875 [inlined]
  [4] partially_interpret!(interp::JET.ConcreteInterpreter{JET.JETAnalyzer{JET.BasicPass{typeof(JET.basic_function_filter)}}, Expr}, mod::Module, src::Core.CodeInfo)
    @ JET C:\Users\Win10\Documents\GitHub\JET.jl\src\toplevel\virtualprocess.jl:799
  [5] _virtual_process!(toplevelex::Expr, filename::String, analyzer::JET.JETAnalyzer{JET.BasicPass{typeof(JET.basic_function_filter)}}, config::JET.ToplevelConfig{Expr}, context::Module, res::JET.VirtualProcessResult)
    @ JET C:\Users\Win10\Documents\GitHub\JET.jl\src\toplevel\virtualprocess.jl:630
  [6] _virtual_process!(s::String, filename::String, analyzer::JET.JETAnalyzer{JET.BasicPass{typeof(JET.basic_function_filter)}}, config::JET.ToplevelConfig{Expr}, context::Module, res::JET.VirtualProcessResult)
    @ JET C:\Users\Win10\Documents\GitHub\JET.jl\src\toplevel\virtualprocess.jl:432
  [7] virtual_process(x::String, filename::String, analyzer::JET.JETAnalyzer{JET.BasicPass{typeof(JET.basic_function_filter)}}, config::JET.ToplevelConfig{Expr})
    @ JET C:\Users\Win10\Documents\GitHub\JET.jl\src\toplevel\virtualprocess.jl:301
  [8] report_text(text::String, filename::String; analyzer::Type{JET.JETAnalyzer}, source::String, jetconfigs::Base.Pairs{Symbol, IOContext{Base.TTY}, Tuple{Symbol}, NamedTuple{(:toplevel_logger,), Tuple{IOContext{Base.TTY}}}})
    @ JET C:\Users\Win10\Documents\GitHub\JET.jl\src\JET.jl:1003
  [9] report_file(filename::String; __default_configs::Tuple{Pair{Symbol, IOContext{Base.TTY}}}, source::Nothing, jetconfigs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ JET C:\Users\Win10\Documents\GitHub\JET.jl\src\JET.jl:826
 [10] report_file(filename::String)
    @ JET C:\Users\Win10\Documents\GitHub\JET.jl\src\JET.jl:801
 [11] top-level scope
    @ none:1
@goerch
Copy link
Contributor Author

goerch commented Dec 3, 2021

It looks to me as if Frame(mod, src) in

    selective_eval_fromstart!(interp, Frame(mod, src), concretize, #= istoplevel =# true)

might change the length of src?

aviatesk pushed a commit that referenced this issue Dec 4, 2021
@aviatesk
Copy link
Owner

aviatesk commented Dec 4, 2021

BoundsError is fixed, but we still need to figure out a way to successfully interpret :foreigncall expressions.

@aviatesk aviatesk changed the title Bounds error in selective_eval! concretization of :foreigncall Dec 4, 2021
goerch added a commit to goerch/JET.jl that referenced this issue Dec 4, 2021
Use optimized JuliaInterpreter frames to support foreign calls. Fixes aviatesk#277 and aviatesk#224, but breaks `eval` tests.
goerch added a commit to goerch/JET.jl that referenced this issue Dec 5, 2021
@goerch
Copy link
Contributor Author

goerch commented Dec 5, 2021

Works after @aviatesk `s last commit.

@goerch goerch closed this as completed Dec 5, 2021
aviatesk pushed a commit that referenced this issue Dec 5, 2021
goerch added a commit to goerch/JET.jl that referenced this issue Dec 5, 2021
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

Successfully merging a pull request may close this issue.

2 participants