Skip to content

Commit 8044dba

Browse files
authored
Merge branch 'master' into Base_strings_StringIndexError_nospecialize
2 parents 10ca4f6 + c4eeabf commit 8044dba

File tree

36 files changed

+602
-411
lines changed

36 files changed

+602
-411
lines changed

Compiler/src/Compiler.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +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,
53-
BINDING_FLAG_DEPWARN,
52+
PARTITION_KIND_GLOBAL, PARTITION_KIND_UNDEF_CONST, PARTITION_KIND_BACKDATED_CONST, PARTITION_KIND_DECLARED,
53+
PARTITION_FLAG_DEPWARN,
5454
Base, BitVector, Bottom, Callable, DataTypeFieldDesc,
5555
EffectsOverride, Filter, Generator, IteratorSize, JLOptions, NUM_EFFECTS_OVERRIDES,
5656
OneTo, Ordering, RefValue, SizeUnknown, _NAMEDTUPLE_NAME,

Compiler/src/abstractinterpretation.jl

Lines changed: 147 additions & 82 deletions
Large diffs are not rendered by default.

Compiler/src/cicache.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ function intersect(a::WorldRange, b::WorldRange)
4040
return ret
4141
end
4242

43+
function union(a::WorldRange, b::WorldRange)
44+
if b.min_world < a.min_world
45+
(b, a) = (a, b)
46+
end
47+
@assert a.max_world >= b.min_world - 1
48+
return WorldRange(a.min_world, b.max_world)
49+
end
50+
4351
"""
4452
struct WorldView
4553

Compiler/src/ssair/verify.jl

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,14 @@ function check_op(ir::IRCode, domtree::DomTree, @nospecialize(op), use_bb::Int,
6262
raise_error()
6363
end
6464
elseif isa(op, GlobalRef)
65-
bpart = lookup_binding_partition(min_world(ir.valid_worlds), op)
66-
while is_some_imported(binding_kind(bpart)) && max_world(ir.valid_worlds) <= bpart.max_world
67-
imported_binding = partition_restriction(bpart)::Core.Binding
68-
bpart = lookup_binding_partition(min_world(ir.valid_worlds), imported_binding)
69-
end
70-
if (!is_defined_const_binding(binding_kind(bpart)) || (bpart.max_world < max_world(ir.valid_worlds))) &&
71-
(op.mod !== Core) && (op.mod !== Base)
72-
# Core and Base are excluded because the frontend uses them for intrinsics, etc.
73-
# TODO: Decide which way to go with these.
74-
@verify_error "Unbound or partitioned GlobalRef not allowed in value position"
75-
raise_error()
65+
if op.mod !== Core && op.mod !== Base
66+
(valid_worlds, alldef) = scan_leaf_partitions(nothing, op, WorldWithRange(min_world(ir.valid_worlds), ir.valid_worlds)) do _, _, bpart
67+
is_defined_const_binding(binding_kind(bpart))
68+
end
69+
if !alldef || max_world(valid_worlds) < max_world(ir.valid_worlds) || min_world(valid_worlds) > min_world(ir.valid_worlds)
70+
@verify_error "Unbound or partitioned GlobalRef not allowed in value position"
71+
raise_error()
72+
end
7673
end
7774
elseif isa(op, Expr)
7875
# Only Expr(:boundscheck) is allowed in value position

Compiler/src/stmtinfo.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,9 +490,7 @@ perform such accesses.
490490
"""
491491
struct GlobalAccessInfo <: CallInfo
492492
b::Core.Binding
493-
bpart::Core.BindingPartition
494493
end
495-
GlobalAccessInfo(::Core.Binding, ::Nothing) = NoCallInfo()
496494
function add_edges_impl(edges::Vector{Any}, info::GlobalAccessInfo)
497495
push!(edges, info.b)
498496
end

Compiler/test/effects.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,17 @@ let effects = Base.infer_effects(setglobal!_nothrow_undefinedyet2)
400400
end
401401
@test_throws TypeError setglobal!_nothrow_undefinedyet2()
402402

403+
module ExportMutableGlobal
404+
global mutable_global_for_setglobal_test::Int = 0
405+
export mutable_global_for_setglobal_test
406+
end
407+
using .ExportMutableGlobal: mutable_global_for_setglobal_test
408+
f_assign_imported() = global mutable_global_for_setglobal_test = 42
409+
let effects = Base.infer_effects(f_assign_imported)
410+
@test !Compiler.is_nothrow(effects)
411+
end
412+
@test_throws ErrorException f_assign_imported()
413+
403414
# Nothrow for setfield!
404415
mutable struct SetfieldNothrow
405416
x::Int

