[m-rev.] diff: deep_profiling.m cleanup

Zoltan Somogyi zs at csse.unimelb.edu.au
Mon Aug 25 16:00:59 AEST 2008


compiler/deep_profiling.m:
	Misc style cleanups.

Zoltan.

cvs diff: Diffing .
Index: deep_profiling.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/deep_profiling.m,v
retrieving revision 1.75
diff -u -b -r1.75 deep_profiling.m
--- deep_profiling.m	29 Jul 2008 23:57:57 -0000	1.75
+++ deep_profiling.m	17 Aug 2008 08:35:13 -0000
@@ -485,7 +485,6 @@
         transform_normal_proc(ModuleInfo, PredProcId, !ProcInfo)
     ).
 
-
 %-----------------------------------------------------------------------------%
 
     % Information relating to variables.  When a variable is added to a
@@ -498,7 +497,6 @@
                 varinfo_vartypes    :: vartypes
             ). 
 
-
     % This structure contains stateful information used throughout the deep
     % profiling transformation of a procedure.
     %
@@ -514,7 +512,6 @@
                 deep_maybe_rec_info     :: maybe(deep_recursion_info)
             ).
 
-
     % Transfrom a procedure.
     %
 :- pred transform_normal_proc(module_info::in, pred_proc_id::in,
@@ -616,7 +613,6 @@
     proc_info_set_goal(Goal, !ProcInfo),
     record_hlds_proc_static(ProcStatic, ExcpVars, !ProcInfo).
 
-
 % Wrap the procedure body in the deep profiling port goals.
 
 :- pred build_det_proc_body(module_info::in, prog_var::in, prog_var::in, 
@@ -654,7 +650,6 @@
     ]),
     Goal = hlds_goal(GoalExpr, GoalInfo).
 
-
 :- pred build_semi_proc_body(module_info::in, prog_var::in, prog_var::in, 
     prog_var::in, maybe(prog_var)::in, hlds_goal_info::in, hlds_goal::in,
     hlds_goal::in, hlds_goal::out) is det.
@@ -705,7 +700,6 @@
     ]),
     Goal = hlds_goal(GoalExpr, GoalInfo).
 
-
 :- pred build_non_proc_body(module_info::in, prog_var::in, prog_var::in, 
     prog_var::in, maybe(prog_var)::in, prog_var::in, hlds_goal_info::in,
     hlds_goal::in, hlds_goal::in, hlds_goal::out) is det.
@@ -797,7 +791,6 @@
     ]),
     Goal = hlds_goal(GoalExpr, GoalInfo).
 
-
     % Transform an inner procedure for deep profiling.  Inner procedures are
     % created by the tail recursion preservation pass above.
     %
@@ -1489,20 +1482,19 @@
         !DeepInfo).
 generate_recursion_counter_saves_and_restores_2([Chunk | Chunks], CSDVar,
         CallGoals, ExitGoals, FailGoals, ExtraVars, !DeepInfo) :-
-
     list.map_foldl(generate_depth_var, Chunk, DepthVars, !DeepInfo),
 
     % We generate three separate variables to hold the constant CSN vector.
     % If we used only one, the code generator would have to save its value
     % on the stack when we enter the disjunction that wraps the goal.
     list.length(Chunk, Length),
