Skip to content

Commit a22d32a

Browse files
author
Ian Atol
committed
Whitespace, fix copy in BoundsError contstructor
1 parent e5e9e90 commit a22d32a

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

base/boot.jl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,12 +279,19 @@ struct BoundsError <: Exception
279279
a::Any
280280
i::Any
281281
BoundsError() = new()
282-
# For now, copy to avoid escaping a
282+
# For now, always* copy to avoid escaping a
283283
# Eventually, we want to figure out if the copy is needed to save the performance of copying
284+
285+
# * to avoid throwing a MethodError and breaking many test suites, first check if copy is defined for a
286+
284287
#BoundsError(@nospecialize(a)) = (@_noinline_meta; new(a))
285-
BoundsError(@nospecialize(a)) = (@_noinline_meta; new(Array(a)))
288+
BoundsError(@nospecialize(a)) = Main.Base.hasmethod(Main.Base.copy, Tuple{typeof(a)}) ?
289+
(@_noinline_meta; new(Main.Base.copy(a))) :
290+
(@_noinline_meta; new(a))
286291
#BoundsError(@nospecialize(a), i) = (@_noinline_meta; new(a, i))
287-
BoundsError(@nospecialize(a), i) = (@_noinline_meta; new(Array(a), i))
292+
BoundsError(@nospecialize(a), i) = Main.Base.hasmethod(Main.Base.copy, Tuple{typeof(a)}) ?
293+
(@_noinline_meta; new(Main.Base.copy(a), i)) :
294+
(@_noinline_meta; new(a, i))
288295
end
289296

290297
struct DivideError <: Exception end

base/compiler/ssair/passes.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,7 +1284,7 @@ end
12841284
function memory_opt!(ir::IRCode)
12851285
compact = IncrementalCompact(ir, false)
12861286
uses = IdDict{Int, Vector{Int}}()
1287-
relevant = IdSet{Int}() # allocations and their sizes
1287+
relevant = IdSet{Int}() # allocations
12881288
revisit = Int[] # potential targets for a mutating_arrayfreeze drop-in
12891289

12901290
function mark_escape(@nospecialize val)
@@ -1450,7 +1450,7 @@ function memory_opt!(ir::IRCode)
14501450
# print(id, " ")
14511451
# end
14521452
# println(" ")
1453-
# print("Revisit: ")
1453+
# print("Revisit: ")
14541454
# Main.Base.show(revisit)
14551455
# println()
14561456
(id in relevant) || continue

test/compiler/immutablearray.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ end
3535

3636
function test_allocate5()
3737
a = [1,2,3]
38-
try
38+
try
3939
getindex(a, 4)
40-
catch end
40+
catch end
4141
Core.ImmutableArray(a)
4242
end
4343

0 commit comments

Comments
 (0)