Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
No build reason found for SLE-Product-HA:aarch64
home:Ledest:erlang:24
erlang
0281-dialyzer-Optimize-supremum-and-infimum.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0281-dialyzer-Optimize-supremum-and-infimum.patch of Package erlang
From d77e883bb89f90d6c750ba234f4edd8184fe56e8 Mon Sep 17 00:00:00 2001 From: Hans Bolinder <hasse@erlang.org> Date: Tue, 13 Jul 2021 12:26:17 +0200 Subject: [PATCH 1/7] dialyzer: Optimize supremum and infimum Profiling showed that erl_types:t_has_var() is used extensively. Many of the calls are made in t_subst/2, which is called from subst_all_vars_to_any(), among other functions. subst_all_vars_to_any() is called from t_sup() and t_inf(), but neither of them need to substitute any() for variables: when called from dialyzer_typesig, there are no variables, and when called from t_from_form() et al, variables are to be kept until later. t_form_form(), which calls t_sup(), now behaves differently as it keeps variables in unions. Also when calling t_tuple/1 variables are kept (t_sup() is called during the handling of opaque types). It is not known if this is a bug fix or can cause problems. --- lib/dialyzer/src/erl_types.erl | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/lib/dialyzer/src/erl_types.erl b/lib/dialyzer/src/erl_types.erl index db3ca22559..2a7bd84ff9 100644 --- a/lib/dialyzer/src/erl_types.erl +++ b/lib/dialyzer/src/erl_types.erl @@ -2583,7 +2583,7 @@ t_sup(Ts) -> t_sup1([H1, H2|T], L) -> t_sup1(T, [t_sup(H1, H2)|L]); -t_sup1([T], []) -> subst_all_vars_to_any(T); +t_sup1([T], []) -> do_not_subst_all_vars_to_any(T); t_sup1(Ts, L) -> t_sup1(Ts++L, []). @@ -2595,7 +2595,7 @@ t_sup(?none, T) -> T; t_sup(T, ?none) -> T; t_sup(?unit, T) -> T; t_sup(T, ?unit) -> T; -t_sup(T, T) -> subst_all_vars_to_any(T); +t_sup(T, T) -> do_not_subst_all_vars_to_any(T); t_sup(?var(_), _) -> ?any; t_sup(_, ?var(_)) -> ?any; t_sup(?atom(Set1), ?atom(Set2)) -> @@ -2889,15 +2889,15 @@ t_inf(T1, T2) -> -spec t_inf(erl_type(), erl_type(), t_inf_opaques()) -> erl_type(). t_inf(?var(_), ?var(_), _Opaques) -> ?any; -t_inf(?var(_), T, _Opaques) -> subst_all_vars_to_any(T); -t_inf(T, ?var(_), _Opaques) -> subst_all_vars_to_any(T); -t_inf(?any, T, _Opaques) -> subst_all_vars_to_any(T); -t_inf(T, ?any, _Opaques) -> subst_all_vars_to_any(T); +t_inf(?var(_), T, _Opaques) -> do_not_subst_all_vars_to_any(T); +t_inf(T, ?var(_), _Opaques) -> do_not_subst_all_vars_to_any(T); +t_inf(?any, T, _Opaques) -> do_not_subst_all_vars_to_any(T); +t_inf(T, ?any, _Opaques) -> do_not_subst_all_vars_to_any(T); t_inf(?none, _, _Opaques) -> ?none; t_inf(_, ?none, _Opaques) -> ?none; t_inf(?unit, _, _Opaques) -> ?unit; % ?unit cases should appear below ?none t_inf(_, ?unit, _Opaques) -> ?unit; -t_inf(T, T, _Opaques) -> subst_all_vars_to_any(T); +t_inf(T, T, _Opaques) -> do_not_subst_all_vars_to_any(T); t_inf(?atom(Set1), ?atom(Set2), _) -> case set_intersection(Set1, Set2) of ?none -> ?none; @@ -3017,13 +3017,13 @@ t_inf(?product(_), _, _Opaques) -> t_inf(_, ?product(_), _Opaques) -> ?none; t_inf(?tuple(?any, ?any, ?any), ?tuple(_, _, _) = T, _Opaques) -> - subst_all_vars_to_any(T); + do_not_subst_all_vars_to_any(T); t_inf(?tuple(_, _, _) = T, ?tuple(?any, ?any, ?any), _Opaques) -> - subst_all_vars_to_any(T); + do_not_subst_all_vars_to_any(T); t_inf(?tuple(?any, ?any, ?any), ?tuple_set(_) = T, _Opaques) -> - subst_all_vars_to_any(T); + do_not_subst_all_vars_to_any(T); t_inf(?tuple_set(_) = T, ?tuple(?any, ?any, ?any), _Opaques) -> - subst_all_vars_to_any(T); + do_not_subst_all_vars_to_any(T); t_inf(?tuple(Elements1, Arity, _Tag1), ?tuple(Elements2, Arity, _Tag2), Opaques) -> case t_inf_lists_strict(Elements1, Elements2, Opaques) of bottom -> ?none; @@ -3409,6 +3409,13 @@ findfirst(N1, N2, U1, B1, U2, B2) -> findfirst(N1+1, N2, U1, B1, U2, B2) end. +%% Optimization. Before Erlang/OTP 25, subst_all_vars_to_any() was +%% called. It turned out that variables are not to be substituted for +%% any() since either there are no variables, or variables are +%% substituted for any() afterwards. +do_not_subst_all_vars_to_any(T) -> + T. + %%----------------------------------------------------------------------------- %% Substitution of variables %% -- 2.31.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor