Skip to content

Commit b655b2c

Browse files
authored
Merge pull request #44675 from JuliaLang/backports-release-1.8
More backports for julia 1.8-beta2
2 parents e191c6e + a00e1f1 commit b655b2c

34 files changed

+595
-511
lines changed

Make.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,8 +652,8 @@ ifeq ($(OS),FreeBSD)
652652
ifneq (,$(findstring gfortran,$(FC)))
653653

654654
# First let's figure out what version of GCC we're dealing with
655-
_GCCMAJOR := $(shell $(FC) -dumpversion | cut -d'.' -f1)
656-
_GCCMINOR := $(shell $(FC) -dumpversion | cut -d'.' -f2)
655+
_GCCMAJOR := $(shell $(FC) -dumpversion 2>/dev/null | cut -d'.' -f1)
656+
_GCCMINOR := $(shell $(FC) -dumpversion 2>/dev/null | cut -d'.' -f2)
657657

658658
# The ports system uses major and minor for GCC < 5 (e.g. gcc49 for GCC 4.9), otherwise major only
659659
ifeq ($(_GCCMAJOR),4)

base/boot.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,10 +421,10 @@ eval(Core, quote
421421
function CodeInstance(
422422
mi::MethodInstance, @nospecialize(rettype), @nospecialize(inferred_const),
423423
@nospecialize(inferred), const_flags::Int32, min_world::UInt, max_world::UInt,
424-
ipo_effects::UInt8, effects::UInt8, @nospecialize(argescapes#=::Union{Nothing,Vector{ArgEscapeInfo}}=#),
424+
ipo_effects::UInt32, effects::UInt32, @nospecialize(argescapes#=::Union{Nothing,Vector{ArgEscapeInfo}}=#),
425425
relocatability::UInt8)
426426
return ccall(:jl_new_codeinst, Ref{CodeInstance},
427-
(Any, Any, Any, Any, Int32, UInt, UInt, UInt8, UInt8, Any, UInt8),
427+
(Any, Any, Any, Any, Int32, UInt, UInt, UInt32, UInt32, Any, UInt8),
428428
mi, rettype, inferred_const, inferred, const_flags, min_world, max_world,
429429
ipo_effects, effects, argescapes,
430430
relocatability)

base/broadcast.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -973,14 +973,14 @@ end
973973
destc = dest.chunks
974974
cind = 1
975975
bc′ = preprocess(dest, bc)
976-
for P in Iterators.partition(eachindex(bc′), bitcache_size)
976+
@inbounds for P in Iterators.partition(eachindex(bc′), bitcache_size)
977977
ind = 1
978978
@simd for I in P
979-
@inbounds tmp[ind] = bc′[I]
979+
tmp[ind] = bc′[I]
980980
ind += 1
981981
end
982982
@simd for i in ind:bitcache_size
983-
@inbounds tmp[i] = false
983+
tmp[i] = false
984984
end
985985
dumpbitcache(destc, cind, tmp)
986986
cind += bitcache_chunks

base/compiler/compiler.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ include("operators.jl")
5858
include("pointer.jl")
5959
include("refvalue.jl")
6060

61+
# the same constructor as defined in float.jl, but with a different name to avoid redefinition
62+
_Bool(x::Real) = x==0 ? false : x==1 ? true : throw(InexactError(:Bool, Bool, x))
63+
6164
# checked arithmetic
6265
const checked_add = +
6366
const checked_sub = -

base/compiler/optimize.jl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,12 +558,21 @@ function convert_to_ircode(ci::CodeInfo, sv::OptimizationState)
558558
idx = 1
559559
oldidx = 1
560560
changemap = fill(0, length(code))
561-
labelmap = coverage ? fill(0, length(code)) : changemap
562561
prevloc = zero(eltype(ci.codelocs))
563562
stmtinfo = sv.stmt_info
564563
codelocs = ci.codelocs
565564
ssavaluetypes = ci.ssavaluetypes::Vector{Any}
566565
ssaflags = ci.ssaflags
566+
if !coverage && JLOptions().code_coverage == 3 # path-specific coverage mode
567+
for line in ci.linetable
568+
if is_file_tracked(line.file)
569+
# if any line falls in a tracked file enable coverage for all
570+
coverage = true
571+
break
572+
end
573+
end
574+
end
575+
labelmap = coverage ? fill(0, length(code)) : changemap
567576
while idx <= length(code)
568577
codeloc = codelocs[idx]
569578
if coverage && codeloc != prevloc && codeloc != 0

base/compiler/ssair/inlining.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,10 +319,15 @@ function ir_inline_item!(compact::IncrementalCompact, idx::Int, argexprs::Vector
319319
inlined_at = Int(compact.result[idx][:line])
320320
topline::Int32 = linetable_offset + Int32(1)
321321
coverage = coverage_enabled(def.module)
322+
coverage_by_path = JLOptions().code_coverage == 3
322323
push!(linetable, LineInfoNode(def.module, def.name, def.file, Int(def.line), inlined_at))
323324
oldlinetable = spec.ir.linetable
324325
for oldline in 1:length(oldlinetable)
325326
entry = oldlinetable[oldline]
327+
if !coverage && coverage_by_path && is_file_tracked(entry.file)
328+
# include topline coverage entry if in path-specific coverage mode, and any file falls under path
329+
coverage = true
330+
end
326331
newentry = LineInfoNode(entry.module, entry.method, entry.file, entry.line,
327332
(entry.inlined_at > 0 ? entry.inlined_at + linetable_offset + (oldline == 1) : inlined_at))
328333
if oldline == 1

base/compiler/typeinfer.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ function finish(me::InferenceState, interp::AbstractInterpreter)
512512
ipo_effects = Effects(ipo_effects; terminates=ALWAYS_TRUE)
513513
end
514514
end
515-
me.result.ipo_effects = ipo_effects
515+
me.ipo_effects = me.result.ipo_effects = ipo_effects
516516
validate_code_in_debug_mode(me.linfo, me.src, "inferred")
517517
nothing
518518
end

base/compiler/typelattice.jl

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -467,45 +467,3 @@ function stupdate1!(state::VarTable, change::StateUpdate)
467467
end
468468
return false
469469
end
470-
471-
# compute typeintersect over the extended inference lattice,
472-
# as precisely as we can,
473-
# where v is in the extended lattice, and t is a Type.
474-
function tmeet(@nospecialize(v), @nospecialize(t))
475-
if isa(v, Const)
476-
if !has_free_typevars(t) && !isa(v.val, t)
477-
return Bottom
478-
end
479-
return v
480-
elseif isa(v, PartialStruct)
481-
has_free_typevars(t) && return v
482-
widev = widenconst(v)
483-
if widev <: t
484-
return v
485-
end
486-
ti = typeintersect(widev, t)
487-
valid_as_lattice(ti) || return Bottom
488-
@assert widev <: Tuple
489-
new_fields = Vector{Any}(undef, length(v.fields))
490-
for i = 1:length(new_fields)
491-
vfi = v.fields[i]
492-
if isvarargtype(vfi)
493-
new_fields[i] = vfi
494-
else
495-
new_fields[i] = tmeet(vfi, widenconst(getfield_tfunc(t, Const(i))))
496-
if new_fields[i] === Bottom
497-
return Bottom
498-
end
499-
end
500-
end
501-
return tuple_tfunc(new_fields)
502-
elseif isa(v, Conditional)
503-
if !(Bool <: t)
504-
return Bottom
505-
end
506-
return v
507-
end
508-
ti = typeintersect(widenconst(v), t)
509-
valid_as_lattice(ti) || return Bottom
510-
return ti
511-
end

base/compiler/types.jl

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,31 +78,33 @@ function Effects(e::Effects = EFFECTS_UNKNOWN;
7878
end
7979

8080
is_total_or_error(effects::Effects) =
81-
effects.consistent === ALWAYS_TRUE && effects.effect_free === ALWAYS_TRUE &&
81+
effects.consistent === ALWAYS_TRUE &&
82+
effects.effect_free === ALWAYS_TRUE &&
8283
effects.terminates === ALWAYS_TRUE
8384

8485
is_total(effects::Effects) =
85-
is_total_or_error(effects) && effects.nothrow === ALWAYS_TRUE
86+
is_total_or_error(effects) &&
87+
effects.nothrow === ALWAYS_TRUE
8688

8789
is_removable_if_unused(effects::Effects) =
8890
effects.effect_free === ALWAYS_TRUE &&
8991
effects.terminates === ALWAYS_TRUE &&
9092
effects.nothrow === ALWAYS_TRUE
9193

9294
function encode_effects(e::Effects)
93-
return (e.consistent.state << 1) |
94-
(e.effect_free.state << 3) |
95-
(e.nothrow.state << 5) |
96-
(e.terminates.state << 7) |
97-
(e.overlayed)
95+
return (e.consistent.state << 0) |
96+
(e.effect_free.state << 2) |
97+
(e.nothrow.state << 4) |
98+
(e.terminates.state << 6) |
99+
(UInt32(e.overlayed) << 8)
98100
end
99-
function decode_effects(e::UInt8)
101+
function decode_effects(e::UInt32)
100102
return Effects(
101-
TriState((e >> 1) & 0x03),
102-
TriState((e >> 3) & 0x03),
103-
TriState((e >> 5) & 0x03),
104-
TriState((e >> 7) & 0x03),
105-
e & 0x01 0x00,
103+
TriState((e >> 0) & 0x03),
104+
TriState((e >> 2) & 0x03),
105+
TriState((e >> 4) & 0x03),
106+
TriState((e >> 6) & 0x03),
107+
_Bool( (e >> 8) & 0x01),
106108
false)
107109
end
108110

base/compiler/utilities.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,12 +359,12 @@ inlining_enabled() = (JLOptions().can_inline == 1)
359359
function coverage_enabled(m::Module)
360360
ccall(:jl_generating_output, Cint, ()) == 0 || return false # don't alter caches
361361
cov = JLOptions().code_coverage
362-
if cov == 1
362+
if cov == 1 # user
363363
m = moduleroot(m)
364364
m === Core && return false
365365
isdefined(Main, :Base) && m === Main.Base && return false
366366
return true
367-
elseif cov == 2
367+
elseif cov == 2 # all
368368
return true
369369
end
370370
return false

0 commit comments

Comments
 (0)