-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into stacktrace-filters
- Loading branch information
Showing
652 changed files
with
26,705 additions
and
69,374 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
MIT License | ||
|
||
Copyright (c) 2009-2024: Jeff Bezanson, Stefan Karpinski, Viral B. Shah, and other contributors: https://github.com/JuliaLang/julia/contributors | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
end of terms and conditions | ||
|
||
Please see [THIRDPARTY.md](../THIRDPARTY.md) for license information for other software used in this project. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name = "Compiler" | ||
uuid = "807dbc54-b67e-4c79-8afb-eafe4df6f2e1" | ||
version = "0.0.2" | ||
|
||
[compat] | ||
julia = "1.10" | ||
|
||
[extras] | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" | ||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" | ||
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb" | ||
|
||
[targets] | ||
test = ["Test", "InteractiveUtils", "Random", "Libdl"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# This file is machine-generated - editing it directly is not advised | ||
|
||
julia_version = "1.12.0-DEV" | ||
manifest_format = "2.0" | ||
project_hash = "84f495a1bf065c95f732a48af36dd0cd2cefb9d5" | ||
|
||
[[deps.Compiler]] | ||
path = "../.." | ||
uuid = "807dbc54-b67e-4c79-8afb-eafe4df6f2e1" | ||
version = "0.0.2" | ||
|
||
[[deps.CompilerDevTools]] | ||
path = "." | ||
uuid = "92b2d91f-d2bd-4c05-9214-4609ac33433f" | ||
version = "0.0.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
name = "CompilerDevTools" | ||
uuid = "92b2d91f-d2bd-4c05-9214-4609ac33433f" | ||
|
||
[deps] | ||
Compiler = "807dbc54-b67e-4c79-8afb-eafe4df6f2e1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
module CompilerDevTools | ||
|
||
using Compiler | ||
using Core.IR | ||
|
||
struct SplitCacheOwner; end | ||
struct SplitCacheInterp <: Compiler.AbstractInterpreter | ||
world::UInt | ||
inf_params::Compiler.InferenceParams | ||
opt_params::Compiler.OptimizationParams | ||
inf_cache::Vector{Compiler.InferenceResult} | ||
function SplitCacheInterp(; | ||
world::UInt = Base.get_world_counter(), | ||
inf_params::Compiler.InferenceParams = Compiler.InferenceParams(), | ||
opt_params::Compiler.OptimizationParams = Compiler.OptimizationParams(), | ||
inf_cache::Vector{Compiler.InferenceResult} = Compiler.InferenceResult[]) | ||
new(world, inf_params, opt_params, inf_cache) | ||
end | ||
end | ||
|
||
Compiler.InferenceParams(interp::SplitCacheInterp) = interp.inf_params | ||
Compiler.OptimizationParams(interp::SplitCacheInterp) = interp.opt_params | ||
Compiler.get_inference_world(interp::SplitCacheInterp) = interp.world | ||
Compiler.get_inference_cache(interp::SplitCacheInterp) = interp.inf_cache | ||
Compiler.cache_owner(::SplitCacheInterp) = SplitCacheOwner() | ||
|
||
import Core.OptimizedGenerics.CompilerPlugins: typeinf, typeinf_edge | ||
@eval @noinline typeinf(::SplitCacheOwner, mi::MethodInstance, source_mode::UInt8) = | ||
Base.invoke_in_world(which(typeinf, Tuple{SplitCacheOwner, MethodInstance, UInt8}).primary_world, Compiler.typeinf_ext, SplitCacheInterp(; world=Base.tls_world_age()), mi, source_mode) | ||
|
||
@eval @noinline function typeinf_edge(::SplitCacheOwner, mi::MethodInstance, parent_frame::Compiler.InferenceState, world::UInt, source_mode::UInt8) | ||
# TODO: This isn't quite right, we're just sketching things for now | ||
interp = SplitCacheInterp(; world) | ||
Compiler.typeinf_edge(interp, mi.def, mi.specTypes, Core.svec(), parent_frame, false, false) | ||
end | ||
|
||
# TODO: This needs special compiler support to properly case split for multiple | ||
# method matches, etc. | ||
@noinline function mi_for_tt(tt, world=Base.tls_world_age()) | ||
interp = SplitCacheInterp(; world) | ||
match, _ = Compiler.findsup(tt, Compiler.method_table(interp)) | ||
Base.specialize_method(match) | ||
end | ||
|
||
function with_new_compiler(f, args...) | ||
tt = Base.signature_type(f, typeof(args)) | ||
world = Base.tls_world_age() | ||
new_compiler_ci = Core.OptimizedGenerics.CompilerPlugins.typeinf( | ||
SplitCacheOwner(), mi_for_tt(tt), Compiler.SOURCE_MODE_ABI | ||
) | ||
invoke(f, new_compiler_ci, args...) | ||
end | ||
|
||
export with_new_compiler | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,208 @@ | ||
# This file is a part of Julia. License is MIT: https://julialang.org/license | ||
|
||
if isdefined(Base, :end_base_include) && !isdefined(Base, :Compiler) | ||
|
||
# Define a dummy `Compiler` module to make it installable even on Julia versions where | ||
# Compiler.jl is not available as a standard library. | ||
@eval module Compiler | ||
function __init__() | ||
println(""" | ||
The `Compiler` standard library is not available for this version of Julia. | ||
Use Julia version `v"1.12.0-DEV.1581"` or later. | ||
""") | ||
end | ||
end | ||
|
||
# When generating an incremental precompile file, we first check whether we | ||
# already have a copy of this *exact* code in the system image. If so, we | ||
# simply generates a pkgimage that has the dependency edges we recorded in | ||
# the system image and simply returns that copy of the compiler. If not, | ||
# we proceed to load/precompile this as an ordinary package. | ||
elseif (isdefined(Base, :generating_output) && Base.generating_output(true) && | ||
Base.samefile(joinpath(Sys.BINDIR, Base.DATAROOTDIR, Base._compiler_require_dependencies[1][2]), @eval @__FILE__) && | ||
!Base.any_includes_stale( | ||
map(Base.compiler_chi, Base._compiler_require_dependencies), | ||
"sysimg", nothing)) | ||
|
||
Base.prepare_compiler_stub_image!() | ||
append!(Base._require_dependencies, map(Base.expand_compiler_path, Base._compiler_require_dependencies)) | ||
# There isn't much point in precompiling native code - downstream users will | ||
# specialize their own versions of the compiler code and we don't activate | ||
# the compiler by default anyway, so let's save ourselves some disk space. | ||
ccall(:jl_suppress_precompile, Cvoid, (Cint,), 1) | ||
|
||
else | ||
|
||
@eval baremodule Compiler | ||
|
||
# Needs to match UUID defined in Project.toml | ||
ccall(:jl_set_module_uuid, Cvoid, (Any, NTuple{2, UInt64}), Compiler, | ||
(0x807dbc54_b67e_4c79, 0x8afb_eafe4df6f2e1)) | ||
|
||
using Core.Intrinsics, Core.IR | ||
|
||
import Core: print, println, show, write, unsafe_write, | ||
_apply_iterate, svec, apply_type, Builtin, IntrinsicFunction, | ||
MethodInstance, CodeInstance, MethodTable, MethodMatch, PartialOpaque, | ||
TypeofVararg, Core, SimpleVector, donotdelete, compilerbarrier, | ||
memoryref_isassigned, memoryrefnew, memoryrefoffset, memoryrefget, | ||
memoryrefset!, typename | ||
|
||
using Base | ||
using Base: Ordering, vect, EffectsOverride, BitVector, @_gc_preserve_begin, @_gc_preserve_end, RefValue, | ||
@nospecializeinfer, @_foldable_meta, fieldindex, is_function_def, indexed_iterate, isexpr, methods, | ||
get_world_counter, JLOptions, _methods_by_ftype, unwrap_unionall, cconvert, unsafe_convert, | ||
issingletontype, isType, rewrap_unionall, has_free_typevars, isvarargtype, hasgenerator, | ||
IteratorSize, SizeUnknown, _array_for, Bottom, generating_output, diff_names, | ||
ismutationfree, NUM_EFFECTS_OVERRIDES, _NAMEDTUPLE_NAME, datatype_fieldtypes, | ||
argument_datatype, isfieldatomic, unwrapva, iskindtype, _bits_findnext, copy_exprargs, | ||
Generator, Filter, ismutabletypename, isvatuple, datatype_fieldcount, | ||
isconcretedispatch, isdispatchelem, datatype_layoutsize, | ||
datatype_arrayelem, unionlen, isidentityfree, _uniontypes, uniontypes, OneTo, Callable, | ||
DataTypeFieldDesc, datatype_nfields, datatype_pointerfree, midpoint, is_valid_intrinsic_elptr, | ||
allocatedinline, isbitsunion, widen_diagonal, unconstrain_vararg_length, | ||
rename_unionall, may_invoke_generator, is_meta_expr_head, is_meta_expr, quoted, | ||
specialize_method, hasintersect, is_nospecializeinfer, is_nospecialized, | ||
get_nospecializeinfer_sig, tls_world_age, uniontype_layout, kwerr, | ||
moduleroot, is_file_tracked, decode_effects_override, lookup_binding_partition, | ||
is_some_imported, binding_kind, is_some_guard, is_some_const_binding, partition_restriction, | ||
BINDING_KIND_GLOBAL, structdiff | ||
using Base.Order | ||
import Base: getindex, setindex!, length, iterate, push!, isempty, first, convert, ==, | ||
copy, popfirst!, in, haskey, resize!, copy!, append!, last, get!, size, | ||
get, iterate, findall, min_world, max_world, _topmod, isready | ||
|
||
const getproperty = Core.getfield | ||
const setproperty! = Core.setfield! | ||
const swapproperty! = Core.swapfield! | ||
const modifyproperty! = Core.modifyfield! | ||
const replaceproperty! = Core.replacefield! | ||
const _DOCS_ALIASING_WARNING = "" | ||
|
||
ccall(:jl_set_istopmod, Cvoid, (Any, Bool), Compiler, false) | ||
|
||
eval(x) = Core.eval(Compiler, x) | ||
eval(m, x) = Core.eval(m, x) | ||
|
||
function include(x::String) | ||
if !isdefined(Base, :end_base_include) | ||
# During bootstrap, all includes are relative to `base/` | ||
x = Base.strcat(Base.strcat(Base.DATAROOT, "julia/Compiler/src/"), x) | ||
end | ||
Base.include(Compiler, x) | ||
end | ||
|
||
function include(mod::Module, x::String) | ||
if !isdefined(Base, :end_base_include) | ||
x = Base.strcat(Base.strcat(Base.DATAROOT, "julia/Compiler/src/"), x) | ||
end | ||
Base.include(mod, x) | ||
end | ||
|
||
macro _boundscheck() Expr(:boundscheck) end | ||
|
||
function return_type end | ||
function is_return_type(Core.@nospecialize(f)) | ||
f === return_type && return true | ||
if isdefined(Base, :Compiler) && Compiler !== Base.Compiler | ||
# Also model the return_type function of the builtin Compiler the same. | ||
# This isn't completely sound. We don't actually have any idea what the | ||
# base compiler will do at runtime. In the fullness of time, we should | ||
# re-work the semantics to make the cache primary and thus avoid having | ||
# to reason about what the compiler may do at runtime, but we're not | ||
# fully there yet. | ||
return f === Base.Compiler.return_type | ||
end | ||
return false | ||
end | ||
|
||
include("sort.jl") | ||
|
||
# We don't include some.jl, but this definition is still useful. | ||
something(x::Nothing, y...) = something(y...) | ||
something(x::Any, y...) = x | ||
|
||
############ | ||
# compiler # | ||
############ | ||
|
||
baremodule BuildSettings | ||
using Core: ARGS, include | ||
using ..Compiler: >, getindex, length | ||
|
||
global MAX_METHODS::Int = 3 | ||
|
||
if length(ARGS) > 2 && ARGS[2] === "--buildsettings" | ||
include(BuildSettings, ARGS[3]) | ||
end | ||
end | ||
|
||
if !isdefined(Base, :end_base_include) | ||
macro show(ex...) | ||
blk = Expr(:block) | ||
for s in ex | ||
push!(blk.args, :(println(stdout, $(QuoteNode(s)), " = ", | ||
begin local value = $(esc(s)) end))) | ||
end | ||
isempty(ex) || push!(blk.args, :value) | ||
blk | ||
end | ||
else | ||
using Base: @show | ||
end | ||
|
||
include("cicache.jl") | ||
include("methodtable.jl") | ||
include("effects.jl") | ||
include("types.jl") | ||
include("utilities.jl") | ||
include("validation.jl") | ||
|
||
include("ssair/basicblock.jl") | ||
include("ssair/domtree.jl") | ||
include("ssair/ir.jl") | ||
include("ssair/tarjan.jl") | ||
|
||
include("abstractlattice.jl") | ||
include("stmtinfo.jl") | ||
include("inferenceresult.jl") | ||
include("inferencestate.jl") | ||
|
||
include("typeutils.jl") | ||
include("typelimits.jl") | ||
include("typelattice.jl") | ||
include("tfuncs.jl") | ||
|
||
include("abstractinterpretation.jl") | ||
include("typeinfer.jl") | ||
include("optimize.jl") | ||
|
||
include("bootstrap.jl") | ||
include("reflection_interface.jl") | ||
include("opaque_closure.jl") | ||
|
||
macro __SOURCE_FILE__() | ||
__source__.file === nothing && return nothing | ||
return QuoteNode(__source__.file::Symbol) | ||
end | ||
|
||
module IRShow end | ||
function load_irshow!() | ||
if isdefined(Base, :end_base_include) | ||
# This code path is exclusively for Revise, which may want to re-run this | ||
# after bootstrap. | ||
include(IRShow, Base.joinpath(Base.dirname(Base.String(@__SOURCE_FILE__)), "ssair/show.jl")) | ||
else | ||
include(IRShow, "ssair/show.jl") | ||
end | ||
end | ||
if !isdefined(Base, :end_base_include) | ||
# During bootstrap, skip including this file and defer it to base/show.jl to include later | ||
else | ||
# When this module is loaded as the standard library, include this file as usual | ||
load_irshow!() | ||
end | ||
|
||
end # baremodule Compiler | ||
|
||
end # if isdefined(Base, :generating_output) && ... |
Oops, something went wrong.