mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-15 22:03:26 +00:00
Implement several more changes that together speed up compilation time
Estimated hours taken: 16 Branches: main Implement several more changes that together speed up compilation time on training_cars_full by 12%, and also improve tools/speedtest -h by 7.2% and tools/speedtest by 1.6%. The first change is designed to eliminate the time that the compiler spends constructing error messages that are then ignored. The working predicates of prog_io_sym_name used to always return a single result, which either gave a description of the thing being looked, or an error message. However, in many places, the caller did not consider not finding the thing being looked for to be an error, and thus threw away the error message, keeping only the "not found" indication. For each predicate with such callers, this diff provides a parallel predicate that indicates "not found" simply by failing. This allows us to eliminate the construction of the error message, the preparation for the construction of the error message (usually by describing the context), and the construction of the "ok" wrapper. The second change is to specialize the handling of from_ground_term_construct scopes in the termination analyzer. To make this easier, I also cleaned up of the infrastructure of the termination analyzer. The third change is to avoid traversing from_ground_term_construct scopes in quantification.m when finding the variables in a goal, since termination analysis no longer needs the information it gathers. The fourth change is to avoid traversing second and later conjuncts in conjunctions twice. The first step in handling conjunctions is to call implicitly_quantify_conj, which builds up a data structure that pairs each conjunct with the variables that occur free in all the conjuncts following it. However, after this was done and each conjunct was annotated with its nonlocals, we used to compute the variables that occur free in the conjunction as a whole from scratch. This diff changes the code so that we now compute that set based on the information we gathered earlier, avoiding a redundant traversal. The fifth change is to create specialized, lower-arity versions of many of the predicates in quantification.m. These versions are intended for traversals that take place after the compiler has replaced lambda expressions with references to separate procedures. These traversals do not need to pass around arguments representing the variables occurring free in the (now non-existent) lambda expressions. compiler/prog_io_sym_name.m: Make the first change described above. Change some predicate names to adopt a consistent naming scheme in which predicates that do the same job and differ only in how they handle errors have names that differ only in a "try_" prefix. Add some predicate versions that do common tests on the output of the base versions. For example, try_parse_sym_name_and_no_args is a version of try_parse_sym_name_and_args that insists on finding an empty argument list. Remove the unused "error term" argument that we used to need a while ago. Move some predicate definitions to make their order match the order of their declarations. Turn a predicate into a function for its caller's convenience. compiler/term_constr_build.m: Make the second change described above by modeling each from_ground_term_construct scope as a single unification, assigning the total size of the ground term to the variable being built. compiler/term_constr_util.m: Put the arguments of some predicates into a more standard order. compiler/lp_rational.m: Change the names of some function symbols to avoid both the use of graphic characters that require quoting and clashes with other types. Change the names of some predicates to make their purpose clear, and to avoid ambiguity. compiler/quantification.m: Make the third, fourth and fifth changes described above. compiler/*.m: Conform to the changes above.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
%-----------------------------------------------------------------------------%
|
||||
% vim: ft=mercury ts=4 sw=4 et
|
||||
%-----------------------------------------------------------------------------%
|
||||
% Copyright (C) 2005-2008 The University of Melbourne.
|
||||
% Copyright (C) 2005-2009 The University of Melbourne.
|
||||
% This file may only be copied under the terms of the GNU General
|
||||
% Public License - see the file COPYING in the Mercury distribution.
|
||||
%-----------------------------------------------------------------------------%
|
||||
@@ -702,7 +702,7 @@ make_transformed_proc(CellVar, FieldVarsList, InsertMap, !ProcInfo) :-
|
||||
proc_info_set_goal(Goal, !ProcInfo),
|
||||
proc_info_set_varset(VarSet, !ProcInfo),
|
||||
proc_info_set_vartypes(VarTypes, !ProcInfo),
|
||||
requantify_proc(!ProcInfo).
|
||||
requantify_proc_general(ordinary_nonlocals_no_lambda, !ProcInfo).
|
||||
|
||||
:- pred insert_proc_start_deconstruction(hlds_goal::in, hlds_goal::out,
|
||||
prog_varset::in, prog_varset::out, vartypes::in, vartypes::out,
|
||||
@@ -1685,7 +1685,7 @@ fix_calls_in_proc(TransformMap, proc(PredId, ProcId), !ModuleInfo) :-
|
||||
proc_info_set_varset(VarSet, !ProcInfo),
|
||||
proc_info_set_vartypes(VarTypes, !ProcInfo),
|
||||
proc_info_set_rtti_varmaps(RttiVarMaps, !ProcInfo),
|
||||
requantify_proc(!ProcInfo),
|
||||
requantify_proc_general(ordinary_nonlocals_no_lambda, !ProcInfo),
|
||||
recompute_instmap_delta_proc(recompute_atomic_instmap_deltas,
|
||||
!ProcInfo, !ModuleInfo),
|
||||
module_info_set_pred_proc_info(PredId, ProcId,
|
||||
@@ -1734,7 +1734,8 @@ fix_calls_in_goal(Goal0, Goal, !VarSet, !VarTypes, !RttiVarMaps,
|
||||
),
|
||||
conj_list_to_goal([ConstructGoal, CallGoal], GoalInfo0, Goal1),
|
||||
RequantifyVars = set.from_list([CellVar | Args0]),
|
||||
implicitly_quantify_goal(RequantifyVars, _, Goal1, Goal,
|
||||
implicitly_quantify_goal_general(ordinary_nonlocals_no_lambda,
|
||||
RequantifyVars, _, Goal1, Goal,
|
||||
!VarSet, !VarTypes, !RttiVarMaps)
|
||||
;
|
||||
Goal = hlds_goal(GoalExpr0, GoalInfo0)
|
||||
|
||||
Reference in New Issue
Block a user