Skip to content

Commit

Permalink
fix precompile script, REPL
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash committed Nov 18, 2024
1 parent 854129d commit 692a21b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 32 deletions.
2 changes: 1 addition & 1 deletion Compiler/src/ssair/inlining.jl
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ function compileable_specialization(code::Union{MethodInstance,CodeInstance}, ef
#println("missing code for ", mi_invoke, " for ", mi)
code = mi_invoke
end
add_inlining_edge!(et, code) # to the dispatch lookup
add_inlining_edge!(et, code) # to the code and edges
return InvokeCase(code, effects, info)
end

Expand Down
2 changes: 1 addition & 1 deletion base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4191,7 +4191,7 @@ end

# Variants that work for `invoke`d calls for which the signature may not be sufficient
precompile(mi::Core.MethodInstance, world::UInt=get_world_counter()) =
(ccall(:jl_compile_method_instance, Cvoid, (Any, Any, UInt), mi, C_NULL, world); return true)
(ccall(:jl_compile_method_instance, Cvoid, (Any, Ptr{Cvoid}, UInt), mi, C_NULL, world); return true)

"""
precompile(f, argtypes::Tuple{Vararg{Any}}, m::Method)
Expand Down
2 changes: 1 addition & 1 deletion src/gf.c
Original file line number Diff line number Diff line change
Expand Up @@ -3196,7 +3196,7 @@ JL_DLLEXPORT int jl_compile_hint(jl_tupletype_t *types)
if (mi == NULL)
return 0;
JL_GC_PROMISE_ROOTED(mi);
jl_compile_method_instance(mi, NULL, world);
jl_compile_method_instance(mi, types, world);
return 1;
}

Expand Down
36 changes: 7 additions & 29 deletions stdlib/REPL/src/precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@ function repl_workload()
# wait for the definitive prompt before start writing to the TTY
check_errors(readuntil(output_copy, JULIA_PROMPT))
write(debug_output, "\n#### REPL STARTED ####\n")
sleep(0.1)
sleep(0.01)
check_errors(readavailable(output_copy))
# Input our script
precompile_lines = split(repl_script::String, '\n'; keepempty=false)
curr = 0
for l in precompile_lines
sleep(0.1)
sleep(0.01) # try to let a bit of output accumulate before reading again
curr += 1
# consume any other output
bytesavailable(output_copy) > 0 && check_errors(readavailable(output_copy))
Expand All @@ -168,7 +168,7 @@ function repl_workload()
occursin(PKG_PROMPT, strbuf) && break
occursin(SHELL_PROMPT, strbuf) && break
occursin(HELP_PROMPT, strbuf) && break
sleep(0.1)
sleep(0.01) # try to let a bit of output accumulate before reading again
end
notify(repl_init_event)
check_errors(strbuf)
Expand All @@ -187,37 +187,15 @@ function repl_workload()
nothing
end

# Copied from PrecompileTools.jl
let
function check_edges(node)
parentmi = node.mi_info.mi
for child in node.children
childmi = child.mi_info.mi
if !(isdefined(childmi, :backedges) && parentmi childmi.backedges)
precompile(childmi.specTypes)
end
check_edges(child)
end
end

if Base.generating_output() && Base.JLOptions().use_pkgimages != 0
Core.Compiler.Timings.reset_timings()
Core.Compiler.__set_measure_typeinf(true)
try
repl_workload()
finally
Core.Compiler.__set_measure_typeinf(false)
Core.Compiler.Timings.close_current_timer()
end
roots = Core.Compiler.Timings._timings[1].children
for child in roots
precompile(child.mi_info.mi.specTypes)
check_edges(child)
end
repl_workload()
precompile(Tuple{typeof(Base.setindex!), Base.Dict{Any, Any}, Any, Int})
precompile(Tuple{typeof(Base.delete!), Base.Set{Any}, String})
precompile(Tuple{typeof(Base.:(==)), Char, String})
precompile(Tuple{typeof(Base.reseteof), Base.TTY})
#for child in copy(Base.newly_inferred)
# precompile((child::Base.CodeInstance).def)
#end
end
end

Expand Down

0 comments on commit 692a21b

Please sign in to comment.