File tree Expand file tree Collapse file tree 3 files changed +14
-7
lines changed Expand file tree Collapse file tree 3 files changed +14
-7
lines changed Original file line number Diff line number Diff 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))
288295end
289296
290297struct DivideError <: Exception end
Original file line number Diff line number Diff line change @@ -1284,7 +1284,7 @@ end
12841284function 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
Original file line number Diff line number Diff line change 3535
3636function 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)
4242end
4343
You can’t perform that action at this time.
0 commit comments