From 5cd1994b89faa27657e2b0bb7ef026124acdff95 Mon Sep 17 00:00:00 2001 From: Hans Bolinder Date: Fri, 13 Jan 2017 13:12:54 +0100 Subject: dialyzer: Do not keep the code server's type info on the heap The table used during translation of forms to types used to be a dictionary of the type info (-type(), -opaque(), and -record()) for all modules. Now it is reduced to the modules that are needed to handle references to types in other modules. The PLT:s type info is still kept on the heap. --- lib/dialyzer/src/dialyzer_plt.erl | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/dialyzer/src/dialyzer_plt.erl') diff --git a/lib/dialyzer/src/dialyzer_plt.erl b/lib/dialyzer/src/dialyzer_plt.erl index 37c22fef48..1bf30cf83b 100644 --- a/lib/dialyzer/src/dialyzer_plt.erl +++ b/lib/dialyzer/src/dialyzer_plt.erl @@ -32,6 +32,7 @@ from_file/1, get_default_plt/0, get_types/1, + get_module_types/2, get_exported_types/1, %% insert/3, insert_list/2, @@ -199,6 +200,12 @@ insert_exported_types(PLT, Set) -> get_types(#plt{types = Types}) -> Types. +-spec get_module_types(plt(), atom()) -> + 'none' | {'value', erl_types:type_table()}. + +get_module_types(#plt{types = Types}, M) when is_atom(M) -> + table_lookup(Types, M). + -spec get_exported_types(plt()) -> sets:set(). get_exported_types(#plt{exported_types = ExpTypes}) -> -- cgit v1.2.3 From e917ae0da957a8b151df54e2f1940fded8d21ad1 Mon Sep 17 00:00:00 2001 From: Hans Bolinder Date: Mon, 16 Jan 2017 13:15:55 +0100 Subject: typer: Fix a bug regarding the -T option The -T option has not been working for a long time. --- lib/dialyzer/src/dialyzer_plt.erl | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/dialyzer/src/dialyzer_plt.erl') diff --git a/lib/dialyzer/src/dialyzer_plt.erl b/lib/dialyzer/src/dialyzer_plt.erl index 1bf30cf83b..511a17d577 100644 --- a/lib/dialyzer/src/dialyzer_plt.erl +++ b/lib/dialyzer/src/dialyzer_plt.erl @@ -144,6 +144,10 @@ delete_list(#plt{info = Info, types = Types, -spec insert_contract_list(plt(), dialyzer_contracts:plt_contracts()) -> plt(). +insert_contract_list(#plt{contracts = Contracts} = PLT, List) -> + NewContracts = dict:merge(fun(_MFA, _Old, New) -> New end, + Contracts, dict:from_list(List)), + PLT#plt{contracts = NewContracts}; insert_contract_list(#mini_plt{contracts = Contracts} = PLT, List) -> true = ets:insert(Contracts, List), PLT. -- cgit v1.2.3 From 2c577356c419b9420cae91a74d4b1602d584275a Mon Sep 17 00:00:00 2001 From: Hans Bolinder Date: Tue, 17 Jan 2017 15:10:58 +0100 Subject: dialyzer: Use less memory for the PLT when analyzing The two tables for (record) types and exported types are no longer kept in memory (by the PLT) when analyzing, which reduces memory consumption. A first step towards removing (or replacing) the #plt{} record. --- lib/dialyzer/src/dialyzer_plt.erl | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'lib/dialyzer/src/dialyzer_plt.erl') diff --git a/lib/dialyzer/src/dialyzer_plt.erl b/lib/dialyzer/src/dialyzer_plt.erl index 511a17d577..26dfeac71e 100644 --- a/lib/dialyzer/src/dialyzer_plt.erl +++ b/lib/dialyzer/src/dialyzer_plt.erl @@ -31,10 +31,8 @@ included_files/1, from_file/1, get_default_plt/0, - get_types/1, get_module_types/2, get_exported_types/1, - %% insert/3, insert_list/2, insert_contract_list/2, insert_callbacks/2, @@ -189,20 +187,17 @@ lookup(Plt, Label) when is_integer(Label) -> lookup_1(#mini_plt{info = Info}, MFAorLabel) -> ets_table_lookup(Info, MFAorLabel). --spec insert_types(plt(), erl_types:mod_records()) -> plt(). +-spec insert_types(plt(), ets:tid()) -> plt(). -insert_types(PLT, Rec) -> - PLT#plt{types = Rec}. +insert_types(MiniPLT, Records) -> + ets:rename(Records, plt_types), + MiniPLT#mini_plt{types = Records}. --spec insert_exported_types(plt(), sets:set()) -> plt(). +-spec insert_exported_types(plt(), ets:tid()) -> plt(). -insert_exported_types(PLT, Set) -> - PLT#plt{exported_types = Set}. - --spec get_types(plt()) -> erl_types:mod_records(). - -get_types(#plt{types = Types}) -> - Types. +insert_exported_types(MiniPLT, ExpTypes) -> + ets:rename(ExpTypes, plt_exported_types), + MiniPLT#mini_plt{exported_types = ExpTypes}. -spec get_module_types(plt(), atom()) -> 'none' | {'value', erl_types:type_table()}. -- cgit v1.2.3 From 643b7dbdb7f208ff69265b4f6b14f79175865c2b Mon Sep 17 00:00:00 2001 From: Hans Bolinder Date: Thu, 19 Jan 2017 16:19:11 +0100 Subject: dialyzer: Compress some PLT tables Compressing the signatures or the contract records would cost time. The contract records are still held in two places (code server and PLT) in many cases. --- lib/dialyzer/src/dialyzer_plt.erl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib/dialyzer/src/dialyzer_plt.erl') diff --git a/lib/dialyzer/src/dialyzer_plt.erl b/lib/dialyzer/src/dialyzer_plt.erl index 26dfeac71e..eb63e9e695 100644 --- a/lib/dialyzer/src/dialyzer_plt.erl +++ b/lib/dialyzer/src/dialyzer_plt.erl @@ -526,10 +526,12 @@ get_mini_plt(#plt{info = Info, contracts = Contracts, callbacks = Callbacks, exported_types = ExpTypes}) -> - [ETSInfo, ETSTypes, ETSContracts, ETSCallbacks, ETSExpTypes] = + [ETSInfo, ETSContracts] = [ets:new(Name, [public]) || - Name <- [plt_info, plt_types, plt_contracts, plt_callbacks, - plt_exported_types]], + Name <- [plt_info, plt_contracts]], + [ETSTypes, ETSCallbacks, ETSExpTypes] = + [ets:new(Name, [compressed, public]) || + Name <- [plt_types, plt_callbacks, plt_exported_types]], CallbackList = dict:to_list(Callbacks), CallbacksByModule = [{M, [Cb || {{M1,_,_},_} = Cb <- CallbackList, M1 =:= M]} || -- cgit v1.2.3