Skip to content

Commit 8fd92c2

Browse files
authored
Merge pull request #561 from JuliaDebug/kc/cckey
also count the number of arguments to cache the compiled ccall
2 parents ca5c050 + ab3348d commit 8fd92c2

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

src/optimize.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ function build_compiled_foreigncall!(stmt::Expr, code, sparams::Vector{Symbol},
317317
end
318318
args = stmt.args[6:end]
319319
# When the ccall is dynamic we pass the pointer as an argument so can reuse the function
320-
cc_key = ((dynamic_ccall ? :ptr : cfunc), RetType, ArgType, evalmod, length(sparams)) # compiled call key
320+
cc_key = ((dynamic_ccall ? :ptr : cfunc), RetType, ArgType, evalmod, length(sparams), length(args)) # compiled call key
321321
f = get(compiled_calls, cc_key, nothing)
322322
if f === nothing
323323
ArgType = Expr(:tuple, Any[parametric_type_to_expr(t) for t in ArgType::SimpleVector]...)

test/core.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ using Test
2929
@test JuliaInterpreter.get_return_node(stmt) isa Core.SSAValue
3030

3131
@test string(JuliaInterpreter.parametric_type_to_expr(Base.Iterators.Stateful{String}))
32-
("Base.Iterators.Stateful{String, VS}", "(Base.Iterators).Stateful{String, VS}")
32+
("Base.Iterators.Stateful{String, VS}", "(Base.Iterators).Stateful{String, VS}", "Base.Iterators.Stateful{String, VS, N}")
3333
end

test/interpret.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,3 +974,8 @@ using LoopVectorization
974974
f_lv!(B)
975975
@test A B
976976
end
977+
978+
@testset "nargs foreigncall #560" begin
979+
@test (@interpret string("", "pcre_h.jl")) == string("", "pcre_h.jl")
980+
@test (@interpret Base.strcat("", "build_h.jl")) == Base.strcat("", "build_h.jl")
981+
end

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ using JuliaInterpreter
22
using Test
33
using Logging
44

5-
include("check_builtins.jl")
65

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

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

1514
@testset "Main tests" begin
15+
include("check_builtins.jl")
1616
include("core.jl")
1717
include("interpret.jl")
1818
include("toplevel.jl")

0 commit comments

Comments
 (0)