Skip to content

Commit 0b205e1

Browse files
authored
Merge branch 'master' into kc/pidlock_repl_history
2 parents 6374135 + eed18bd commit 0b205e1

File tree

249 files changed

+5712
-3327
lines changed

Some content is hidden

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

249 files changed

+5712
-3327
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
/julia-*
1212
/source-dist.tmp
1313
/source-dist.tmp1
14+
/test/results_*.json
15+
/test/results_*.dat
1416

1517
*.expmap
1618
*.exe

CONTRIBUTING.md

+41-20
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,40 @@ Hi! If you are new to the Julia community: welcome, and thanks for trying Julia.
44

55
If you are already familiar with Julia itself, this blog post by Katharine Hyatt on [Making your first Julia pull request](https://kshyatt.github.io/post/firstjuliapr/) is a great way to get started.
66

7-
## Learning Julia
8-
9-
[The learning page](https://julialang.org/learning) has a great list of resources for new and experienced users alike.
10-
11-
## Before filing an issue
12-
13-
- Reporting a potential bug? Please read the "[How to file a bug report](https://github.com/JuliaLang/julia/blob/master/CONTRIBUTING.md#how-to-file-a-bug-report)" section to make sure that all necessary information is included.
147

15-
- Contributing code? Be sure to review the [contributor checklist](https://github.com/JuliaLang/julia/blob/master/CONTRIBUTING.md#contributor-checklist) for helpful tips on the tools we use to build Julia.
8+
# Table of Contents
169

17-
- Library feature requests are generally not accepted on this issue tracker. New libraries should be developed as [packages](https://julialang.github.io/Pkg.jl/v1/creating-packages/). Discuss ideas for libraries at the [Julia Discourse forum](https://discourse.julialang.org). Doing so will often lead to pointers to existing projects and bring together collaborators with common interests.
10+
1. [Learning Julia](#learning-julia)
11+
2. [Filing an issue](#filing-an-issue)
12+
- [Before filing an issue](#before-filing-an-issue)
13+
- [How to file a bug report](#how-to-file-a-bug-report)
14+
3. [Submitting contributions](#submitting-contributions)
15+
- [Contributor Checklist](#contributor-checklist)
16+
- [Writing tests](#writing-tests)
17+
- [Improving documentation](#improving-documentation)
18+
- [Contributing to core functionality or base libraries](#contributing-to-core-functionality-or-base-libraries)
19+
- [Contributing to the standard library](#contributing-to-the-standard-library)
20+
- [Contributing to patch releases](#contributing-to-patch-releases)
21+
- [Code Formatting Guidelines](#code-formatting-guidelines)
22+
- [Git Recommendations For Pull Requests](#git-recommendations-for-pull-requests)
23+
4. [Resources](#resources)
1824

19-
## Contributor Checklist
20-
21-
* Create a [GitHub account](https://github.com/signup/free).
2225

23-
* [Fork Julia](https://github.com/JuliaLang/julia/fork).
26+
## Learning Julia
2427

25-
* Build the software and libraries (the first time takes a while, but it's fast after that). Detailed build instructions are in the [README](https://github.com/JuliaLang/julia/tree/master/README.md). Julia depends on several external packages; most are automatically downloaded and installed, but are less frequently updated than Julia itself.
28+
[The learning page](https://julialang.org/learning) has a great list of resources for new and experienced users alike.
2629

27-
* Keep Julia current. Julia is a fast-moving target, and many details of the language are still settling out. Keep the repository up-to-date and rebase work-in-progress frequently to make merges simpler.
30+
## Filing an issue
2831

29-
* Learn to use [git](https://git-scm.com), the version control system used by GitHub and the Julia project. Try a tutorial such as the one [provided by GitHub](https://try.GitHub.io/levels/1/challenges/1).
32+
### Before filing an issue
3033

31-
* Review discussions on the [Julia Discourse forum](https://discourse.julialang.org).
34+
- Reporting a potential bug? Please read the "[How to file a bug report](https://github.com/JuliaLang/julia/blob/master/CONTRIBUTING.md#how-to-file-a-bug-report)" section to make sure that all necessary information is included.
3235

33-
* For more detailed tips, read the [submission guide](https://github.com/JuliaLang/julia/blob/master/CONTRIBUTING.md#submitting-contributions) below.
36+
- Contributing code? Be sure to review the [contributor checklist](https://github.com/JuliaLang/julia/blob/master/CONTRIBUTING.md#contributor-checklist) for helpful tips on the tools we use to build Julia.
3437

35-
* Relax and have fun!
38+
- Library feature requests are generally not accepted on this issue tracker. New libraries should be developed as [packages](https://julialang.github.io/Pkg.jl/v1/creating-packages/). Discuss ideas for libraries at the [Julia Discourse forum](https://discourse.julialang.org). Doing so will often lead to pointers to existing projects and bring together collaborators with common interests.
3639

37-
## How to file a bug report
40+
### How to file a bug report
3841

3942
A useful bug report filed as a GitHub issue provides information about how to reproduce the error.
4043

@@ -56,6 +59,24 @@ A useful bug report filed as a GitHub issue provides information about how to re
5659

5760
## Submitting contributions
5861

62+
### Contributor Checklist
63+
64+
* Create a [GitHub account](https://github.com/signup/free).
65+
66+
* [Fork Julia](https://github.com/JuliaLang/julia/fork).
67+
68+
* Build the software and libraries (the first time takes a while, but it's fast after that). Detailed build instructions are in the [README](https://github.com/JuliaLang/julia/tree/master/README.md). Julia depends on several external packages; most are automatically downloaded and installed, but are less frequently updated than Julia itself.
69+
70+
* Keep Julia current. Julia is a fast-moving target, and many details of the language are still settling out. Keep the repository up-to-date and rebase work-in-progress frequently to make merges simpler.
71+
72+
* Learn to use [git](https://git-scm.com), the version control system used by GitHub and the Julia project. Try a tutorial such as the one [provided by GitHub](https://try.GitHub.io/levels/1/challenges/1).
73+
74+
* Review discussions on the [Julia Discourse forum](https://discourse.julialang.org).
75+
76+
* For more detailed tips, read the [submission guide](https://github.com/JuliaLang/julia/blob/master/CONTRIBUTING.md#submitting-contributions) below.
77+
78+
* Relax and have fun!
79+
5980
### Writing tests
6081

6182
There are never enough tests. Track [code coverage at Codecov](https://codecov.io/github/JuliaLang/julia), and help improve it.

Compiler/extras/CompilerDevTools/src/CompilerDevTools.jl

+39-11
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,74 @@
11
module CompilerDevTools
22

33
using Compiler
4+
using Compiler: argextype, widenconst
45
using Core.IR
6+
using Base: isexpr
7+
8+
mutable struct SplitCacheOwner end
59

6-
struct SplitCacheOwner; end
710
struct SplitCacheInterp <: Compiler.AbstractInterpreter
811
world::UInt
12+
owner::SplitCacheOwner
913
inf_params::Compiler.InferenceParams
1014
opt_params::Compiler.OptimizationParams
1115
inf_cache::Vector{Compiler.InferenceResult}
1216
codegen_cache::IdDict{CodeInstance,CodeInfo}
1317
function SplitCacheInterp(;
1418
world::UInt = Base.get_world_counter(),
19+
owner::SplitCacheOwner = SplitCacheOwner(),
1520
inf_params::Compiler.InferenceParams = Compiler.InferenceParams(),
1621
opt_params::Compiler.OptimizationParams = Compiler.OptimizationParams(),
1722
inf_cache::Vector{Compiler.InferenceResult} = Compiler.InferenceResult[])
18-
new(world, inf_params, opt_params, inf_cache, IdDict{CodeInstance,CodeInfo}())
23+
new(world, owner, inf_params, opt_params, inf_cache, IdDict{CodeInstance,CodeInfo}())
1924
end
2025
end
2126

2227
Compiler.InferenceParams(interp::SplitCacheInterp) = interp.inf_params
2328
Compiler.OptimizationParams(interp::SplitCacheInterp) = interp.opt_params
2429
Compiler.get_inference_world(interp::SplitCacheInterp) = interp.world
2530
Compiler.get_inference_cache(interp::SplitCacheInterp) = interp.inf_cache
26-
Compiler.cache_owner(::SplitCacheInterp) = SplitCacheOwner()
31+
Compiler.cache_owner(interp::SplitCacheInterp) = interp.owner
2732
Compiler.codegen_cache(interp::SplitCacheInterp) = interp.codegen_cache
2833

2934
import Core.OptimizedGenerics.CompilerPlugins: typeinf, typeinf_edge
30-
@eval @noinline typeinf(::SplitCacheOwner, mi::MethodInstance, source_mode::UInt8) =
31-
Base.invoke_in_world(which(typeinf, Tuple{SplitCacheOwner, MethodInstance, UInt8}).primary_world, Compiler.typeinf_ext_toplevel, SplitCacheInterp(; world=Base.tls_world_age()), mi, source_mode)
35+
@eval @noinline typeinf(owner::SplitCacheOwner, mi::MethodInstance, source_mode::UInt8) =
36+
Base.invoke_in_world(which(typeinf, Tuple{SplitCacheOwner, MethodInstance, UInt8}).primary_world, Compiler.typeinf_ext_toplevel, SplitCacheInterp(; world=Base.tls_world_age(), owner), mi, source_mode)
3237

33-
@eval @noinline function typeinf_edge(::SplitCacheOwner, mi::MethodInstance, parent_frame::Compiler.InferenceState, world::UInt, source_mode::UInt8)
38+
@eval @noinline function typeinf_edge(owner::SplitCacheOwner, mi::MethodInstance, parent_frame::Compiler.InferenceState, world::UInt, source_mode::UInt8)
3439
# TODO: This isn't quite right, we're just sketching things for now
35-
interp = SplitCacheInterp(; world)
40+
interp = SplitCacheInterp(; world, owner)
3641
Compiler.typeinf_edge(interp, mi.def, mi.specTypes, Core.svec(), parent_frame, false, false)
3742
end
3843

39-
function with_new_compiler(f, args...)
40-
mi = @ccall jl_method_lookup(Any[f, args...]::Ptr{Any}, (1+length(args))::Csize_t, Base.tls_world_age()::Csize_t)::Ref{Core.MethodInstance}
41-
world = Base.tls_world_age()
44+
function lookup_method_instance(f, args...)
45+
@ccall jl_method_lookup(Any[f, args...]::Ptr{Any}, (1+length(args))::Csize_t, Base.tls_world_age()::Csize_t)::Ref{Core.MethodInstance}
46+
end
47+
48+
function Compiler.optimize(interp::SplitCacheInterp, opt::Compiler.OptimizationState, caller::Compiler.InferenceResult)
49+
@invoke Compiler.optimize(interp::Compiler.AbstractInterpreter, opt::Compiler.OptimizationState, caller::Compiler.InferenceResult)
50+
ir = opt.result.ir::Compiler.IRCode
51+
override = GlobalRef(@__MODULE__(), :with_new_compiler)
52+
for inst in ir.stmts
53+
stmt = inst[:stmt]
54+
isexpr(stmt, :call) || continue
55+
f = stmt.args[1]
56+
f === override && continue
57+
if isa(f, GlobalRef)
58+
T = widenconst(argextype(f, ir))
59+
T <: Core.Builtin && continue
60+
end
61+
insert!(stmt.args, 1, override)
62+
insert!(stmt.args, 3, interp.owner)
63+
end
64+
end
65+
66+
with_new_compiler(f, args...; owner::SplitCacheOwner = SplitCacheOwner()) = with_new_compiler(f, owner, args...)
67+
68+
function with_new_compiler(f, owner::SplitCacheOwner, args...)
69+
mi = lookup_method_instance(f, args...)
4270
new_compiler_ci = Core.OptimizedGenerics.CompilerPlugins.typeinf(
43-
SplitCacheOwner(), mi, Compiler.SOURCE_MODE_ABI
71+
owner, mi, Compiler.SOURCE_MODE_ABI
4472
)
4573
invoke(f, new_compiler_ci, args...)
4674
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using Test
2+
using Compiler: code_cache
3+
using Base: inferencebarrier
4+
using CompilerDevTools
5+
using CompilerDevTools: lookup_method_instance, SplitCacheInterp
6+
7+
@testset "CompilerDevTools" begin
8+
do_work(x, y) = x + y
9+
f1() = do_work(inferencebarrier(1), inferencebarrier(2))
10+
interp = SplitCacheInterp()
11+
cache = code_cache(interp)
12+
mi = lookup_method_instance(f1)
13+
@test !haskey(cache, mi)
14+
@test with_new_compiler(f1, interp.owner) === 3
15+
@test haskey(cache, mi)
16+
# Here `do_work` is compiled at runtime, and so must have
17+
# required extra work to be cached under the same cache owner.
18+
mi = lookup_method_instance(do_work, 1, 2)
19+
@test haskey(cache, mi)
20+
end;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
using Pkg
2+
3+
Pkg.activate(dirname(@__DIR__)) do
4+
Pkg.instantiate()
5+
include("runtests.jl")
6+
end

Compiler/src/Compiler.jl

+16-16
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ using Core: ABIOverride, Builtin, CodeInstance, IntrinsicFunction, MethodInstanc
4949

5050
using Base
5151
using Base: @_foldable_meta, @_gc_preserve_begin, @_gc_preserve_end, @nospecializeinfer,
52-
BINDING_KIND_GLOBAL, BINDING_KIND_UNDEF_CONST, BINDING_KIND_BACKDATED_CONST, BINDING_KIND_DECLARED,
52+
PARTITION_KIND_GLOBAL, PARTITION_KIND_UNDEF_CONST, PARTITION_KIND_BACKDATED_CONST, PARTITION_KIND_DECLARED,
53+
PARTITION_FLAG_DEPWARN,
5354
Base, BitVector, Bottom, Callable, DataTypeFieldDesc,
5455
EffectsOverride, Filter, Generator, IteratorSize, JLOptions, NUM_EFFECTS_OVERRIDES,
5556
OneTo, Ordering, RefValue, SizeUnknown, _NAMEDTUPLE_NAME,
@@ -68,7 +69,7 @@ using Base: @_foldable_meta, @_gc_preserve_begin, @_gc_preserve_end, @nospeciali
6869
structdiff, tls_world_age, unconstrain_vararg_length, unionlen, uniontype_layout,
6970
uniontypes, unsafe_convert, unwrap_unionall, unwrapva, vect, widen_diagonal,
7071
_uncompressed_ir, maybe_add_binding_backedge!, datatype_min_ninitialized,
71-
partialstruct_undef_length, partialstruct_init_undef
72+
partialstruct_init_undefs, fieldcount_noerror
7273
using Base.Order
7374

7475
import Base: ==, _topmod, append!, convert, copy, copy!, findall, first, get, get!,
@@ -192,23 +193,22 @@ end
192193
module IRShow end # relies on string and IO operations defined in Base
193194
baremodule TrimVerifier end # relies on IRShow, so define this afterwards
194195

195-
function load_irshow!()
196-
if isdefined(Base, :end_base_include)
197-
# This code path is exclusively for Revise, which may want to re-run this
198-
# after bootstrap.
199-
Compilerdir = Base.dirname(Base.String(@__SOURCE_FILE__))
200-
include(IRShow, Base.joinpath(Compilerdir, "ssair/show.jl"))
201-
include(TrimVerifier, Base.joinpath(Compilerdir, "verifytrim.jl"))
202-
else
196+
if isdefined(Base, :end_base_include)
197+
# When this module is loaded as the standard library, include these files as usual
198+
include(IRShow, "ssair/show.jl")
199+
include(TrimVerifier, "verifytrim.jl")
200+
else
201+
function load_irshow!()
202+
Base.delete_method(Base.which(verify_typeinf_trim, (IO, Vector{Any}, Bool)),)
203203
include(IRShow, "ssair/show.jl")
204204
include(TrimVerifier, "verifytrim.jl")
205205
end
206-
end
207-
if !isdefined(Base, :end_base_include)
208-
# During bootstrap, skip including this file and defer it to base/show.jl to include later
209-
else
210-
# When this module is loaded as the standard library, include this file as usual
211-
load_irshow!()
206+
function verify_typeinf_trim(io::IO, codeinfos::Vector{Any}, onlywarn::Bool)
207+
# stub implementation
208+
msg = "--trim verifier not defined"
209+
onlywarn ? println(io, msg) : error(msg)
210+
end
211+
# During bootstrap, skip including these files and defer to base/show.jl to include it later
212212
end
213213

214214
end # baremodule Compiler

0 commit comments

Comments
 (0)