[m-rev.] diff: Make dep_par_conj.m more conservative.

Paul Bone pbone at csse.unimelb.edu.au
Mon Jan 24 17:30:05 AEDT 2011


The dependant parallel conjunction transformation is generating invalid code in
some situations.  This change makes the pushing of signals and waits more
conservative avoiding the problem(s).

compiler/dep_par_conj.m:
    Don't push signals or waits into procedures that:
        + Have already been specialised.
        + Contain parallel conjunctions.

Index: compiler/dep_par_conj.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/dep_par_conj.m,v
retrieving revision 1.46
diff -u -p -b -r1.46 dep_par_conj.m
--- compiler/dep_par_conj.m	30 Dec 2010 11:17:53 -0000	1.46
+++ compiler/dep_par_conj.m	24 Jan 2011 06:21:58 -0000
@@ -1790,14 +1790,32 @@ maybe_specialize_call_and_goals(RevGoals
     Goal0 = hlds_goal(GoalExpr0, _),
     GoalExpr0 = plain_call(PredId, ProcId, CallVars, _, _, _),
 
-    module_info_pred_info(!.SpecInfo ^ spec_module_info, PredId, PredInfo),
+    ModuleInfo = !.SpecInfo ^ spec_module_info,
+    module_info_pred_info(ModuleInfo, PredId, PredInfo),
+    module_info_proc_info(ModuleInfo, PredId, ProcId, ProcInfo),
+    DoneParProcs = values(!.SpecInfo ^ spec_done_procs),
+    PredProcId = proc(PredId, ProcId),
     % We cannot push wait or signal goals into a procedure whose code we don't
     % have access to.
     % XXX: We have access to opt_imported procedures. The reason why this test
     % does not look for them is that we used to run dep_par_conj only *after*
     % mercury_compile used to invoke dead_proc_elim to delete opt_imported
     % procedures.
-    ( list.member(ProcId, pred_info_non_imported_procids(PredInfo)) ->
+    (
+        list.member(ProcId, pred_info_non_imported_procids(PredInfo)),
+
+        % These tests avoid some problems we've had with pushing signals and
+        % waits into callees.
+        % + Don't push signals or waits into any procedure that contains a new
+        %   parallel conjunction.
+        proc_info_get_has_parallel_conj(ProcInfo, no),
+        % + Don't push signals or waits into any procedure that has already
+        %   been specialised by pushing some signals or waits into it.
+        not (
+            member(DoneParProc, DoneParProcs),
+            PredProcId = DoneParProc ^ new_ppid
+        )
+    ->
         % Look for a contiguous sequence of wait goals at the start of
         % RevGoals (i.e. the goals immediately before Goal0) and for a
         % contiguous sequence of signal goals at the start of FwdGoals0
@@ -1815,7 +1833,6 @@ maybe_specialize_call_and_goals(RevGoals
         % the wait goals represented by PushedWaitPairs, and similarly
         % for SignalGoals.
 
-        PredProcId = proc(PredId, ProcId),
         find_relevant_pushable_wait_goals(RevGoals0, PredProcId,
             CallVars, PushedWaitPairs, UnPushedWaitGoals, RevGoals1,
             !SpecInfo),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 489 bytes
Desc: Digital signature
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20110124/b07a34dd/attachment.sig>


More information about the reviews mailing list