Skip to content

Commit 1efd53f

Browse files
authored
Merge branch 'master' into test_for_no_invalidations
2 parents 4bbc378 + 8e03cb1 commit 1efd53f

File tree

9 files changed

+66
-36
lines changed

9 files changed

+66
-36
lines changed

Compiler/src/abstractinterpretation.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2565,7 +2565,6 @@ function abstract_eval_setglobalonce!(interp::AbstractInterpreter, sv::AbsIntSta
25652565
end
25662566
end
25672567

2568-
25692568
function abstract_eval_replaceglobal!(interp::AbstractInterpreter, sv::AbsIntState, saw_latestworld::Bool, argtypes::Vector{Any})
25702569
if length(argtypes) in (5, 6, 7)
25712570
(M, s, x, v) = argtypes[2], argtypes[3], argtypes[4], argtypes[5]
@@ -3671,7 +3670,7 @@ end
36713670

36723671
function global_assignment_rt_exct(interp::AbstractInterpreter, sv::AbsIntState, saw_latestworld::Bool, g::GlobalRef, @nospecialize(newty))
36733672
if saw_latestworld
3674-
return Pair{Any,Any}(newty, Union{ErrorException, TypeError})
3673+
return Pair{Any,Any}(newty, ErrorException)
36753674
end
36763675
(valid_worlds, ret) = scan_partitions((interp, _, partition)->global_assignment_binding_rt_exct(interp, partition, newty), interp, g, sv.world)
36773676
update_valid_age!(sv, valid_worlds)
@@ -3688,10 +3687,10 @@ function global_assignment_binding_rt_exct(interp::AbstractInterpreter, partitio
36883687
ty = kind == PARTITION_KIND_DECLARED ? Any : partition_restriction(partition)
36893688
wnewty = widenconst(newty)
36903689
if !hasintersect(wnewty, ty)
3691-
return Pair{Any,Any}(Bottom, TypeError)
3690+
return Pair{Any,Any}(Bottom, ErrorException)
36923691
elseif !(wnewty <: ty)
36933692
retty = tmeet(typeinf_lattice(interp), newty, ty)
3694-
return Pair{Any,Any}(retty, TypeError)
3693+
return Pair{Any,Any}(retty, ErrorException)
36953694
end
36963695
return Pair{Any,Any}(newty, Bottom)
36973696
end

Compiler/src/ssair/irinterp.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function concrete_eval_invoke(interp::AbstractInterpreter, ci::CodeInstance, arg
3232
end
3333

3434
function abstract_eval_invoke_inst(interp::AbstractInterpreter, inst::Instruction, irsv::IRInterpretationState)
35-
stmt = inst[:stmt]
35+
stmt = inst[:stmt]::Expr
3636
ci = stmt.args[1]
3737
if ci isa MethodInstance
3838
world = frame_world(irsv)

Compiler/src/ssair/passes.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ function find_def_for_use(
183183
end
184184

185185
function collect_leaves(compact::IncrementalCompact, @nospecialize(val), @nospecialize(typeconstraint), 𝕃ₒ::AbstractLattice,
186-
predecessors = ((@nospecialize(def), compact::IncrementalCompact) -> isa(def, PhiNode) ? def.values : nothing))
186+
predecessors::Pre = ((@nospecialize(def), compact::IncrementalCompact) -> isa(def, PhiNode) ? def.values : nothing)) where {Pre}
187187
if isa(val, Union{OldSSAValue, SSAValue})
188188
val, typeconstraint = simple_walk_constraint(compact, val, typeconstraint)
189189
end
@@ -271,7 +271,7 @@ Starting at `val` walk use-def chains to get all the leaves feeding into this `v
271271
`predecessors(def, compact)` is a callback which should return the set of possible
272272
predecessors for a "phi-like" node (PhiNode or Core.ifelse) or `nothing` otherwise.
273273
"""
274-
function walk_to_defs(compact::IncrementalCompact, @nospecialize(defssa), @nospecialize(typeconstraint), predecessors, 𝕃ₒ::AbstractLattice)
274+
function walk_to_defs(compact::IncrementalCompact, @nospecialize(defssa), @nospecialize(typeconstraint), predecessors::Pre, 𝕃ₒ::AbstractLattice) where {Pre}
275275
visited_philikes = AnySSAValue[]
276276
isa(defssa, AnySSAValue) || return Any[defssa], visited_philikes
277277
def = compact[defssa][:stmt]

Compiler/test/inference.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6408,4 +6408,9 @@ let src = code_typed1((Base.RefValue{String}, String)) do x, val
64086408
@test isa(retval, Core.SSAValue)
64096409
end
64106410

6411+
global invalid_setglobal!_exct_modeling::Int
6412+
@test Base.infer_exception_type((Float64,)) do x
6413+
setglobal!(@__MODULE__, :invalid_setglobal!_exct_modeling, x)
6414+
end == ErrorException
6415+
64116416
end # module inference

base/task.jl

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,16 @@ function throwto(t::Task, @nospecialize exc)
11451145
return try_yieldto(identity)
11461146
end
11471147

1148+
@inline function wait_forever()
1149+
while true
1150+
wait()
1151+
end
1152+
end
1153+
1154+
const get_sched_task = OncePerThread{Task}() do
1155+
@task wait_forever()
1156+
end
1157+
11481158
function ensure_rescheduled(othertask::Task)
11491159
ct = current_task()
11501160
W = workqueue_for(Threads.threadid())
@@ -1181,25 +1191,39 @@ end
11811191

11821192
checktaskempty = Partr.multiq_check_empty
11831193

1184-
@noinline function poptask(W::StickyWorkqueue)
1185-
task = trypoptask(W)
1186-
if !(task isa Task)
1187-
task = ccall(:jl_task_get_next, Ref{Task}, (Any, Any, Any), trypoptask, W, checktaskempty)
1188-
end
1189-
set_next_task(task)
1190-
nothing
1191-
end
1192-
11931194
function wait()
11941195
ct = current_task()
11951196
# [task] user_time -yield-or-done-> wait_time
11961197
record_running_time!(ct)
1198+
# let GC run
11971199
GC.safepoint()
1198-
W = workqueue_for(Threads.threadid())
1199-
poptask(W)
1200-
result = try_yieldto(ensure_rescheduled)
1200+
# check for libuv events
12011201
process_events()
1202-
# return when we come out of the queue
1202+
1203+
# get the next task to run
1204+
result = nothing
1205+
have_result = false
1206+
W = workqueue_for(Threads.threadid())
1207+
task = trypoptask(W)
1208+
if !(task isa Task)
1209+
# No tasks to run; switch to the scheduler task to run the
1210+
# thread sleep logic.
1211+
sched_task = get_sched_task()
1212+
if ct !== sched_task
1213+
result = yieldto(sched_task)
1214+
have_result = true
1215+
else
1216+
task = ccall(:jl_task_get_next, Ref{Task}, (Any, Any, Any),
1217+
trypoptask, W, checktaskempty)
1218+
end
1219+
end
1220+
# We may have already switched tasks (via the scheduler task), so
1221+
# only switch if we haven't.
1222+
if !have_result
1223+
@assert task isa Task
1224+
set_next_task(task)
1225+
result = try_yieldto(ensure_rescheduled)
1226+
end
12031227
return result
12041228
end
12051229

src/gc-stock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,7 @@ static void gc_sweep_page(gc_page_profiler_serializer_t *s, jl_gc_pool_t *p, jl_
948948

949949
done:
950950
if (re_use_page) {
951+
gc_update_page_fragmentation_data(pg);
951952
push_lf_back(allocd, pg);
952953
}
953954
else {
@@ -956,7 +957,6 @@ static void gc_sweep_page(gc_page_profiler_serializer_t *s, jl_gc_pool_t *p, jl_
956957
push_lf_back(&global_page_pool_lazily_freed, pg);
957958
}
958959
gc_page_profile_write_to_file(s);
959-
gc_update_page_fragmentation_data(pg);
960960
gc_time_count_page(freedall, pg_skpd);
961961
jl_ptls_t ptls = jl_current_task->ptls;
962962
// Note that we aggregate the `pool_live_bytes` over all threads before returning this

stdlib/Random/src/RNGs.jl

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,21 +147,26 @@ function show(io::IO, rng::MersenneTwister)
147147
end
148148
print(io, MersenneTwister, "(", repr(rng.seed), ", (")
149149
# state
150-
adv = Integer[rng.adv_jump, rng.adv]
150+
sep = ", "
151+
show(io, rng.adv_jump)
152+
print(io, sep)
153+
show(io, rng.adv)
151154
if rng.adv_vals != -1 || rng.adv_ints != -1
152-
if rng.adv_vals == -1
153-
@assert rng.idxF == MT_CACHE_F
154-
push!(adv, 0, 0) # "(0, 0)" is nicer on the eyes than (-1, 1002)
155-
else
156-
push!(adv, rng.adv_vals, rng.idxF)
157-
end
155+
# "(0, 0)" is nicer on the eyes than (-1, 1002)
156+
s = rng.adv_vals != -1
157+
print(io, sep)
158+
show(io, s ? rng.adv_vals : zero(rng.adv_vals))
159+
print(io, sep)
160+
show(io, s ? rng.idxF : zero(rng.idxF))
158161
end
159162
if rng.adv_ints != -1
160163
idxI = (length(rng.ints)*16 - rng.idxI) / 8 # 8 represents one Int64
161164
idxI = Int(idxI) # idxI should always be an integer when using public APIs
162-
push!(adv, rng.adv_ints, idxI)
165+
print(io, sep)
166+
show(io, rng.adv_ints)
167+
print(io, sep)
168+
show(io, idxI)
163169
end
164-
join(io, adv, ", ")
165170
print(io, "))")
166171
end
167172

stdlib/Sockets/test/runtests.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -547,14 +547,12 @@ end
547547
fetch(r)
548548
end
549549

550-
let addr = Sockets.InetAddr(ip"127.0.0.1", 4444)
551-
srv = listen(addr)
550+
let addr = Sockets.InetAddr(ip"192.0.2.5", 4444)
552551
s = Sockets.TCPSocket()
553552
Sockets.connect!(s, addr)
554553
r = @async close(s)
555554
@test_throws Base._UVError("connect", Base.UV_ECANCELED) Sockets.wait_connected(s)
556555
fetch(r)
557-
close(srv)
558556
end
559557
end
560558

test/channels.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -463,15 +463,14 @@ end
463463
cb = first(async.cond.waitq)
464464
@test isopen(async)
465465
ccall(:uv_async_send, Cvoid, (Ptr{Cvoid},), async)
466-
ccall(:uv_async_send, Cvoid, (Ptr{Cvoid},), async)
467-
@test isempty(Base.Workqueue)
468466
Base.process_events() # schedule event
469467
Sys.iswindows() && Base.process_events() # schedule event (windows?)
470-
@test length(Base.Workqueue) == 1
471468
ccall(:uv_async_send, Cvoid, (Ptr{Cvoid},), async)
472469
@test tc[] == 0
473470
yield() # consume event
474471
@test tc[] == 1
472+
ccall(:uv_async_send, Cvoid, (Ptr{Cvoid},), async)
473+
Base.process_events()
475474
Sys.iswindows() && Base.process_events() # schedule event (windows?)
476475
yield() # consume event
477476
@test tc[] == 2

0 commit comments

Comments
 (0)