[m-rev.] diff: fix MLDS --no-special-preds bug

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Dec 11 13:55:37 AEDT 2003


Estimated hours taken: 3
Branches: main

Fix a bug introduced by petdr's Dec 2 bug fix which introduced wrapper
functions for unify and compare procs to unbox their arguments,
which caused the tests/valid/unify_typeinfo_bug test case to fail.

The bug was that with --no-special-preds, we were generating invalid
MLDS code, because the code to introduce wrapper functions assumed
that the function being wrapped was defined in the same module,
but with --no-special-preds, the procedure being wrapped is always
private_builtin.unused/0.

In the case of a procedure with arity zero, the wrapper is not needed
(it's just a tail call), so the simplest fix was to just optimize
that case.

compiler/rtti_to_mlds.m:
	If the procedure being wrapped has arity zero, don't bother to
	generate a wrapper function, since it is not needed.

Workspace: /home/jupiter/fjh/ws-jupiter/mercury
Index: compiler/rtti_to_mlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/rtti_to_mlds.m,v
retrieving revision 1.44
diff -u -d -r1.44 rtti_to_mlds.m
--- compiler/rtti_to_mlds.m	1 Dec 2003 22:31:35 -0000	1.44
+++ compiler/rtti_to_mlds.m	11 Dec 2003 02:26:27 -0000
@@ -1096,9 +1096,17 @@
 	% which unboxes the arguments if necessary.
 	%
 	( univ_to_type(RttiProcIdUniv, RttiProcId) ->
-		NumExtra = 0,
-		gen_wrapper_func_and_initializer(ModuleInfo, NumExtra,
+		( RttiProcId ^ arity = 0 ->
+			% If there are no arguments, then there's no unboxing
+			% to do, so we don't need a wrapper.
+			% (This case can occur with --no-special-preds, where
+			% the procedure will be private_builtin.unused/0.)
+			Init = gen_init_proc_id(ModuleInfo, RttiProcId)
+		;
+			NumExtra = 0,
+			gen_wrapper_func_and_initializer(ModuleInfo, NumExtra,
 				RttiProcId, special_pred, Init, !ExtraDefns)
+		)
 	;
 		error("gen_init_special_pred: cannot extract univ value")
 	).

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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