[m-rev.] Re: deep profiling grade broken

Zoltan Somogyi zs at csse.unimelb.edu.au
Sun Aug 20 15:33:09 AEST 2006


On 18-Aug-2006, Julien Fischer <juliensf at csse.unimelb.edu.au> wrote:
> The problem can be reduced to:
> 
> 	:- module io.
> 	:- interface.
> 	:- type io.state ---> state(c_pointer).
> 	:- type io.io == io.state.
> 
> (Compile with: mmc -C -O0 --grade asm_fast.gc.profdeep )
> 
> It looks like something is going wrong with the compiler generated
> unification predicate for io.io/0.

> 	Uncaught Mercury exception:
> 	Software Error: llds_out.m: Unexpected: stack var out of range
> 	Stack dump not available in this grade.

This is strange. I can reproduce the problem on aral and ceres, but not
on mundula or my laptop.

On all machines, the unify pred for io.io is initially constructed as

	equiv_type_cast(HeadVar__1_1, Cast_HeadVar1_3)
	equiv_type_cast(HeadVar__2_2, Cast_HeadVar2_4)
	Cast_HeadVar1_3 = Cast_HeadVar2_4

On mundula and alys (my laptop), the last unification is classified as a
complicated unify and transformed into a call, which is handled properly.
On aral and ceres, the last unifications is classified as an atomic unification
to be implemented directly, which causes the abort because the cast headvars,
being of dummy type, are allocated dummy stack slots.

I don't know what the cause of the difference between the two pairs of machines
is, except that it may have to do with the contents of private_builtin (the
pred id of the unify pred for io.io is different on different systems).
However, the following diff should avoid the problem arising in the first
place.

Zoltan.

compiler/unify_proc.m:
	When generating the code of unify and compare predicates, generate
	the same code for types that are equivalent to dummy types (e.g.
	io.io) as for dummy types themselves (e.g. io.state). This is
	to avoid potential problems with the cast versions of head variables
	being allocated to dummy stack slots by the LLDS code generator.

cvs diff: Diffing compiler
Index: compiler/unify_proc.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/unify_proc.m,v
retrieving revision 1.169
diff -u -b -r1.169 unify_proc.m
--- compiler/unify_proc.m	4 Aug 2006 10:51:20 -0000	1.169
+++ compiler/unify_proc.m	20 Aug 2006 05:10:59 -0000
@@ -762,8 +762,14 @@
             )
         ;
             TypeBody = eqv_type(EqvType),
+            ( is_dummy_argument_type(ModuleInfo, EqvType) ->
+                % Treat this type as if it were a dummy type itself.
+                Goal = true_goal_with_context(Context),
+                quantify_clauses_body([H1, H2], Goal, Context, Clauses, !Info)
+            ;
             generate_unify_clauses_eqv_type(EqvType, H1, H2,
                 Context, Clauses, !Info)
+            )
         ;
             TypeBody = solver_type(_, _),
             % If no user defined equality predicate is given,
@@ -963,13 +969,12 @@
             )
         ;
             TypeBody = eqv_type(_Type),
-            % The only place that the index predicate for a type
-            % can ever be called from is the compare predicate
-            % for that type. However, the compare predicate for
-            % an equivalence type never calls the index predicate
-            % for that type; it calls the compare predicate of
-            % the expanded type instead. Therefore the clause body
-            % we are generating should never be invoked.
+            % The only place that the index predicate for a type can ever
+            % be called from is the compare predicate for that type. However,
+            % the compare predicate for an equivalence type never calls
+            % the index predicate for that type; it calls the compare predicate
+            % of the expanded type instead. Therefore the clause body we are
+            % generating should never be invoked.
             unexpected(this_file, "trying to create index proc for eqv type")
         ;
             TypeBody = foreign_type(_),
@@ -1018,8 +1023,14 @@
             )
         ;
             TypeBody = eqv_type(EqvType),
+            ( is_dummy_argument_type(ModuleInfo, EqvType) ->
+                % Treat this type as if it were a dummy type itself.
+                generate_dummy_compare_clauses(Res, H1, H2, Context, Clauses,
+                    !Info)
+            ;
             generate_compare_clauses_eqv_type(EqvType,
                 Res, H1, H2, Context, Clauses, !Info)
+            )
         ;
             TypeBody = foreign_type(_),
             generate_compare_clauses_eqv_type(c_pointer_type,
cvs diff: Diffing compiler/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