[m-dev.] for review: no label names in the label table

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Apr 26 13:08:21 AEST 1999


On 25-Apr-1999, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> 
> Include label names in the label table only if needed. This reduces the
> size of the object file for queens.m with debugging enabled by 18%.
> 
> runtime/mercury_conf_param.h:
> 	Define and document MR_INSERT_LABEL_NAMES, which is turned on
> 	only when we want label names to be included in the label table.

It wasn't clear to me from the documentation that you added here whether
this applied only to internal labels or whether it applied to entry
points as well.

> 	This occurs when some forms of low level debugging are turned on,
> 	and also with profiling (although I am not sure *exactly* what
> 	profiling needs the label names for).

Profiling needs the names of procedure entry labels so that it can print them
out in the `Prof.Decls' file, which is used by the profiler to map
the addresses for which we record profiling information to names.
Search for "label" in runtime/mercury_prof.{c,h} and read the comments
there.  (Note that the profiler demangles the label names before printing
them, of course.)

I'm pretty sure that profiling does not need the names of internal labels.
So it might be better to have two different configuration macros, one
for procedure entry labels and one for internal labels.

> +++ mercury_agc_debug.c	1999/04/25 10:25:53
> @@ -87,7 +87,11 @@
>  	*/
>  
>  	while (MR_DETISM_DET_STACK(entry_layout->MR_sle_detism)) {
> +		if (label->i_name != NULL) {
>  		fprintf(stderr, "    label: %s\n", label->i_name);
> +		} else {
> +			fprintf(stderr, "    label: unknown\n");
> +		}

The first call to printf() should be intended another tab.

> +++ mercury_goto.h	1999/04/25 10:07:47
> @@ -25,6 +25,20 @@
>  				&(paste(mercury_data__layout__,label))
>  
>  /*
> +** Passing the name of a label to MR_insert_{internal,entry}_label
> +** causes that name to be included in the executable as static readonly data.
> +** Since label names are quite big, we include them only when needed.
> +*/
> +
> +#if defined(MR_INSERT_LABEL_NAMES)
> +#define	MR_insert_internal(n, a, l)	MR_insert_internal_label(n, a, l)
> +#define	MR_insert_entry(n, a, l)	MR_insert_entry_label(n, a, l)
> +#else
> +#define	MR_insert_internal(n, a, l)	MR_insert_internal_label(NULL, a, l)
> +#define	MR_insert_entry(n, a, l)	MR_insert_entry_label(NULL, a, l)
> +#endif

The #defines here should be intended by two spaces.

> +++ mercury_label.c	1999/04/25 10:18:09
>  #ifdef	MR_LOWLEVEL_DEBUG
>  	if (MR_progdebug) {
> +		/*
> +		** We can't assume that MR_LOWLEVEL_DEBUG was turned on
> +		** in the code that generated the call to this function
> +		** just because MR_LOWLEVEL_DEBUG is turned on here.
> +		*/
> +		if (name != NULL) {
>  		printf("recording entry label %s at %p\n", name, addr);
> +		} else {
> +			printf("recording entry label at %p\n", addr);
> +		}

The first call to printf() should be intended another tab.

> +++ mercury_misc.c	1999/04/25 10:23:27
> @@ -434,12 +434,16 @@
>  
>  	internal = MR_lookup_internal_by_addr(w);
>  	if (internal != NULL) {
> +		if (internal->i_name != NULL) {
>  		printf("label %s (%p)\n", internal->i_name, w);
>  	} else {
> +			printf("label (%p)\n", w);
> +		}
> +	} else {

You need to fix the indentation here too.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list