Skip to content

Commit bdc35b2

Browse files
authored
Backports for 1.12.2 (#59920)
2 parents ba1e628 + d9323c0 commit bdc35b2

File tree

64 files changed

+442
-293
lines changed

Some content is hidden

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

64 files changed

+442
-293
lines changed

Compiler/src/abstractinterpretation.jl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -872,11 +872,12 @@ function abstract_call_method_with_const_args(interp::AbstractInterpreter,
872872
concrete_eval_result = nothing
873873
if eligibility === :concrete_eval
874874
concrete_eval_result = concrete_eval_call(interp, f, result, arginfo, sv, invokecall)
875-
# if we don't inline the result of this concrete evaluation,
876-
# give const-prop' a chance to inline a better method body
877-
if !may_optimize(interp) || (
878-
may_inline_concrete_result(concrete_eval_result.const_result::ConcreteResult) ||
879-
concrete_eval_result.rt === Bottom) # unless this call deterministically throws and thus is non-inlineable
875+
if (concrete_eval_result !== nothing && # allow external abstract interpreters to disable concrete evaluation ad-hoc
876+
# if we don't inline the result of this concrete evaluation,
877+
# give const-prop' a chance to inline a better method body
878+
(!may_optimize(interp) ||
879+
may_inline_concrete_result(concrete_eval_result.const_result::ConcreteResult) ||
880+
concrete_eval_result.rt === Bottom)) # unless this call deterministically throws and thus is non-inlineable
880881
return concrete_eval_result
881882
end
882883
# TODO allow semi-concrete interp for this call?
@@ -3457,7 +3458,7 @@ function abstract_eval_nonlinearized_foreigncall_name(
34573458
callresult = Future{CallMeta}()
34583459
i::Int = 1
34593460
nextstate::UInt8 = 0x0
3460-
local ai, res
3461+
local ai::Future, res::Future
34613462
function evalargs(interp, sv)
34623463
if nextstate === 0x1
34633464
@goto state1

Compiler/src/tfuncs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ function pointer_eltype(@nospecialize(ptr))
713713
end
714714

715715
@nospecs function pointerarith_tfunc(𝕃::AbstractLattice, ptr, offset)
716-
return ptr
716+
return widenconst(ptr)
717717
end
718718
@nospecs function pointerref_tfunc(𝕃::AbstractLattice, a, i, align)
719719
return pointer_eltype(a)

Compiler/src/typeinfer.jl

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -761,17 +761,10 @@ function type_annotate!(interp::AbstractInterpreter, sv::InferenceState)
761761
end
762762

763763
function merge_call_chain!(::AbstractInterpreter, parent::InferenceState, child::InferenceState)
764-
# add backedge of parent <- child
765-
# then add all backedges of parent <- parent.parent
764+
# update all cycleid to be in the same group
766765
frames = parent.callstack::Vector{AbsIntState}
767766
@assert child.callstack === frames
768767
ancestorid = child.cycleid
769-
while true
770-
add_cycle_backedge!(parent, child)
771-
parent.cycleid === ancestorid && break
772-
child = parent
773-
parent = cycle_parent(child)::InferenceState
774-
end
775768
# ensure that walking the callstack has the same cycleid (DAG)
776769
for frameid = reverse(ancestorid:length(frames))
777770
frame = frames[frameid]::InferenceState
@@ -782,7 +775,6 @@ function merge_call_chain!(::AbstractInterpreter, parent::InferenceState, child:
782775
end
783776

784777
function add_cycle_backedge!(caller::InferenceState, frame::InferenceState)
785-
update_valid_age!(caller, frame.world.valid_worlds)
786778
backedge = (caller, caller.currpc)
787779
contains_is(frame.cycle_backedges, backedge) || push!(frame.cycle_backedges, backedge)
788780
return frame
@@ -801,9 +793,8 @@ end
801793
# frame matching `mi` is encountered, then there is a cycle in the call graph
802794
# (i.e. `mi` is a descendant callee of itself). Upon encountering this cycle,
803795
# we "resolve" it by merging the call chain, which entails updating each intermediary
804-
# frame's `cycleid` field and adding the appropriate backedges. Finally,
805-
# we return `mi`'s pre-existing frame. If no cycles are found, `nothing` is
806-
# returned instead.
796+
# frame's `cycleid` field. Finally, we return `mi`'s pre-existing frame.
797+
# If no cycles are found, `nothing` is returned instead.
807798
function resolve_call_cycle!(interp::AbstractInterpreter, mi::MethodInstance, parent::AbsIntState)
808799
# TODO (#48913) implement a proper recursion handling for irinterp:
809800
# This works most of the time currently just because the irinterp code doesn't get used much with
@@ -992,6 +983,7 @@ function typeinf_edge(interp::AbstractInterpreter, method::Method, @nospecialize
992983
result.ci_as_edge = edge_ci # set the edge for the inliner usage
993984
VolatileInferenceResult(result)
994985
end
986+
isinferred || add_cycle_backedge!(caller, frame)
995987
mresult[] = MethodCallResult(interp, caller, method, bestguess, exc_bestguess, effects,
996988
edge, edgecycle, edgelimited, volatile_inf_result)
997989
return true
@@ -1010,6 +1002,7 @@ function typeinf_edge(interp::AbstractInterpreter, method::Method, @nospecialize
10101002
update_valid_age!(caller, valid_worlds)
10111003
bestguess = frame.bestguess
10121004
exc_bestguess = refine_exception_type(frame.exc_bestguess, effects)
1005+
add_cycle_backedge!(caller, frame)
10131006
return Future(MethodCallResult(interp, caller, method, bestguess, exc_bestguess, effects, nothing, edgecycle, edgelimited))
10141007
end
10151008

Compiler/test/effects.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,3 +1478,10 @@ let effects = Base.infer_effects((Core.SimpleVector,Int); optimize=false) do sve
14781478
end
14791479

14801480
@test Compiler.is_nothrow(Base.infer_effects(length, (Core.SimpleVector,)))
1481+
1482+
1483+
# https://github.com/JuliaLang/julia/issues/60009
1484+
function null_offset(offset)
1485+
Ptr{UInt8}(C_NULL) + offset
1486+
end
1487+
@test null_offset(Int(100)) == Ptr{UInt8}(UInt(100))

Makefile

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ endif
204204

205205
# private libraries, that are installed in $(prefix)/lib/julia
206206
JL_PRIVATE_LIBS-0 := libccalltest libccalllazyfoo libccalllazybar libllvmcalltest
207+
JL_PRIVATE_LIBS-1 := # libraries from USE_SYSTEM=1
208+
JL_PRIVATE_EXES := 7z
209+
JL_PRIVATE_TOOLS := lld$(EXE) dsymutil$(EXE)
207210
ifeq ($(JULIA_BUILD_MODE),release)
208211
JL_PRIVATE_LIBS-0 += libjulia-internal libjulia-codegen
209212
else ifeq ($(JULIA_BUILD_MODE),debug)
@@ -325,9 +328,6 @@ endif
325328
-$(INSTALL_M) $(wildcard $(build_private_libdir)/*.a) $(DESTDIR)$(private_libdir)/
326329
-rm -f $(DESTDIR)$(private_libdir)/sys-o.a
327330

328-
# We have a single exception; we want 7z.dll to live in private_libexecdir,
329-
# not bindir, so that 7z.exe can find it.
330-
-mv $(DESTDIR)$(bindir)/7z.dll $(DESTDIR)$(private_libexecdir)/
331331
-$(INSTALL_M) $(build_bindir)/libopenlibm.dll.a $(DESTDIR)$(libdir)/
332332
-$(INSTALL_M) $(build_libdir)/libssp.dll.a $(DESTDIR)$(libdir)/
333333
else
@@ -384,14 +384,12 @@ endif
384384
done \
385385
done
386386
endif
387-
# Install `7z` into private_libexecdir
388-
$(INSTALL_M) $(build_bindir)/7z$(EXE) $(DESTDIR)$(private_libexecdir)/
389-
390-
# Install `lld` into private_libexecdir
391-
$(INSTALL_M) $(build_depsbindir)/lld$(EXE) $(DESTDIR)$(private_libexecdir)/
392-
393-
# Install `dsymutil` into private_libexecdir/
394-
$(INSTALL_M) $(build_depsbindir)/dsymutil$(EXE) $(DESTDIR)$(private_libexecdir)/
387+
for exe in $(JL_PRIVATE_EXES) ; do \
388+
$(INSTALL_M) $(build_private_libexecdir)/$$exe $(DESTDIR)$(private_libexecdir) || exit 1; \
389+
done
390+
for exe in $(JL_PRIVATE_TOOLS) ; do \
391+
$(INSTALL_M) $(build_depsbindir)/$$exe $(DESTDIR)$(private_libexecdir) || exit 1; \
392+
done
395393

396394
# Copy public headers
397395
cp -R -L $(build_includedir)/julia/* $(DESTDIR)$(includedir)/julia

base/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
/uv_constants.jl
88
/version_git.jl
99
/version_git.jl.phony
10+
/version_git_dirty
1011
/userimg.jl
1112
/JuliaSyntax

base/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,4 +306,5 @@ clean:
306306
-rm -f $(BUILDDIR)/file_constants.jl
307307
-rm -f $(BUILDDIR)/version_git.jl
308308
-rm -f $(BUILDDIR)/version_git.jl.phony
309+
-rm -f $(BUILDDIR)/version_git_dirty
309310
-rm -f $(build_private_libdir)/lib*.$(SHLIB_EXT)*

base/docs/basedocs.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,8 +1396,6 @@ a tuple of types. All types, as well as the LLVM code, should be specified as li
13961396
not as variables or expressions (it may be necessary to use `@eval` to generate these
13971397
literals).
13981398
1399-
[Opaque pointers](https://llvm.org/docs/OpaquePointers.html) (written as `ptr`) are not allowed in the LLVM code.
1400-
14011399
See
14021400
[`test/llvmcall.jl`](https://github.com/JuliaLang/julia/blob/v$VERSION/test/llvmcall.jl)
14031401
for usage examples.

base/float.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ See also: [`iszero`](@ref), [`isone`](@ref), [`isinf`](@ref), [`ismissing`](@ref
709709
isnan(x::AbstractFloat) = (x != x)::Bool
710710
isnan(x::Number) = false
711711

712-
isfinite(x::AbstractFloat) = !isnan(x - x)
712+
isfinite(x::AbstractFloat) = !(isnan(x - x)::Bool)
713713
isfinite(x::Real) = decompose(x)[3] != 0
714714
isfinite(x::Integer) = true
715715

base/loading.jl

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -667,20 +667,45 @@ function env_project_file(env::String)::Union{Bool,String}
667667
end
668668

669669
function base_project(project_file)
670-
base_dir = abspath(joinpath(dirname(project_file), ".."))
671-
base_project_file = env_project_file(base_dir)
672-
base_project_file isa String || return nothing
673-
d = parsed_toml(base_project_file)
674-
workspace = get(d, "workspace", nothing)::Union{Dict{String, Any}, Nothing}
675-
if workspace === nothing
676-
return nothing
677-
end
678-
projects = get(workspace, "projects", nothing)::Union{Vector{String}, Nothing, String}
679-
projects === nothing && return nothing
680-
if projects isa Vector && basename(dirname(project_file)) in projects
681-
return base_project_file
670+
home_dir = abspath(homedir())
671+
project_dir = abspath(dirname(project_file))
672+
current_dir = project_dir
673+
# Only stop at home boundary if we started under home
674+
started_in_home = startswith(project_dir, home_dir)
675+
676+
while true
677+
parent_dir = dirname(current_dir)
678+
# Stop if we've reached root
679+
if parent_dir == current_dir
680+
return nothing
681+
end
682+
# Stop if we started in home and have now left it
683+
if started_in_home && !startswith(parent_dir, home_dir)
684+
return nothing
685+
end
686+
687+
base_project_file = env_project_file(parent_dir)
688+
if base_project_file isa String
689+
d = parsed_toml(base_project_file)
690+
workspace = get(d, "workspace", nothing)::Union{Dict{String, Any}, Nothing}
691+
if workspace !== nothing
692+
projects = get(workspace, "projects", nothing)::Union{Vector{String}, Nothing, String}
693+
if projects isa Vector
694+
# Check if any project in the workspace matches the original project
695+
workspace_root = dirname(base_project_file)
696+
for project in projects
697+
project_path = joinpath(workspace_root, project)
698+
if isdir(project_path)
699+
if samefile(project_path, project_dir)
700+
return base_project_file
701+
end
702+
end
703+
end
704+
end
705+
end
706+
end
707+
current_dir = parent_dir
682708
end
683-
return nothing
684709
end
685710

686711
function project_deps_get(env::String, name::String)::Union{Nothing,PkgId}

0 commit comments

Comments
 (0)