diff --git a/base/condition.jl b/base/condition.jl index 69caf4a4cec3d..19a6f7a9bc55c 100644 --- a/base/condition.jl +++ b/base/condition.jl @@ -139,7 +139,7 @@ is raised as an exception in the woken tasks. Return the count of tasks woken up. Return 0 if no tasks are waiting on `condition`. """ -notify(c::GenericCondition, @nospecialize(arg = nothing); all=true, error=false) = notify(c, arg, all, error) +@constprop :none notify(c::GenericCondition, @nospecialize(arg = nothing); all=true, error=false) = notify(c, arg, all, error) function notify(c::GenericCondition, @nospecialize(arg), all, error) assert_havelock(c) cnt = 0 diff --git a/base/dict.jl b/base/dict.jl index c5adf4068d49b..dabdfa5c34773 100644 --- a/base/dict.jl +++ b/base/dict.jl @@ -172,7 +172,7 @@ hashindex(key, sz) = (((hash(key)::UInt % Int) & (sz-1)) + 1)::Int @propagate_inbounds isslotfilled(h::Dict, i::Int) = h.slots[i] == 0x1 @propagate_inbounds isslotmissing(h::Dict, i::Int) = h.slots[i] == 0x2 -function rehash!(h::Dict{K,V}, newsz = length(h.keys)) where V where K +@constprop :none function rehash!(h::Dict{K,V}, newsz = length(h.keys)) where V where K olds = h.slots oldk = h.keys oldv = h.vals diff --git a/base/loading.jl b/base/loading.jl index 0cbf0a52b9e68..f303a4501f06c 100644 --- a/base/loading.jl +++ b/base/loading.jl @@ -842,7 +842,7 @@ const TIMING_IMPORTS = Threads.Atomic{Int}(0) # returns `true` if require found a precompile cache for this sourcepath, but couldn't load it # returns `false` if the module isn't known to be precompilable # returns the set of modules restored if the cache load succeeded -function _require_search_from_serialized(pkg::PkgId, sourcepath::String, depth::Int = 0) +@constprop :none function _require_search_from_serialized(pkg::PkgId, sourcepath::String, depth::Int = 0) t_before = time_ns() paths = find_all_in_cache_path(pkg) for path_to_try in paths::Vector{String} @@ -876,8 +876,8 @@ function _require_search_from_serialized(pkg::PkgId, sourcepath::String, depth:: else if TIMING_IMPORTS[] > 0 elapsed = round((time_ns() - t_before) / 1e6, digits = 1) - tree_prefix = depth == 0 ? "" : "$(" "^(depth-1))┌ " - print("$(lpad(elapsed, 9)) ms ") + tree_prefix = depth == 0 ? "" : " "^(depth-1)*"┌ " + print(lpad(elapsed, 9), " ms ") printstyled(tree_prefix, color = :light_black) println(pkg.name) end @@ -1076,7 +1076,7 @@ const module_keys = IdDict{Module,PkgId}() # the reverse is_root_module(m::Module) = @lock require_lock haskey(module_keys, m) root_module_key(m::Module) = @lock require_lock module_keys[m] -function register_root_module(m::Module) +@constprop :none function register_root_module(m::Module) # n.b. This is called from C after creating a new module in `Base.__toplevel__`, # instead of adding them to the binding table there. @lock require_lock begin @@ -1859,7 +1859,7 @@ get_compiletime_preferences(::Nothing) = String[] # returns true if it "cachefile.ji" is stale relative to "modpath.jl" # otherwise returns the list of dependencies to also check -function stale_cachefile(modpath::String, cachefile::String; ignore_loaded = false) +@constprop :none function stale_cachefile(modpath::String, cachefile::String; ignore_loaded::Bool = false) io = open(cachefile, "r") try if !isvalid_cache_header(io) diff --git a/base/logging.jl b/base/logging.jl index 731b203a950ba..667b8ddead983 100644 --- a/base/logging.jl +++ b/base/logging.jl @@ -73,7 +73,7 @@ catch_exceptions(logger) = true # Prevent invalidation when packages define custom loggers # Using invoke in combination with @nospecialize eliminates backedges to these methods -function _invoked_shouldlog(logger, level, _module, group, id) +Base.@constprop :none function _invoked_shouldlog(logger, level, _module, group, id) @nospecialize return invoke( shouldlog, @@ -494,7 +494,7 @@ function current_logstate() end # helper function to get the current logger, if enabled for the specified message type -@noinline function current_logger_for_env(std_level::LogLevel, group, _module) +@noinline Base.@constprop :none function current_logger_for_env(std_level::LogLevel, group, _module) logstate = current_logstate() if std_level >= logstate.min_enabled_level || env_override_minlevel(group, _module) return logstate.logger @@ -536,7 +536,7 @@ end let _debug_groups_include::Vector{Symbol} = Symbol[], _debug_groups_exclude::Vector{Symbol} = Symbol[], _debug_str::String = "" -global function env_override_minlevel(group, _module) +global Base.@constprop :none function env_override_minlevel(group, _module) debug = get(ENV, "JULIA_DEBUG", "") if !(debug === _debug_str) _debug_str = debug diff --git a/base/stacktraces.jl b/base/stacktraces.jl index 8483aec55cbff..3cb81d82bd3f7 100644 --- a/base/stacktraces.jl +++ b/base/stacktraces.jl @@ -103,7 +103,7 @@ Given a pointer to an execution context (usually generated by a call to `backtra up stack frame context information. Returns an array of frame information for all functions inlined at that point, innermost function first. """ -function lookup(pointer::Ptr{Cvoid}) +Base.@constprop :none function lookup(pointer::Ptr{Cvoid}) infos = ccall(:jl_lookup_code_address, Any, (Ptr{Cvoid}, Cint), pointer, false)::Core.SimpleVector pointer = convert(UInt64, pointer) isempty(infos) && return [StackFrame(empty_sym, empty_sym, -1, nothing, true, false, pointer)] # this is equal to UNKNOWN @@ -157,7 +157,7 @@ Returns a stack trace in the form of a vector of `StackFrame`s. (By default stac doesn't return C functions, but this can be enabled.) When called without specifying a trace, `stacktrace` first calls `backtrace`. """ -function stacktrace(trace::Vector{<:Union{Base.InterpreterIP,Core.Compiler.InterpreterIP,Ptr{Cvoid}}}, c_funcs::Bool=false) +Base.@constprop :none function stacktrace(trace::Vector{<:Union{Base.InterpreterIP,Core.Compiler.InterpreterIP,Ptr{Cvoid}}}, c_funcs::Bool=false) stack = StackTrace() for ip in trace for frame in lookup(ip) @@ -170,7 +170,7 @@ function stacktrace(trace::Vector{<:Union{Base.InterpreterIP,Core.Compiler.Inter return stack end -function stacktrace(c_funcs::Bool=false) +Base.@constprop :none function stacktrace(c_funcs::Bool=false) stack = stacktrace(backtrace(), c_funcs) # Remove frame for this function (and any functions called by this function). remove_frames!(stack, :stacktrace) diff --git a/base/util.jl b/base/util.jl index 9b89c5a40cf1e..5bc649b7bce7d 100644 --- a/base/util.jl +++ b/base/util.jl @@ -126,9 +126,9 @@ See also [`print`](@ref), [`println`](@ref), [`show`](@ref). !!! compat "Julia 1.7" Keywords except `color` and `bold` were added in Julia 1.7. """ -printstyled(io::IO, msg...; bold::Bool=false, underline::Bool=false, blink::Bool=false, reverse::Bool=false, hidden::Bool=false, color::Union{Int,Symbol}=:normal) = +@constprop :none printstyled(io::IO, msg...; bold::Bool=false, underline::Bool=false, blink::Bool=false, reverse::Bool=false, hidden::Bool=false, color::Union{Int,Symbol}=:normal) = with_output_color(print, color, io, msg...; bold=bold, underline=underline, blink=blink, reverse=reverse, hidden=hidden) -printstyled(msg...; bold::Bool=false, underline::Bool=false, blink::Bool=false, reverse::Bool=false, hidden::Bool=false, color::Union{Int,Symbol}=:normal) = +@constprop :none printstyled(msg...; bold::Bool=false, underline::Bool=false, blink::Bool=false, reverse::Bool=false, hidden::Bool=false, color::Union{Int,Symbol}=:normal) = printstyled(stdout, msg...; bold=bold, underline=underline, blink=blink, reverse=reverse, hidden=hidden, color=color) """ diff --git a/contrib/generate_precompile.jl b/contrib/generate_precompile.jl index 3c31c4c118c00..4b1d53319d81b 100644 --- a/contrib/generate_precompile.jl +++ b/contrib/generate_precompile.jl @@ -36,6 +36,8 @@ precompile(Tuple{typeof(Base.display_error), Base.ExceptionStack}) precompile(Tuple{Core.kwftype(typeof(Type)), NamedTuple{(:sizehint,), Tuple{Int}}, Type{IOBuffer}}) precompile(Base.CoreLogging.current_logger_for_env, (Base.CoreLogging.LogLevel, String, Module)) precompile(Base.CoreLogging.current_logger_for_env, (Base.CoreLogging.LogLevel, Symbol, Module)) +precompile(Base.CoreLogging.env_override_minlevel, (Symbol, Module)) +precompile(Base.StackTraces.lookup, (Ptr{Nothing},)) """ for T in (Float16, Float32, Float64), IO in (IOBuffer, IOContext{IOBuffer}, Base.TTY, IOContext{Base.TTY})