-    generate_csn_vector(Length, Chunk, CallVars1, CallGoals1, CallCellVar,
+    generate_csn_vector(Length, Chunk, CSNCallVars, CSNCallGoals, CallCellVar,
         !DeepInfo),
-    generate_csn_vector(Length, Chunk, ExitVars1, ExitGoals1, ExitCellVar,
+    generate_csn_vector(Length, Chunk, CSNExitVars, CSNExitGoals, ExitCellVar,
         !DeepInfo),
-    generate_csn_vector(Length, Chunk, FailVars1, FailGoals1, FailCellVar,
+    generate_csn_vector(Length, Chunk, CSNFailVars, CSNFailGoals, FailCellVar,
         !DeepInfo),
-    list.condense([CallVars1, ExitVars1, FailVars1], ExtraVars1),
+    list.condense([CSNCallVars, CSNExitVars, CSNFailVars], CSNExtraVars),
 
     CallPredName = string.format("save_recursion_depth_%d", [i(Length)]),
     ExitPredName = string.format("restore_recursion_depth_exit_%d",
@@ -1518,12 +1510,12 @@
         [CSDVar, FailCellVar | DepthVars], [], FailCellGoal),
 
     generate_recursion_counter_saves_and_restores_2(Chunks, CSDVar,
-        CallGoals2, ExitGoals2, FailGoals2, ExtraVars2, !DeepInfo),
+        TailCallGoals, TailExitGoals, TailFailGoals, TailExtraVars, !DeepInfo),
 
-    list.append(CallGoals1, [CallCellGoal | CallGoals2], CallGoals),
-    list.append(ExitGoals1, [ExitCellGoal | ExitGoals2], ExitGoals),
-    list.append(FailGoals1, [FailCellGoal | FailGoals2], FailGoals),
-    list.append(ExtraVars1, ExtraVars2, ExtraVars).
+    CallGoals = CSNCallGoals ++ [CallCellGoal | TailCallGoals],
+    ExitGoals = CSNExitGoals ++ [ExitCellGoal | TailExitGoals],
+    FailGoals = CSNFailGoals ++ [FailCellGoal | TailFailGoals],
+    ExtraVars = CSNExtraVars ++ TailExtraVars.
 
 :- pred generate_depth_var(int::in, prog_var::out,
     deep_info::in, deep_info::out) is det.
@@ -1534,7 +1526,6 @@
     generate_var(VarName, int_type, DepthVar, VarInfo0, VarInfo),
     !:DeepInfo = !.DeepInfo ^ deep_varinfos := VarInfo.
 
-
 :- pred generate_csn_vector(int::in, list(int)::in, list(prog_var)::out,
     list(hlds_goal)::out, prog_var::out,
     deep_info::in, deep_info::out) is det.
@@ -1648,7 +1639,6 @@
         unify_context(umc_explicit, [])),
     Goal = hlds_goal(GoalExpr, GoalInfo).
 
-
     % Create a variable with the given name and type, adding it to the
     % var_info structure.
     %
@@ -1663,7 +1653,6 @@
         !:VarInfo = var_info(!.VarSet, !.VarTypes)
     ).
 
-
     % Create a variable with the given name and type, adding it to the
     % separate prog_varset and vartypes structures. 
     %
@@ -1674,7 +1663,6 @@
     svvarset.new_named_var(Name, Var, !VarSet),
     svmap.set(Var, Type, !VarTypes).
 
-
 :- pred maybe_generate_activation_ptr(bool::in, prog_var::in, prog_var::in,
         maybe(prog_var)::out, hlds_deep_excp_vars::out, var_info::in, 
         var_info::out) is det.
@@ -1692,7 +1680,6 @@
     ),
     ExcpVars = hlds_deep_excp_vars(TopCSD, MiddleCSD, MaybeActivationPtr).
 
-
 :- pred generate_outermost_proc_dyns(bool::in, prog_var::in, prog_var::in, 
         maybe(prog_var)::out, prog_var::out, hlds_deep_excp_vars::out, 
         var_info::in, var_info::out) is det.
@@ -1713,7 +1700,6 @@
     generate_var("NewOutermost", c_pointer_type, NewOutermostProcDyn,
         !VarInfo).
 
-
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
 
@@ -1854,7 +1840,6 @@
     MaybeDeepInfo = yes(DeepInfo),
     proc_info_set_maybe_deep_profile_info(MaybeDeepInfo, !ProcInfo).
 
-
 %-----------------------------------------------------------------------------%
 % Coverage Profiling.
 %-----------------------------------------------------------------------------%
