From 0448c64be671017a6ef25e9122f493f433e60811 Mon Sep 17 00:00:00 2001 From: Stavros Aronis Date: Fri, 17 Feb 2012 18:06:27 +0100 Subject: Prepare for parallel dataflow --- lib/dialyzer/src/dialyzer_dataflow.erl | 5 ++- lib/dialyzer/src/dialyzer_succ_typings.erl | 55 ++++++++++++++++-------------- 2 files changed, 32 insertions(+), 28 deletions(-) (limited to 'lib/dialyzer/src') diff --git a/lib/dialyzer/src/dialyzer_dataflow.erl b/lib/dialyzer/src/dialyzer_dataflow.erl index 69575ad63a..248ad328ab 100644 --- a/lib/dialyzer/src/dialyzer_dataflow.erl +++ b/lib/dialyzer/src/dialyzer_dataflow.erl @@ -123,12 +123,11 @@ get_warnings(Tree, Plt, Callgraph, Records, NoWarnUnused) -> {State4#state.warnings, state__all_fun_types(State4)}. -spec get_fun_types(cerl:c_module(), dialyzer_plt:plt(), - dialyzer_callgraph:callgraph(), dict()) -> - {dict(), dialyzer_callgraph:callgraph()}. + dialyzer_callgraph:callgraph(), dict()) -> dict(). get_fun_types(Tree, Plt, Callgraph, Records) -> State = analyze_module(Tree, Plt, Callgraph, Records, false), - {state__all_fun_types(State), State#state.callgraph}. + state__all_fun_types(State). %%-------------------------------------------------------------------- diff --git a/lib/dialyzer/src/dialyzer_succ_typings.erl b/lib/dialyzer/src/dialyzer_succ_typings.erl index 21cc13d849..76b6d8954b 100644 --- a/lib/dialyzer/src/dialyzer_succ_typings.erl +++ b/lib/dialyzer/src/dialyzer_succ_typings.erl @@ -196,34 +196,53 @@ refine_succ_typings([M|Rest], State, Fixpoint) -> Msg = io_lib:format("Dataflow of module: ~w\n", [M]), send_log(State#st.parent, Msg), ?debug("~s\n", [Msg]), - {NewCallgraph, FixpointFromScc} = - refine_one_module(M, Callgraph, CodeServer, PLT), + Data = collect_refine_scc_data(M, {CodeServer, Callgraph, PLT}), + FixpointFromScc = refine_one_module(Data), NewFixpoint = ordsets:union(Fixpoint, FixpointFromScc), - refine_succ_typings(Rest, State#st{callgraph = NewCallgraph}, NewFixpoint); + refine_succ_typings(Rest, State, NewFixpoint); refine_succ_typings([], State, Fixpoint) -> case Fixpoint =:= [] of true -> {fixpoint, State}; false -> {not_fixpoint, Fixpoint, State} end. --spec refine_one_module(module(), dialyzer_callgraph:callgraph(), - dialyzer_codeserver:codeserver(), dialyzer_plt:plt()) -> - {dialyzer_callgraph:callgraph(), [label()]}. % ordset +-type servers() :: term(). +-type scc_data() :: term(). +-type scc_refine_data() :: term(). +-type scc() :: [mfa_or_funlbl()] | [module()]. + +-spec find_depends_on(scc(), servers()) -> [scc()]. + +find_depends_on(SCC, {_Codeserver, Callgraph, _Plt}) -> + dialyzer_callgraph:get_depends_on(SCC, Callgraph). + +-spec find_required_by(scc(), servers()) -> [scc()]. + +find_required_by(SCC, {_Codeserver, Callgraph, _Plt}) -> + dialyzer_callgraph:get_required_by(SCC, Callgraph). -refine_one_module(M, Callgraph, CodeServer, PLT) -> +-spec collect_refine_scc_data(module(), servers()) -> scc_refine_data(). + +collect_refine_scc_data(M, {CodeServer, Callgraph, PLT}) -> ModCode = dialyzer_codeserver:lookup_mod_code(M, CodeServer), AllFuns = collect_fun_info([ModCode]), Records = dialyzer_codeserver:lookup_mod_records(M, CodeServer), - {NewFunTypes, NewCallgraph} = - dialyzer_dataflow:get_fun_types(ModCode, PLT, Callgraph, Records), FunTypes = get_fun_types_from_plt(AllFuns, Callgraph, PLT), + {ModCode, PLT, Callgraph, Records, FunTypes}. + +-spec refine_one_module(scc_refine_data()) -> + {dialyzer_callgraph:callgraph(), [label()]}. % ordset + +refine_one_module({ModCode, PLT, Callgraph, Records, FunTypes}) -> + NewFunTypes = + dialyzer_dataflow:get_fun_types(ModCode, PLT, Callgraph, Records), case reached_fixpoint(FunTypes, NewFunTypes) of true -> - {NewCallgraph, ordsets:new()}; + ordsets:new(); {false, NotFixpoint} -> ?debug("Not fixpoint\n", []), insert_into_plt(dict:from_list(NotFixpoint), Callgraph, PLT), - {NewCallgraph, ordsets:from_list([FunLbl || {FunLbl,_Type} <- NotFixpoint])} + ordsets:from_list([FunLbl || {FunLbl,_Type} <- NotFixpoint]) end. reached_fixpoint(OldTypes, NewTypes) -> @@ -302,20 +321,6 @@ find_succ_typings([], State, Coordinator) -> false -> {not_fixpoint, NotFixpoint, State} end. --type servers() :: term(). --type scc_data() :: term(). --type scc() :: [mfa_or_funlbl()]. - --spec find_depends_on(scc(), servers()) -> [scc()]. - -find_depends_on(SCC, {_Codeserver, Callgraph, _Plt}) -> - dialyzer_callgraph:get_depends_on(SCC, Callgraph). - --spec find_required_by(scc(), servers()) -> [scc()]. - -find_required_by(SCC, {_Codeserver, Callgraph, _Plt}) -> - dialyzer_callgraph:get_required_by(SCC, Callgraph). - -spec collect_scc_data(scc(), servers()) -> scc_data(). collect_scc_data(SCC, {Codeserver, Callgraph, Plt}) -> -- cgit v1.2.3