From 337f017a6d091a91d8a9f228d301316193e6e6f0 Mon Sep 17 00:00:00 2001 From: Kristoffer Date: Thu, 29 Dec 2022 21:39:24 +0100 Subject: [PATCH 1/3] also count the number of arguments to cache the compiled ccall --- src/optimize.jl | 2 +- test/interpret.jl | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/optimize.jl b/src/optimize.jl index 7294c8a751180..7a2dda2df12f2 100644 --- a/src/optimize.jl +++ b/src/optimize.jl @@ -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]...) diff --git a/test/interpret.jl b/test/interpret.jl index 5d338d3410c2d..d2a1763268732 100644 --- a/test/interpret.jl +++ b/test/interpret.jl @@ -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 From 7c312ef933aabed5415e6a8dfa2fc3fe4affde7a Mon Sep 17 00:00:00 2001 From: Kristoffer Date: Thu, 29 Dec 2022 22:05:29 +0100 Subject: [PATCH 2/3] move builtin check into main testset --- test/runtests.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/runtests.jl b/test/runtests.jl index ba8f166eb0d4b..65073af05fae9 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2,7 +2,6 @@ using JuliaInterpreter using Test using Logging -include("check_builtins.jl") @test isempty(detect_ambiguities(JuliaInterpreter, Base, Core)) @@ -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") From ab3348d35af07b578a3aff510186da0e1978e867 Mon Sep 17 00:00:00 2001 From: Kristoffer Date: Thu, 29 Dec 2022 22:05:51 +0100 Subject: [PATCH 3/3] allow for an extra parameter in `Iterators.Stateful` --- test/core.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/core.jl b/test/core.jl index a8905690d4798..42b1cbd286c78 100644 --- a/test/core.jl +++ b/test/core.jl @@ -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