@@ -1863,20 +1848,16 @@
     %
 :- type proc_coverage_info
     --->    proc_coverage_info(
+                % A map from coverage point indexes to coverage point
+                % information. Updated as coverage points are inserted.
                 ci_coverage_points          :: map(int, coverage_point_info),
-                                            % A map from coverage point indexes
-                                            % to coverage point information,
-                                            % Updated as coverage points are
-                                            % inserted.
                 
+                % Used to track the next coverage point index to be allocated.
                 ci_cp_index_counter         :: counter,
-                                            % Used to track the next coverage
-                                            % point index to be allocated.
                                             
-                ci_var_info                 :: var_info,
-                                            % Information about variables, this
-                                            % is updated as variables are
+                % Information about variables, this is updated as variables are
                                             % introduced. 
+                ci_var_info                 :: var_info,
 
                 ci_module_info              :: module_info,
                 ci_pred_proc_id             :: pred_proc_id,
@@ -1888,11 +1869,9 @@
     %
 :- type coverage_profiling_options
     --->    coverage_profiling_options(
-                
-                %
                 % These fields correspond to coverage profiling options that
                 % may be specified on the command line.  Except cpu_use_2pass.
-                %
+
                 cpo_may_fail            :: bool,
                 cpo_multi               :: bool,
                 cpo_any                 :: bool,
@@ -1902,15 +1881,14 @@
                 cpo_use_portcounts      :: bool,
                 cpo_use_trivial         :: bool,
 
+                % cpu_use_2pass is true if some information needs to be
+                % collected in an initial forwards-pass.
                 cpo_use_2pass           :: bool
-                                        % cpu_use_2pass is true if some
-                                        % information needs to be collected in
-                                        % an initial forwards-pass. 
             ).
 
     % Return wheather each coverage point type should be enabled and iff
-    % coverage any coverage points are enabled then preform the coverage
-    % proflining pass.
+    % coverage any coverage points are enabled then perform the coverage
+    % profiling pass.
     %
 :- pred coverage_profiling_options(module_info::in,
     coverage_profiling_options::out) is det.
@@ -1918,9 +1896,7 @@
 coverage_profiling_options(ModuleInfo, CoveragePointOptions) :-
     module_info_get_globals(ModuleInfo, Globals),
 
-    %
     % Coverage point types.
-    %
     globals.lookup_bool_option(Globals, profile_deep_coverage_may_fail,
         MayFail),
     globals.lookup_bool_option(Globals, profile_deep_coverage_multi,
@@ -1934,9 +1910,7 @@
     globals.lookup_bool_option(Globals, profile_deep_coverage_branch_disj,
         BranchDisj),
 
-    %
     % Interpret options for tuning the coverage profiling pass.
-    %
     globals.lookup_bool_option(Globals, profile_deep_coverage_use_portcounts,
         UsePortCounts),
     globals.lookup_bool_option(Globals, profile_deep_coverage_use_trivial,
@@ -1947,8 +1921,6 @@
         BranchIf, BranchSwitch, BranchDisj, UsePortCounts, UseTrivial,
         Use2Pass).
 
-
-
     % Transform the goal if coverage profiling should be performed, otherwise
     % return it un-altered.
     %
@@ -1974,7 +1946,6 @@
     CoverageInfo ^ ci_var_info = !:VarInfo,
     coverage_points_map_list(CoveragePointsMap, CoveragePoints).
    
-
     % Transform a goal for coverage profiling.  This is the second pass of
     % the coverage profiling transformation.  This is done in several steps.
     %
@@ -2006,11 +1977,9 @@
     Goal0 = hlds_goal(GoalExpr0, GoalInfo0),
     Detism = GoalInfo0 ^ goal_info_get_determinism,
    
-    %
-    % Depending on command line arguments first pass information may or
-    % may-not be available, if it is not avalible sensible defaults are
-    % assumed.
-    %
+    % Depending on command line arguments first pass information may or may not
+    % be available, if it is not avalible sensible defaults are assumed.
+
     Use2Pass = !.Info ^ ci_coverage_profiling_opts ^ cpo_use_2pass,
     (
         Use2Pass = yes,
@@ -2027,12 +1996,10 @@
         GoalHasPortCounts = goal_does_not_have_port_counts
     ),
   
-    %
     % Step 1.
     %
     % Consider inserting a coverage point after this goal to measure how
     % many solutions it may have.
-    %
     (
         GoalTrivial = goal_is_nontrivial,
         (
@@ -2052,16 +2019,15 @@
                     % Because parallel conjunctions arn't common and this is
                     % really only an optimiztion so I've only enabled it for
                     % plain conjunctions.
-                    %
+
                     GoalExpr0 = conj(plain_conj, _)
                 ->
-                    %
                     % Never insert coverage points after conjunctions, wait
                     % until the algorithm recurses to inside the conjunction
                     % and make a better decision about the last conjunct.
                     % This can reduce the number of coverage points inserted
                     % in some cases.
-                    %
+
                     MaybeCPType = no
                 ;
                     (
@@ -2103,22 +2069,18 @@
                             MaybeCPType = no
                         )
                     ;
-                        %
                         % In this case we know that execution will always stop
                         % at this goal, no coverage point is needed (or would
                         % work).
-                        %
                         ( Detism = detism_erroneous
                         ; Detism = detism_failure
                         ),
                         MaybeCPType = no
                     ;
-                        %
                         % This should never occur, as other coverage points
                         % would have been inserted to ensure coverage is known
                         % here, unless they are disabled.  We don't insert a
                         % coverage point here since we shouldn't have to.
-                        %
                         ( Detism = detism_det
                         ; Detism = detism_cc_multi
                         ),
@@ -2135,15 +2097,12 @@
         )
     ;
         GoalTrivial = goal_is_trivial,
-
         MaybeCPType = no
     ),
 
-    %
     % Step 2.
     %
     % Update coverage known information.  
-    %
     (
         MaybeCPType = yes(_),
         CoverageAfterKnown = coverage_after_known
@@ -2177,11 +2136,9 @@
         )
     ),
 
-    %
     % Step 3.
     %
     % Apply transformation recursively.
-    %
     (   
         ( GoalExpr0 = unify(_, _, _, _, _)
         ; GoalExpr0 = plain_call(_, _, _, _, _, _)
@@ -2198,11 +2155,10 @@
             AddedImpurityInner),
         GoalExpr1 = conj(ConjType, Goals)
     ;
-        %
         % There may be optimizations that can allow us to avoid inserting
         % superfluous coverage points, however they are most likely to be
         % non-trivial.
-        %
+
         GoalExpr0 = disj(Goals0),
         coverage_prof_second_pass_disj(Path, 1, Goals0, Goals, !Info,
             AddedImpurityInner),
@@ -2243,10 +2199,7 @@
         GoalExpr1 = negation(NegGoal)
     ;
         GoalExpr0 = scope(Reason, ScopeGoal0),
-        ( 
-            Detism = ScopeGoal0 ^ hlds_goal_info ^
-                goal_info_get_determinism
-        ->
+        ( Detism = ScopeGoal0 ^ hlds_goal_info ^ goal_info_get_determinism ->
             ScopeCut = scope_is_no_cut
         ;
             ScopeCut = scope_is_cut
@@ -2271,11 +2224,9 @@
     add_impurity_if_needed(AddedImpurityInner, GoalInfo0, GoalInfo1),
     Goal1 = hlds_goal(GoalExpr1, GoalInfo1),
     
-    %
     % Step 4.
     %
     % Insert the coverage point if we decided to earlier.
-    %
     (
         MaybeCPType = yes(CPType),
         CPInfo = coverage_point_info(Path, CPType),
@@ -2290,7 +2241,6 @@
         AddedImpurity = AddedImpurityInner
     ).
 
-
     % Perform the coverage profiling transformation for conjuncts starting
     % at the tail of the goal list and moving back towards the head.  The
     % goal list represents the list of goals within a conjunction minus
@@ -2306,27 +2256,22 @@
 
 coverage_prof_second_pass_conj(_, _, _, [], [], !CoverageAfterKnown,
     !Info, no).
-coverage_prof_second_pass_conj(Path, Pos, ConjType, 
-        [Goal0 | Goals0], Goals, 
-        CoverageAfterKnown0, NextCoverageAfterKnown, !Info,
-        AddedImpurity) :-
-    coverage_prof_second_pass_conj(Path, Pos+1, ConjType,
-        Goals0, Goals1, CoverageAfterKnown0, CoverageAfterKnown, !Info,
-        AddedImpurityTail),
-    coverage_prof_second_pass_goal(snoc(Path, step_conj(Pos)),
-        Goal0, Goal1, CoverageAfterKnown, NextCoverageAfterKnown, !Info,
-        AddedImpurityHead),
+coverage_prof_second_pass_conj(Path, Pos, ConjType, [Goal0 | Goals0], Goals,
+        CoverageAfterKnown0, NextCoverageAfterKnown, !Info, AddedImpurity) :-
+    coverage_prof_second_pass_conj(Path, Pos+1, ConjType, Goals0, Goals1,
+        CoverageAfterKnown0, CoverageAfterKnown, !Info, AddedImpurityTail),
+    coverage_prof_second_pass_goal(snoc(Path, step_conj(Pos)), Goal0, Goal1,
+        CoverageAfterKnown, NextCoverageAfterKnown, !Info, AddedImpurityHead),
     (
         Goal1 = hlds_goal(conj(plain_conj, ConjGoals), _),
         ConjType = plain_conj
     ->
         Goals = ConjGoals ++ Goals1
     ;
-        Goals = [ Goal1 | Goals1 ]
+        Goals = [Goal1 | Goals1]
     ),
     bool.or(AddedImpurityHead, AddedImpurityTail, AddedImpurity).
 
-
     % Perform the coverage profiling transformation over goals within a
     % disjunction.  The list of goals represents the tail of the disjunction
     % currently being transformed.
@@ -2373,7 +2318,6 @@
 
     bool.or(AddedImpurityHead, AddedImpurityTail, AddedImpurity).
 
-
 :- pred coverage_prof_second_pass_switchcase(goal_path::in, int::in, 
     can_fail::in, list(case)::in, list(case)::out, 
     coverage_after_known::in, coverage_after_known::out, 
@@ -2387,12 +2331,11 @@
         NextCoverageAfterKnown, !Info, AddedImpurity) :-
     Goal0 = Case0 ^ case_goal,
 
-    %
     % If the switch cannot fail and this is the last case then the coverage
     % at the end of this case can be computed from the coverage after the
     % entire switch and coverage information for the tail of the switch
     % such as branch coverage points.
-    %
+
     (
         Cases0 = [],
         (
@@ -2446,7 +2389,6 @@
         NextCoverageAfterKnownTail, NextCoverageAfterKnown), 
     bool.or(AddedImpurityHead, AddedImpurityTail, AddedImpurity).
 
-
     % Determine if branch coverage points should be inserted in either or
     % both of the then and else branches, insert them and transform the
     % sub-goals.
@@ -2463,14 +2405,13 @@
 coverage_prof_second_pass_ite(Path, ITEExistVars, Cond0, Then0, Else0, 
         GoalExpr, CoverageAfterITEKnown, NextCoverageAfterKnown,
         !Info, AddedImpurity) :-
-    %
     % If the then and else goals have exactly one solution and coverage is
     % known after the ite, then the coverage at the end of one branch can
-    % be computed from the other branch and the coverage known after the
-    % ITE.  This helps later to insert fewer coverage points in the
-    % beginning of the branches, and may also help reduce coverage points
-    % within the branches. 
-    %
+    % be computed from the other branch and the coverage known after the ite.
+    % This helps later to insert fewer coverage points in the beginning of
+    % the branches, and may also help reduce coverage points within the
+    % branches.
+
     (
         CoverageAfterITEKnown = coverage_after_known,
         ThenDetism = Then0 ^ hlds_goal_info ^ goal_info_get_determinism,
@@ -2484,9 +2425,8 @@
                 ; ElseDetism = detism_cc_multi
                 ),
                 
-                %
-                % Now which should have coverage known,
-                %
+                % Now which should have coverage known.
+                % XXX What does that comment mean?
                 Use2Pass = !.Info ^ ci_coverage_profiling_opts ^
                     cpo_use_2pass,
                 (
@@ -2506,12 +2446,11 @@
                 ;
                     ThenHasPortCounts = goal_has_port_counts,
                    
-                    % 
                     % Although we don't know if Else has port counts, at
                     % this point we're either making the deliberate
                     % decision below or an arbitrary decision, so
                     % it doesn't matter if Else has port counts or not.
-                    %
+
                     CoverageAfterElseKnown = coverage_after_unknown,
                     CoverageAfterThenKnown = coverage_after_known
                 )
@@ -2543,7 +2482,6 @@
         CoverageAfterThenKnown = coverage_after_unknown
     ),
     
-    
     % Transform Else branch,
     coverage_prof_second_pass_goal(snoc(Path, step_ite_else), Else0, Else1, 
         CoverageAfterElseKnown, CoverageBeforeElseKnown1, !Info, 
@@ -2554,7 +2492,6 @@
         CoverageAfterThenKnown, CoverageBeforeThenKnown1, !Info,
         AddedImpurityThenGoal),
     
-    %
     % Gather information and decide what coverage points to insert.
     %
     % Notice that it doesn't matter if any of the goals are trivial or not,
@@ -2563,7 +2500,7 @@
     %
     % Whatever we do we will ensure that the coverage will be known at the
     % beginning of each branch,
-    %
+
     CPOBranchIf = !.Info ^ ci_coverage_profiling_opts ^ cpo_branch_ite,
     dp_goal_info(_, CondHasPortCounts) =
         Cond0 ^ hlds_goal_info ^ goal_info_get_dp_info, 
@@ -2606,9 +2543,7 @@
         InsertCPElse = no
     ),
 
-    %
     % Insert any coverage points.
-    %
     maybe_insert_coverage_point_before(InsertCPElse, Else1, Else,
         CoverageBeforeElseKnown1, CoverageBeforeElseKnown, !Info, 
         AddedImpurityElseCP),
@@ -2619,23 +2554,18 @@
         AddedImpurityThenCP),
     bool.or(AddedImpurityThenGoal, AddedImpurityThenCP, AddedImpurityThen),
 
-    %
     % Transform Cond branch.
-    %
     coverage_after_known_branch(CoverageBeforeThenKnown,
         CoverageBeforeElseKnown, CoverageKnownAfterCond),
     coverage_prof_second_pass_goal(snoc(Path, step_ite_cond), 
         Cond0, Cond, CoverageKnownAfterCond, NextCoverageAfterKnown, !Info,
         AddedImpurityCond),
     
-    %
     % Build goal experession and tidy up.
-    %
     AddedImpurity = bool.or(AddedImpurityCond,
         bool.or(AddedImpurityThen, AddedImpurityElse)), 
     GoalExpr = if_then_else(ITEExistVars, Cond, Then, Else).
 
-
     % Insert a coverage point in a conjunction before the current goal if
     % the coverage point info has been provided.
     %
@@ -2651,10 +2581,8 @@
         _, coverage_after_known, !Info, yes) :-
     insert_coverage_point_before(CPInfo, !Goal, !Info).
 
-
-    % Insert a coverage point before the given goal,  This returns a flat
-    % conjunction consisting of a coverage point followed by the input
-    % goal.
+    % Insert a coverage point before the given goal. This returns a flat
+    % conjunction consisting of a coverage point followed by the input goal.
     %
 :- pred insert_coverage_point_before(coverage_point_info::in,
     hlds_goal::in, hlds_goal::out, 
@@ -2671,7 +2599,6 @@
     ),
     create_conj_from_list(Goals, plain_conj, !:Goal).
 
-
     % Used to describe if coverage information is known at a partiular point
     % within a procedure.
     %
@@ -2720,7 +2647,6 @@
         Trivial = goal_is_nontrivial
     ).
 
