Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
0402dfa
Do not fail if fastpath for TLS can't be found
vchuravy Jan 6, 2022
66bf907
Fix cpu-features.ll opt invocation
vchuravy Jan 6, 2022
9a38042
Make notunroll test robust against loop-rotation
vchuravy Jan 6, 2022
12cf20c
Revert "CI (Buildkite): temporarily allow the `llvmpasses` job to fai…
vchuravy Jan 6, 2022
45faa5c
tests: fix type-error in computing duration (#43691)
vtjnash Jan 7, 2022
a05cb7e
doc: add reference to `rethrow()` in `throw` docstring, closes #43669…
adigitoleo Jan 7, 2022
cbf6c1c
doc: add Xoshiro example (#43697)
bkmgit Jan 7, 2022
dc61f29
Fix sparse array `setindex(::Int, ::Vector)` (#43678)
dkarrasch Jan 7, 2022
4f1ff0b
Docstring of `|>`: add parentheses around `->` func (#43699)
tfiers Jan 7, 2022
e9ad4f6
Merge pull request #43689 from JuliaLang/vc/llvmpasses
vchuravy Jan 7, 2022
b0fbc5c
[Test] avoid scanning Base twice for ambiguities (#43694)
vtjnash Jan 7, 2022
7f27dea
Fix Base.StackTraces.lookup(C_NULL - 1) on macOS 12 (#43612)
dnadlinger Jan 7, 2022
02f7332
[Test] make TestLogger respect `maxlog` (#43641)
ericphanson Jan 7, 2022
ad129a9
🤖 Bump the Pkg stdlib from fff928aa to 32880c47 (#43693)
DilumAluthgeBot Jan 7, 2022
dab212e
replace inefficient logic (#43708)
IanButterworth Jan 8, 2022
7e5f691
inference: add some error checks for atomic `getfield` with boundsche…
aviatesk Jan 8, 2022
dacd16f
reflection: use a real world for lookups (#43695)
vtjnash Jan 8, 2022
95cfbcc
inference: add error/throwness checks for `setfield!` (#43603)
aviatesk Jan 8, 2022
acb6e16
inference: introduce more error/throwness checks for array primitives…
aviatesk Jan 8, 2022
45d22df
Throw `CapturedException`s from asyncmap to avoid dropping the stackt…
ericphanson Jan 8, 2022
5f6b8a1
Generate memset and memmove intrinsics from ccalls (#43580)
pchintalapudi Jan 8, 2022
cd81054
Add `get_preferences()` to load all prefs in the current environment …
staticfloat Jan 9, 2022
7499513
inference: follow up #43603, better `getfield_tfunc` impl (#43713)
aviatesk Jan 9, 2022
709bc5c
`base/version_git.sh`: fix the default value for `Base.GIT_VERSION_IN…
DilumAluthge Jan 9, 2022
f7bb391
Fix build against LLVM 14 (Git main) (#43722)
dnadlinger Jan 10, 2022
dbd10e0
reflection: remove `_methods_by_ftype` with array arguments (#43710)
aviatesk Jan 10, 2022
85d141f
Align ccall() jl_set_task_tid return type with C declaration [nfc]
dnadlinger Jan 10, 2022
02005c2
src: fix minor headers issues (#43687)
vtjnash Jan 10, 2022
5686038
[REPL] handle failure of edit call gracefully (#43690)
vtjnash Jan 10, 2022
a3828c5
Avoid warning due to unused jl_set_gc_and_wait() on Darwin [nfc]
dnadlinger Jan 10, 2022
7b62896
Add `setcpuaffinity(cmd, cpus)` for setting CPU affinity of subproces…
tkf Jan 10, 2022
c883dbd
Merge pull request #43742 from dnadlinger/fix-set-task-tid-return
vchuravy Jan 10, 2022
3a55a1c
Merge pull request #43743 from dnadlinger/no-set-gc-and-wait-on-darwin
vchuravy Jan 10, 2022
9432e58
Add internal docs for dump.c (#43656)
timholy Jan 10, 2022
07b3b22
add missing codegen fallback functions and fix test (#43706)
JeffBezanson Jan 10, 2022
31dfef6
Fix ref to "git_version.jl" to "version_git.jl", minor typo (#43734)
mkitti Jan 10, 2022
a7e4f6d
`InteractiveUtils.versioninfo()`: print the value of the `LD_LIBRARY_…
DilumAluthge Jan 10, 2022
13b3e77
don't create empty handler list when calling `show_error_hints` (#43733)
aviatesk Jan 11, 2022
6b272af
[Codegen] Remove global nulls variables (#43757)
pchintalapudi Jan 11, 2022
b59e852
follow up #43565 (#43755)
aviatesk Jan 11, 2022
631f195
Simpler and More Clear ``Common Operations'' (#43741)
WrRan Jan 11, 2022
3b5f985
codegen: Avoid some uses of PointerType::getElementType() (#43721)
dnadlinger Jan 11, 2022
c1696b9
🤖 Bump the Pkg stdlib from 32880c47 to c3139663 (#43763)
DilumAluthgeBot Jan 11, 2022
7a4b43f
Add do-block syntax for Semaphore acquire. Add Semaphore tests (#43730)
IanButterworth Jan 11, 2022
18b825b
add syntax for empty n-dimensional arrays (#41618)
simeonschaub Jan 11, 2022
91f4af9
all permission masks get type UInt16 (#43726)
KlausC Jan 11, 2022
98e2321
When given - as the program name, read program from stdin (#43191)
fredrikekre Jan 12, 2022
f0d46ae
`versioninfo`: make sure not to print the same environment variable t…
DilumAluthge Jan 12, 2022
0968929
Add some comments to `Make.inc` that explicitly define what we mean w…
DilumAluthge Jan 12, 2022
0d89074
Remove various uses of jl_LLVMContext in codegen (#43749)
pchintalapudi Jan 12, 2022
9d05e7b
run a temp cleanup after the precompilation step (#43761)
KristofferC Jan 12, 2022
22b4a03
deps: Add missing checksums for Clang (#43769)
vchuravy Jan 12, 2022
2ed3ec4
Add missing colour `:light_white` (#43744)
eschnett Jan 12, 2022
c030bc8
CI (Buildkite): set both the `RR_LOG` and `RR_UNDER_RR_LOG` environme…
DilumAluthge Jan 12, 2022
79fc931
Add TBAA caching to jl_codectx_t (#43764)
pchintalapudi Jan 12, 2022
3d24fd8
Remove spurious at_show from loading test (#43774)
vchuravy Jan 12, 2022
29ea1fe
Remove explicit references to jl_data_layout (#43756)
pchintalapudi Jan 12, 2022
08ff456
Send AdjOrTrans(BlasMatrix) oop-products to BLAS (#43435)
dkarrasch Jan 12, 2022
fd8b2ab
promote ranges to the largest of the the start, step, or length (as a…
vtjnash Jan 12, 2022
f046fc8
Remove global basic integer types (#43752)
pchintalapudi Jan 12, 2022
0279b73
Add and use `isaccessiblefile` for `isfile_casesensitive` (#42922)
ven-k Jan 12, 2022
b08d9ee
docs: mention `const` field attribute of mutable struct (#43531)
jakobnissen Jan 12, 2022
2939272
macOS: workaround a dyld/libunwind deadlock issue since 12.1
vtjnash Jan 7, 2022
267b124
macOS: extend the workaround to cover the dyld/exc_server deadlock is…
vtjnash Jan 12, 2022
32abe71
fix typo in doc string for `display` (#43781)
JeffBezanson Jan 12, 2022
8997a90
Remove global thunk attribute (#43782)
pchintalapudi Jan 12, 2022
a401aac
Remove global basic pointer types (#43754)
pchintalapudi Jan 13, 2022
99d4e65
Handle freeze instruction in FindBaseValue (#43728)
vchuravy Jan 13, 2022
b351286
fix ranges PR conflict (#43790)
vtjnash Jan 13, 2022
1b33119
Merge pull request #43701 from JuliaLang/jn/43578
vtjnash Jan 13, 2022
9da2dad
Define show for CartesianIndices (#43780)
eschnett Jan 13, 2022
89f2332
Fix #43004 by commenting out broken throw tests (#43739)
mkitti Jan 13, 2022
49f4f78
Add trailing nl for `display(::TextDisplay, ...)` (#43787)
t-bltg Jan 13, 2022
5847647
Track memops more accurately (#43778)
pchintalapudi Jan 14, 2022
294b0df
Fix nothrow modeling of have_fma (#43785)
Keno Jan 14, 2022
5289a5e
`InteractiveUtils.versioninfo(; verbose = true)`: remove unnecessary …
DilumAluthge Jan 14, 2022
f70a86a
Add description of local kw in global scope (#42794)
tomtuamnuq Jan 14, 2022
5064528
Show only the "Test Passed" message when a test passes (#43795)
nickrobinson251 Jan 14, 2022
b57d2e1
move SparseArrays to the external repo https://github.com/JuliaLang/S…
KristofferC Jan 14, 2022
a9edea1
Allow branch folding to look at type information
Keno Jan 12, 2022
35a5172
Fix bug where Conditional wasn't being marked as ConstAPI
Keno Jan 12, 2022
f15b4c3
Cleanup `copy_oftype`-like functions in factorizations (#43700)
dkarrasch Jan 14, 2022
de85dea
Optimize `permutedims` on *diagonals (#43792)
dkarrasch Jan 14, 2022
14154fc
Profile: Faster data dict lookup (#43805)
IanButterworth Jan 14, 2022
7b1cc4b
Allow reinterpreting singleton types (#43500)
Liozou Jan 14, 2022
7ab26e0
Merge pull request #43797 from ianatol/ia/condfolding
aviatesk Jan 15, 2022
bff3eb6
Revert "Profile: Faster data dict lookup (#43805)" (#43814)
vtjnash Jan 15, 2022
49c667d
Try to fix `fma` on windows (#43530)
N5N3 Jan 15, 2022
39c7355
Clean up more uses of jl_LLVMContext (#43791)
pchintalapudi Jan 15, 2022
a32a066
[REPL] More accurate `ends_with_semicolon` (#43374)
fonsp Jan 15, 2022
3522661
Add specialization of foreach for tuples (#31901)
danielmatz Jan 16, 2022
b65c19a
[LLVM] Remove LLVM 11 patches from source-tree (#43824)
vchuravy Jan 16, 2022
8536522
Use `GlobalRef` of `Core.CodeInfo` in `@generated` (#43823)
devmotion Jan 16, 2022
75a1d0f
[LLVM] Add support for building experimental targets (#43822)
vchuravy Jan 16, 2022
dd0c14b
Fix getindex and setindex! on 0-dimensional reinterpretarray (#43819)
Liozou Jan 17, 2022
8667272
Small test cleanup (#43831)
Keno Jan 17, 2022
f03e839
Fix splatnew test (#43835)
Keno Jan 17, 2022
591f066
Move sparse matrix tests to the new SparseArrays.jl repo (#43832)
ViralBShah Jan 17, 2022
4b036f0
Update Documenter to latest version. (#43843)
fredrikekre Jan 17, 2022
d6cd37a
InteractiveUtils: add const annotations (#43846)
aviatesk Jan 17, 2022
45acb76
🤖 Bump the SparseArrays stdlib from 205b770 to 16dd9bd (#43848)
DilumAluthgeBot Jan 17, 2022
c5158f4
Fix typos in runtime_intrinsics.c (#43850)
tkf Jan 18, 2022
eb724e0
Add defalg methods to resolve potential dispatch ambiguities (#43426)
bkamins Jan 18, 2022
51ded1c
Simplify loading code from stdin during precompilation. (#43853)
maleadt Jan 18, 2022
1f266b8
Move typeassert effect-free modeling to the proper place (#43830)
Keno Jan 18, 2022
aa1bd28
Fix `extrema(x; dims)` for inputs with `NaN/missing` (#43604)
N5N3 Jan 18, 2022
8ec5580
Remove have_fma from the public API exports. (#43854)
maleadt Jan 19, 2022
5864e43
Fix `tmerge` for (partially) const types with undef fields (#43812)
martinholters Jan 19, 2022
ef23d6d
Allocation profiler (#42768)
vilterp Jan 19, 2022
db13a49
try wrapping pool alloc
vilterp Jan 12, 2022
00a791e
update exported functions
vilterp Jan 12, 2022
d0f5ce0
avoid segfault by zeroing out type tag
vilterp Jan 18, 2022
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
1 change: 0 additions & 1 deletion .buildkite/pipelines/main/misc/llvmpasses.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ steps:
timeout_in_minutes: 60
- label: "llvmpasses"
key: "llvmpasses"
soft_fail: true # TODO: delete this line
plugins:
- JuliaCI/julia#v1:
# Drop default "registries" directory, so it is not persisted from execution to execution
Expand Down
3 changes: 2 additions & 1 deletion .buildkite/utilities/rr/rr_capture.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ mktempdir(temp_parent_dir) do dir

new_env = copy(ENV)
new_env["_RR_TRACE_DIR"] = joinpath(dir, "rr_traces")
new_env["RR_LOG"]="all:debug"
new_env["RR_LOG"] = "all:debug"
new_env["RR_UNDER_RR_LOG"] = "all:debug"
new_env["RR_LOG_BUFFER"]="100000"
new_env["JULIA_RR"] = capture_script_path
t_start = time()
Expand Down
6 changes: 6 additions & 0 deletions Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
# Set to zero to turn off extra precompile (e.g. for the REPL)
JULIA_PRECOMPILE ?= 1

# Set FORCE_ASSERTIONS to 1 to enable assertions in the C and C++ portions
# of the Julia code base. You may also want to set LLVM_ASSERTIONS to 1,
# which will enable assertions in LLVM.
# An "assert build" of Julia is a build that has both FORCE_ASSERTIONS=1
# and LLVM_ASSERTIONS=1.
FORCE_ASSERTIONS ?= 0

# OPENBLAS build options
Expand Down Expand Up @@ -330,6 +335,7 @@ INSTALL_M := $(JULIAHOME)/contrib/install.sh 755

# LLVM Options
LLVMROOT := $(build_prefix)
# Set LLVM_ASSERTIONS to 1 to enable assertions in LLVM.
LLVM_ASSERTIONS := 0
LLVM_DEBUG := 0
# set to 1 to get clang and compiler-rt
Expand Down
11 changes: 11 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ New language features
* Mutable struct fields may now be annotated as `const` to prevent changing
them after construction, providing for greater clarity and optimization
ability of these objects ([#43305]).
* Empty n-dimensional arrays can now be created using multiple semicolons inside square brackets, i.e. `[;;;]` creates a 0×0×0 `Array`. ([#41618])

Language changes
----------------
Expand Down Expand Up @@ -59,6 +60,7 @@ Command-line option changes
* New option `--strip-ir` to remove the compiler's IR (intermediate representation) of source
code when building a system image. The resulting image will only work if `--compile=all` is
used, or if all needed code is precompiled ([#42925]).
* When the program file is `-` the code to be executed is read from standard in ([#43191]).

Multi-threading changes
-----------------------
Expand All @@ -72,6 +74,7 @@ New library functions
---------------------

* `hardlink(src, dst)` can be used to create hard links. ([#41639])
* `setcpuaffinity(cmd, cpus)` can be used to set CPU affinity of sub-processes. ([#42469])
* `diskstat(path=pwd())` can be used to return statistics about the disk. ([#42248])

New library features
Expand All @@ -96,6 +99,7 @@ Standard library changes
arithmetic to error if the result may be wrapping. Or use a package such as SaferIntegers.jl when
constructing the range. ([#40382])
* TCP socket objects now expose `closewrite` functionality and support half-open mode usage ([#40783]).
* `extrema` now supports `init` keyword argument ([#36265], [#43604]).
* Intersect returns a result with the eltype of the type-promoted eltypes of the two inputs ([#41769]).
* `Iterators.countfrom` now accepts any type that defines `+`. ([#37747])

Expand Down Expand Up @@ -135,6 +139,9 @@ Standard library changes
Further, percent utilization is now reported as a total or per-thread, based on whether the thread is idle or not at
each sample. `Profile.fetch()` by default strips out the new metadata to ensure backwards compatibility with external
profiling data consumers, but can be included with the `include_meta` kwarg. ([#41742])
* The new `Profile.Allocs` module allows memory allocations to be profiled. The stack trace, type, and size of each
allocation is recorded, and a `sample_rate` argument allows a tunable amount of allocations to be skipped,
reducing performance overhead. ([#42768])

#### Random

Expand All @@ -151,6 +158,10 @@ Standard library changes

#### SparseArrays

* The code for SparseArrays has been moved from the Julia repo to the external
repo at https://github.com/JuliaLang/SparseArrays.jl. This is only a code
movement and does not impact any usage ([#43813]).

* New sparse concatenation functions `sparse_hcat`, `sparse_vcat`, and `sparse_hvcat` return
`SparseMatrixCSC` output independent from the types of the input arguments. They make
concatenation behavior available, in which the presence of some special "sparse" matrix
Expand Down
2 changes: 1 addition & 1 deletion base/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ endif
$(BUILDDIR)/version_git.jl.phony: $(SRCDIR)/version_git.sh
ifneq ($(NO_GIT), 1)
sh $< $(SRCDIR) > $@
@# This to avoid touching git_version.jl when it is not modified,
@# This to avoid touching version_git.jl when it is not modified,
@# so that the system image does not need to be rebuilt.
@if ! cmp -s $@ version_git.jl; then \
$(call PRINT_PERL,) \
Expand Down
2 changes: 1 addition & 1 deletion base/asyncmap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ function start_worker_task!(worker_tasks, exec_func, chnl, batch_size=nothing)
end
catch e
close(chnl)
retval = e
retval = capture_exception(e, catch_backtrace())
end
retval
end
Expand Down
1 change: 1 addition & 0 deletions base/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,7 @@ broadcasted(::DefaultArrayStyle{1}, ::typeof(*), r::LinRange, x::Number) = LinRa
broadcasted(::DefaultArrayStyle{1}, ::typeof(*), r::OrdinalRange, x::AbstractFloat) =
Base.range_start_step_length(first(r)*x, step(r)*x, length(r))

#broadcasted(::DefaultArrayStyle{1}, ::typeof(/), r::AbstractRange, x::Number) = range(first(r)/x, last(r)/x, length=length(r))
broadcasted(::DefaultArrayStyle{1}, ::typeof(/), r::AbstractRange, x::Number) = range(first(r)/x, step=step(r)/x, length=length(r))
broadcasted(::DefaultArrayStyle{1}, ::typeof(/), r::StepRangeLen{T}, x::Number) where {T} =
StepRangeLen{typeof(T(r.ref)/x)}(r.ref/x, r.step/x, length(r), r.offset)
Expand Down
7 changes: 5 additions & 2 deletions base/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ function eval_user_input(errio, @nospecialize(ast), show_value::Bool)
@error "Evaluation succeeded, but an error occurred while displaying the value" typeof(value)
rethrow()
end
println()
end
end
break
Expand Down Expand Up @@ -301,7 +300,11 @@ function exec_options(opts)
exit_on_sigint(true)
end
try
include(Main, PROGRAM_FILE)
if PROGRAM_FILE == "-"
include_string(Main, read(stdin, String), "stdin")
else
include(Main, PROGRAM_FILE)
end
catch
invokelatest(display_error, scrub_repl_backtrace(current_exceptions()))
if !is_interactive::Bool
Expand Down
53 changes: 48 additions & 5 deletions base/cmd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,31 @@ struct Cmd <: AbstractCmd
flags::UInt32 # libuv process flags
env::Union{Vector{String},Nothing}
dir::String
cpus::Union{Nothing,Vector{UInt16}}
Cmd(exec::Vector{String}) =
new(exec, false, 0x00, nothing, "")
Cmd(cmd::Cmd, ignorestatus, flags, env, dir) =
new(exec, false, 0x00, nothing, "", nothing)
Cmd(cmd::Cmd, ignorestatus, flags, env, dir, cpus = nothing) =
new(cmd.exec, ignorestatus, flags, env,
dir === cmd.dir ? dir : cstr(dir))
dir === cmd.dir ? dir : cstr(dir), cpus)
function Cmd(cmd::Cmd; ignorestatus::Bool=cmd.ignorestatus, env=cmd.env, dir::AbstractString=cmd.dir,
cpus::Union{Nothing,Vector{UInt16}} = cmd.cpus,
detach::Bool = 0 != cmd.flags & UV_PROCESS_DETACHED,
windows_verbatim::Bool = 0 != cmd.flags & UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS,
windows_hide::Bool = 0 != cmd.flags & UV_PROCESS_WINDOWS_HIDE)
flags = detach * UV_PROCESS_DETACHED |
windows_verbatim * UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS |
windows_hide * UV_PROCESS_WINDOWS_HIDE
new(cmd.exec, ignorestatus, flags, byteenv(env),
dir === cmd.dir ? dir : cstr(dir))
dir === cmd.dir ? dir : cstr(dir), cpus)
end
end

has_nondefault_cmd_flags(c::Cmd) =
c.ignorestatus ||
c.flags != 0x00 ||
c.env !== nothing ||
c.dir !== ""
c.dir !== "" ||
c.cpus !== nothing

"""
Cmd(cmd::Cmd; ignorestatus, detach, windows_verbatim, windows_hide, env, dir)
Expand Down Expand Up @@ -114,6 +117,8 @@ function show(io::IO, cmd::Cmd)
print_env = cmd.env !== nothing
print_dir = !isempty(cmd.dir)
(print_env || print_dir) && print(io, "setenv(")
print_cpus = cmd.cpus !== nothing
print_cpus && print(io, "setcpuaffinity(")
print(io, '`')
join(io, map(cmd.exec) do arg
replace(sprint(context=io) do io
Expand All @@ -123,6 +128,11 @@ function show(io::IO, cmd::Cmd)
end, '`' => "\\`")
end, ' ')
print(io, '`')
if print_cpus
print(io, ", ")
show(io, collect(Int, cmd.cpus))
print(io, ")")
end
print_env && (print(io, ","); show(io, cmd.env))
print_dir && (print(io, "; dir="); show(io, cmd.dir))
(print_dir || print_env) && print(io, ")")
Expand Down Expand Up @@ -294,6 +304,39 @@ function addenv(cmd::Cmd, env::Vector{<:AbstractString}; inherit::Bool = true)
return addenv(cmd, Dict(k => v for (k, v) in eachsplit.(env, "=")); inherit)
end

"""
setcpuaffinity(original_command::Cmd, cpus) -> command::Cmd

Set the CPU affinity of the `command` by a list of CPU IDs (1-based) `cpus`. Passing
`cpus = nothing` means to unset the CPU affinity if the `original_command` has any.

This function is supported only in Linux and Windows. It is not supported in macOS because
libuv does not support affinity setting.

!!! compat "Julia 1.8"
This function requires at least Julia 1.8.

# Examples

In Linux, the `taskset` command line program can be used to see how `setcpuaffinity` works.

```julia
julia> run(setcpuaffinity(`sh -c 'taskset -p \$\$'`, [1, 2, 5]));
pid 2273's current affinity mask: 13
```

Note that the mask value `13` reflects that the first, second, and the fifth bits (counting
from the least significant position) are turned on:

```julia
julia> 0b010011
0x13
```
"""
function setcpuaffinity end
setcpuaffinity(cmd::Cmd, ::Nothing) = Cmd(cmd; cpus = nothing)
setcpuaffinity(cmd::Cmd, cpus) = Cmd(cmd; cpus = collect(UInt16, cpus))

(&)(left::AbstractCmd, right::AbstractCmd) = AndCmds(left, right)
redir_out(src::AbstractCmd, dest::AbstractCmd) = OrCmds(src, dest)
redir_err(src::AbstractCmd, dest::AbstractCmd) = ErrOrCmds(src, dest)
Expand Down
13 changes: 13 additions & 0 deletions base/compiler/compiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,19 @@ include("compiler/abstractinterpretation.jl")
include("compiler/typeinfer.jl")
include("compiler/optimize.jl") # TODO: break this up further + extract utilities

# required for bootstrap
# TODO: find why this is needed and remove it.
function extrema(x::Array)
isempty(x) && throw(ArgumentError("collection must be non-empty"))
vmin = vmax = x[1]
for i in 2:length(x)
xi = x[i]
vmax = max(vmax, xi)
vmin = min(vmin, xi)
end
return vmin, vmax
end

include("compiler/bootstrap.jl")
ccall(:jl_set_typeinf_func, Cvoid, (Any,), typeinf_ext_toplevel)

Expand Down
30 changes: 14 additions & 16 deletions base/compiler/optimize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ const _PURE_BUILTINS = Any[tuple, svec, ===, typeof, nfields]
# known to be effect-free if the are nothrow
const _PURE_OR_ERROR_BUILTINS = [
fieldtype, apply_type, isa, UnionAll,
getfield, arrayref, const_arrayref, isdefined, Core.sizeof,
getfield, arrayref, const_arrayref, arraysize, isdefined, Core.sizeof,
Core.kwfunc, Core.ifelse, Core._typevar, (<:)
]

Expand Down Expand Up @@ -237,7 +237,7 @@ function stmt_effect_free(@nospecialize(stmt), @nospecialize(rt), src::Union{IRC
end
return true
elseif head === :foreigncall
return foreigncall_effect_free(stmt, rt, src)
return foreigncall_effect_free(stmt, src)
elseif head === :new_opaque_closure
length(args) < 5 && return false
typ = argextype(args[1], src)
Expand All @@ -262,7 +262,7 @@ function stmt_effect_free(@nospecialize(stmt), @nospecialize(rt), src::Union{IRC
return true
end

function foreigncall_effect_free(stmt::Expr, @nospecialize(rt), src::Union{IRCode,IncrementalCompact})
function foreigncall_effect_free(stmt::Expr, src::Union{IRCode,IncrementalCompact})
args = stmt.args
name = args[1]
isa(name, QuoteNode) && (name = name.value)
Expand Down Expand Up @@ -293,9 +293,7 @@ end

function alloc_array_no_throw(args::Vector{Any}, ndims::Int, src::Union{IRCode,IncrementalCompact})
length(args) ≥ ndims+6 || return false
atype = widenconst(argextype(args[6], src))
isType(atype) || return false
atype = atype.parameters[1]
atype = instanceof_tfunc(argextype(args[6], src))[1]
dims = Csize_t[]
for i in 1:ndims
dim = argextype(args[i+6], src)
Expand All @@ -309,9 +307,7 @@ end

function new_array_no_throw(args::Vector{Any}, src::Union{IRCode,IncrementalCompact})
length(args) ≥ 7 || return false
atype = widenconst(argextype(args[6], src))
isType(atype) || return false
atype = atype.parameters[1]
atype = instanceof_tfunc(argextype(args[6], src))[1]
dims = argextype(args[7], src)
isa(dims, Const) || return dims === Tuple{}
dimsval = dims.val
Expand Down Expand Up @@ -406,13 +402,14 @@ function finish(interp::AbstractInterpreter, opt::OptimizationState,
force_noinline = _any(@nospecialize(x) -> isexpr(x, :meta) && x.args[1] === :noinline, ir.meta)

# compute inlining and other related optimizations
if (isa(result, Const) || isconstType(result))
wresult = isa(result, InterConditional) ? widenconditional(result) : result
if (isa(wresult, Const) || isconstType(wresult))
proven_pure = false
# must be proven pure to use constant calling convention;
# otherwise we might skip throwing errors (issue #20704)
# TODO: Improve this analysis; if a function is marked @pure we should really
# only care about certain errors (e.g. method errors and type errors).
if length(ir.stmts) < 10
if length(ir.stmts) < 15
proven_pure = true
for i in 1:length(ir.stmts)
node = ir.stmts[i]
Expand Down Expand Up @@ -440,14 +437,14 @@ function finish(interp::AbstractInterpreter, opt::OptimizationState,
# Still set pure flag to make sure `inference` tests pass
# and to possibly enable more optimization in the future
src.pure = true
if isa(result, Const)
val = result.val
if isa(wresult, Const)
val = wresult.val
if is_inlineable_constant(val)
analyzed = ConstAPI(val)
end
else
@assert isconstType(result)
analyzed = ConstAPI(result.parameters[1])
@assert isconstType(wresult)
analyzed = ConstAPI(wresult.parameters[1])
end
force_noinline || (src.inlineable = true)
end
Expand Down Expand Up @@ -628,7 +625,8 @@ function is_pure_intrinsic_infer(f::IntrinsicFunction)
end

# whether `f` is effect free if nothrow
intrinsic_effect_free_if_nothrow(f) = f === Intrinsics.pointerref || is_pure_intrinsic_infer(f)
intrinsic_effect_free_if_nothrow(f) = f === Intrinsics.pointerref ||
f === Intrinsics.have_fma || is_pure_intrinsic_infer(f)

## Computing the cost of a function body

Expand Down
21 changes: 10 additions & 11 deletions base/compiler/ssair/inlining.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,9 @@ end
function check_effect_free!(ir::IRCode, idx::Int, @nospecialize(stmt), @nospecialize(rt))
if stmt_effect_free(stmt, rt, ir)
ir.stmts[idx][:flag] |= IR_FLAG_EFFECT_FREE
return true
end
return false
end

# Handles all analysis and inlining of intrinsics and builtins. In particular,
Expand Down Expand Up @@ -1107,10 +1109,16 @@ function process_simple!(ir::IRCode, idx::Int, state::InliningState, todo::Vecto
return nothing
end

check_effect_free!(ir, idx, stmt, rt)
if check_effect_free!(ir, idx, stmt, rt)
if sig.f === typeassert || sig.ft ⊑ typeof(typeassert)
# typeassert is a no-op if effect free
ir.stmts[idx][:inst] = stmt.args[2]
return nothing
end
end

if sig.f !== Core.invoke && is_builtin(sig)
# No inlining for builtins (other invoke/apply)
# No inlining for builtins (other invoke/apply/typeassert)
return nothing
end

Expand Down Expand Up @@ -1379,15 +1387,6 @@ function early_inline_special_case(
ir::IRCode, stmt::Expr, @nospecialize(type), sig::Signature,
params::OptimizationParams)
(; f, ft, argtypes) = sig
if (f === typeassert || ft ⊑ typeof(typeassert)) && length(argtypes) == 3
# typeassert(x::S, T) => x, when S<:T
a3 = argtypes[3]
if (isType(a3) && !has_free_typevars(a3) && argtypes[2] ⊑ a3.parameters[1]) ||
(isa(a3, Const) && isa(a3.val, Type) && argtypes[2] ⊑ a3.val)
val = stmt.args[2]
return SomeCase(val === nothing ? QuoteNode(val) : val)
end
end

if params.inlining
if isa(type, Const) # || isconstType(type)
Expand Down
Loading