Skip to content

Commit

Permalink
Merge branch 'master' into pv-compiler-timings-lock
Browse files Browse the repository at this point in the history
  • Loading branch information
NHDaly authored Dec 30, 2022
2 parents 5dce6f2 + 4d206c9 commit 979ad5f
Show file tree
Hide file tree
Showing 157 changed files with 3,330 additions and 1,387 deletions.
19 changes: 17 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,10 @@ release-candidate: release testall
@echo 10. Follow packaging instructions in doc/build/distributing.md to create binary packages for all platforms
@echo 11. Upload to AWS, update https://julialang.org/downloads and http://status.julialang.org/stable links
@echo 12. Update checksums on AWS for tarball and packaged binaries
@echo 13. Announce on mailing lists
@echo 14. Change master to release-0.X in base/version.jl and base/version_git.sh as in 4cb1e20
@echo 13. Update versions.json
@echo 14. Push to Juliaup (https://github.com/JuliaLang/juliaup/wiki/Adding-a-Julia-version)
@echo 15. Announce on mailing lists
@echo 16. Change master to release-0.X in base/version.jl and base/version_git.sh as in 4cb1e20
@echo

$(build_man1dir)/julia.1: $(JULIAHOME)/doc/man/julia.1 | $(build_man1dir)
Expand Down Expand Up @@ -260,13 +262,21 @@ ifeq ($(OS),WINNT)
-$(INSTALL_M) $(wildcard $(build_bindir)/*.dll) $(DESTDIR)$(bindir)/
ifeq ($(JULIA_BUILD_MODE),release)
-$(INSTALL_M) $(build_libdir)/libjulia.dll.a $(DESTDIR)$(libdir)/
-$(INSTALL_M) $(build_libdir)/libjulia-internal.dll.a $(DESTDIR)$(libdir)/
else ifeq ($(JULIA_BUILD_MODE),debug)
-$(INSTALL_M) $(build_libdir)/libjulia-debug.dll.a $(DESTDIR)$(libdir)/
-$(INSTALL_M) $(build_libdir)/libjulia-internal-debug.dll.a $(DESTDIR)$(libdir)/
endif

# We have a single exception; we want 7z.dll to live in libexec, not bin, so that 7z.exe can find it.
-mv $(DESTDIR)$(bindir)/7z.dll $(DESTDIR)$(libexecdir)/
-$(INSTALL_M) $(build_bindir)/libopenlibm.dll.a $(DESTDIR)$(libdir)/
-$(INSTALL_M) $(build_libdir)/libssp.dll.a $(DESTDIR)$(libdir)/
# The rest are compiler dependencies, as an example memcpy is exported by msvcrt
# These are files from mingw32 and required for creating shared libraries like our caches.
-$(INSTALL_M) $(build_libdir)/libgcc_s.a $(DESTDIR)$(libdir)/
-$(INSTALL_M) $(build_libdir)/libgcc.a $(DESTDIR)$(libdir)/
-$(INSTALL_M) $(build_libdir)/libmsvcrt.a $(DESTDIR)$(libdir)/
else

# Copy over .dSYM directories directly for Darwin
Expand Down Expand Up @@ -331,6 +341,11 @@ else ifeq ($(JULIA_BUILD_MODE),debug)
$(INSTALL_M) $(build_private_libdir)/sys-debug.$(SHLIB_EXT) $(DESTDIR)$(private_libdir)
endif

# Cache stdlibs
@$(call PRINT_JULIA, $(call spawn,$(JULIA_EXECUTABLE)) --startup-file=no $(JULIAHOME)/contrib/cache_stdlibs.jl)
# CI uses `--check-bounds=yes` which impacts the cache flags
@$(call PRINT_JULIA, $(call spawn,$(JULIA_EXECUTABLE)) --startup-file=no --check-bounds=yes $(JULIAHOME)/contrib/cache_stdlibs.jl)

# Copy in all .jl sources as well
mkdir -p $(DESTDIR)$(datarootdir)/julia/base $(DESTDIR)$(datarootdir)/julia/test
cp -R -L $(JULIAHOME)/base/* $(DESTDIR)$(datarootdir)/julia/base
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ Standard library changes
#### Test


* The `@test_broken` macro (or `@test` with `broken=true`) now complains if the test expression returns a
non-boolean value in the same way as a non-broken test. ([#47804])

#### Dates


Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ and then use the command prompt to change into the resulting julia directory. By
Julia. However, most users should use the [most recent stable version](https://github.com/JuliaLang/julia/releases)
of Julia. You can get this version by running:

git checkout v1.8.3
git checkout v1.8.4

To build the `julia` executable, run `make` from within the julia directory.

Expand Down
2 changes: 2 additions & 0 deletions base/Base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ include("idset.jl")
include("iterators.jl")
using .Iterators: zip, enumerate, only
using .Iterators: Flatten, Filter, product # for generators
using .Iterators: Stateful # compat (was formerly used in reinterpretarray.jl)

include("namedtuple.jl")

Expand Down Expand Up @@ -417,6 +418,7 @@ include("threadcall.jl")
include("uuid.jl")
include("pkgid.jl")
include("toml_parser.jl")
include("linking.jl")
include("loading.jl")

# misc useful functions & macros
Expand Down
6 changes: 6 additions & 0 deletions base/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ ifeq ($(DARWIN_FRAMEWORK), 1)
@echo "const DARWIN_FRAMEWORK_NAME = \"$(FRAMEWORK_NAME)\"" >> $@
else
@echo "const DARWIN_FRAMEWORK = false" >> $@
endif
ifeq ($(OS), Darwin)
@echo "const MACOS_PRODUCT_VERSION = \"$(shell sw_vers -productVersion)\"" >> $@
@echo "const MACOS_PLATFORM_VERSION = \"$(shell xcrun --show-sdk-version)\"" >> $@
endif
@echo "const BUILD_TRIPLET = \"$(BB_TRIPLET_LIBGFORTRAN_CXXABI)\"" >> $@

Expand Down Expand Up @@ -227,6 +231,8 @@ else
$(eval $(call symlink_system_library,CSL,libgcc_s,1))
endif
endif
else
$(eval $(call symlink_system_library,CSL,libgcc_s,1))
endif
ifneq (,$(LIBGFORTRAN_VERSION))
$(eval $(call symlink_system_library,CSL,libgfortran,$(LIBGFORTRAN_VERSION)))
Expand Down
7 changes: 4 additions & 3 deletions base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2730,7 +2730,8 @@ keepat!(a::Vector, m::AbstractVector{Bool}) = _keepat!(a, m)
# set-like operators for vectors
# These are moderately efficient, preserve order, and remove dupes.

_unique_filter!(pred, update!, state) = function (x)
_unique_filter!(pred::P, update!::U, state) where {P,U} = function (x)
# P, U force specialization
if pred(x, state)
update!(state, x)
true
Expand All @@ -2756,7 +2757,7 @@ union!(v::AbstractVector{T}, itrs...) where {T} =
symdiff!(v::AbstractVector{T}, itrs...) where {T} =
_grow!(_shrink_filter!(symdiff!(Set{T}(), v, itrs...)), v, itrs)

function _shrink!(shrinker!, v::AbstractVector, itrs)
function _shrink!(shrinker!::F, v::AbstractVector, itrs) where F
seen = Set{eltype(v)}()
filter!(_grow_filter!(seen), v)
shrinker!(seen, itrs...)
Expand All @@ -2768,7 +2769,7 @@ setdiff!( v::AbstractVector, itrs...) = _shrink!(setdiff!, v, itrs)

vectorfilter(T::Type, f, v) = T[x for x in v if f(x)]

function _shrink(shrinker!, itr, itrs)
function _shrink(shrinker!::F, itr, itrs) where F
T = promote_eltype(itr, itrs...)
keep = shrinker!(Set{T}(itr), itrs...)
vectorfilter(T, _shrink_filter!(keep), itr)
Expand Down
4 changes: 2 additions & 2 deletions base/boot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -524,12 +524,12 @@ module IR
export CodeInfo, MethodInstance, CodeInstance, GotoNode, GotoIfNot, ReturnNode,
NewvarNode, SSAValue, Slot, SlotNumber, TypedSlot, Argument,
PiNode, PhiNode, PhiCNode, UpsilonNode, LineInfoNode,
Const, PartialStruct
Const, PartialStruct, InterConditional, PartialOpaque

import Core: CodeInfo, MethodInstance, CodeInstance, GotoNode, GotoIfNot, ReturnNode,
NewvarNode, SSAValue, Slot, SlotNumber, TypedSlot, Argument,
PiNode, PhiNode, PhiCNode, UpsilonNode, LineInfoNode,
Const, PartialStruct
Const, PartialStruct, InterConditional, PartialOpaque

end

Expand Down
31 changes: 31 additions & 0 deletions base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2250,6 +2250,13 @@ function abstract_eval_statement_expr(interp::AbstractInterpreter, e::Expr, vtyp
merge_effects!(interp, sv, effects)
if isa(sv, InferenceState)
sv.stmt_info[sv.currpc] = info
# mark this call statement as DCE-elgible
# TODO better to do this in a single pass based on the `info` object at the end of abstractinterpret?
if is_removable_if_unused(effects)
add_curr_ssaflag!(sv, IR_FLAG_EFFECT_FREE)
else
sub_curr_ssaflag!(sv, IR_FLAG_EFFECT_FREE)
end
end
end
t = rt
Expand Down Expand Up @@ -2309,6 +2316,7 @@ function abstract_eval_statement_expr(interp::AbstractInterpreter, e::Expr, vtyp
else
consistent = ALWAYS_FALSE
nothrow = false
t = refine_partial_type(t)
end
effects = Effects(EFFECTS_TOTAL; consistent, nothrow)
merge_effects!(interp, sv, effects)
Expand All @@ -2327,6 +2335,8 @@ function abstract_eval_statement_expr(interp::AbstractInterpreter, e::Expr, vtyp
nothrow = isexact
t = PartialStruct(t, at.fields::Vector{Any})
end
else
t = refine_partial_type(t)
end
consistent = !ismutabletype(t) ? ALWAYS_TRUE : CONSISTENT_IF_NOTRETURNED
effects = Effects(EFFECTS_TOTAL; consistent, nothrow)
Expand Down Expand Up @@ -2359,6 +2369,14 @@ function abstract_eval_statement_expr(interp::AbstractInterpreter, e::Expr, vtyp
(;rt, effects) = abstract_eval_foreigncall(interp, e, vtypes, sv, mi)
t = rt
merge_effects!(interp, sv, effects)
if isa(sv, InferenceState)
# mark this call statement as DCE-elgible
if is_removable_if_unused(effects)
add_curr_ssaflag!(sv, IR_FLAG_EFFECT_FREE)
else
sub_curr_ssaflag!(sv, IR_FLAG_EFFECT_FREE)
end
end
elseif ehead === :cfunction
effects = EFFECTS_UNKNOWN
merge_effects!(interp, sv, effects)
Expand Down Expand Up @@ -2421,6 +2439,19 @@ function abstract_eval_statement_expr(interp::AbstractInterpreter, e::Expr, vtyp
return RTEffects(t, effects)
end

# refine the result of instantiation of partially-known type `t` if some invariant can be assumed
function refine_partial_type(@nospecialize t)
tβ€² = unwrap_unionall(t)
if isa(tβ€², DataType) && tβ€².name === _NAMEDTUPLE_NAME && length(tβ€².parameters) == 2 &&
(tβ€².parameters[1] === () || tβ€².parameters[2] === Tuple{})
# if the first/second parameter of `NamedTuple` is known to be empty,
# the second/first argument should also be empty tuple type,
# so refine it here
return Const(NamedTuple())
end
return t
end

function abstract_eval_foreigncall(interp::AbstractInterpreter, e::Expr, vtypes::Union{VarTable, Nothing}, sv::Union{InferenceState, IRCode}, mi::Union{MethodInstance, Nothing}=nothing)
abstract_eval_value(interp, e.args[1], vtypes, sv)
miβ€² = isa(sv, InferenceState) ? sv.linfo : mi
Expand Down
44 changes: 33 additions & 11 deletions base/compiler/abstractlattice.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,36 +44,41 @@ end
widenlattice(𝕃::ConditionalsLattice) = 𝕃.parent
is_valid_lattice_norec(::ConditionalsLattice, @nospecialize(elem)) = isa(elem, Conditional)

"""
struct InterConditionalsLattice{𝕃<:AbstractLattice} <: AbstractLattice
A lattice extending a base lattice `𝕃` and adjoining `InterConditional`.
"""
struct InterConditionalsLattice{𝕃<:AbstractLattice} <: AbstractLattice
parent::𝕃
end
widenlattice(𝕃::InterConditionalsLattice) = 𝕃.parent
is_valid_lattice_norec(::InterConditionalsLattice, @nospecialize(elem)) = isa(elem, InterConditional)

"""
struct MustAliasesLattice{𝕃}
struct MustAliasesLattice{𝕃<:AbstractLattice}
A lattice extending lattice `𝕃` and adjoining `MustAlias`.
"""
struct MustAliasesLattice{𝕃 <: AbstractLattice} <: AbstractLattice
struct MustAliasesLattice{𝕃<:AbstractLattice} <: AbstractLattice
parent::𝕃
end
widenlattice(𝕃::MustAliasesLattice) = 𝕃.parent
is_valid_lattice_norec(𝕃::MustAliasesLattice, @nospecialize(elem)) = isa(elem, MustAlias)
is_valid_lattice_norec(::MustAliasesLattice, @nospecialize(elem)) = isa(elem, MustAlias)

"""
struct InterMustAliasesLattice{𝕃}
struct InterMustAliasesLattice{𝕃<:AbstractLattice}
A lattice extending lattice `𝕃` and adjoining `InterMustAlias`.
"""
struct InterMustAliasesLattice{𝕃 <: AbstractLattice} <: AbstractLattice
struct InterMustAliasesLattice{𝕃<:AbstractLattice} <: AbstractLattice
parent::𝕃
end
widenlattice(𝕃::InterMustAliasesLattice) = 𝕃.parent
is_valid_lattice_norec(𝕃::InterMustAliasesLattice, @nospecialize(elem)) = isa(elem, InterMustAlias)
is_valid_lattice_norec(::InterMustAliasesLattice, @nospecialize(elem)) = isa(elem, InterMustAlias)

const AnyConditionalsLattice{𝕃} = Union{ConditionalsLattice{𝕃}, InterConditionalsLattice{𝕃}}
const AnyMustAliasesLattice{𝕃} = Union{MustAliasesLattice{𝕃}, InterMustAliasesLattice{𝕃}}
const AnyConditionalsLattice{𝕃<:AbstractLattice} = Union{ConditionalsLattice{𝕃}, InterConditionalsLattice{𝕃}}
const AnyMustAliasesLattice{𝕃<:AbstractLattice} = Union{MustAliasesLattice{𝕃}, InterMustAliasesLattice{𝕃}}

const SimpleInferenceLattice = typeof(PartialsLattice(ConstsLattice()))
const BaseInferenceLattice = typeof(ConditionalsLattice(SimpleInferenceLattice.instance))
Expand All @@ -83,7 +88,7 @@ const IPOResultLattice = typeof(InterConditionalsLattice(SimpleInferenceLattice.
struct InferenceLattice{𝕃<:AbstractLattice} <: AbstractLattice
The full lattice used for abstract interpretation during inference.
Takes a base lattice `𝕃` and adjoins `LimitedAccuracy`.
Extends a base lattice `𝕃` and adjoins `LimitedAccuracy`.
"""
struct InferenceLattice{𝕃<:AbstractLattice} <: AbstractLattice
parent::𝕃
Expand All @@ -94,8 +99,8 @@ is_valid_lattice_norec(::InferenceLattice, @nospecialize(elem)) = isa(elem, Limi
"""
struct OptimizerLattice{𝕃<:AbstractLattice} <: AbstractLattice
The lattice used by the optimizer. Extends
`BaseInferenceLattice` with `MaybeUndef`.
The lattice used by the optimizer.
Extends a base lattice `𝕃` and adjoins `MaybeUndef`.
"""
struct OptimizerLattice{𝕃<:AbstractLattice} <: AbstractLattice
parent::𝕃
Expand Down Expand Up @@ -131,6 +136,23 @@ remaining mostly associative and commutative.
"""
function tmerge end

"""
tmerge_field(𝕃::AbstractLattice, a, b) -> nothing or lattice element
Compute a lattice join of elements `a` and `b` over the lattice `𝕃`,
where `a` and `b` are fields of `PartialStruct` or `Const`.
This is an opt-in interface to allow external lattice implementation to provide its own
field-merge strategy. If it returns `nothing`, `tmerge(::PartialsLattice, ...)`
will use the default aggressive type merge implementation that does not use `tmerge`
recursively to reach convergence.
"""
function tmerge_field end

function tmerge_field(𝕃::AbstractLattice, @nospecialize(a), @nospecialize(b))
return tmerge_field(widenlattice(𝕃), a, b)
end
tmerge_field(::JLTypeLattice, @nospecialize(a), @nospecialize(b)) = nothing

"""
βŠ‘(𝕃::AbstractLattice, a, b)
Expand Down
2 changes: 2 additions & 0 deletions base/compiler/inferencestate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,8 @@ function print_callstack(sv::InferenceState)
end

get_curr_ssaflag(sv::InferenceState) = sv.src.ssaflags[sv.currpc]
add_curr_ssaflag!(sv::InferenceState, flag::UInt8) = sv.src.ssaflags[sv.currpc] |= flag
sub_curr_ssaflag!(sv::InferenceState, flag::UInt8) = sv.src.ssaflags[sv.currpc] &= ~flag

function narguments(sv::InferenceState)
def = sv.linfo.def
Expand Down
Loading

0 comments on commit 979ad5f

Please sign in to comment.