-
 :- pred goal_has_port_counts_and(goal_has_port_counts::in,
     goal_has_port_counts::in, goal_has_port_counts::out) is det.
 
@@ -2734,7 +2660,6 @@
         HasPortCounts = goal_does_not_have_port_counts
     ).
 
-
     % Given the a goal and whether port counts are availible before it
     % determine if port counts can be used to determine how often execution
     % reaches the poind imediatly after this goal.
@@ -2744,26 +2669,23 @@
 
 has_port_counts_after(Goal, PCDirect, PCBefore, PC) :-
     (
-        % 
-        % The trivial case.  If port counts are directly availible then
-        % the can be used to determine coverage immediately after it.
-        %
+        % The trivial case. If port counts are directly available,
+        % then they can be used to determine coverage immediately after it.
+
         PCDirect = goal_has_port_counts,
         PC = goal_has_port_counts
     ;
         PCDirect = goal_does_not_have_port_counts,
         
-        %
-        % If port counts arn't directly avalible but are before this goal
+        % If port counts aren't directly available but are before this goal
         % and this goal behaves deterministically (it cannot fail or redo),
         % then they can be used to determine how often execution reaches the
-        % point after this goal).
-        %
+        % point after this goal.
+
         Detism = Goal ^ hlds_goal_info ^ goal_info_get_determinism,
         has_port_counts_if_det(Detism, PCBefore, PC)
     ).
     
