@@ -91,39 +91,59 @@ for T in (Float16, Float32, Float64), IO in (IOBuffer, IOContext{IOBuffer}, Base
9191 hardcoded_precompile_statements *= " precompile(Tuple{typeof(show), $IO , $T })\n "
9292end
9393
94+ # Precompiles for Revise and other packages
9495precompile_script = """
95- # NOTE: these were moved to the end of Base.jl. TODO: move back here.
96- # # Used by Revise & its dependencies
97- # while true # force inference
98- # delete!(push!(Set{Module}(), Base), Main)
99- # m = first(methods(+))
100- # delete!(push!(Set{Method}(), m), m)
101- # empty!(Set())
102- # push!(push!(Set{Union{GlobalRef,Symbol}}(), :two), GlobalRef(Base, :two))
103- # (setindex!(Dict{String,Base.PkgId}(), Base.PkgId(Base), "file.jl"))["file.jl"]
104- # (setindex!(Dict{Symbol,Vector{Int}}(), [1], :two))[:two]
105- # (setindex!(Dict{Base.PkgId,String}(), "file.jl", Base.PkgId(Base)))[Base.PkgId(Base)]
106- # (setindex!(Dict{Union{GlobalRef,Symbol}, Vector{Int}}(), [1], :two))[:two]
107- # (setindex!(IdDict{Type, Union{Missing, Vector{Tuple{LineNumberNode, Expr}}}}(), missing, Int))[Int]
108- # Dict{Symbol, Union{Nothing, Bool, Symbol}}(:one => false)[:one]
109- # Dict(Base => [:(1+1)])[Base]
110- # Dict(:one => [1])[:one]
111- # Dict("abc" => Set())["abc"]
112- # pushfirst!([], sum)
113- # get(Base.pkgorigins, Base.PkgId(Base), nothing)
114- # sort!([1,2,3])
115- # unique!([1,2,3])
116- # cumsum([1,2,3])
117- # append!(Int[], BitSet())
118- # isempty(BitSet())
119- # delete!(BitSet([1,2]), 3)
120- # deleteat!(Int32[1,2,3], [1,3])
121- # deleteat!(Any[1,2,3], [1,3])
122- # Core.svec(1, 2) == Core.svec(3, 4)
123- # # copy(Core.Compiler.retrieve_code_info(Core.Compiler.specialize_method(which(+, (Int, Int)), [Int, Int], Core.svec())))
124- # any(t->t[1].line > 1, [(LineNumberNode(2,:none),:(1+1))])
125- # break # end force inference
126- # end
96+ for match = Base._methods(+, (Int, Int), -1, Base.get_world_counter())
97+ m = match.method
98+ delete!(push!(Set{Method}(), m), m)
99+ copy(Core.Compiler.retrieve_code_info(Core.Compiler.specialize_method(match), typemax(UInt)))
100+
101+ empty!(Set())
102+ push!(push!(Set{Union{GlobalRef,Symbol}}(), :two), GlobalRef(Base, :two))
103+ (setindex!(Dict{String,Base.PkgId}(), Base.PkgId(Base), "file.jl"))["file.jl"]
104+ (setindex!(Dict{Symbol,Vector{Int}}(), [1], :two))[:two]
105+ (setindex!(Dict{Base.PkgId,String}(), "file.jl", Base.PkgId(Base)))[Base.PkgId(Base)]
106+ (setindex!(Dict{Union{GlobalRef,Symbol}, Vector{Int}}(), [1], :two))[:two]
107+ (setindex!(IdDict{Type, Union{Missing, Vector{Tuple{LineNumberNode, Expr}}}}(), missing, Int))[Int]
108+ Dict{Symbol, Union{Nothing, Bool, Symbol}}(:one => false)[:one]
109+ Dict(Base => [:(1+1)])[Base]
110+ Dict(:one => [1])[:one]
111+ Dict("abc" => Set())["abc"]
112+ pushfirst!([], sum)
113+ get(Base.pkgorigins, Base.PkgId(Base), nothing)
114+ sort!([1,2,3])
115+ unique!([1,2,3])
116+ cumsum([1,2,3])
117+ append!(Int[], BitSet())
118+ isempty(BitSet())
119+ delete!(BitSet([1,2]), 3)
120+ deleteat!(Int32[1,2,3], [1,3])
121+ deleteat!(Any[1,2,3], [1,3])
122+ Core.svec(1, 2) == Core.svec(3, 4)
123+ any(t->t[1].line > 1, [(LineNumberNode(2,:none), :(1+1))])
124+
125+ # Code loading uses this
126+ sortperm(mtime.(readdir(".")), rev=true)
127+ # JLLWrappers uses these
128+ Dict{Base.UUID,Set{String}}()[Base.UUID("692b3bcd-3c85-4b1f-b108-f13ce0eb3210")] = Set{String}()
129+ get!(Set{String}, Dict{Base.UUID,Set{String}}(), Base.UUID("692b3bcd-3c85-4b1f-b108-f13ce0eb3210"))
130+ eachindex(IndexLinear(), Expr[])
131+ push!(Expr[], Expr(:return, false))
132+ vcat(String[], String[])
133+ k, v = (:hello => nothing)
134+ precompile(Base.indexed_iterate, (Pair{Symbol, Union{Nothing, String}}, Int))
135+ precompile(Base.indexed_iterate, (Pair{Symbol, Union{Nothing, String}}, Int, Int))
136+ # Preferences uses these
137+ precompile(Base.get_preferences, (Base.UUID,))
138+ precompile(Base.record_compiletime_preference, (Base.UUID, String))
139+ get(Dict{String,Any}(), "missing", nothing)
140+ delete!(Dict{String,Any}(), "missing")
141+ for (k, v) in Dict{String,Any}()
142+ println(k)
143+ end
144+
145+ break # only actually need to do this once
146+ end
127147"""
128148
129149julia_exepath () = joinpath (Sys. BINDIR, Base. julia_exename ())
0 commit comments