[m-rev.] for review: miscellaneous par conj fixes

Peter Wang wangp at students.cs.mu.OZ.AU
Mon Apr 17 17:43:38 AEST 2006


Estimated hours taken: 1
Branches: main

Some miscellaneous parallel conjunction related fixes.

compiler/add_clause.m:
	Keep parallel conjuncts in the order they were written, not reversed.
	This is less confusing when debugging.

compiler/det_report.m:
	Add a missing space in an error message.

compiler/hlds_out.m:
	Indent the opening bracket of parallel conjunctions in HLDS dumps.

compiler/par_conj_gen.m:
	In the code generated for parallel conjunctions, don't attempt to copy
	output variables which are of dummy types back to the parent thread's
	stack frame.

tests/valid/Mmakefile:
tests/valid/par_dummy.m:
	Add test case for the fix above.

Index: compiler/add_clause.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/add_clause.m,v
retrieving revision 1.22
diff -u -r1.22 add_clause.m
--- compiler/add_clause.m	29 Mar 2006 08:06:34 -0000	1.22
+++ compiler/add_clause.m	17 Apr 2006 05:52:40 -0000
@@ -653,9 +653,9 @@
     conj_list_to_goal(L, GoalInfo, Goal).
 transform_goal_2(par_conj_expr(A0, B0), _, Subst, Goal, NumAdded, !VarSet,
         !ModuleInfo, !QualInfo, !SInfo, !IO) :-
-    get_rev_par_conj(B0, Subst, [], R0, 0, NumAddedB,
+    get_rev_par_conj(A0, Subst, [], R0, 0, NumAddedA,
         !VarSet, !ModuleInfo, !QualInfo, !SInfo, !IO),
-    get_rev_par_conj(A0, Subst, R0, R,  NumAddedB, NumAdded,
+    get_rev_par_conj(B0, Subst, R0, R,  NumAddedA, NumAdded,
         !VarSet, !ModuleInfo, !QualInfo, !SInfo, !IO),
     L = list.reverse(R),
     goal_info_init(GoalInfo),
Index: compiler/det_report.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/det_report.m,v
retrieving revision 1.116
diff -u -r1.116 det_report.m
--- compiler/det_report.m	29 Mar 2006 08:06:42 -0000	1.116
+++ compiler/det_report.m	17 Apr 2006 05:52:40 -0000
@@ -1451,7 +1451,7 @@
         unexpected(this_file,
             "strange determinism error for parallel conjunction")
     ),
-    Rest = "The current implementation supports only single-solution"
+    Rest = "The current implementation supports only single-solution "
         ++ "non-failing parallel conjunctions.",
     ReportSpec = error_msg_spec(no, Context, 0, [words(First), words(Rest)]),
     globals.io_get_globals(Globals, !IO),
Index: compiler/hlds_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_out.m,v
retrieving revision 1.389
diff -u -r1.389 hlds_out.m
--- compiler/hlds_out.m	29 Mar 2006 08:06:48 -0000	1.389
+++ compiler/hlds_out.m	17 Apr 2006 05:52:40 -0000
@@ -1591,6 +1591,7 @@
             )
         ;
             ConjType = parallel_conj,
+            write_indent(Indent, !IO),
             io.write_string("( % parallel conjunction\n", !IO),
             write_goal_a(Goal, ModuleInfo, VarSet, AppendVarNums, Indent + 1,
                 "\n", TypeQual, !IO),
Index: compiler/par_conj_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/par_conj_gen.m,v
retrieving revision 1.24
diff -u -r1.24 par_conj_gen.m
--- compiler/par_conj_gen.m	29 Mar 2006 08:07:12 -0000	1.24
+++ compiler/par_conj_gen.m	17 Apr 2006 05:52:40 -0000
@@ -116,6 +116,7 @@
 :- implementation.
 
 :- import_module check_hlds.mode_util.
+:- import_module check_hlds.type_util.
 :- import_module hlds.hlds_data.
 :- import_module hlds.hlds_llds.
 :- import_module hlds.hlds_module.
@@ -137,6 +138,7 @@
 :- import_module maybe.
 :- import_module pair.
 :- import_module set.
+:- import_module string.
 
 %---------------------------------------------------------------------------%
 
@@ -264,19 +266,28 @@
 copy_outputs(CI, [Var | Vars], SpSlot, Code) :-
     code_info.get_variable_slot(CI, Var, SrcSlot),
     ( SrcSlot = stackvar(SlotNum) ->
-        % The stack pointer points to the last used word on the stack.
-        % We want MR_sp[-0] = MR_sv(1), MR_sp[-1] = MR_sv(2), etc.
-        NegSlotNum = (1 - SlotNum),
-        DestSlot = field(yes(0), lval(SpSlot), const(int_const(NegSlotNum)))
+        (
+            code_info.get_module_info(CI, ModuleInfo),
+            code_info.variable_type(CI, Var) = Type,
+            is_dummy_argument_type(ModuleInfo, Type)
+        ->
+            % Don't copy dummy values.
+            ThisCode = empty
+        ;
+            % The stack pointer points to the last used word on the stack.
+            % We want MR_sp[-0] = MR_sv(1), MR_sp[-1] = MR_sv(2), etc.
+            NegSlotNum = (1 - SlotNum),
+            DestSlot = field(yes(0), lval(SpSlot), const(int_const(NegSlotNum))),
+            VarName = code_info.variable_to_string(CI, Var),
+            Msg = "copy result " ++ VarName ++ " to parent stackframe",
+            ThisCode = node([assign(DestSlot, lval(SrcSlot)) - Msg])
+        ),
+        Code = tree(ThisCode, RestCode),
+        copy_outputs(CI, Vars, SpSlot, RestCode)
     ;
         unexpected(this_file,
             "copy_outputs: par conj in model non procedure!")
-    ),
-    ThisCode = node([
-        assign(DestSlot, lval(SrcSlot)) - "copy result to parent stackframe"
-    ]),
-    Code = tree(ThisCode, RestCode),
-    copy_outputs(CI, Vars, SpSlot, RestCode).
+    ).
 
 :- pred place_all_outputs(list(prog_var)::in, code_info::in, code_info::out)
     is det.
Index: tests/valid/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/valid/Mmakefile,v
retrieving revision 1.170
diff -u -r1.170 Mmakefile
--- tests/valid/Mmakefile	27 Mar 2006 13:25:54 -0000	1.170
+++ tests/valid/Mmakefile	17 Apr 2006 05:53:14 -0000
@@ -162,6 +162,7 @@
 	no_warn_obsolete \
 	nondet_live \
 	overloading \
+	par_dummy \
 	parsing_bug_main \
 	pred_with_no_modes \
 	qualified_cons_id \
Index: tests/valid/par_dummy.m
===================================================================
RCS file: tests/valid/par_dummy.m
diff -N tests/valid/par_dummy.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/valid/par_dummy.m	17 Apr 2006 05:46:19 -0000
@@ -0,0 +1,17 @@
+% Was trying to copy dummy outputs back to stack of parent thread.
+%
+% Uncaught Mercury exception:
+% Software Error: llds_out.m: Unexpected: stack var out of range
+
+:- module par_dummy.
+:- interface.
+
+:- type t ---> t.
+:- pred p(t::out) is det.
+
+:- implementation.
+
+p(X) :-
+    ( true
+    & X = t
+    ).
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list