base/Base.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ include(strcat(BUILDROOT, "version_git.jl")) # include($BUILDROOT/base/version_g
2121

2222
# Initialize DL_LOAD_PATH as early as possible. We are defining things here in
2323
# a slightly more verbose fashion than usual, because we're running so early.
24-
const DL_LOAD_PATH = String[]
2524
let os = ccall(:jl_get_UNAME, Any, ())
2625
if os === :Darwin || os === :Apple
2726
if Base.DARWIN_FRAMEWORK

base/Base_compiler.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ end
334334

335335
BUILDROOT::String = ""
336336
DATAROOT::String = ""
337+
const DL_LOAD_PATH = String[]
337338

338339
baremodule BuildSettings end
339340

base/anyall.jl

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,20 @@ for ItrT = (Tuple,Any)
132132
end
133133
end
134134

135+
# When the function is side effect-free, we may avoid short-circuiting to help
136+
# vectorize the loop.
137+
function _any(::typeof(identity), itr::Tuple{Vararg{Bool}}, ::Colon)
138+
@_terminates_locally_meta
139+
r = false
140+
for i in eachindex(itr)
141+
# Avoid bounds checking to help vectorization. Use `getfield` directly,
142+
# instead of `@inbounds itr[i]`, for better effects.
143+
v = getfield(itr, i, false)
144+
r |= v
145+
end
146+
r
147+
end
148+
135149
# Specialized versions of any(f, ::Tuple)
136150
# We fall back to the for loop implementation all elements have the same type or
137151
# if the tuple is too large.
@@ -205,6 +219,20 @@ for ItrT = (Tuple,Any)
205219
end
206220
end
207221

222+
# When the function is side effect-free, we may avoid short-circuiting to help
223+
# vectorize the loop.
224+
function _all(::typeof(identity), itr::Tuple{Vararg{Bool}}, ::Colon)
225+
@_terminates_locally_meta
226+
r = true
227+
for i in eachindex(itr)
228+
# Avoid bounds checking to help vectorization. Use `getfield` directly,
229+
# instead of `@inbounds itr[i]`, for better effects.
230+
v = getfield(itr, i, false)
231+
r &= v
232+
end
233+
r
234+
end
235+
208236
# Specialized versions of all(f, ::Tuple),
209237
# This is similar to any(f, ::Tuple) defined above.
210238
function all(f, itr::Tuple)
@@ -227,5 +255,3 @@ end
227255
return _all_tuple(f, anymissing, rest...)
228256
end
229257
@inline _all_tuple(f, anymissing) = anymissing ? missing : true
230-
231-
all(::Tuple{Missing}) = missing

base/invalidation.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ function invalidate_code_for_globalref!(b::Core.Binding, invalidated_bpart::Core
140140
end
141141
end
142142
end
143-
if (invalidated_bpart.kind & BINDING_FLAG_EXPORTED != 0) || (new_bpart !== nothing && (new_bpart.kind & BINDING_FLAG_EXPORTED != 0))
143+
if (invalidated_bpart.kind & PARTITION_FLAG_EXPORTED != 0) || (new_bpart !== nothing && (new_bpart.kind & PARTITION_FLAG_EXPORTED != 0))
144144
# This binding was exported - we need to check all modules that `using` us to see if they
145145
# have a binding that is affected by this change.
146146
usings_backedges = ccall(:jl_get_module_usings_backedges, Any, (Any,), gr.mod)
@@ -151,7 +151,7 @@ function invalidate_code_for_globalref!(b::Core.Binding, invalidated_bpart::Core
151151
isdefined(user_binding, :partitions) || continue
152152
latest_bpart = user_binding.partitions
153153
latest_bpart.max_world == typemax(UInt) || continue
154-
binding_kind(latest_bpart) in (BINDING_KIND_IMPLICIT, BINDING_KIND_FAILED, BINDING_KIND_GUARD) || continue
154+
binding_kind(latest_bpart) in (PARTITION_KIND_IMPLICIT, PARTITION_KIND_FAILED, PARTITION_KIND_GUARD) || continue
155155
@atomic :release latest_bpart.max_world = new_max_world
156156
invalidate_code_for_globalref!(convert(Core.Binding, user_binding), latest_bpart, nothing, new_max_world)
157157
end

0 commit comments

Comments
 (0)