-    
     % Given the current goal's determinism and wheather the next earliest goal
     % has port counts does this goal have port counts
     %
@@ -2773,15 +2695,14 @@
 has_port_counts_if_det(Detism, HasPortCounts0, HasPortCounts) :-
     (
         ( Detism = detism_det
-        ; Detism = detism_cc_multi )
+        ; Detism = detism_cc_multi
+        )
     ->
         HasPortCounts = HasPortCounts0
     ;
         HasPortCounts = goal_does_not_have_port_counts
     ).
 
-
-
     % Used to gather some information about goals before the coverage
     % transformation.
     %
@@ -2793,19 +2714,15 @@
     Goal0 = hlds_goal(GoalExpr0, GoalInfo0),
 
     (
-        %
-        % Call Goals
-        %
         ( GoalExpr0 = plain_call(_, _, _, _, _, _)
         ; GoalExpr0 = generic_call(_, _, _, _)
-        ; GoalExpr0 = call_foreign_proc(_, _, _, _, _, _, _) ),
-        
+        ; GoalExpr0 = call_foreign_proc(_, _, _, _, _, _, _)
+        ),
         Trivial0 = goal_is_nontrivial,
         HasPortCountsDirect = goal_has_port_counts,
         GoalExpr = GoalExpr0
     ;
         GoalExpr0 = unify(_, _, _, _, _),
