Skip to content

Commit

Permalink
Merge branch 'master' into eph/limit-repl
Browse files Browse the repository at this point in the history
  • Loading branch information
ericphanson authored Jul 7, 2024
2 parents 43767ef + aa07585 commit 03f5ba9
Show file tree
Hide file tree
Showing 101 changed files with 1,005 additions and 945 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/LabelCheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ jobs:
with:
# REQUIRED_LABELS_ANY: "bug,enhancement,skip-changelog"
# REQUIRED_LABELS_ANY_DESCRIPTION: "Select at least one label ['bug','enhancement','skip-changelog']"
BANNED_LABELS: "needs docs,needs compat annotation,needs more info,needs nanosoldier run,needs news,needs pkgeval,needs tests,DO NOT MERGE"
BANNED_LABELS_DESCRIPTION: "A PR should not be merged with `needs *` or `DO NOT MERGE` labels"
BANNED_LABELS: "needs docs,needs compat annotation,needs more info,needs nanosoldier run,needs news,needs pkgeval,needs tests,needs decision,DO NOT MERGE,status:DO NOT MERGE"
BANNED_LABELS_DESCRIPTION: "A PR should not be merged with `needs *` or `status:DO NOT MERGE` labels"
19 changes: 16 additions & 3 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,9 @@ Daniel Karrasch <[email protected]> <[email protected]>
Roger Luo <[email protected]> <[email protected]>
Roger Luo <[email protected]> <[email protected]>

Frames Catherine White <[email protected]> <[email protected]>
Frames Catherine White <[email protected]> <[email protected]>
Frames Catherine White <[email protected]> <[email protected]>
Frames White <[email protected]> <[email protected]>
Frames White <[email protected]> <[email protected]>
Frames White <[email protected]> <[email protected]>

Claire Foster <[email protected]> <[email protected]>

Expand All @@ -295,3 +295,16 @@ Jishnu Bhattacharya <[email protected]> <[email protected]

Shuhei Kadowaki <[email protected]> <[email protected]>
Shuhei Kadowaki <[email protected]> <[email protected]>

inky <[email protected]>
inky <[email protected]> <[email protected]>

Lilith Orion Hafner <[email protected]> <[email protected]>
Lilith Orion Hafner <[email protected]> <[email protected]>

Timothy <[email protected]>

Bhuminjay Soni <[email protected]>
Bhuminjay Soni <[email protected]> <[email protected]>

Florian Atteneder <[email protected]>
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,14 @@ endif
@printf $(JULCOLOR)' ==> ./julia binary sizes\n'$(ENDCOLOR)
$(call spawn,$(LLVM_SIZE) -A $(call cygpath_w,$(build_private_libdir)/sys.$(SHLIB_EXT)) \
$(call cygpath_w,$(build_shlibdir)/libjulia.$(SHLIB_EXT)) \
$(call cygpath_w,$(build_shlibdir)/libjulia-internal.$(SHLIB_EXT)) \
$(call cygpath_w,$(build_shlibdir)/libjulia-codegen.$(SHLIB_EXT)) \
$(call cygpath_w,$(build_bindir)/julia$(EXE)))
ifeq ($(OS),Darwin)
$(call spawn,$(LLVM_SIZE) -A $(call cygpath_w,$(build_shlibdir)/libLLVM.$(SHLIB_EXT)))
else
$(call spawn,$(LLVM_SIZE) -A $(call cygpath_w,$(build_shlibdir)/$(LLVM_SHARED_LIB_NAME).$(SHLIB_EXT)))
endif
@printf $(JULCOLOR)' ==> ./julia launch speedtest\n'$(ENDCOLOR)
@time $(call spawn,$(build_bindir)/julia$(EXE) -e '')
@time $(call spawn,$(build_bindir)/julia$(EXE) -e '')
Expand Down
26 changes: 23 additions & 3 deletions base/Base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,28 @@ function strcat(x::String, y::String)
end
return out
end
include(strcat((length(Core.ARGS)>=2 ? Core.ARGS[2] : ""), "build_h.jl")) # include($BUILDROOT/base/build_h.jl)
include(strcat((length(Core.ARGS)>=2 ? Core.ARGS[2] : ""), "version_git.jl")) # include($BUILDROOT/base/version_git.jl)

