Skip to content

Commit 7afc7de

Browse files
authored
Merge branch 'master' into jn/45759-46557-31485
2 parents 7ef53af + 517ad06 commit 7afc7de

File tree

142 files changed

+3135
-2306
lines changed

Some content is hidden

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

142 files changed

+3135
-2306
lines changed

Make.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1503,7 +1503,7 @@ endef
15031503
WINE ?= wine
15041504

15051505
ifeq ($(BINARY),32)
1506-
HEAPLIM := --heap-size-hint=500M
1506+
HEAPLIM := --heap-size-hint=1000M
15071507
else
15081508
HEAPLIM :=
15091509
endif

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ and then use the command prompt to change into the resulting julia directory. By
9393
Julia. However, most users should use the [most recent stable version](https://github.com/JuliaLang/julia/releases)
9494
of Julia. You can get this version by running:
9595

96-
git checkout v1.9.0
96+
git checkout v1.9.2
9797

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

base/binaryplatforms.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ julia> wordsize(Platform("x86_64", "macos"))
494494
wordsize(p::AbstractPlatform) = (arch(p) ("i686", "armv6l", "armv7l")) ? 32 : 64
495495

496496
"""
497-
triplet(p::AbstractPlatform; exclude_tags::Vector{String})
497+
triplet(p::AbstractPlatform)
498498
499499
Get the target triplet for the given `Platform` object as a `String`.
500500

base/bitarray.jl

+6-4
Original file line numberDiff line numberDiff line change
@@ -1791,9 +1791,10 @@ function bit_map!(f::F, dest::BitArray, A::BitArray) where F
17911791
dest_last = destc[len_Ac]
17921792
_msk = _msk_end(A)
17931793
# first zero out the bits mask is going to change
1794-
destc[len_Ac] = (dest_last & (~_msk))
17951794
# then update bits by `or`ing with a masked RHS
1796-
destc[len_Ac] |= f(Ac[len_Ac]) & _msk
1795+
# DO NOT SEPARATE ONTO TO LINES.
1796+
# Otherwise there will be bugs when Ac aliases destc
1797+
destc[len_Ac] = (dest_last & (~_msk)) | f(Ac[len_Ac]) & _msk
17971798
dest
17981799
end
17991800
function bit_map!(f::F, dest::BitArray, A::BitArray, B::BitArray) where F
@@ -1812,9 +1813,10 @@ function bit_map!(f::F, dest::BitArray, A::BitArray, B::BitArray) where F
18121813
dest_last = destc[len_Ac]
18131814
_msk = _msk_end(min_bitlen)
18141815
# first zero out the bits mask is going to change
1815-
destc[len_Ac] = (dest_last & ~(_msk))
18161816
# then update bits by `or`ing with a masked RHS
1817-
destc[len_Ac] |= f(Ac[end], Bc[end]) & _msk
1817+
# DO NOT SEPARATE ONTO TO LINES.
1818+
# Otherwise there will be bugs when Ac or Bc aliases destc
1819+
destc[len_Ac] = (dest_last & ~(_msk)) | f(Ac[end], Bc[end]) & _msk
18181820
dest
18191821
end
18201822

base/client.jl

+8-8
Original file line numberDiff line numberDiff line change
@@ -325,11 +325,11 @@ function exec_options(opts)
325325
end
326326
end
327327
if repl || is_interactive::Bool
328-
if interactiveinput
329-
banner = (opts.banner != 0) # --banner!=no
330-
else
331-
banner = (opts.banner == 1) # --banner=yes
332-
end
328+
b = opts.banner
329+
auto = b == -1
330+
banner = b == 0 || (auto && !interactiveinput) ? :no :
331+
b == 1 || (auto && interactiveinput) ? :yes :
332+
:short # b == 2
333333
run_main_repl(interactiveinput, quiet, banner, history_file, color_set)
334334
end
335335
nothing
@@ -409,14 +409,14 @@ end
409409
global active_repl
410410

411411
# run the requested sort of evaluation loop on stdio
412-
function run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_file::Bool, color_set::Bool)
412+
function run_main_repl(interactive::Bool, quiet::Bool, banner::Symbol, history_file::Bool, color_set::Bool)
413413
load_InteractiveUtils()
414414

415415
if interactive && isassigned(REPL_MODULE_REF)
416416
invokelatest(REPL_MODULE_REF[]) do REPL
417417
term_env = get(ENV, "TERM", @static Sys.iswindows() ? "" : "dumb")
418418
term = REPL.Terminals.TTYTerminal(term_env, stdin, stdout, stderr)
419-
banner && Base.banner(term)
419+
banner == :no || Base.banner(term, short=banner==:short)
420420
if term.term_type == "dumb"
421421
repl = REPL.BasicREPL(term)
422422
quiet || @warn "Terminal not fully functional"
@@ -436,7 +436,7 @@ function run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_fil
436436
if interactive && !quiet
437437
@warn "REPL provider not available: using basic fallback"
438438
end
439-
banner && Base.banner()
439+
banner == :no || Base.banner(short=banner==:short)
440440
let input = stdin
441441
if isa(input, File) || isa(input, IOStream)
442442
# for files, we can slurp in the whole thing at once

base/compiler/abstractinterpretation.jl

+36-16
Original file line numberDiff line numberDiff line change
@@ -773,11 +773,13 @@ struct ConstCallResults
773773
const_result::ConstResult
774774
effects::Effects
775775
edge::MethodInstance
776-
ConstCallResults(@nospecialize(rt),
777-
const_result::ConstResult,
778-
effects::Effects,
779-
edge::MethodInstance) =
780-
new(rt, const_result, effects, edge)
776+
function ConstCallResults(
777+
@nospecialize(rt),
778+
const_result::ConstResult,
779+
effects::Effects,
780+
edge::MethodInstance)
781+
return new(rt, const_result, effects, edge)
782+
end
781783
end
782784

783785
function abstract_call_method_with_const_args(interp::AbstractInterpreter,
@@ -791,24 +793,33 @@ function abstract_call_method_with_const_args(interp::AbstractInterpreter,
791793
return nothing
792794
end
793795
eligibility = concrete_eval_eligible(interp, f, result, arginfo, sv)
796+
concrete_eval_result = nothing
794797
if eligibility === :concrete_eval
795-
return concrete_eval_call(interp, f, result, arginfo, sv; invokecall)
798+
concrete_eval_result = concrete_eval_call(interp, f, result, arginfo, sv, invokecall)
799+
# if we don't inline the result of this concrete evaluation,
800+
# give const-prop' a chance to inline a better method body
801+
if !may_optimize(interp) || (
802+
may_inline_concrete_result(concrete_eval_result.const_result::ConcreteResult) ||
803+
concrete_eval_result.rt === Bottom) # unless this call deterministically throws and thus is non-inlineable
804+
return concrete_eval_result
805+
end
806+
# TODO allow semi-concrete interp for this call?
796807
end
797808
mi = maybe_get_const_prop_profitable(interp, result, f, arginfo, si, match, sv)
798-
mi === nothing && return nothing
809+
mi === nothing && return concrete_eval_result
799810
if is_constprop_recursed(result, mi, sv)
800811
add_remark!(interp, sv, "[constprop] Edge cycle encountered")
801812
return nothing
802813
end
803814
# try semi-concrete evaluation
804815
if eligibility === :semi_concrete_eval
805-
res = semi_concrete_eval_call(interp, mi, result, arginfo, sv)
806-
if res !== nothing
807-
return res
816+
irinterp_result = semi_concrete_eval_call(interp, mi, result, arginfo, sv)
817+
if irinterp_result !== nothing
818+
return irinterp_result
808819
end
809820
end
810821
# try constant prop'
811-
return const_prop_call(interp, mi, result, arginfo, sv)
822+
return const_prop_call(interp, mi, result, arginfo, sv, concrete_eval_result)
812823
end
813824

814825
function const_prop_enabled(interp::AbstractInterpreter, sv::AbsIntState, match::MethodMatch)
@@ -887,7 +898,7 @@ function collect_const_args(argtypes::Vector{Any}, start::Int)
887898
end
888899

889900
function concrete_eval_call(interp::AbstractInterpreter,
890-
@nospecialize(f), result::MethodCallResult, arginfo::ArgInfo, sv::AbsIntState;
901+
@nospecialize(f), result::MethodCallResult, arginfo::ArgInfo, sv::AbsIntState,
891902
invokecall::Union{InvokeCall,Nothing}=nothing)
892903
args = collect_const_args(arginfo, #=start=#2)
893904
if invokecall !== nothing
@@ -901,7 +912,7 @@ function concrete_eval_call(interp::AbstractInterpreter,
901912
Core._call_in_world_total(world, f, args...)
902913
catch
903914
# The evaluation threw. By :consistent-cy, we're guaranteed this would have happened at runtime
904-
return ConstCallResults(Union{}, ConcreteResult(edge, result.effects), result.effects, edge)
915+
return ConstCallResults(Bottom, ConcreteResult(edge, result.effects), result.effects, edge)
905916
end
906917
return ConstCallResults(Const(value), ConcreteResult(edge, EFFECTS_TOTAL, value), EFFECTS_TOTAL, edge)
907918
end
@@ -1159,16 +1170,20 @@ function semi_concrete_eval_call(interp::AbstractInterpreter,
11591170
# that are newly resovled by irinterp
11601171
# state = InliningState(interp)
11611172
# ir = ssa_inlining_pass!(irsv.ir, state, propagate_inbounds(irsv))
1162-
new_effects = Effects(result.effects; nothrow)
1163-
return ConstCallResults(rt, SemiConcreteResult(mi, ir, new_effects), new_effects, mi)
1173+
effects = result.effects
1174+
if !is_nothrow(effects)
1175+
effects = Effects(effects; nothrow)
1176+
end
1177+
return ConstCallResults(rt, SemiConcreteResult(mi, ir, effects), effects, mi)
11641178
end
11651179
end
11661180
end
11671181
return nothing
11681182
end
11691183

11701184
function const_prop_call(interp::AbstractInterpreter,
1171-
mi::MethodInstance, result::MethodCallResult, arginfo::ArgInfo, sv::AbsIntState)
1185+
mi::MethodInstance, result::MethodCallResult, arginfo::ArgInfo, sv::AbsIntState,
1186+
concrete_eval_result::Union{Nothing,ConstCallResults}=nothing)
11721187
inf_cache = get_inference_cache(interp)
11731188
𝕃ᵢ = typeinf_lattice(interp)
11741189
inf_result = cache_lookup(𝕃ᵢ, mi, arginfo.argtypes, inf_cache)
@@ -1191,6 +1206,11 @@ function const_prop_call(interp::AbstractInterpreter,
11911206
return nothing
11921207
end
11931208
@assert inf_result.result !== nothing
1209+
if concrete_eval_result !== nothing
1210+
# override return type and effects with concrete evaluation result if available
1211+
inf_result.result = concrete_eval_result.rt
1212+
inf_result.ipo_effects = concrete_eval_result.effects
1213+
end
11941214
else
11951215
# found the cache for this constant prop'
11961216
if inf_result.result === nothing

base/compiler/optimize.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ function slot2reg(ir::IRCode, ci::CodeInfo, sv::OptimizationState)
618618
svdef = sv.linfo.def
619619
nargs = isa(svdef, Method) ? Int(svdef.nargs) : 0
620620
@timeit "domtree 1" domtree = construct_domtree(ir.cfg.blocks)
621-
defuse_insts = scan_slot_def_use(nargs, ci, ir.stmts.inst)
621+
defuse_insts = scan_slot_def_use(nargs, ci, ir.stmts.stmt)
622622
𝕃ₒ = optimizer_lattice(sv.inlining.interp)
623623
@timeit "construct_ssa" ir = construct_ssa!(ci, ir, domtree, defuse_insts, sv.slottypes, 𝕃ₒ) # consumes `ir`
624624
# NOTE now we have converted `ir` to the SSA form and eliminated slots
@@ -646,7 +646,7 @@ function statement_cost(ex::Expr, line::Int, src::Union{CodeInfo, IRCode}, sptyp
646646
if ftyp === IntrinsicFunction && farg isa SSAValue
647647
# if this comes from code that was already inlined into another function,
648648
# Consts have been widened. try to recover in simple cases.
649-
farg = isa(src, CodeInfo) ? src.code[farg.id] : src.stmts[farg.id][:inst]
649+
farg = isa(src, CodeInfo) ? src.code[farg.id] : src[farg][:stmt]
650650
if isa(farg, GlobalRef) || isa(farg, QuoteNode) || isa(farg, IntrinsicFunction) || isexpr(farg, :static_parameter)
651651
ftyp = argextype(farg, src, sptypes)
652652
end
@@ -741,7 +741,7 @@ function inline_cost(ir::IRCode, params::OptimizationParams,
741741
cost_threshold::Integer=params.inline_cost_threshold)::InlineCostType
742742
bodycost::Int = 0
743743
for line = 1:length(ir.stmts)
744-
stmt = ir.stmts[line][:inst]
744+
stmt = ir[SSAValue(line)][:stmt]
745745
thiscost = statement_or_branch_cost(stmt, line, ir, ir.sptypes, params)
746746
bodycost = plus_saturate(bodycost, thiscost)
747747
bodycost > cost_threshold && return MAX_INLINE_COST

base/compiler/ssair/EscapeAnalysis/EscapeAnalysis.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ function analyze_escapes(ir::IRCode, nargs::Int, call_resolved::Bool, get_escape
671671
local anyupdate = false
672672

673673
for pc in nstmts:-1:1
674-
stmt = getinst(ir, pc)[:inst]
674+
stmt = getinst(ir, pc)[:stmt]
675675

676676
# collect escape information
677677
if isa(stmt, Expr)
@@ -784,7 +784,7 @@ function compute_frameinfo(ir::IRCode, call_resolved::Bool)
784784
end
785785
for idx in 1:nstmts+nnewnodes
786786
inst = getinst(ir, idx)
787-
stmt = inst[:inst]
787+
stmt = inst[:stmt]
788788
if !call_resolved
789789
# TODO don't call `check_effect_free!` in the inlinear
790790
check_effect_free!(ir, idx, stmt, inst[:type], 𝕃ₒ)

base/compiler/ssair/inlining.jl

+17-16
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ function cfg_inline_item!(ir::IRCode, idx::Int, todo::InliningTodo, state::CFGIn
135135
last_block_idx = last(state.cfg.blocks[block].stmts)
136136
if false # TODO: ((idx+1) == last_block_idx && isa(ir[SSAValue(last_block_idx)], GotoNode))
137137
need_split = false
138-
post_bb_id = -ir[SSAValue(last_block_idx)][:inst].label
138+
post_bb_id = -ir[SSAValue(last_block_idx)][:stmt].label
139139
else
140140
post_bb_id = length(state.new_cfg_blocks) + length(inlinee_cfg.blocks) + (need_split_before ? 1 : 0)
141141
need_split = true #!(idx == last_block_idx)
@@ -196,7 +196,7 @@ function cfg_inline_item!(ir::IRCode, idx::Int, todo::InliningTodo, state::CFGIn
196196
for (old_block, new_block) in enumerate(bb_rename_range)
197197
if (length(state.new_cfg_blocks[new_block].succs) == 0)
198198
terminator_idx = last(inlinee_cfg.blocks[old_block].stmts)
199-
terminator = todo.ir[SSAValue(terminator_idx)][:inst]
199+
terminator = todo.ir[SSAValue(terminator_idx)][:stmt]
200200
if isa(terminator, ReturnNode) && isdefined(terminator, :val)
201201
any_edges = true
202202
push!(state.new_cfg_blocks[new_block].succs, post_bb_id)
@@ -556,7 +556,7 @@ function ir_inline_unionsplit!(compact::IncrementalCompact, idx::Int, argexprs::
556556
union_split::UnionSplit, boundscheck::Symbol,
557557
todo_bbs::Vector{Tuple{Int,Int}}, params::OptimizationParams)
558558
(; fully_covered, atype, cases, bbs) = union_split
559-
stmt, typ, line = compact.result[idx][:inst], compact.result[idx][:type], compact.result[idx][:line]
559+
stmt, typ, line = compact.result[idx][:stmt], compact.result[idx][:type], compact.result[idx][:line]
560560
join_bb = bbs[end]
561561
pn = PhiNode()
562562
local bb = compact.active_result_bb
@@ -605,9 +605,9 @@ function ir_inline_unionsplit!(compact::IncrementalCompact, idx::Int, argexprs::
605605
if isa(case, InliningTodo)
606606
val = ir_inline_item!(compact, idx, argexprs′, case, boundscheck, todo_bbs)
607607
elseif isa(case, InvokeCase)
608-
inst = Expr(:invoke, case.invoke, argexprs′...)
608+
invoke_stmt = Expr(:invoke, case.invoke, argexprs′...)
609609
flag = flags_for_effects(case.effects)
610-
val = insert_node_here!(compact, NewInstruction(inst, typ, case.info, line, flag))
610+
val = insert_node_here!(compact, NewInstruction(invoke_stmt, typ, case.info, line, flag))
611611
else
612612
case = case::ConstantCase
613613
val = case.val
@@ -993,7 +993,7 @@ function handle_single_case!(todo::Vector{Pair{Int,Any}},
993993
ir::IRCode, idx::Int, stmt::Expr, @nospecialize(case),
994994
isinvoke::Bool = false)
995995
if isa(case, ConstantCase)
996-
ir[SSAValue(idx)][:inst] = case.val
996+
ir[SSAValue(idx)][:stmt] = case.val
997997
elseif isa(case, InvokeCase)
998998
is_foldable_nothrow(case.effects) && inline_const_if_inlineable!(ir[SSAValue(idx)]) && return nothing
999999
isinvoke && rewrite_invoke_exprargs!(stmt)
@@ -1120,7 +1120,7 @@ function inline_apply!(todo::Vector{Pair{Int,Any}},
11201120
break
11211121
end
11221122
if nonempty_idx != 0
1123-
ir.stmts[idx][:inst] = stmt.args[nonempty_idx]
1123+
ir[SSAValue(idx)][:stmt] = stmt.args[nonempty_idx]
11241124
return nothing
11251125
end
11261126
end
@@ -1236,8 +1236,9 @@ end
12361236
# this method does not access the method table or otherwise process generic
12371237
# functions.
12381238
function process_simple!(todo::Vector{Pair{Int,Any}}, ir::IRCode, idx::Int, state::InliningState)
1239-
stmt = ir.stmts[idx][:inst]
1240-
rt = ir.stmts[idx][:type]
1239+
inst = ir[SSAValue(idx)]
1240+
stmt = inst[:stmt]
1241+
rt = inst[:type]
12411242
if !(stmt isa Expr)
12421243
check_effect_free!(ir, idx, stmt, rt, state)
12431244
return nothing
@@ -1247,7 +1248,7 @@ function process_simple!(todo::Vector{Pair{Int,Any}}, ir::IRCode, idx::Int, stat
12471248
if head === :splatnew
12481249
inline_splatnew!(ir, idx, stmt, rt, state)
12491250
elseif head === :new_opaque_closure
1250-
narrow_opaque_closure!(ir, stmt, ir.stmts[idx][:info], state)
1251+
narrow_opaque_closure!(ir, stmt, inst[:info], state)
12511252
elseif head === :invoke
12521253
sig = call_sig(ir, stmt)
12531254
sig === nothing && return nothing
@@ -1267,14 +1268,14 @@ function process_simple!(todo::Vector{Pair{Int,Any}}, ir::IRCode, idx::Int, stat
12671268
# Check if we match any of the early inliners
12681269
earlyres = early_inline_special_case(ir, stmt, rt, sig, state)
12691270
if isa(earlyres, SomeCase)
1270-
ir.stmts[idx][:inst] = earlyres.val
1271+
inst[:stmt] = earlyres.val
12711272
return nothing
12721273
end
12731274

12741275
if check_effect_free!(ir, idx, stmt, rt, state)
12751276
if sig.f === typeassert || (optimizer_lattice(state.interp), sig.ft, typeof(typeassert))
12761277
# typeassert is a no-op if effect free
1277-
ir.stmts[idx][:inst] = stmt.args[2]
1278+
inst[:stmt] = stmt.args[2]
12781279
return nothing
12791280
end
12801281
end
@@ -1288,7 +1289,7 @@ function process_simple!(todo::Vector{Pair{Int,Any}}, ir::IRCode, idx::Int, stat
12881289
# Special case inliners for regular functions
12891290
lateres = late_inline_special_case!(ir, idx, stmt, rt, sig, state)
12901291
if isa(lateres, SomeCase)
1291-
ir[SSAValue(idx)][:inst] = lateres.val
1292+
inst[:stmt] = lateres.val
12921293
check_effect_free!(ir, idx, lateres.val, rt, state)
12931294
return nothing
12941295
end
@@ -1576,7 +1577,7 @@ function handle_modifyfield!_call!(ir::IRCode, idx::Int, stmt::Expr, info::Modif
15761577
case === nothing && return nothing
15771578
stmt.head = :invoke_modify
15781579
pushfirst!(stmt.args, case.invoke)
1579-
ir.stmts[idx][:inst] = stmt
1580+
ir[SSAValue(idx)][:stmt] = stmt
15801581
return nothing
15811582
end
15821583

@@ -1636,7 +1637,7 @@ end
16361637
function inline_const_if_inlineable!(inst::Instruction)
16371638
rt = inst[:type]
16381639
if rt isa Const && is_inlineable_constant(rt.val)
1639-
inst[:inst] = quoted(rt.val)
1640+
inst[:stmt] = quoted(rt.val)
16401641
return true
16411642
end
16421643
inst[:flag] |= IR_FLAG_EFFECT_FREE | IR_FLAG_NOTHROW
@@ -1691,7 +1692,7 @@ end
16911692

16921693
function linear_inline_eligible(ir::IRCode)
16931694
length(ir.cfg.blocks) == 1 || return false
1694-
terminator = ir[SSAValue(last(ir.cfg.blocks[1].stmts))][:inst]
1695+
terminator = ir[SSAValue(last(ir.cfg.blocks[1].stmts))][:stmt]
16951696
isa(terminator, ReturnNode) || return false
16961697
isdefined(terminator, :val) || return false
16971698
return true

0 commit comments

Comments
 (0)