Skip to content

Commit

Permalink
set default max_methods to 3
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jun 19, 2020
1 parent 96ff7f0 commit baa9b27
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
4 changes: 2 additions & 2 deletions base/compiler/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct OptimizationParams
inline_cost_threshold::Int = 100,
inline_nonleaf_penalty::Int = 1000,
inline_tupleret_bonus::Int = 400,
max_methods::Int = 4,
max_methods::Int = 3,
tuple_splat::Int = 32,
union_splitting::Int = 4,
)
Expand Down Expand Up @@ -107,7 +107,7 @@ struct InferenceParams
function InferenceParams(;
ipo_constant_propagation::Bool = true,
aggressive_constant_propagation::Bool = false,
max_methods::Int = 4,
max_methods::Int = 3,
union_splitting::Int = 4,
apply_union_enum::Int = 8,
tupletype_depth::Int = 3,
Expand Down
17 changes: 15 additions & 2 deletions test/worlds.jl
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,12 @@ applyf35855(Any[1])
wany3 = worlds(instance(applyf35855, (Vector{Any},)))
src3 = code_typed(applyf35855, (Vector{Any},))[1]
@test (wany3 == wany2) == equal(src3, src2) # don't invalidate unless you also change the code
f35855(::AbstractVector) = 4 # next test would pass if this were ::Vector{Int}
f35855(::AbstractVector) = 4
applyf35855(Any[1])
wany4 = worlds(instance(applyf35855, (Vector{Any},)))
src4 = code_typed(applyf35855, (Vector{Any},))[1]
@test_broken (wany4 == wany3) == equal(src4, src3)
# this passes when max_methods == 3, fails when set to 4
@test (wany4 == wany3) == equal(src4, src3)
f35855(::Dict) = 5
applyf35855(Any[1])
wany5 = worlds(instance(applyf35855, (Vector{Any},)))
Expand All @@ -291,6 +292,18 @@ wany6 = worlds(instance(applyf35855, (Vector{Any},)))
src6 = code_typed(applyf35855, (Vector{Any},))[1]
@test (wany6 == wany5) == equal(src6, src5)

applyf35855_2(c) = f35855_2(c[1])
f35855_2(::Int) = 1
f35855_2(::Float64) = 2
applyf35855_2(Any[1])
wany3 = worlds(instance(applyf35855_2, (Vector{Any},)))
src3 = code_typed(applyf35855_2, (Vector{Any},))[1]
f35855_2(::AbstractVector) = 4 # next test would pass if this were ::Vector{Int}
applyf35855_2(Any[1])
wany4 = worlds(instance(applyf35855_2, (Vector{Any},)))
src4 = code_typed(applyf35855_2, (Vector{Any},))[1]
@test_broken (wany4 == wany3) == equal(src4, src3)

## ambiguities do not trigger invalidation
using Printf
Printf.gen("%f")
Expand Down

0 comments on commit baa9b27

Please sign in to comment.