From baa9b2733c0ee0c16eb8f0c67af9540a64c1eb18 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Fri, 19 Jun 2020 11:07:24 -0400 Subject: [PATCH] set default max_methods to 3 --- base/compiler/types.jl | 4 ++-- test/worlds.jl | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/base/compiler/types.jl b/base/compiler/types.jl index 068574b80d0c9..d371b6a1c8786 100644 --- a/base/compiler/types.jl +++ b/base/compiler/types.jl @@ -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, ) @@ -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, diff --git a/test/worlds.jl b/test/worlds.jl index 92ee5866e1517..878dd24adadb4 100644 --- a/test/worlds.jl +++ b/test/worlds.jl @@ -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},))) @@ -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")