-
         Trivial0 = goal_is_trivial,
         HasPortCountsDirect = goal_does_not_have_port_counts,
         GoalExpr = GoalExpr0
@@ -2821,10 +2738,8 @@
             Trivial0, HasPortCountsBefore, HasPortCountsDirect0),
         GoalExpr = disj(Goals),
         
-        %
         % Only if the disjunction cannot fail can we know the coverage after
         % the disjunction if port counts are available from every disjunct.
-        %
         Detism = goal_info_get_determinism(GoalInfo0),
         determinism_components(Detism, CanFail, _),
         (
@@ -2859,10 +2774,9 @@
     ;
         GoalExpr0 = if_then_else(Vars, CondGoal0, ThenGoal0, ElseGoal0),
        
-        %
         % The then and else parts of a ITE goal will be able to use the
         % port counts provided by the cond goal if it has them.
-        %
+
         coverage_prof_first_pass(CPOptions, CondGoal0, CondGoal,
             HasPortCountsBefore, dp_goal_info(TrivialCond, HasPortCountsCond)),
         
@@ -2873,17 +2787,14 @@
 
         GoalExpr = if_then_else(Vars, CondGoal, ThenGoal, ElseGoal),
 
+        % An ITE is trivial iff all of its inner goals are trivial,
 
-        %
-        % An ITE is trivial iff all of it's inner goals are trivial, 
-        %
         goal_trivial_and(TrivialCond, TrivialThen, Trivial1),
         goal_trivial_and(Trivial1, TrivialElse, Trivial0),
 
-        %
         % And it has port counts iff it will end in a goal with a port count
         % regardless of how the condition evaluates.
-        %
+
         goal_has_port_counts_and(HasPortCountsThen, HasPortCountsElse,
             HasPortCountsDirect)
     ;
@@ -2910,13 +2821,10 @@
         Trivial = goal_is_nontrivial
     ),
 
