Skip to content

Commit ecee0f7

Browse files
authored
Backports for 1.12.1 (#59705)
2 parents b907bd0 + 4f05d8d commit ecee0f7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+738
-302
lines changed

.buildkite-external-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
main
1+
release-julia-1.12

Compiler/src/Compiler.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ using Core: ABIOverride, Builtin, CodeInstance, IntrinsicFunction, MethodInstanc
4141
MethodTable, MethodCache, PartialOpaque, SimpleVector, TypeofVararg,
4242
_apply_iterate, apply_type, compilerbarrier, donotdelete, memoryref_isassigned,
4343
memoryrefget, memoryrefnew, memoryrefoffset, memoryrefset!, print, println, show, svec,
44-
typename, unsafe_write, write
44+
typename, unsafe_write, write, stdout, stderr
4545

46-
using Base
4746
using Base: @_foldable_meta, @_gc_preserve_begin, @_gc_preserve_end, @nospecializeinfer,
4847
PARTITION_KIND_GLOBAL, PARTITION_KIND_UNDEF_CONST, PARTITION_KIND_BACKDATED_CONST, PARTITION_KIND_DECLARED,
4948
PARTITION_FLAG_DEPWARN,
@@ -64,7 +63,10 @@ using Base: @_foldable_meta, @_gc_preserve_begin, @_gc_preserve_end, @nospeciali
6463
partition_restriction, quoted, rename_unionall, rewrap_unionall, specialize_method,
6564
structdiff, tls_world_age, unconstrain_vararg_length, unionlen, uniontype_layout,
6665
uniontypes, unsafe_convert, unwrap_unionall, unwrapva, vect, widen_diagonal,
67-
_uncompressed_ir, maybe_add_binding_backedge!
66+
_uncompressed_ir, maybe_add_binding_backedge!,
67+
devnull, devnull as stdin
68+
69+
using Base
6870
using Base.Order
6971

7072
import Base: ==, _topmod, append!, convert, copy, copy!, findall, first, get, get!,

Compiler/src/abstractinterpretation.jl

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2488,7 +2488,7 @@ function abstract_eval_setglobal!(interp::AbstractInterpreter, sv::AbsIntState,
24882488
(rt, exct) = global_assignment_rt_exct(interp, sv, saw_latestworld, gr, v)
24892489
return CallMeta(rt, exct, Effects(setglobal!_effects, nothrow=exct===Bottom), GlobalAccessInfo(convert(Core.Binding, gr)))
24902490
end
2491-
return CallMeta(Union{}, TypeError, EFFECTS_THROWS, NoCallInfo())
2491+
return CallMeta(Union{}, Union{TypeError, ErrorException}, EFFECTS_THROWS, NoCallInfo())
24922492
end
24932493
= partialorder(typeinf_lattice(interp))
24942494
if !(hasintersect(widenconst(M), Module) && hasintersect(widenconst(s), Symbol))
@@ -3444,9 +3444,13 @@ function refine_partial_type(@nospecialize t)
34443444
return t
34453445
end
34463446

3447-
abstract_eval_nonlinearized_foreigncall_name(interp::AbstractInterpreter, e, sstate::StatementState, sv::IRInterpretationState) = nothing
3447+
abstract_eval_nonlinearized_foreigncall_name(
3448+
::AbstractInterpreter, @nospecialize(e), ::StatementState, ::IRInterpretationState
3449+
) = nothing
34483450

3449-
function abstract_eval_nonlinearized_foreigncall_name(interp::AbstractInterpreter, e, sstate::StatementState, sv::AbsIntState)
3451+
function abstract_eval_nonlinearized_foreigncall_name(
3452+
interp::AbstractInterpreter, @nospecialize(e), sstate::StatementState, sv::InferenceState
3453+
)
34503454
if isexpr(e, :call)
34513455
n = length(e.args)
34523456
argtypes = Vector{Any}(undef, n)
@@ -3728,7 +3732,7 @@ end
37283732

37293733
function global_assignment_rt_exct(interp::AbstractInterpreter, sv::AbsIntState, saw_latestworld::Bool, g::GlobalRef, @nospecialize(newty))
37303734
if saw_latestworld
3731-
return Pair{Any,Any}(newty, ErrorException)
3735+
return Pair{Any,Any}(newty, Union{TypeError, ErrorException})
37323736
end
37333737
newty′ = RefValue{Any}(newty)
37343738
(valid_worlds, ret) = scan_partitions(interp, g, sv.world) do interp::AbstractInterpreter, ::Core.Binding, partition::Core.BindingPartition
@@ -3743,15 +3747,16 @@ function global_assignment_binding_rt_exct(interp::AbstractInterpreter, partitio
37433747
if is_some_guard(kind)
37443748
return Pair{Any,Any}(newty, ErrorException)
37453749
elseif is_some_const_binding(kind) || is_some_imported(kind)
3746-
return Pair{Any,Any}(Bottom, ErrorException)
3750+
# N.B.: Backdating should not improve inference in an earlier world
3751+
return Pair{Any,Any}(kind == PARTITION_KIND_BACKDATED_CONST ? newty : Bottom, ErrorException)
37473752
end
37483753
ty = kind == PARTITION_KIND_DECLARED ? Any : partition_restriction(partition)
37493754
wnewty = widenconst(newty)
37503755
if !hasintersect(wnewty, ty)
3751-
return Pair{Any,Any}(Bottom, ErrorException)
3756+
return Pair{Any,Any}(Bottom, TypeError)
37523757
elseif !(wnewty <: ty)
37533758
retty = tmeet(typeinf_lattice(interp), newty, ty)
3754-
return Pair{Any,Any}(retty, ErrorException)
3759+
return Pair{Any,Any}(retty, TypeError)
37553760
end
37563761
return Pair{Any,Any}(newty, Bottom)
37573762
end

Compiler/src/opaque_closure.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ function Core.OpaqueClosure(ir::IRCode, @nospecialize env...;
4848
end
4949
src.slotflags = fill(zero(UInt8), nargtypes)
5050
src.slottypes = copy(ir.argtypes)
51+
src.min_world = ir.valid_worlds.min_world
52+
src.max_world = ir.valid_worlds.max_world
5153
src.isva = isva
5254
src.nargs = UInt(nargtypes)
5355
src = ir_to_codeinf!(src, ir)

Compiler/src/tfuncs.jl

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -586,15 +586,19 @@ add_tfunc(nfields, 1, 1, nfields_tfunc, 1)
586586
add_tfunc(Core._expr, 1, INT_INF, @nospecs((𝕃::AbstractLattice, args...)->Expr), 100)
587587
add_tfunc(svec, 0, INT_INF, @nospecs((𝕃::AbstractLattice, args...)->SimpleVector), 20)
588588

589-
@nospecs function _svec_len_tfunc(𝕃::AbstractLattice, s)
589+
@nospecs function _svec_len_tfunc(::AbstractLattice, s)
590590
if isa(s, Const) && isa(s.val, SimpleVector)
591591
return Const(length(s.val))
592592
end
593593
return Int
594594
end
595595
add_tfunc(Core._svec_len, 1, 1, _svec_len_tfunc, 1)
596+
@nospecs function _svec_len_nothrow(𝕃::AbstractLattice, s)
597+
= partialorder(𝕃)
598+
return s SimpleVector
599+
end
596600

597-
@nospecs function _svec_ref_tfunc(𝕃::AbstractLattice, s, i)
601+
@nospecs function _svec_ref_tfunc(::AbstractLattice, s, i)
598602
if isa(s, Const) && isa(i, Const)
599603
s, i = s.val, i.val
600604
if isa(s, SimpleVector) && isa(i, Int)
@@ -604,7 +608,7 @@ add_tfunc(Core._svec_len, 1, 1, _svec_len_tfunc, 1)
604608
return Any
605609
end
606610
add_tfunc(Core._svec_ref, 2, 2, _svec_ref_tfunc, 1)
607-
@nospecs function typevar_tfunc(𝕃::AbstractLattice, n, lb_arg, ub_arg)
611+
@nospecs function typevar_tfunc(::AbstractLattice, n, lb_arg, ub_arg)
608612
lb = Union{}
609613
ub = Any
610614
ub_certain = lb_certain = true
@@ -2363,7 +2367,7 @@ function _builtin_nothrow(𝕃::AbstractLattice, @nospecialize(f::Builtin), argt
23632367
return compilerbarrier_nothrow(argtypes[1], nothing)
23642368
elseif f === Core._svec_len
23652369
na == 1 || return false
2366-
return _svec_len_tfunc(𝕃, argtypes[1]) isa Const
2370+
return _svec_len_nothrow(𝕃, argtypes[1])
23672371
elseif f === Core._svec_ref
23682372
na == 2 || return false
23692373
return _svec_ref_tfunc(𝕃, argtypes[1], argtypes[2]) isa Const
@@ -2974,6 +2978,13 @@ function intrinsic_exct(𝕃::AbstractLattice, f::IntrinsicFunction, argtypes::V
29742978
return Union{}
29752979
end
29762980

2981+
if f === Intrinsics.add_ptr || f === Intrinsics.sub_ptr
2982+
if !(argtypes[1] Ptr && argtypes[2] UInt)
2983+
return TypeError
2984+
end
2985+
return Union{}
2986+
end
2987+
29772988
# The remaining intrinsics are math/bits/comparison intrinsics.
29782989
# All the non-floating point intrinsics work on primitive values of the same type.
29792990
isshift = f === shl_int || f === lshr_int || f === ashr_int

Compiler/test/effects.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,6 +1438,11 @@ let effects = Base.infer_effects(Core.Intrinsics.pointerset, Tuple{Vararg{Any}})
14381438
@test Compiler.is_consistent(effects)
14391439
@test !Compiler.is_effect_free(effects)
14401440
end
1441+
@test Compiler.intrinsic_nothrow(Core.Intrinsics.add_ptr, Any[Ptr{Int}, UInt])
1442+
@test Compiler.intrinsic_nothrow(Core.Intrinsics.sub_ptr, Any[Ptr{Int}, UInt])
1443+
@test !Compiler.intrinsic_nothrow(Core.Intrinsics.add_ptr, Any[UInt, UInt])
1444+
@test !Compiler.intrinsic_nothrow(Core.Intrinsics.sub_ptr, Any[UInt, UInt])
1445+
@test Compiler.is_nothrow(Base.infer_effects(+, Tuple{Ptr{UInt8}, UInt}))
14411446
# effects modeling for atomic intrinsics
14421447
# these functions especially need to be marked !effect_free since they imply synchronization
14431448
for atomicfunc = Any[
@@ -1471,3 +1476,5 @@ let effects = Base.infer_effects((Core.SimpleVector,Int); optimize=false) do sve
14711476
@test !Compiler.is_nothrow(effects)
14721477
@test Compiler.is_terminates(effects)
14731478
end
1479+
1480+
@test Compiler.is_nothrow(Base.infer_effects(length, (Core.SimpleVector,)))

Compiler/test/inference.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6235,7 +6235,7 @@ g57292(xs::String...) = getfield(("abc",), 1, :not_atomic, xs...)
62356235
global invalid_setglobal!_exct_modeling::Int
62366236
@test Base.infer_exception_type((Float64,)) do x
62376237
setglobal!(@__MODULE__, :invalid_setglobal!_exct_modeling, x)
6238-
end == ErrorException
6238+
end == TypeError
62396239

62406240
# Issue #58257 - Hang in inference during BindingPartition resolution
62416241
module A58257

Compiler/test/special_loading.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# This file is a part of Julia. License is MIT: https://julialang.org/license
22

3-
mktempdir() do dir
3+
include(joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "test", "tempdepot.jl"))
4+
mkdepottempdir() do dir
45
withenv("JULIA_DEPOT_PATH" => dir * (Sys.iswindows() ? ";" : ":"), "JULIA_LOAD_PATH" => nothing) do
56
cd(joinpath(@__DIR__, "CompilerLoadingTest")) do
67
@test success(pipeline(`$(Base.julia_cmd()[1]) --startup-file=no --project=. compiler_loading_test.jl`; stdout, stderr))

Compiler/test/validation.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ using Test, Core.IR
44

55
include("setup_Compiler.jl")
66

7+
@testset "stdio validation" begin
8+
for s in (:stdout, :stderr, :print, :println, :write)
9+
@test getglobal(Compiler, s) === getglobal(Core, s)
10+
@test isconst(Compiler, s)
11+
end
12+
@test Compiler.stdin === devnull
13+
@test isconst(Compiler, :stdin)
14+
end
15+
716
function f22938(a, b, x...)
817
nothing
918
nothing

Makefile

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,7 @@ julia-src-release julia-src-debug : julia-src-% : julia-deps julia_flisp.boot.in
110110
julia-cli-release julia-cli-debug: julia-cli-% : julia-deps
111111
@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT)/cli $*
112112

113-
julia-sysimg-ji : $(TOP_LEVEL_PKG_LINK_TARGETS) julia-stdlib julia-base julia-cli-$(JULIA_BUILD_MODE) julia-src-$(JULIA_BUILD_MODE) | $(build_private_libdir)
114-
@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT) -f sysimage.mk sysimg-ji JULIA_EXECUTABLE='$(JULIA_EXECUTABLE)'
115-
116-
julia-sysimg-bc : $(TOP_LEVEL_PKG_LINK_TARGETS) julia-stdlib julia-base julia-cli-$(JULIA_BUILD_MODE) julia-src-$(JULIA_BUILD_MODE) | $(build_private_libdir)
117-
@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT) -f sysimage.mk sysimg-bc JULIA_EXECUTABLE='$(JULIA_EXECUTABLE)'
118-
119-
julia-sysimg-release julia-sysimg-debug : julia-sysimg-% : julia-sysimg-ji julia-src-%
113+
julia-sysimg-release julia-sysimg-debug : julia-sysimg-% : julia-src-% $(TOP_LEVEL_PKG_LINK_TARGETS) julia-stdlib julia-base julia-cli-% julia-src-% | $(build_private_libdir)
120114
@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT) -f sysimage.mk sysimg-$*
121115

122116
julia-debug julia-release : julia-% : julia-sysimg-% julia-src-% julia-symlink julia-libccalltest \

0 commit comments

Comments
 (0)