Fix a few spots where the conversion to 4-space indentation went

Estimated hours taken: 0.1
Branches: main

compiler/deep_profiling.m:
	Fix a few spots where the conversion to 4-space indentation went
	astray or where there are now unnecessary line breaks.
This commit is contained in:
Julien Fischer
2006-01-10 06:35:56 +00:00
parent a0927de6f9
commit 6371128312

View File

@@ -1,18 +1,18 @@
%-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------%
% vim: ft=mercury ts=4 sw=4 et % vim: ft=mercury ts=4 sw=4 et
%-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------%
% Copyright (C) 2001-2005 The University of Melbourne. % Copyright (C) 2001-2006 The University of Melbourne.
% This file may only be copied under the terms of the GNU General % This file may only be copied under the terms of the GNU General
% Public License - see the file COPYING in the Mercury distribution. % Public License - see the file COPYING in the Mercury distribution.
%-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------%
%
% File: deep_profiling.m. % File: deep_profiling.m.
% Main author: conway. % Main author: conway.
%
% This module applies the deep profiling transformation described in the paper % This module applies the deep profiling transformation described in the paper
% ``Engineering a profiler for a logic programming language'' by Thomas Conway % ``Engineering a profiler for a logic programming language'' by Thomas Conway
% and Zoltan Somogyi. % and Zoltan Somogyi.
%
%-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------%
:- module ll_backend__deep_profiling. :- module ll_backend__deep_profiling.
@@ -80,8 +80,7 @@ apply_deep_profiling_transformation(!ModuleInfo) :-
module_info_predids(!.ModuleInfo, PredIds), module_info_predids(!.ModuleInfo, PredIds),
module_info_get_predicate_table(!.ModuleInfo, PredTable0), module_info_get_predicate_table(!.ModuleInfo, PredTable0),
predicate_table_get_preds(PredTable0, PredMap0), predicate_table_get_preds(PredTable0, PredMap0),
list__foldl(transform_predicate(!.ModuleInfo), PredIds, list.foldl(transform_predicate(!.ModuleInfo), PredIds, PredMap0, PredMap),
PredMap0, PredMap),
predicate_table_set_preds(PredMap, PredTable0, PredTable), predicate_table_set_preds(PredMap, PredTable0, PredTable),
module_info_set_predicate_table(PredTable, !ModuleInfo). module_info_set_predicate_table(PredTable, !ModuleInfo).
@@ -128,8 +127,8 @@ apply_tail_recursion_to_proc(PredProcId, !ModuleInfo) :-
ClonePredProcId = proc(PredId, CloneProcId), ClonePredProcId = proc(PredId, CloneProcId),
ApplyInfo = apply_tail_recursion_info(!.ModuleInfo, ApplyInfo = apply_tail_recursion_info(!.ModuleInfo,
[PredProcId - ClonePredProcId], Detism, Outputs), [PredProcId - ClonePredProcId], Detism, Outputs),
apply_tail_recursion_to_goal(Goal0, ApplyInfo, Goal, apply_tail_recursion_to_goal(Goal0, ApplyInfo, Goal, no,
no, FoundTailCall, _), FoundTailCall, _),
FoundTailCall = yes FoundTailCall = yes
-> ->
proc_info_set_goal(Goal, ProcInfo0, ProcInfo1), proc_info_set_goal(Goal, ProcInfo0, ProcInfo1),
@@ -328,8 +327,7 @@ apply_tail_recursion_to_conj([Goal0 | Goals0], ApplyInfo0, [Goal | Goals],
apply_tail_recursion_to_disj([], _, [], !FoundTailCall). apply_tail_recursion_to_disj([], _, [], !FoundTailCall).
apply_tail_recursion_to_disj([Goal0], ApplyInfo, [Goal], apply_tail_recursion_to_disj([Goal0], ApplyInfo, [Goal],
!FoundTailCall) :- !FoundTailCall) :-
apply_tail_recursion_to_goal(Goal0, ApplyInfo, Goal, apply_tail_recursion_to_goal(Goal0, ApplyInfo, Goal, !FoundTailCall, _).
!FoundTailCall, _).
apply_tail_recursion_to_disj([Goal0 | Goals0], ApplyInfo, [Goal0 | Goals], apply_tail_recursion_to_disj([Goal0 | Goals0], ApplyInfo, [Goal0 | Goals],
!FoundTailCall) :- !FoundTailCall) :-
Goals0 = [_ | _], Goals0 = [_ | _],
@@ -342,10 +340,8 @@ apply_tail_recursion_to_disj([Goal0 | Goals0], ApplyInfo, [Goal0 | Goals],
apply_tail_recursion_to_cases([], _, [], !FoundTailCall). apply_tail_recursion_to_cases([], _, [], !FoundTailCall).
apply_tail_recursion_to_cases([case(ConsId, Goal0) | Cases0], ApplyInfo, apply_tail_recursion_to_cases([case(ConsId, Goal0) | Cases0], ApplyInfo,
[case(ConsId, Goal) | Cases], !FoundTailCall) :- [case(ConsId, Goal) | Cases], !FoundTailCall) :-
apply_tail_recursion_to_goal(Goal0, ApplyInfo, Goal, apply_tail_recursion_to_goal(Goal0, ApplyInfo, Goal, !FoundTailCall, _),
!FoundTailCall, _), apply_tail_recursion_to_cases(Cases0, ApplyInfo, Cases, !FoundTailCall).
apply_tail_recursion_to_cases(Cases0, ApplyInfo, Cases,
!FoundTailCall).
%-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------%
@@ -381,16 +377,13 @@ figure_out_rec_call_numbers(Goal, !N, !TailCallSites) :-
GoalExpr = unify(_, _, _, _, _) GoalExpr = unify(_, _, _, _, _)
; ;
GoalExpr = conj(Goals), GoalExpr = conj(Goals),
figure_out_rec_call_numbers_in_goal_list(Goals, figure_out_rec_call_numbers_in_goal_list(Goals, !N, !TailCallSites)
!N, !TailCallSites)
; ;
GoalExpr = disj(Goals), GoalExpr = disj(Goals),
figure_out_rec_call_numbers_in_goal_list(Goals, figure_out_rec_call_numbers_in_goal_list(Goals, !N, !TailCallSites)
!N, !TailCallSites)
; ;
GoalExpr = switch(_, _, Cases), GoalExpr = switch(_, _, Cases),
figure_out_rec_call_numbers_in_case_list(Cases, figure_out_rec_call_numbers_in_case_list(Cases, !N, !TailCallSites)
!N, !TailCallSites)
; ;
GoalExpr = if_then_else(_, Cond, Then, Else), GoalExpr = if_then_else(_, Cond, Then, Else),
figure_out_rec_call_numbers(Cond, !N, !TailCallSites), figure_out_rec_call_numbers(Cond, !N, !TailCallSites),
@@ -398,8 +391,7 @@ figure_out_rec_call_numbers(Goal, !N, !TailCallSites) :-
figure_out_rec_call_numbers(Else, !N, !TailCallSites) figure_out_rec_call_numbers(Else, !N, !TailCallSites)
; ;
GoalExpr = par_conj(Goals), GoalExpr = par_conj(Goals),
figure_out_rec_call_numbers_in_goal_list(Goals, figure_out_rec_call_numbers_in_goal_list(Goals, !N, !TailCallSites)
!N, !TailCallSites)
; ;
GoalExpr = scope(_, Goal1), GoalExpr = scope(_, Goal1),
figure_out_rec_call_numbers(Goal1, !N, !TailCallSites) figure_out_rec_call_numbers(Goal1, !N, !TailCallSites)
@@ -591,8 +583,7 @@ transform_det_proc(ModuleInfo, PredProcId, !ProcInfo) :-
generate_call(ModuleInfo, "det_call_port_code_sr", 4, generate_call(ModuleInfo, "det_call_port_code_sr", 4,
[ProcStaticVar, TopCSD, MiddleCSD, ActivationPtr1], [ProcStaticVar, TopCSD, MiddleCSD, ActivationPtr1],
[TopCSD, MiddleCSD, ActivationPtr1], CallPortCode0), [TopCSD, MiddleCSD, ActivationPtr1], CallPortCode0),
goal_add_feature(save_deep_excp_vars, goal_add_feature(save_deep_excp_vars, CallPortCode0, CallPortCode),
CallPortCode0, CallPortCode),
generate_call(ModuleInfo, "det_exit_port_code_sr", 3, generate_call(ModuleInfo, "det_exit_port_code_sr", 3,
[TopCSD, MiddleCSD, ActivationPtr1], [], ExitPortCode) [TopCSD, MiddleCSD, ActivationPtr1], [], ExitPortCode)
; ;
@@ -600,8 +591,7 @@ transform_det_proc(ModuleInfo, PredProcId, !ProcInfo) :-
generate_call(ModuleInfo, "det_call_port_code_ac", 3, generate_call(ModuleInfo, "det_call_port_code_ac", 3,
[ProcStaticVar, TopCSD, MiddleCSD], [ProcStaticVar, TopCSD, MiddleCSD],
[TopCSD, MiddleCSD], CallPortCode0), [TopCSD, MiddleCSD], CallPortCode0),
goal_add_feature(save_deep_excp_vars, goal_add_feature(save_deep_excp_vars, CallPortCode0, CallPortCode),
CallPortCode0, CallPortCode),
generate_call(ModuleInfo, "det_exit_port_code_ac", 2, generate_call(ModuleInfo, "det_exit_port_code_ac", 2,
[TopCSD, MiddleCSD], [], ExitPortCode) [TopCSD, MiddleCSD], [], ExitPortCode)
), ),
@@ -674,8 +664,8 @@ transform_semi_proc(ModuleInfo, PredProcId, !ProcInfo) :-
), ),
IsInInterface = is_proc_in_interface(ModuleInfo, PredId, ProcId), IsInInterface = is_proc_in_interface(ModuleInfo, PredId, ProcId),
ProcStatic = hlds_proc_static(FileName, LineNumber, ProcStatic = hlds_proc_static(FileName, LineNumber, IsInInterface,
IsInInterface, CallSites), CallSites),
ShroudedPredProcId = shroud_pred_proc_id(proc(PredId, ProcId)), ShroudedPredProcId = shroud_pred_proc_id(proc(PredId, ProcId)),
ProcStaticConsId = deep_profiling_proc_layout(ShroudedPredProcId), ProcStaticConsId = deep_profiling_proc_layout(ShroudedPredProcId),
generate_unify(ProcStaticConsId, ProcStaticVar, BindProcStaticVarGoal), generate_unify(ProcStaticConsId, ProcStaticVar, BindProcStaticVarGoal),
@@ -791,8 +781,7 @@ transform_non_proc(ModuleInfo, PredProcId, !ProcInfo) :-
OldOutermostProcDyn2, NewOutermostProcDyn], OldOutermostProcDyn2, NewOutermostProcDyn],
[TopCSD, MiddleCSD, OldOutermostProcDyn2, NewOutermostProcDyn], [TopCSD, MiddleCSD, OldOutermostProcDyn2, NewOutermostProcDyn],
CallPortCode0), CallPortCode0),
goal_add_feature(save_deep_excp_vars, goal_add_feature(save_deep_excp_vars, CallPortCode0, CallPortCode),
CallPortCode0, CallPortCode),
generate_call(ModuleInfo, "non_exit_port_code_sr", 3, generate_call(ModuleInfo, "non_exit_port_code_sr", 3,
[TopCSD, MiddleCSD, OldOutermostProcDyn2], [], [TopCSD, MiddleCSD, OldOutermostProcDyn2], [],
ExitPortCode), ExitPortCode),
@@ -809,8 +798,7 @@ transform_non_proc(ModuleInfo, PredProcId, !ProcInfo) :-
[ProcStaticVar, TopCSD, MiddleCSD, NewOutermostProcDyn], [ProcStaticVar, TopCSD, MiddleCSD, NewOutermostProcDyn],
[TopCSD, MiddleCSD, NewOutermostProcDyn], [TopCSD, MiddleCSD, NewOutermostProcDyn],
CallPortCode0), CallPortCode0),
goal_add_feature(save_deep_excp_vars, goal_add_feature(save_deep_excp_vars, CallPortCode0, CallPortCode),
CallPortCode0, CallPortCode),
generate_call(ModuleInfo, "non_exit_port_code_ac", 2, generate_call(ModuleInfo, "non_exit_port_code_ac", 2,
[TopCSD, MiddleCSD], [], ExitPortCode), [TopCSD, MiddleCSD], [], ExitPortCode),
generate_call(ModuleInfo, "non_fail_port_code_ac", 2, generate_call(ModuleInfo, "non_fail_port_code_ac", 2,
@@ -826,12 +814,12 @@ transform_non_proc(ModuleInfo, PredProcId, !ProcInfo) :-
RedoPortGoalInfo0, RedoPortGoalInfo), RedoPortGoalInfo0, RedoPortGoalInfo),
RedoPortCode = RedoPortExpr - RedoPortGoalInfo, RedoPortCode = RedoPortExpr - RedoPortGoalInfo,
% Even though the procedure has a model_non interface determinism, % Even though the procedure has a model_non interface determinism, the
% the actual determinism of its original body goal may have been % actual determinism of its original body goal may have been at_most once.
% at_most once. However, the exit/redo disjunction we insert into % However, the exit/redo disjunction we insert into the procedure body
% the procedure body means that the procedure body does actually leave % means that the procedure body does actually leave a nondet stack frame
% a nondet stack frame when it succeeds, and its determinism must be % when it succeeds, and its determinism must be adjusted accordingly.
% adjusted accordingly. %
goal_info_get_determinism(GoalInfo0, Detism0), goal_info_get_determinism(GoalInfo0, Detism0),
determinism_components(Detism0, CanFail, _), determinism_components(Detism0, CanFail, _),
determinism_components(Detism, CanFail, at_most_many), determinism_components(Detism, CanFail, at_most_many),
@@ -953,14 +941,13 @@ transform_goal(Path, scope(Reason0, SubGoal0) - GoalInfo0, Goal,
Reason = Reason0, Reason = Reason0,
AddForceCommit = no AddForceCommit = no
; ;
% Given a subgoal containing both at_most_many code and % Given a subgoal containing both at_most_many code and impure code,
% impure code, determinism analysis will remove the `scope' % determinism analysis will remove the `scope' wrapped around that
% wrapped around that subgoal if it is allowed to. If we get % subgoal if it is allowed to. If we get here, then the subgoal inside
% here, then the subgoal inside the `scope' contains % the `scope' contains at_most_many code (which means that removing
% at_most_many code (which means that removing the scope % the scope will change its determinism) and the deep profiling
% will change its determinism) and the deep profiling
% transformation will make it impure as well. % transformation will make it impure as well.
%
MaybeCut = cut, MaybeCut = cut,
( Reason0 = commit(_) -> ( Reason0 = commit(_) ->
Reason = commit(force_pruning), Reason = commit(force_pruning),
@@ -985,12 +972,9 @@ transform_goal(Path, scope(Reason0, SubGoal0) - GoalInfo0, Goal,
transform_goal(Path, if_then_else(IVars, Cond0, Then0, Else0) - GoalInfo0, transform_goal(Path, if_then_else(IVars, Cond0, Then0, Else0) - GoalInfo0,
if_then_else(IVars, Cond, Then, Else) - GoalInfo, if_then_else(IVars, Cond, Then, Else) - GoalInfo,
AddedImpurity, !DeepInfo) :- AddedImpurity, !DeepInfo) :-
transform_goal([ite_cond | Path], Cond0, Cond, AddedImpurityC, transform_goal([ite_cond | Path], Cond0, Cond, AddedImpurityC, !DeepInfo),
!DeepInfo), transform_goal([ite_then | Path], Then0, Then, AddedImpurityT, !DeepInfo),
transform_goal([ite_then | Path], Then0, Then, AddedImpurityT, transform_goal([ite_else | Path], Else0, Else, AddedImpurityE, !DeepInfo),
!DeepInfo),
transform_goal([ite_else | Path], Else0, Else, AddedImpurityE,
!DeepInfo),
( (
( AddedImpurityC = yes ( AddedImpurityC = yes
; AddedImpurityT = yes ; AddedImpurityT = yes
@@ -1011,8 +995,7 @@ transform_goal(Path, Goal0 - GoalInfo0, GoalAndInfo, AddedImpurity,
!DeepInfo) :- !DeepInfo) :-
Goal0 = foreign_proc(Attrs, _, _, _, _, _), Goal0 = foreign_proc(Attrs, _, _, _, _, _),
( may_call_mercury(Attrs) = may_call_mercury -> ( may_call_mercury(Attrs) = may_call_mercury ->
wrap_foreign_code(Path, Goal0 - GoalInfo0, GoalAndInfo, wrap_foreign_code(Path, Goal0 - GoalInfo0, GoalAndInfo, !DeepInfo),
!DeepInfo),
AddedImpurity = yes AddedImpurity = yes
; ;
GoalAndInfo = Goal0 - GoalInfo0, GoalAndInfo = Goal0 - GoalInfo0,
@@ -1206,10 +1189,12 @@ wrap_call(GoalPath, Goal0, Goal, !DeepInfo) :-
module_info_get_globals(ModuleInfo, Globals), module_info_get_globals(ModuleInfo, Globals),
globals__lookup_bool_option(Globals, globals__lookup_bool_option(Globals,
use_zeroing_for_ho_cycles, UseZeroing), use_zeroing_for_ho_cycles, UseZeroing),
( UseZeroing = yes -> (
UseZeroing = yes,
transform_higher_order_call(Globals, GoalCodeModel, transform_higher_order_call(Globals, GoalCodeModel,
Goal1, Goal2, !DeepInfo) Goal1, Goal2, !DeepInfo)
; ;
UseZeroing = no,
Goal2 = Goal1 Goal2 = Goal1
) )
), ),
@@ -1305,8 +1290,7 @@ transform_higher_order_call(Globals, CodeModel, Goal0, Goal, !DeepInfo) :-
!:DeepInfo = !.DeepInfo ^ vars := VarSet, !:DeepInfo = !.DeepInfo ^ vars := VarSet,
!:DeepInfo = !.DeepInfo ^ var_types := VarTypes, !:DeepInfo = !.DeepInfo ^ var_types := VarTypes,
ExtraNonLocals = set__list_to_set( ExtraNonLocals = set__list_to_set([SavedCountVar, SavedPtrVar]),
[SavedCountVar, SavedPtrVar]),
generate_call(!.DeepInfo ^ module_info, generate_call(!.DeepInfo ^ module_info,
"save_and_zero_activation_info_ac", 2, "save_and_zero_activation_info_ac", 2,