Skip to content

Commit

Permalink
only infer concrete union-split signatures to cut down on inference
Browse files Browse the repository at this point in the history
reduce O(n^2) behavior of `jl_recache_types`

these help #24383
  • Loading branch information
JeffBezanson committed Oct 29, 2017
1 parent 5478834 commit 880ca90
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,10 @@ function _methods_by_ftype(t::ANY, lim::Int, world::UInt, min::Array{UInt,1}, ma
end
end
if 1 < nu <= 64
return _methods_by_ftype(Any[tp...], t, length(tp), lim, [], world, min, max)
ms = _methods_by_ftype(Any[tp...], t, length(tp), lim, [], world, min, max)
if all(m->isleaftype(m[1]), ms)
return ms
end
end
# XXX: the following can return incorrect answers that the above branch would have corrected
return ccall(:jl_matching_methods, Any, (Any, Cint, Cint, UInt, Ptr{UInt}, Ptr{UInt}), t, lim, 0, world, min, max)
Expand Down
2 changes: 2 additions & 0 deletions src/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -3035,6 +3035,8 @@ static jl_datatype_t *jl_recache_type(jl_datatype_t *dt, size_t start, jl_value_
t = dt;
}
assert(t->uid != 0);
if (t == dt && v == NULL)
return t;
// delete / replace any other usages of this type in the backref list
// with the newly constructed object
size_t i = start;
Expand Down

0 comments on commit 880ca90

Please sign in to comment.