diff --git a/base/Base.jl b/base/Base.jl index 1d481e2cdaee66..878448c3e3964f 100644 --- a/base/Base.jl +++ b/base/Base.jl @@ -391,6 +391,42 @@ end_base_include = time_ns() const _sysimage_modules = PkgId[] in_sysimage(pkgid::PkgId) = pkgid in _sysimage_modules +# Precompiles for Revise +# TODO: move these to contrib/generate_precompile.jl +# The problem is they don't work there +let m = which(+, (Int, Int)) + while true # defeat interpreter heuristic to force compilation + delete!(push!(Set{Method}(), m), m) + copy(Core.Compiler.retrieve_code_info(Core.Compiler.specialize_method(m, [Int, Int], Core.svec()))) + + empty!(Set()) + push!(push!(Set{Union{GlobalRef,Symbol}}(), :two), GlobalRef(Base, :two)) + (setindex!(Dict{String,Base.PkgId}(), Base.PkgId(Base), "file.jl"))["file.jl"] + (setindex!(Dict{Symbol,Vector{Int}}(), [1], :two))[:two] + (setindex!(Dict{Base.PkgId,String}(), "file.jl", Base.PkgId(Base)))[Base.PkgId(Base)] + (setindex!(Dict{Union{GlobalRef,Symbol}, Vector{Int}}(), [1], :two))[:two] + (setindex!(IdDict{Type, Union{Missing, Vector{Tuple{LineNumberNode, Expr}}}}(), missing, Int))[Int] + Dict{Symbol, Union{Nothing, Bool, Symbol}}(:one => false)[:one] + Dict(Base => [:(1+1)])[Base] + Dict(:one => [1])[:one] + Dict("abc" => Set())["abc"] + pushfirst!([], sum) + get(Base.pkgorigins, Base.PkgId(Base), nothing) + sort!([1,2,3]) + unique!([1,2,3]) + cumsum([1,2,3]) + append!(Int[], BitSet()) + isempty(BitSet()) + delete!(BitSet([1,2]), 3) + deleteat!(Int32[1,2,3], [1,3]) + deleteat!(Any[1,2,3], [1,3]) + Core.svec(1, 2) == Core.svec(3, 4) + any(t->t[1].line > 1, [(LineNumberNode(2,:none), :(1+1))]) + + break # end defeat interpreter heuristic + end +end + if is_primary_base_module function __init__() # try to ensuremake sure OpenBLAS does not set CPU affinity (#1070, #9639) diff --git a/contrib/generate_precompile.jl b/contrib/generate_precompile.jl index d609c897018866..1e5de2ca83c5a5 100644 --- a/contrib/generate_precompile.jl +++ b/contrib/generate_precompile.jl @@ -55,34 +55,38 @@ cd("complet_path\t\t$CTRL_C """ precompile_script = """ -# Used by Revise & its dependencies -delete!(push!(Set{Module}(), Base), Main) -m = first(methods(+)) -delete!(push!(Set{Method}(), m), m) -empty!(Set()) -push!(push!(Set{Union{GlobalRef,Symbol}}(), :two), GlobalRef(Base, :two)) -(setindex!(Dict{String,Base.PkgId}(), Base.PkgId(Base), "file.jl"))["file.jl"] -(setindex!(Dict{Symbol,Vector{Int}}(), [1], :two))[:two] -(setindex!(Dict{Base.PkgId,String}(), "file.jl", Base.PkgId(Base)))[Base.PkgId(Base)] -(setindex!(Dict{Union{GlobalRef,Symbol}, Vector{Int}}(), [1], :two))[:two] -(setindex!(IdDict{Type, Union{Missing, Vector{Tuple{LineNumberNode, Expr}}}}(), missing, Int))[Int] -Dict{Symbol, Union{Nothing, Bool, Symbol}}(:one => false)[:one] -Dict(Base => [:(1+1)])[Base] -Dict(:one => [1])[:one] -Dict("abc" => Set())["abc"] -pushfirst!([], sum) -get(Base.pkgorigins, Base.PkgId(Base), nothing) -sort!([1,2,3]) -unique!([1,2,3]) -cumsum([1,2,3]) -append!(Int[], BitSet()) -isempty(BitSet()) -delete!(BitSet([1,2]), 3) -deleteat!(Int32[1,2,3], [1,3]) -deleteat!(Any[1,2,3], [1,3]) -Core.svec(1, 2) == Core.svec(3, 4) -copy(Core.Compiler.retrieve_code_info(Core.Compiler.specialize_method(which(+, (Int, Int)), [Int, Int], Core.svec()))) -any(t->t[1].line > 1, [(LineNumberNode(2,:none),:(1+1))]) +# NOTE: these were moved to the end of Base.jl. TODO: move back here. +# # Used by Revise & its dependencies +# while true # force inference +# delete!(push!(Set{Module}(), Base), Main) +# m = first(methods(+)) +# delete!(push!(Set{Method}(), m), m) +# empty!(Set()) +# push!(push!(Set{Union{GlobalRef,Symbol}}(), :two), GlobalRef(Base, :two)) +# (setindex!(Dict{String,Base.PkgId}(), Base.PkgId(Base), "file.jl"))["file.jl"] +# (setindex!(Dict{Symbol,Vector{Int}}(), [1], :two))[:two] +# (setindex!(Dict{Base.PkgId,String}(), "file.jl", Base.PkgId(Base)))[Base.PkgId(Base)] +# (setindex!(Dict{Union{GlobalRef,Symbol}, Vector{Int}}(), [1], :two))[:two] +# (setindex!(IdDict{Type, Union{Missing, Vector{Tuple{LineNumberNode, Expr}}}}(), missing, Int))[Int] +# Dict{Symbol, Union{Nothing, Bool, Symbol}}(:one => false)[:one] +# Dict(Base => [:(1+1)])[Base] +# Dict(:one => [1])[:one] +# Dict("abc" => Set())["abc"] +# pushfirst!([], sum) +# get(Base.pkgorigins, Base.PkgId(Base), nothing) +# sort!([1,2,3]) +# unique!([1,2,3]) +# cumsum([1,2,3]) +# append!(Int[], BitSet()) +# isempty(BitSet()) +# delete!(BitSet([1,2]), 3) +# deleteat!(Int32[1,2,3], [1,3]) +# deleteat!(Any[1,2,3], [1,3]) +# Core.svec(1, 2) == Core.svec(3, 4) +# # copy(Core.Compiler.retrieve_code_info(Core.Compiler.specialize_method(which(+, (Int, Int)), [Int, Int], Core.svec()))) +# any(t->t[1].line > 1, [(LineNumberNode(2,:none),:(1+1))]) +# break # end force inference +# end """ julia_exepath() = joinpath(Sys.BINDIR::String, Base.julia_exename())