Skip to content

Commit

Permalink
Whitespace, fix copy in BoundsError contstructor
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Atol committed Oct 25, 2021
1 parent e5e9e90 commit a22d32a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
13 changes: 10 additions & 3 deletions base/boot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,19 @@ struct BoundsError <: Exception
a::Any
i::Any
BoundsError() = new()
# For now, copy to avoid escaping a
# For now, always* copy to avoid escaping a
# Eventually, we want to figure out if the copy is needed to save the performance of copying

# * to avoid throwing a MethodError and breaking many test suites, first check if copy is defined for a

#BoundsError(@nospecialize(a)) = (@_noinline_meta; new(a))
BoundsError(@nospecialize(a)) = (@_noinline_meta; new(Array(a)))
BoundsError(@nospecialize(a)) = Main.Base.hasmethod(Main.Base.copy, Tuple{typeof(a)}) ?
(@_noinline_meta; new(Main.Base.copy(a))) :
(@_noinline_meta; new(a))
#BoundsError(@nospecialize(a), i) = (@_noinline_meta; new(a, i))
BoundsError(@nospecialize(a), i) = (@_noinline_meta; new(Array(a), i))
BoundsError(@nospecialize(a), i) = Main.Base.hasmethod(Main.Base.copy, Tuple{typeof(a)}) ?
(@_noinline_meta; new(Main.Base.copy(a), i)) :
(@_noinline_meta; new(a, i))
end

struct DivideError <: Exception end
Expand Down
4 changes: 2 additions & 2 deletions base/compiler/ssair/passes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,7 @@ end
function memory_opt!(ir::IRCode)
compact = IncrementalCompact(ir, false)
uses = IdDict{Int, Vector{Int}}()
relevant = IdSet{Int}() # allocations and their sizes
relevant = IdSet{Int}() # allocations
revisit = Int[] # potential targets for a mutating_arrayfreeze drop-in

function mark_escape(@nospecialize val)
Expand Down Expand Up @@ -1450,7 +1450,7 @@ function memory_opt!(ir::IRCode)
# print(id, " ")
# end
# println(" ")
# print("Revisit: ")
# print("Revisit: ")
# Main.Base.show(revisit)
# println()
(id in relevant) || continue
Expand Down
4 changes: 2 additions & 2 deletions test/compiler/immutablearray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ end

function test_allocate5()
a = [1,2,3]
try
try
getindex(a, 4)
catch end
catch end
Core.ImmutableArray(a)
end

Expand Down

0 comments on commit a22d32a

Please sign in to comment.