-    %
     % Annotate the goal with this new information.
-    %
     Info = dp_goal_info(Trivial, HasPortCounts),
     goal_info_set_maybe_dp_info(yes(Info), GoalInfo0, GoalInfo).
 
-
     % Combine information about goals within a conjunction
     %
 :- pred coverage_prof_first_pass_conj(coverage_profiling_options::in,
@@ -2929,11 +2837,10 @@
         dp_goal_info(TrivialGoal, HasPortCounts)),
     goal_trivial_and(TrivialAcc, TrivialGoal, Trivial).
 
-
     % Combine information about goals within a disjunction
     %
-    % A portcount may be avalible to the goal executed when first entering a
-    % disjunction.  However it's impractical to deterimine if any disjuncts
+    % A portcount may be available to the goal executed when first entering a
+    % disjunction. However it is impractical to determine if any disjuncts
     % other than the first are ever tried.  So port counts at the beginning of
     % them are unknown.
     %
@@ -2943,7 +2850,7 @@
 
 coverage_prof_first_pass_disj(_, [], [], goal_is_trivial, !HasPortCounts).
 
-coverage_prof_first_pass_disj(CPOptions, [ Goal0 | Goals0 ], [ Goal | Goals ],
+coverage_prof_first_pass_disj(CPOptions, [Goal0 | Goals0], [Goal | Goals],
         Trivial, HasPortCountsBefore, HasPortCounts) :-
     coverage_prof_first_pass(CPOptions, Goal0, Goal, HasPortCountsBefore,
         dp_goal_info(TrivialGoal, HasPortCountsGoal)),
@@ -2953,7 +2860,6 @@
     goal_has_port_counts_and(HasPortCountsGoal, HasPortCountsDisj,
         HasPortCounts).
 
-
     % A switch is handled like a disjunction except that it can't be known
     % how often execution will enter the first case, so this also cannot use
     % the portcount of a goal before it.
@@ -2964,9 +2870,8 @@
 
 coverage_prof_first_pass_switchcase(_, [], [], goal_is_trivial, 
     goal_has_port_counts).
-
 coverage_prof_first_pass_switchcase(CPOptions, 
-    [ Case0 | Cases0 ], [ Case | Cases ], Trivial, HasPortCounts) :-
+        [Case0 | Cases0], [Case | Cases], Trivial, HasPortCounts) :-
     Case0 = case(FirstFunctor, LaterFunctors, Goal0),
 
     coverage_prof_first_pass(CPOptions, Goal0, Goal,
@@ -2980,7 +2885,6 @@
 
     Case = case(FirstFunctor, LaterFunctors, Goal).
 
-
     % Builds a list of goals that will form a conjunction) for a coverage
     % point.
     %
@@ -2997,9 +2901,8 @@
     !:CoverageInfo = !.CoverageInfo ^ ci_coverage_points := CoveragePointInfos,
     !:CoverageInfo = !.CoverageInfo ^ ci_cp_index_counter := CPIndexCounter,
 