BUILDROOT::String = ""

baremodule BuildSettings
end

let i = 1
global BUILDROOT
while i <= length(Core.ARGS)
if Core.ARGS[i] == "--buildsettings"
include(BuildSettings, ARGS[i+1])
i += 1
else
BUILDROOT = Core.ARGS[i]
end
i += 1
end
end

include(strcat(BUILDROOT, "build_h.jl")) # include($BUILDROOT/base/build_h.jl)
include(strcat(BUILDROOT, "version_git.jl")) # include($BUILDROOT/base/version_git.jl)

# Initialize DL_LOAD_PATH as early as possible. We are defining things here in
# a slightly more verbose fashion than usual, because we're running so early.
const DL_LOAD_PATH = String[]
Expand Down Expand Up @@ -562,7 +582,7 @@ include(mapexpr::Function, mod::Module, _path::AbstractString) = _include(mapexp

# External libraries vendored into Base
Core.println("JuliaSyntax/src/JuliaSyntax.jl")
include(@__MODULE__, string((length(Core.ARGS)>=2 ? Core.ARGS[2] : ""), "JuliaSyntax/src/JuliaSyntax.jl")) # include($BUILDROOT/base/JuliaSyntax/JuliaSyntax.jl)
include(@__MODULE__, string(BUILDROOT, "JuliaSyntax/src/JuliaSyntax.jl")) # include($BUILDROOT/base/JuliaSyntax/JuliaSyntax.jl)

end_base_include = time_ns()

Expand Down
2 changes: 1 addition & 1 deletion base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3287,7 +3287,7 @@ one *without* a colon in the slice. This is `view(A,:,i,:)`, whereas
`mapslices(f, A; dims=(1,3))` uses `A[:,i,:]`. The function `f` may mutate
values in the slice without affecting `A`.
"""
function mapslices(f, A::AbstractArray; dims)
@constprop :aggressive function mapslices(f, A::AbstractArray; dims)
isempty(dims) && return map(f, A)

for d in dims
Expand Down
7 changes: 7 additions & 0 deletions base/boot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,13 @@ function (g::GeneratedFunctionStub)(world::UInt, source::LineNumberNode, @nospec
end
end

# If the generator is a subtype of this trait, inference caches the generated unoptimized
# code, sacrificing memory space to improve the performance of subsequent inferences.
# This tradeoff is not appropriate in general cases (e.g., for `GeneratedFunctionStub`s
# generated from the front end), but it can be justified for generators involving complex
# code transformations, such as a Cassette-like system.
abstract type CachedGenerator end

NamedTuple() = NamedTuple{(),Tuple{}}(())

eval(Core, :(NamedTuple{names}(args::Tuple) where {names} =
Expand Down
33 changes: 14 additions & 19 deletions base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -692,11 +692,9 @@ function edge_matches_sv(interp::AbstractInterpreter, frame::AbsIntState,
# The other `CodeInfo`s we inspect will already have this field inflated, so we just
# access it directly instead (to avoid regeneration).
world = get_inference_world(interp)
callee_method2 = method_for_inference_heuristics(method, sig, sparams, world) # Union{Method, Nothing}

inf_method2 = method_for_inference_limit_heuristics(frame) # limit only if user token match
inf_method2 isa Method || (inf_method2 = nothing)
if callee_method2 !== inf_method2
callee_method2 = method_for_inference_heuristics(method, sig, sparams, world)
inf_method2 = method_for_inference_limit_heuristics(frame)
if callee_method2 !== inf_method2 # limit only if user token match
return false
end
if isa(frame, InferenceState) && cache_owner(frame.interp) !== cache_owner(interp)
Expand Down Expand Up @@ -733,27 +731,24 @@ end

# This function is used for computing alternate limit heuristics
function method_for_inference_heuristics(method::Method, @nospecialize(sig), sparams::SimpleVector, world::UInt)
if isdefined(method, :generator) && !(method.generator isa Core.GeneratedFunctionStub) && may_invoke_generator(method, sig, sparams)
method_instance = specialize_method(method, sig, sparams)
if isa(method_instance, MethodInstance)
cinfo = get_staged(method_instance, world)
if isa(cinfo, CodeInfo)
method2 = cinfo.method_for_inference_limit_heuristics
if method2 isa Method
return method2
end
if (hasgenerator(method) && !(method.generator isa Core.GeneratedFunctionStub) &&
may_invoke_generator(method, sig, sparams))
mi = specialize_method(method, sig, sparams)
cinfo = get_staged(mi, world)
if isa(cinfo, CodeInfo)
method2 = cinfo.method_for_inference_limit_heuristics
if method2 isa Method
return method2
end
end
end
return nothing
end

function matches_sv(parent::AbsIntState, sv::AbsIntState)
sv_method2 = method_for_inference_limit_heuristics(sv) # limit only if user token match
sv_method2 isa Method || (sv_method2 = nothing)
parent_method2 = method_for_inference_limit_heuristics(parent) # limit only if user token match
parent_method2 isa Method || (parent_method2 = nothing)
return frame_instance(parent).def === frame_instance(sv).def && sv_method2 === parent_method2
# limit only if user token match
return (frame_instance(parent).def === frame_instance(sv).def &&
method_for_inference_limit_heuristics(sv) === method_for_inference_limit_heuristics(parent))
end

function is_edge_recursed(edge::MethodInstance, caller::AbsIntState)
Expand Down
12 changes: 12 additions & 0 deletions base/compiler/compiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,18 @@ something(x::Any, y...) = x
# compiler #
############

baremodule BuildSettings
using Core: ARGS, include
using Core.Compiler: >, getindex, length

MAX_METHODS::Int = 3
UNOPTIMIZE_THROW_BLOCKS::Bool = true

if length(ARGS) > 2 && ARGS[2] === "--buildsettings"
include(BuildSettings, ARGS[3])
end
end

if false
import Base: Base, @show
else
Expand Down
5 changes: 3 additions & 2 deletions base/compiler/inferencestate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -603,9 +603,10 @@ end
function InferenceState(result::InferenceResult, cache_mode::UInt8, interp::AbstractInterpreter)
# prepare an InferenceState object for inferring lambda
world = get_inference_world(interp)
src = retrieve_code_info(result.linfo, world)
mi = result.linfo
src = retrieve_code_info(mi, world)
src === nothing && return nothing
maybe_validate_code(result.linfo, src, "lowered")
maybe_validate_code(mi, src, "lowered")
return InferenceState(result, src, cache_mode, interp)
end
InferenceState(result::InferenceResult, cache_mode::Symbol, interp::AbstractInterpreter) =
Expand Down
9 changes: 9 additions & 0 deletions base/compiler/ssair/verify.jl
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,15 @@ function verify_ir(ir::IRCode, print::Bool=true,
# undefined GlobalRef as assignment RHS is OK
continue
end
elseif stmt.head === :isdefined
if length(stmt.args) > 2 || (length(stmt.args) == 2 && !isa(stmt.args[2], Bool))
@verify_error "malformed isdefined"
error("")
end
if stmt.args[1] isa GlobalRef
# undefined GlobalRef is OK in isdefined
continue
end
elseif stmt.head === :gc_preserve_end
# We allow gc_preserve_end tokens to span across try/catch
# blocks, which isn't allowed for regular SSA values, so
Expand Down
2 changes: 1 addition & 1 deletion base/compiler/tfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@ end
end

@nospecs function _getfield_tfunc(𝕃::AnyMustAliasesLattice, s00, name, setfield::Bool)
return _getfield_tfunc(widenlattice(𝕃), widenmustalias(s00), name, setfield)
return _getfield_tfunc(widenlattice(𝕃), widenmustalias(s00), widenmustalias(name), setfield)
end

@nospecs function _getfield_tfunc(𝕃::PartialsLattice, s00, name, setfield::Bool)
Expand Down
4 changes: 2 additions & 2 deletions base/compiler/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,14 @@ struct InferenceParams
end
function InferenceParams(
params::InferenceParams = InferenceParams( # default constructor
#=max_methods::Int=# 3,
#=max_methods::Int=# BuildSettings.MAX_METHODS,
#=max_union_splitting::Int=# 4,
#=max_apply_union_enum::Int=# 8,
#=max_tuple_splat::Int=# 32,
#=tuple_complexity_limit_depth::Int=# 3,
#=ipo_constant_propagation::Bool=# true,
#=aggressive_constant_propagation::Bool=# false,
#=unoptimize_throw_blocks::Bool=# true,
#=unoptimize_throw_blocks::Bool=# BuildSettings.UNOPTIMIZE_THROW_BLOCKS,
#=assume_bindings_static::Bool=# false,
#=ignore_recursion_hardlimit::Bool=# false);
max_methods::Int = params.max_methods,
Expand Down
22 changes: 17 additions & 5 deletions base/compiler/utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,27 @@ use_const_api(li::CodeInstance) = invoke_api(li) == 2

function get_staged(mi::MethodInstance, world::UInt)
may_invoke_generator(mi) || return nothing
cache_ci = (mi.def::Method).generator isa Core.CachedGenerator ?
RefValue{CodeInstance}() : nothing
try
# user code might throw errors – ignore them
ci = ccall(:jl_code_for_staged, Any, (Any, UInt, Ptr{Cvoid}), mi, world, C_NULL)::CodeInfo
return ci
catch
return call_get_staged(mi, world, cache_ci)
catch # user code might throw errors – ignore them
return nothing
end
end

# enable caching of unoptimized generated code if the generator is `CachedGenerator`
function call_get_staged(mi::MethodInstance, world::UInt, cache_ci::RefValue{CodeInstance})
token = @_gc_preserve_begin cache_ci
cache_ci_ptr = pointer_from_objref(cache_ci)
src = ccall(:jl_code_for_staged, Ref{CodeInfo}, (Any, UInt, Ptr{CodeInstance}), mi, world, cache_ci_ptr)
@_gc_preserve_end token
return src
end
function call_get_staged(mi::MethodInstance, world::UInt, ::Nothing)
return ccall(:jl_code_for_staged, Ref{CodeInfo}, (Any, UInt, Ptr{Cvoid}), mi, world, C_NULL)
end

function get_cached_uninferred(mi::MethodInstance, world::UInt)
ccall(:jl_cached_uninferred, Any, (Any, UInt), mi.cache, world)::CodeInstance
end
Expand All @@ -162,7 +174,7 @@ function retrieve_code_info(mi::MethodInstance, world::UInt)
# @atomic ci.inferred = C_NULL
return src
end
c = isdefined(def, :generator) ? get_staged(mi, world) : nothing
c = hasgenerator(def) ? get_staged(mi, world) : nothing
if c === nothing && isdefined(def, :source)
src = def.source
if src === nothing
Expand Down
4 changes: 2 additions & 2 deletions base/compiler/validation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const VALID_EXPR_HEADS = IdDict{Symbol,UnitRange{Int}}(
:(&) => 1:1,
:(=) => 2:2,
:method => 1:4,
:const => 1:1,
:const => 1:2,
:new => 1:typemax(Int),
:splatnew => 2:2,
:the_exception => 0:0,
Expand All @@ -24,7 +24,7 @@ const VALID_EXPR_HEADS = IdDict{Symbol,UnitRange{Int}}(
:global => 1:1,
:foreigncall => 5:typemax(Int), # name, RT, AT, nreq, (cconv, effects), args..., roots...
:cfunction => 5:5,
:isdefined => 1:1,
:isdefined => 1:2,
:code_coverage_effect => 0:0,
:loopinfo => 0:typemax(Int),
:gc_preserve_begin => 0:typemax(Int),
Expand Down
2 changes: 1 addition & 1 deletion base/cpuid.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Base.:<=(a::ISA, b::ISA) = a.features <= b.features
Base.:<(a::ISA, b::ISA) = a.features < b.features
Base.isless(a::ISA, b::ISA) = a < b

include(string(length(Core.ARGS) >= 2 ? Core.ARGS[2] : "", "features_h.jl")) # include($BUILDROOT/base/features_h.jl)
include(string(Base.BUILDROOT, "features_h.jl")) # include($BUILDROOT/base/features_h.jl)

# Keep in sync with `arch_march_isa_mapping`.
const ISAs_by_family = Dict(
Expand Down
5 changes: 3 additions & 2 deletions base/docs/Docs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -821,8 +821,9 @@ compiler-generated hidden symbols starting with `#`).
See also: [`names`](@ref), [`Docs.hasdoc`](@ref), [`Base.ispublic`](@ref).
"""
function undocumented_names(mod::Module; private::Bool=false)
filter!(names(mod; non_public=true, deprecated=true)) do sym
!hasdoc(mod, sym) && (private || Base.ispublic(mod, sym))
filter!(names(mod; all=true)) do sym
!hasdoc(mod, sym) && !startswith(string(sym), '#') &&
(private || Base.ispublic(mod, sym))
end
end

Expand Down
10 changes: 5 additions & 5 deletions base/essentials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -864,11 +864,11 @@ end
Using `@inbounds` may return incorrect results/crashes/corruption
for out-of-bounds indices. The user is responsible for checking it manually.
Only use `@inbounds` when it is certain from the information locally available
that all accesses are in bounds. In particular, using `1:length(A)` instead of
`eachindex(A)` in a function like the one above is _not_ safely inbounds because
the first index of `A` may not be `1` for all user defined types that subtype
`AbstractArray`.
Only use `@inbounds` when you are certain that all accesses are in bounds (as
undefined behavior, e.g. crashes, might occur if this assertion is violated). For
example, using `1:length(A)` instead of `eachindex(A)` in a function like
the one above is _not_ safely inbounds because the first index of `A` may not
be `1` for all user defined types that subtype `AbstractArray`.
"""
macro inbounds(blk)
return Expr(:block,
Expand Down
2 changes: 1 addition & 1 deletion base/filesystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ uv_fs_req_cleanup(req) = ccall(:uv_fs_req_cleanup, Cvoid, (Ptr{Cvoid},), req)
include("path.jl")
include("stat.jl")
include("file.jl")
include(string(length(Core.ARGS) >= 2 ? Core.ARGS[2] : "", "file_constants.jl")) # include($BUILDROOT/base/file_constants.jl)
include(string(Base.BUILDROOT, "file_constants.jl")) # include($BUILDROOT/base/file_constants.jl)

## Operations with File (fd) objects ##

Expand Down
7 changes: 5 additions & 2 deletions base/gmp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ else
const libgmp = "libgmp.so.10"
end

version() = VersionNumber(unsafe_string(unsafe_load(cglobal((:__gmp_version, libgmp), Ptr{Cchar}))))
_version() = unsafe_string(unsafe_load(cglobal((:__gmp_version, libgmp), Ptr{Cchar})))
version() = VersionNumber(_version())
major_version() = _version()[1]
bits_per_limb() = Int(unsafe_load(cglobal((:__gmp_bits_per_limb, libgmp), Cint)))

const VERSION = version()
const MAJOR_VERSION = major_version()
const BITS_PER_LIMB = bits_per_limb()

# GMP's mp_limb_t is by default a typedef of `unsigned long`, but can also be configured to be either
Expand Down Expand Up @@ -102,7 +105,7 @@ const ALLOC_OVERFLOW_FUNCTION = Ref(false)

function __init__()
try
if version().major != VERSION.major || bits_per_limb() != BITS_PER_LIMB
if major_version() != MAJOR_VERSION || bits_per_limb() != BITS_PER_LIMB
msg = """The dynamically loaded GMP library (v\"$(version())\" with __gmp_bits_per_limb == $(bits_per_limb()))
does not correspond to the compile time version (v\"$VERSION\" with __gmp_bits_per_limb == $BITS_PER_LIMB).
Please rebuild Julia."""
Expand Down
2 changes: 1 addition & 1 deletion base/libc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if Sys.iswindows()
export GetLastError, FormatMessage
end

include(string(length(Core.ARGS) >= 2 ? Core.ARGS[2] : "", "errno_h.jl")) # include($BUILDROOT/base/errno_h.jl)
include(string(Base.BUILDROOT, "errno_h.jl")) # include($BUILDROOT/base/errno_h.jl)

## RawFD ##

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

# Core definitions for interacting with the libuv library from Julia

include(string(length(Core.ARGS) >= 2 ? Core.ARGS[2] : "", "uv_constants.jl")) # include($BUILDROOT/base/uv_constants.jl)
include(string(Base.BUILDROOT, "uv_constants.jl")) # include($BUILDROOT/base/uv_constants.jl)

# convert UV handle data to julia object, checking for null
function uv_sizeof_handle(handle)
Expand Down
Loading

0 comments on commit 03f5ba9

Please sign in to comment.