[m-rev.] for review: base variable for field access

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Nov 6 17:46:50 AEDT 2003


On 06-Nov-2003, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> compiler/mlds_to_c.m:
> 	When filling in the fields of a newly allocated cell, use a fresh local
> 	variable as the base address for the field references in preference to
> 	lvals that are more expensive to access.

This comment from the log message should also go in the source code.

> +++ compiler/mlds_to_c.m	6 Nov 2003 00:45:34 -0000
> @@ -2838,8 +2838,22 @@
>  	mlds_maybe_output_heap_profile_instr(Context, Indent + 1, Args,
>  			FuncName, MaybeCtorName),
>  
> +	( { Target = var(_, _) } ->
> +		{ Base = lval(Target) }
> +	;
> +		% It doesn't matter what string we pick for BaseVarName,
> +		% as long as its declaration doesn't hide any of the variables
> +		% inside Args. This is not hard to ensure, since the printed
> +		% forms of the variables inside Args all include "__".
> +		{ BaseVarName = "base" },
> +		{ Base = string(BaseVarName) },
>  	mlds_indent(Context, Indent + 1),
> -	mlds_output_lval(Target),
> +		io__write_string("MR_Word "),
> +		io__write_string(BaseVarName),
> +		io__write_string(";\n")

Rather than hard-coding MR_Word here, you should use
mlds_output_type_prefix/suffix:

		mlds_output_type_prefix(Type),
		io__write_string(" "),
		io__write_string(BaseVarName),
		mlds_output_type_suffix(Type),
		io__write_string(";\n")

Might be worth double-checking that it works OK -- and doesn't introduce any
new warnings from the C compiler -- in grade hl.gc and/or when allocating
types that don't get represented as MR_Word, e.g. tuples.

Otherwise, that looks fine.

-- 
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