-    %
     % Build unifications for the coverage point index and the proc static.
-    %
+
     some [!VarInfo] (
         !:VarInfo = !.CoverageInfo ^ ci_var_info,
         
@@ -3012,32 +2915,29 @@
         !:CoverageInfo = !.CoverageInfo ^ ci_var_info := !.VarInfo
     ),
 
-    %
     % Build a call to the instrumentation code.
-    %
+
     ModuleInfo = !.CoverageInfo ^ ci_module_info,
     get_deep_profile_builtin_ppid(ModuleInfo, "increment_coverage_point_count", 
         2, PredId, ProcId),
     Ground = ground(shared, none),
-    make_foreign_args([ ProcLayoutVar, CPIndexVar ],
-        [ (yes("ProcLayout" - (Ground -> Ground)) - native_if_possible),
-          (yes("CPIndex" - (Ground -> Ground)) - native_if_possible) ],
-        [ c_pointer_type, int_type ], ForeignArgVars),
+    make_foreign_args([ProcLayoutVar, CPIndexVar],
+        [(yes("ProcLayout" - (Ground -> Ground)) - native_if_possible),
+        (yes("CPIndex" - (Ground -> Ground)) - native_if_possible)],
+        [c_pointer_type, int_type], ForeignArgVars),
     coverage_point_ll_code(ForeignCallAttrs, ForeignCode),
     CallGoalExpr = call_foreign_proc(ForeignCallAttrs, PredId, ProcId, 
         ForeignArgVars, [], no, ForeignCode),
     
-    Vars = [ ProcLayoutVar, CPIndexVar ],
+    Vars = [ProcLayoutVar, CPIndexVar],
     NonLocals = list_to_set(Vars),
     instmap_delta_from_assoc_list(assoc_list.from_corresponding_lists(Vars, 
         [Ground, Ground]), InstMapDelta),
     CallGoalInfo = impure_init_goal_info(NonLocals, InstMapDelta, detism_det),
     CallGoal = hlds_goal(CallGoalExpr, CallGoalInfo), 
 
-    % construct complete goal list.
-    Goals = [ GoalUnifyIndex, GoalUnifyProcLayout, CallGoal ].
-      
-
+    % Construct complete goal list.
+    Goals = [GoalUnifyIndex, GoalUnifyProcLayout, CallGoal].
 
     % Turn a map of coverage points and their indexs into a list in sorted
     % order.
@@ -3049,7 +2949,6 @@
     to_sorted_assoc_list(Map, AssocList),
     values(AssocList, List).
 
-
     % Retrive the pred and proc ids from either the deep_mabye_rec_info or
     % deep_pred_proc_id fields of a deep_info structure.
     %
@@ -3067,9 +2966,7 @@
         PredProcId = proc(PredId, ProcId)
     ).
     
-    
-    % Create a proc static cons id from the deep recursion info.  This is used
-    % in several places.
+    % Create a proc static cons_id from the deep recursion info.
     %
 :- pred proc_static_cons_id(proc_coverage_info::in, cons_id::out) is det.
 
@@ -3078,14 +2975,13 @@
     ShroudedPredProcId = shroud_pred_proc_id(proc(PredId, ProcId)),
     ProcStaticConsId = deep_profiling_proc_layout(ShroudedPredProcId).
 
-
     % Returns a string containing the Low Level C code for a coverage point.
     %
 :- pred coverage_point_ll_code(pragma_foreign_proc_attributes::out, 
     pragma_foreign_code_impl::out) is det.
 
 coverage_point_ll_code(ForeignProcAttrs, ForeignCodeImpl) :-
-    some [ !ForeignProcAttrs ] (
+    some [!ForeignProcAttrs] (
         % I don't think this would be thread safe but the cost of the mutexes
         % may be too high.
         !:ForeignProcAttrs = default_attributes(lang_c),
@@ -3100,7 +2996,6 @@
     Code = 
 "{
 #ifdef MR_DEEP_PROFILING
-
     const MR_ProcLayout *pl;
     MR_ProcStatic       *ps;
 
@@ -3126,8 +3021,8 @@
     ps->MR_ps_coverage_points[CPIndex]++;
 
     /*
-     * This procedure doesn't collect statistics about the deep profiler as
-     * they can be generated by the profiling data it's self.
+    ** This procedure doesn't collect statistics about the deep profiler,
+    ** as they can be generated by the profiling data itself.
      */
 
     MR_leave_instrumentation();
cvs diff: Diffing notes
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list