Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DO NOT MERGE: Comparison of v1.10.2+RAI to v1.10.2 #212

Draft
wants to merge 109 commits into
base: v1.10.2-comparison
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
5aa21c0
Extensions: make loading of extensions independent of what packages a…
KristofferC Jan 29, 2024
e7c563a
RAI: Add 'RAI' as the build part of the semantic version
Mar 1, 2024
9314aa6
RAI: Track blocks and bytes allocated for GC pools
d-netto Oct 30, 2023
3c79c50
RAI: Change task ordering behavior to prioritize older tasks
kpamnany Aug 9, 2023
71435e3
RAI: Prepend signal number and thread ID on backtraces
kpamnany Aug 21, 2023
c70be9e
Add GC metric `last_incremental_sweep` (#50190)
li1 Jul 6, 2023
2fbcf5a
RAI: Disable huge pages for all mmap'ed memory
kpamnany Aug 21, 2023
6468d9e
RAI: Never use MADV_FREE
kuszmaul Aug 22, 2023
c053c42
Allocation Profiler: Types for all allocations (#50337)
NHDaly Jul 31, 2023
5931671
Metric for number of live bytes in the pool allocator (#51151)
d-netto Aug 21, 2023
0f706c4
Export num_stack_mappings to track the number of in-flight stack map…
NHDaly Sep 20, 2023
ecf48c3
parallelize sweeping of object pools (#51282)
d-netto Sep 22, 2023
165a150
don't print task backtrace for GC threads (#51413) (#78)
kpamnany Sep 26, 2023
04d0aef
RAI: Prepend "thread (%d) " to output from `jl_print_task_backtraces()`
kpamnany Oct 9, 2023
315f49e
Add heartbeat capability
kpamnany Oct 7, 2023
08424f3
Change heartbeat thread controls
kpamnany Nov 12, 2023
48723bb
make pool_live_bytes metric more accurate (#52015)
d-netto Nov 4, 2023
66d02fe
bugfix: load jl_n_threads in jl_gc_pool_live_bytes (#52034)
d-netto Nov 6, 2023
b351973
bugfix: don't set pool_live_bytes to zero at the end of GC (#107)
d-netto Nov 7, 2023
18b3b07
add some instrumentation to measure page utilization per size class (…
d-netto Nov 16, 2023
6051f41
add a compile-time option to enable 4k page sizes (#52229)
d-netto Nov 22, 2023
361f3ce
functionality to expose page utilization at the julia level (#113)
d-netto Dec 6, 2023
cc1f3e2
backport memory pressure callback to 1.9 (#114)
d-netto Dec 13, 2023
a0af597
page profile (#123)
d-netto Dec 29, 2023
4a3d5bd
revert GC heuristics back to 1.9 (#126)
d-netto Jan 4, 2024
61c1b96
Set the number of GC threads to number of compute threads
d-netto Jan 12, 2024
54c08b9
reduce contention on page metadata lists during the sweeping phase (#…
d-netto Jan 21, 2024
a0183a1
Change to streaming out the heap snapshot data (#52854)
Drvi Feb 1, 2024
d3268f8
Fix condition for `unreachable` code in IRCode conversion (#53512)
topolarity Mar 7, 2024
2c22634
typeintersect: fix `UnionAll` unaliasing bug caused by innervars. (#5…
N5N3 Mar 6, 2024
aefe3c9
gc scheduler synchronization fixes to 1.10 (#53661) (#133)
d-netto Mar 15, 2024
9a0475d
Add GitHub template and workflows needed on the default branch (#135)
Drvi Mar 19, 2024
6cd7ce2
Add `Base.checked_pow(x,y)` to `Base.Checked` library (#52849) (#134)
d-netto Mar 19, 2024
31f3d1d
Remove some duplicates from emitted compilation traces for Julia 1.10…
kpamnany Mar 20, 2024
4859e9c
--safe-crash-log-file flag (#140)
d-netto Mar 22, 2024
b5d3e64
create phantom task for GC threads (#53815) (#141)
d-netto Mar 28, 2024
703a262
Correct GC bug (usage of `not_freed_enough`) (#143)
d-netto Apr 7, 2024
4973851
Fix the OpenBLAS checksum for Julia 1.10 (#54017)
kpamnany Apr 10, 2024
f61f92a
Stop updating upstream 1.9 branch (#144)
nickrobinson251 Apr 15, 2024
01b4a24
RAI: do not prepend thread ID to backtraces from signal handler context
kpamnany Apr 18, 2024
bcd9f13
add function to query GC page size (#54115) (#147)
d-netto Apr 20, 2024
82d6ee0
RAI: Change optimization aggressiveness for `-O1` from `None` to `Less`
kpamnany Apr 4, 2024
653b24c
fix typo in gc_mark_memory8 when chunking a large array (#149)
d-netto Apr 29, 2024
3930d18
correctly track freed bytes in array_to_string (#54309) (#151)
d-netto May 3, 2024
e8cd7a4
Make TestLogger thread-safe (introduce a lock) (#152)
NHDaly May 22, 2024
ada3603
Add `jl_inside_heartbeat_thread()`
kpamnany May 24, 2024
96ec5a0
Write heartbeat thread output to the safe crash log
kpamnany May 24, 2024
6479c07
Refactor JSON printing code
kpamnany May 24, 2024
26d6100
Revert "Refactor JSON printing code"
kpamnany May 27, 2024
9741930
Revert "Write heartbeat thread output to the safe crash log"
kpamnany May 27, 2024
df1244c
Revert "Add `jl_inside_heartbeat_thread()`"
kpamnany May 27, 2024
3f82711
Write heartbeat thread output to safe crash log (#155)
kpamnany May 27, 2024
b882d43
Fix `gc_first_tid` setting (#157)
kpamnany May 31, 2024
7afe5a0
Add boundscheck in bindingkey_eq to avoid OOB access due to data race…
kpamnany Jun 5, 2024
775c5d2
Add boundscheck in speccache_eq to avoid OOB access due to data race …
kpamnany Jun 19, 2024
84dc564
make realloc_string explicitely allocate a new string instead of real…
d-netto Jun 27, 2024
2ed98a2
reset mark queue indices at the end of GC (#52780)
d-netto Jan 8, 2024
e4b3521
optimize remset marking (#52476)
d-netto Mar 8, 2024
163e85e
print types more verbosely in page profiler (#53256)
d-netto Apr 25, 2024
546ad08
fix stale docstring in gc_sweep_page (#54743)
d-netto Jun 9, 2024
ba14e75
use atomic-fetch-and in write barrier slow-path (#54744)
d-netto Jun 10, 2024
a47fd20
remove a bunch of bit unnecessary bit clearing in bigval's sz field (…
d-netto Jun 27, 2024
454ed8c
simplify handling of buffered pages (#54961)
d-netto Jun 28, 2024
efd3744
address a TODO in gc_sweep_page (i.e. save an unnecessary fetch-add) …
d-netto Jun 29, 2024
01e1015
NFC: create an actual set of functions to manipulate GC thread ids (#…
d-netto Jul 1, 2024
abdd894
remove stale objprofile (#54991)
d-netto Jul 2, 2024
6b0d990
delete possibly stale reset_gc_stats (#55015)
d-netto Jul 3, 2024
a19c7b1
remove unused jl_gc_alloc_*w (#55026)
d-netto Jul 5, 2024
c8f56c6
cleanup remset logic a bit (#55021)
d-netto Jul 6, 2024
145375d
change memory parameters to signed integers to prevent signed to unsi…
d-netto Jul 12, 2024
14b9441
drop jl_gc_pool_alloc in favor of instrumented version (#55085)
d-netto Jul 9, 2024
9490ee3
create GC TLS (#55086)
d-netto Jul 10, 2024
1f66e0d
Simplify sweeping of big values (#54936)
d-netto Jul 15, 2024
7ae4e32
delete some unused fields of jl_gc_mark_cache_t (#55138)
d-netto Jul 16, 2024
5f234f0
create separate function to spawn GC threads (#55108)
d-netto Jul 16, 2024
1c192fd
cap live_bytes to zero in a few places where GC intervals are compute…
d-netto Aug 12, 2024
ec21f11
dont reset maxsize in jl_array_to_string (#172)
d-netto Aug 14, 2024
53e658c
simple dynamic race detector for jl_array_to_string (#173)
d-netto Aug 22, 2024
0e5b029
Redact object data in heap snapshots, with option to opt-out (#55326)…
kpamnany Aug 26, 2024
7843330
instrument GC to breakdown times spent in each step of sweeping (#176)
d-netto Sep 4, 2024
c690603
fix cmdlineargs test in our fork (#182)
d-netto Sep 20, 2024
a911d00
[Dates] Make test more robust against non-UTC timezones (#55829) (#184)
d-netto Sep 23, 2024
037dc51
Adjust heartbeat behavior (#180)
kpamnany Sep 24, 2024
8e9f7de
Revert "[Dates] Make test more robust against non-UTC timezones (#558…
d-netto Sep 25, 2024
3d458df
expose metric to report reasons why full GCs were triggered (#55826) …
d-netto Sep 30, 2024
75cf8dc
Add `--trace-dispatch` (#183)
kpamnany Sep 30, 2024
01980b3
stackwalk: fix jl_thread_suspend_and_get_state race (#56047) (#192)
kpamnany Oct 17, 2024
f481fc9
add `--trace-compile-timing` arg to add compile timing comments (#546…
kpamnany Oct 23, 2024
fc4ae84
Wall-time/all tasks profiler (#55889) (#193)
d-netto Oct 29, 2024
8fe069c
Fix a backport error in PR 187 (#197)
kpamnany Nov 5, 2024
9162ec8
Only update the world age when a new method is loaded (#196)
kpamnany Nov 8, 2024
5610223
Fix trampoline assembly for build on clang 18 on apple silicon (#5463…
Drvi Nov 19, 2024
918a99d
Optionally disallow defining new methods and drop backedges (#198)
Drvi Nov 21, 2024
9344ba8
Canonicalize names of nested functions by keeping a more fine grained…
kpamnany Dec 5, 2024
ce667bc
Add per-Task cpu time metric (#56320) (#194)
nickrobinson251 Dec 9, 2024
e36910c
skip heartbeat thread from CPU profile (#201)
d-netto Jan 3, 2025
4fdcc11
ReentrantLock: wakeup a single task on unlock and add a short spin (#…
kpamnany Jan 6, 2025
d0efc46
Add try/catch around handle_message() to catch errors during logging.…
NHDaly Jan 17, 2025
25fb6f8
Add `Experimental.wait_with_timeout` (#57148) (#207)
kpamnany Jan 27, 2025
1fff8cc
add option to dump backtrace of stop-the-world straggler (#57045) (#208)
d-netto Feb 2, 2025
b37edae
Add timing when `PRECOMPILE_TRACE_COMPILE` is set (#57251) (#209)
kpamnany Feb 4, 2025
94ace4c
introduce safepoint_waiter (#210)
d-netto Feb 4, 2025
9dcccc4
Use `uv_thread_equal` to compare thread IDs (#211)
kpamnany Feb 4, 2025
377f917
Use task stacks of size 8MB (up from 4MB) (#213)
charnik Feb 10, 2025
4032092
Add exit code to `Base.compilecache` error message (#57455) (#215)
kpamnany Feb 18, 2025
827c19f
Use `Base.process_status(p)` instead of `p.exitcode` in error message…
kpamnany Feb 20, 2025
a85728e
Backport inference fixes (#216)
kpamnany Feb 25, 2025
6a92fce
avoid overflow on functionality to print backtrace of safepoint strag…
d-netto Mar 1, 2025
590b807
make the default timeout 60s
d-netto Mar 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# See https://github.com/actions/labeler
port-to-master: '**'
port-to-v1.10: '**'
14 changes: 14 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!---
PRs to RelationalAI/julia must be opened to the correct branch (see
https://github.com/RelationalAI/raicode/blob/master/nix/julia-version.json).
-->
## PR Description

_What does this PR do?_

## Checklist

Requirements for merging:
- [ ] I have opened an issue or PR upstream on JuliaLang/julia: <link to JuliaLang/julia>
- [ ] I have removed the `port-to-*` labels that don't apply.
- [ ] I have opened a PR on raicode to test these changes: <link to raicode>
17 changes: 17 additions & 0 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# See https://github.com/actions/labeler
name: "Pull Request Labeler"
on:
pull_request_target:
types:
- opened

jobs:
triage:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v4
with:
dot: true
16 changes: 16 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: "Close stale PRs"
on:
schedule:
- cron: "0 0 * * *" # every night at midnight

jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v8
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-pr-message: 'This PR is stale because it has been open 30 days with no activity. Comment or remove stale label, or this PR will be closed in 5 days.'
days-before-stale: 30
days-before-close: 5
stale-pr-label: 'stale'
28 changes: 28 additions & 0 deletions .github/workflows/update-upstream-branches.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: "Update upstream branches"
on:
schedule:
- cron: "0 0 * * *" # every night at midnight
workflow_dispatch:

jobs:
PullUpstream:
runs-on: ubuntu-latest
strategy:
fail-fast: false # run all jobs in the matrix even if one fails
matrix:
branch:
- "master"
- "backports-release-1.10"
steps:
- name: Checkout RAI/julia
uses: actions/checkout@v3
with:
ref: ${{ matrix.branch }}
- name: Update ${{ matrix.branch }}
run: |
git config --global user.email "julia-engineering@relational.ai"
git config --global user.name "RAI CI (GitHub Action Automation)"

git remote add upstream https://github.com/JuliaLang/julia
git pull upstream ${{ matrix.branch }}
git push origin ${{ matrix.branch }}
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ Deprecated or removed

* The `@pure` macro is now deprecated. Use `Base.@assume_effects :foldable` instead ([#48682]).

- A wall-time profiler is now available for users who need a sampling profiler that captures tasks regardless of their scheduling or running state. This type of profiler enables profiling of I/O-heavy tasks and helps detect areas of heavy contention in the system ([#55889]).

<!--- generated by NEWS-update.jl: -->
[#31836]: https://github.com/JuliaLang/julia/issues/31836
[#40105]: https://github.com/JuliaLang/julia/issues/40105
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.10.2
1.10.2+RAI
1 change: 1 addition & 0 deletions base/Base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@ function __init__()
init_load_path()
init_active_project()
append!(empty!(_sysimage_modules), keys(loaded_modules))
empty!(explicit_loaded_modules)
if haskey(ENV, "JULIA_MAX_NUM_PRECOMPILE_FILES")
MAX_NUM_PRECOMPILE_FILES[] = parse(Int, ENV["JULIA_MAX_NUM_PRECOMPILE_FILES"])
end
Expand Down
28 changes: 23 additions & 5 deletions base/boot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,33 @@
#end

#mutable struct Task
# parent::Task
# next::Any
# queue::Any
# storage::Any
# state::Symbol
# donenotify::Any
# result::Any
# exception::Any
# backtrace::Any
# logstate::Any
# scope::Any
# code::Any
# @atomic _state::UInt8
# sticky::UInt8
# priority::UInt16
# @atomic _isexception::UInt8
# pad00::UInt8
# pad01::UInt8
# pad02::UInt8
# rngState0::UInt64
# rngState1::UInt64
# rngState2::UInt64
# rngState3::UInt64
# rngState4::UInt64
# const metrics_enabled::Bool
# pad10::UInt8
# pad11::UInt8
# pad12::UInt8
# @atomic first_enqueued_at::UInt64
# @atomic last_started_running_at::UInt64
# @atomic running_time_ns::UInt64
# @atomic finished_at::UInt64
#end

export
Expand Down
15 changes: 14 additions & 1 deletion base/checked.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ return both the unchecked results and a boolean value denoting the presence of a
module Checked

export checked_neg, checked_abs, checked_add, checked_sub, checked_mul,
checked_div, checked_rem, checked_fld, checked_mod, checked_cld,
checked_div, checked_rem, checked_fld, checked_mod, checked_cld, checked_pow,
checked_length, add_with_overflow, sub_with_overflow, mul_with_overflow

import Core.Intrinsics:
Expand Down Expand Up @@ -358,6 +358,19 @@ The overflow protection may impose a perceptible performance penalty.
"""
checked_cld(x::T, y::T) where {T<:Integer} = cld(x, y) # Base.cld already checks

"""
Base.checked_pow(x, y)

Calculates `^(x,y)`, checking for overflow errors where applicable.

The overflow protection may impose a perceptible performance penalty.
"""
checked_pow(x::Integer, y::Integer) = checked_power_by_squaring(x, y)

checked_power_by_squaring(x_, p::Integer) = Base.power_by_squaring(x_, p; mul = checked_mul)
# For Booleans, the default implementation covers all cases.
checked_power_by_squaring(x::Bool, p::Integer) = Base.power_by_squaring(x, p)

"""
Base.checked_length(r)

Expand Down
59 changes: 37 additions & 22 deletions base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ function find_matching_methods(𝕃::AbstractLattice,
for i in 1:length(split_argtypes)
arg_n = split_argtypes[i]::Vector{Any}
sig_n = argtypes_to_type(arg_n)
sig_n === Bottom && continue
mt = ccall(:jl_method_table_for, Any, (Any,), sig_n)
mt === nothing && return FailedMethodMatch("Could not identify method table for call")
mt = mt::MethodTable
Expand Down Expand Up @@ -506,7 +507,10 @@ function abstract_call_method(interp::AbstractInterpreter,
return MethodCallResult(Any, false, false, nothing, Effects())
end
sigtuple = unwrap_unionall(sig)
sigtuple isa DataType || return MethodCallResult(Any, false, false, nothing, Effects())
sigtuple isa DataType ||
return MethodCallResult(Any, false, false, nothing, Effects())
all(@nospecialize(x) -> isvarargtype(x) || valid_as_lattice(x, true), sigtuple.parameters) ||
return MethodCallResult(Union{}, false, false, nothing, EFFECTS_THROWS) # catch bad type intersections early

if is_nospecializeinfer(method)
sig = get_nospecializeinfer_sig(method, sig, sparams)
Expand Down Expand Up @@ -1385,25 +1389,35 @@ function precise_container_type(interp::AbstractInterpreter, @nospecialize(itft)
end
if isa(tti, Union)
utis = uniontypes(tti)
if any(@nospecialize(t) -> !isa(t, DataType) || !(t <: Tuple) || !isknownlength(t), utis)
return AbstractIterationResult(Any[Vararg{Any}], nothing, Effects())
end
ltp = length((utis[1]::DataType).parameters)
for t in utis
if length((t::DataType).parameters) != ltp
return AbstractIterationResult(Any[Vararg{Any}], nothing)
# refine the Union to remove elements that are not valid tags for objects
filter!(@nospecialize(x) -> valid_as_lattice(x, true), utis)
if length(utis) == 0
return AbstractIterationResult(Any[], nothing) # oops, this statement was actually unreachable
elseif length(utis) == 1
tti = utis[1]
tti0 = rewrap_unionall(tti, tti0)
else
if any(@nospecialize(t) -> !isa(t, DataType) || !(t <: Tuple) || !isknownlength(t), utis)
return AbstractIterationResult(Any[Vararg{Any}], nothing, Effects())
end
end
result = Any[ Union{} for _ in 1:ltp ]
for t in utis
tps = (t::DataType).parameters
_all(valid_as_lattice, tps) || continue
for j in 1:ltp
result[j] = tmerge(result[j], rewrap_unionall(tps[j], tti0))
ltp = length((utis[1]::DataType).parameters)
for t in utis
if length((t::DataType).parameters) != ltp
return AbstractIterationResult(Any[Vararg{Any}], nothing)
end
end
result = Any[ Union{} for _ in 1:ltp ]
for t in utis
tps = (t::DataType).parameters
for j in 1:ltp
@assert valid_as_lattice(tps[j], true)
result[j] = tmerge(result[j], rewrap_unionall(tps[j], tti0))
end
end
return AbstractIterationResult(result, nothing)
end
return AbstractIterationResult(result, nothing)
elseif tti0 <: Tuple
end
if tti0 <: Tuple
if isa(tti0, DataType)
return AbstractIterationResult(Any[ p for p in tti0.parameters ], nothing)
elseif !isa(tti, DataType)
Expand Down Expand Up @@ -1667,7 +1681,7 @@ end
return isa_condition(xt, ty, max_union_splitting)
end
@inline function isa_condition(@nospecialize(xt), @nospecialize(ty), max_union_splitting::Int)
tty_ub, isexact_tty = instanceof_tfunc(ty)
tty_ub, isexact_tty = instanceof_tfunc(ty, true)
tty = widenconst(xt)
if isexact_tty && !isa(tty_ub, TypeVar)
tty_lb = tty_ub # TODO: this would be wrong if !isexact_tty, but instanceof_tfunc doesn't preserve this info
Expand All @@ -1677,7 +1691,7 @@ end
# `typeintersect` may be unable narrow down `Type`-type
thentype = tty_ub
end
valid_as_lattice(thentype) || (thentype = Bottom)
valid_as_lattice(thentype, true) || (thentype = Bottom)
elsetype = typesubtract(tty, tty_lb, max_union_splitting)
return ConditionalTypes(thentype, elsetype)
end
Expand Down Expand Up @@ -1923,7 +1937,7 @@ function abstract_invoke(interp::AbstractInterpreter, (; fargs, argtypes)::ArgIn
ft′ = argtype_by_index(argtypes, 2)
ft = widenconst(ft′)
ft === Bottom && return CallMeta(Bottom, EFFECTS_THROWS, NoCallInfo())
(types, isexact, isconcrete, istype) = instanceof_tfunc(argtype_by_index(argtypes, 3))
(types, isexact, isconcrete, istype) = instanceof_tfunc(argtype_by_index(argtypes, 3), false)
isexact || return CallMeta(Any, Effects(), NoCallInfo())
unwrapped = unwrap_unionall(types)
if types === Bottom || !(unwrapped isa DataType) || unwrapped.name !== Tuple.name
Expand Down Expand Up @@ -2153,6 +2167,7 @@ function abstract_call_unknown(interp::AbstractInterpreter, @nospecialize(ft),
end
# non-constant function, but the number of arguments is known and the `f` is not a builtin or intrinsic
atype = argtypes_to_type(arginfo.argtypes)
atype === Bottom && return CallMeta(Union{}, Union{}, EFFECTS_THROWS, NoCallInfo()) # accidentally unreachable
return abstract_call_gf_by_type(interp, nothing, arginfo, si, atype, sv, max_methods)
end

Expand Down Expand Up @@ -2380,7 +2395,7 @@ function abstract_eval_statement_expr(interp::AbstractInterpreter, e::Expr, vtyp
(; rt, effects) = abstract_eval_call(interp, e, vtypes, sv)
t = rt
elseif ehead === :new
t, isexact = instanceof_tfunc(abstract_eval_value(interp, e.args[1], vtypes, sv))
t, isexact = instanceof_tfunc(abstract_eval_value(interp, e.args[1], vtypes, sv), true)
ut = unwrap_unionall(t)
consistent = ALWAYS_FALSE
nothrow = false
Expand Down Expand Up @@ -2444,7 +2459,7 @@ function abstract_eval_statement_expr(interp::AbstractInterpreter, e::Expr, vtyp
end
effects = Effects(EFFECTS_TOTAL; consistent, nothrow)
elseif ehead === :splatnew
t, isexact = instanceof_tfunc(abstract_eval_value(interp, e.args[1], vtypes, sv))
t, isexact = instanceof_tfunc(abstract_eval_value(interp, e.args[1], vtypes, sv), true)
nothrow = false # TODO: More precision
if length(e.args) == 2 && isconcretedispatch(t) && !ismutabletype(t)
at = abstract_eval_value(interp, e.args[2], vtypes, sv)
Expand Down
8 changes: 5 additions & 3 deletions base/compiler/abstractlattice.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,18 @@ is_valid_lattice_norec(::InferenceLattice, @nospecialize(elem)) = isa(elem, Limi
"""
tmeet(𝕃::AbstractLattice, a, b::Type)

Compute the lattice meet of lattice elements `a` and `b` over the lattice `𝕃`.
If `𝕃` is `JLTypeLattice`, this is equivalent to type intersection.
Compute the lattice meet of lattice elements `a` and `b` over the lattice `𝕃`,
dropping any results that will not be inhabited at runtime.
If `𝕃` is `JLTypeLattice`, this is equivalent to type intersection plus the
elimination of results that have no concrete subtypes.
Note that currently `b` is restricted to being a type
(interpreted as a lattice element in the `JLTypeLattice` sub-lattice of `𝕃`).
"""
function tmeet end

function tmeet(::JLTypeLattice, @nospecialize(a::Type), @nospecialize(b::Type))
ti = typeintersect(a, b)
valid_as_lattice(ti) || return Bottom
valid_as_lattice(ti, true) || return Bottom
return ti
end

Expand Down
4 changes: 2 additions & 2 deletions base/compiler/optimize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ function stmt_effect_flags(𝕃ₒ::AbstractLattice, @nospecialize(stmt), @nospe
elseif head === :new_opaque_closure
length(args) < 4 && return (false, false, false)
typ = argextype(args[1], src)
typ, isexact = instanceof_tfunc(typ)
typ, isexact = instanceof_tfunc(typ, true)
isexact || return (false, false, false)
⊑(𝕃ₒ, typ, Tuple) || return (false, false, false)
rt_lb = argextype(args[2], src)
Expand Down Expand Up @@ -561,7 +561,7 @@ function convert_to_ircode(ci::CodeInfo, sv::OptimizationState)
idx += 1
prevloc = codeloc
end
if code[idx] isa Expr && ssavaluetypes[idx] === Union{}
if ssavaluetypes[idx] === Union{} && code[idx] !== nothing && !(code[idx] isa Core.Const)
if !(idx < length(code) && isa(code[idx + 1], ReturnNode) && !isdefined((code[idx + 1]::ReturnNode), :val))
# insert unreachable in the same basic block after the current instruction (splitting it)
insert!(code, idx + 1, ReturnNode())
Expand Down
7 changes: 4 additions & 3 deletions base/compiler/ssair/inlining.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1202,7 +1202,7 @@ function handle_invoke_call!(todo::Vector{Pair{Int,Any}},
end

function invoke_signature(argtypes::Vector{Any})
ft, argtyps = widenconst(argtypes[2]), instanceof_tfunc(widenconst(argtypes[3]))[1]
ft, argtyps = widenconst(argtypes[2]), instanceof_tfunc(widenconst(argtypes[3]), false)[1]
return rewrap_unionall(Tuple{ft, unwrap_unionall(argtyps).parameters...}, argtyps)
end

Expand Down Expand Up @@ -1450,8 +1450,9 @@ function handle_call!(todo::Vector{Pair{Int,Any}},
cases = compute_inlining_cases(info, flag, sig, state)
cases === nothing && return nothing
cases, all_covered, joint_effects = cases
handle_cases!(todo, ir, idx, stmt, argtypes_to_type(sig.argtypes), cases,
all_covered, joint_effects)
atype = argtypes_to_type(sig.argtypes)
atype === Union{} && return nothing # accidentally actually unreachable
handle_cases!(todo, ir, idx, stmt, atype, cases, all_covered, joint_effects)
end

function handle_match!(cases::Vector{InliningCase},
Expand Down
2 changes: 1 addition & 1 deletion base/compiler/ssair/passes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1704,7 +1704,7 @@ function adce_pass!(ir::IRCode, inlining::Union{Nothing,InliningState}=nothing)
else
if is_known_call(stmt, typeassert, compact) && length(stmt.args) == 3
# nullify safe `typeassert` calls
ty, isexact = instanceof_tfunc(argextype(stmt.args[3], compact))
ty, isexact = instanceof_tfunc(argextype(stmt.args[3], compact), true)
if isexact && ⊑(𝕃ₒ, argextype(stmt.args[2], compact), ty)
compact[idx] = nothing
continue
Expand Down
Loading
Loading