Skip to content

Commit

Permalink
Merge pull request #561 from JuliaDebug/kc/cckey
Browse files Browse the repository at this point in the history
also count the number of arguments to cache the compiled ccall
  • Loading branch information
KristofferC authored Dec 29, 2022
2 parents ca5c050 + ab3348d commit 8fd92c2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/optimize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ function build_compiled_foreigncall!(stmt::Expr, code, sparams::Vector{Symbol},
end
args = stmt.args[6:end]
# When the ccall is dynamic we pass the pointer as an argument so can reuse the function
cc_key = ((dynamic_ccall ? :ptr : cfunc), RetType, ArgType, evalmod, length(sparams)) # compiled call key
cc_key = ((dynamic_ccall ? :ptr : cfunc), RetType, ArgType, evalmod, length(sparams), length(args)) # compiled call key
f = get(compiled_calls, cc_key, nothing)
if f === nothing
ArgType = Expr(:tuple, Any[parametric_type_to_expr(t) for t in ArgType::SimpleVector]...)
Expand Down
2 changes: 1 addition & 1 deletion test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ using Test
@test JuliaInterpreter.get_return_node(stmt) isa Core.SSAValue

@test string(JuliaInterpreter.parametric_type_to_expr(Base.Iterators.Stateful{String}))
("Base.Iterators.Stateful{String, VS}", "(Base.Iterators).Stateful{String, VS}")
("Base.Iterators.Stateful{String, VS}", "(Base.Iterators).Stateful{String, VS}", "Base.Iterators.Stateful{String, VS, N}")
end
5 changes: 5 additions & 0 deletions test/interpret.jl
Original file line number Diff line number Diff line change
Expand Up @@ -974,3 +974,8 @@ using LoopVectorization
f_lv!(B)
@test A B
end

@testset "nargs foreigncall #560" begin
@test (@interpret string("", "pcre_h.jl")) == string("", "pcre_h.jl")
@test (@interpret Base.strcat("", "build_h.jl")) == Base.strcat("", "build_h.jl")
end
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ using JuliaInterpreter
using Test
using Logging

include("check_builtins.jl")

@test isempty(detect_ambiguities(JuliaInterpreter, Base, Core))

Expand All @@ -13,6 +12,7 @@ end
Core.eval(JuliaInterpreter, :(debug_mode() = true))

@testset "Main tests" begin
include("check_builtins.jl")
include("core.jl")
include("interpret.jl")
include("toplevel.jl")
Expand Down

0 comments on commit 8fd92c2

Please sign in to comment.