Skip to content

Commit 0a78c30

Browse files
authored
Merge pull request #463 from JuliaDebug/teh/run_compiled_revise
Push a few ccalling methods onto compiled_methods
2 parents 841a613 + 853e75c commit 0a78c30

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/optimize.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,16 @@ function optimize!(code::CodeInfo, scope)
183183
arg1 = stmt.args[1]
184184
if (arg1 === :llvmcall || lookup_stmt(code.code, arg1) === Base.llvmcall) && isempty(sparams) && scope isa Method
185185
nargs = length(stmt.args)-4
186-
delete_idx = build_compiled_call!(stmt, Base.llvmcall, code, idx, nargs, sparams, evalmod)
186+
# Call via `invokelatest` to avoid compiling it until we need it
187+
delete_idx = Base.invokelatest(build_compiled_call!, stmt, Base.llvmcall, code, idx, nargs, sparams, evalmod)
187188
delete_idx === nothing && error("llvmcall must be compiled, but exited early from build_compiled_call!")
188189
push!(foreigncalls_idx, idx)
189190
append!(delete_idxs, delete_idx)
190191
end
191192
elseif stmt.head === :foreigncall && scope isa Method
192193
nargs = foreigncall_version == 0 ? stmt.args[5]::Int : length(stmt.args[3]::SimpleVector)
193-
delete_idx = build_compiled_call!(stmt, :ccall, code, idx, nargs, sparams, evalmod)
194+
# Call via `invokelatest` to avoid compiling it until we need it
195+
delete_idx = Base.invokelatest(build_compiled_call!, stmt, :ccall, code, idx, nargs, sparams, evalmod)
194196
if delete_idx !== nothing
195197
push!(foreigncalls_idx, idx)
196198
append!(delete_idxs, delete_idx)

src/packagedef.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,13 @@ function set_compiled_methods()
106106
end
107107
end
108108

109+
# This is about performance, not safety (issue #462)
110+
push!(compiled_methods, which(nameof, (Module,)))
111+
push!(compiled_methods, which(Base.binding_module, (Module, Symbol)))
112+
push!(compiled_methods, which(Base.unsafe_pointer_to_objref, (Ptr,)))
113+
push!(compiled_methods, which(Vector{Int}, (UndefInitializer, Int)))
114+
push!(compiled_methods, which(fill!, (Vector{Int8}, Int)))
115+
109116
###########
110117
# Modules #
111118
###########

0 commit comments

Comments
 (0)