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

Zoltan Somogyi zs at cs.mu.OZ.AU
Sun Apr 25 19:13:48 AEST 1999


For review by anyone whose code uses the label table.

Estimated hours taken: 3

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

runtime/mercury_goto.h:
	If MR_INSERT_LABEL_NAMES is not defined, always pass a NULL pointer
	instead of the label name to the functions that insert into the label
	table. By ignoring the label names, we prevent the inclusion of those
	long names in the rodata section of the object file.

runtime/mercury_label.h:
	Document that the names may be NULL.

runtime/mercury_accurate_gc.c:
runtime/mercury_label.c:
runtime/mercury_misc.c:
	Don't assume that label names are always valid.

Zoltan.

cvs diff: Diffing .
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/exceptions
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing library
cvs diff: Diffing lp_solve
cvs diff: Diffing profiler
cvs diff: Diffing runtime
cvs diff: cannot find runtime/imp.h
Index: runtime/mercury_accurate_gc.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_accurate_gc.c,v
retrieving revision 1.4
diff -u -b -u -r1.4 mercury_accurate_gc.c
--- mercury_accurate_gc.c	1998/11/11 02:14:14	1.4
+++ mercury_accurate_gc.c	1999/04/25 10:27:26
@@ -106,16 +106,30 @@
 		** This means we have reached some handwritten code that has
 		** no further information about the stack frame.
 		*/
-		fprintf(stderr, "Mercury runtime: LABEL: %s has no stack"
-				"layout info\n", entry_label->e_name);
+		fprintf(stderr, "Mercury runtime: the label ");
+		if (entry_label->e_name != NULL) {
+			fprintf(stderr, "%s has no stack layout info\n",
+				entry_label->e_name);
+		} else {
+			fprintf(stderr, "at address %p "
+				"has no stack layout info\n",
+				entry_label->e_addr);
+		}
+
 		fprintf(stderr, "Mercury runtime: Trying to continue...\n");
 		return;
 	}
 
 #ifdef MR_DEBUG_AGC_SCHEDULING
+	if (entry_label->e_name != NULL) {
 	fprintf(stderr, "scheduling called at: %s (%ld %lx)\n",
 		entry_label->e_name, (long) entry_label->e_addr,
 		(long) entry_label->e_addr);
+	} else {
+		fprintf(stderr, "scheduling called at: (%ld %lx)\n",
+			(long) entry_label->e_addr,
+			(long) entry_label->e_addr);
+	}
 	fflush(NULL);
 #endif
 
Index: runtime/mercury_agc_debug.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_agc_debug.c,v
retrieving revision 1.8
diff -u -b -u -r1.8 mercury_agc_debug.c
--- mercury_agc_debug.c	1998/11/11 02:14:15	1.8
+++ 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");
+		}
 
 		if (success_ip == MR_stack_trace_bottom) {
 			break;
Index: runtime/mercury_conf_param.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_conf_param.h,v
retrieving revision 1.20
diff -u -b -u -r1.20 mercury_conf_param.h
--- mercury_conf_param.h	1999/04/22 06:13:58	1.20
+++ mercury_conf_param.h	1999/04/25 10:18:21
@@ -236,6 +236,21 @@
 #endif
 
 /*
+** MR_INSERT_LABEL_NAMES -- the label table should contain the names of labels
+**			    as well as their addresses and layouts.
+**			    (label names are quite big, so prefer not to
+**			    include them unless they are necessary).
+*/
+
+#ifdef MR_INSERT_LABEL_NAMES
+  #error "MR_INSERT_LABEL_NAMES should not be defined on the command line"
+#endif
+#if defined(PROFILE_CALLS) || defined(MR_LOWLEVEL_DEBUG) \
+		|| defined(MR_DEBUG_AGC_SCHEDULING)
+  #define MR_INSERT_LABEL_NAMES
+#endif
+
+/*
 ** MR_NEED_INITIALIZATION_AT_START -- the module specific initialization code
 **				      must be run before any Mercury code
 **				      is run.
Index: runtime/mercury_goto.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_goto.h,v
retrieving revision 1.18
diff -u -b -u -r1.18 mercury_goto.h
--- mercury_goto.h	1998/11/12 03:16:25	1.18
+++ 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
+
+/*
 ** Taking the address of a label can inhibit gcc's optimization,
 ** because it assumes that anything can jump there.
 ** Therefore we want to do it only if we're debugging,
@@ -37,16 +51,16 @@
 ** a layout structure, use the _sl variant.
 */
 
-#define make_label_ai(n, a, l)		MR_insert_internal_label(n, a, NULL)
-#define make_label_sl(n, a, l)		MR_insert_internal_label(n, a, \
+#define make_label_ai(n, a, l)		MR_insert_internal(n, a, NULL)
+#define make_label_sl(n, a, l)		MR_insert_internal(n, a, \
 						MR_INTERNAL_LAYOUT(l))
 
-#define make_local_ai(n, a, l)		MR_insert_entry_label(n, a, NULL)
-#define make_local_sl(n, a, l)		MR_insert_entry_label(n, a, \
+#define make_local_ai(n, a, l)		MR_insert_entry(n, a, NULL)
+#define make_local_sl(n, a, l)		MR_insert_entry(n, a, \
 						MR_ENTRY_LAYOUT(l))
 
-#define make_entry_ai(n, a, l)		MR_insert_entry_label(n, a, NULL)
-#define make_entry_sl(n, a, l)		MR_insert_entry_label(n, a, \
+#define make_entry_ai(n, a, l)		MR_insert_entry(n, a, NULL)
+#define make_entry_sl(n, a, l)		MR_insert_entry(n, a, \
 						MR_ENTRY_LAYOUT(l))
 
 #if defined(MR_INSERT_LABELS)
Index: runtime/mercury_label.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_label.c,v
retrieving revision 1.12
diff -u -b -u -r1.12 mercury_label.c
--- mercury_label.c	1999/03/11 06:32:59	1.12
+++ mercury_label.c	1999/04/25 10:18:09
@@ -94,12 +94,23 @@
 	MR_do_init_label_tables();
 
 #ifdef	PROFILE_CALLS
-	if (MR_profiling) MR_prof_output_addr_decl(name, addr);
+	if (MR_profiling) {
+		MR_prof_output_addr_decl(name, addr);
+	}
 #endif
 
 #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);
+		}
 	}
 #endif
 
@@ -201,7 +212,17 @@
 
 #ifdef	MR_LOWLEVEL_DEBUG
 	if (MR_progdebug) {
-		printf("inserting internal label %s at %p\n", name, addr);
+		/*
+		** 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("inserting internal label %s at %p\n",
+				name, addr);
+		} else {
+			printf("inserting internal label at %p\n", addr);
+		}
 	}
 #endif
 
Index: runtime/mercury_misc.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_misc.c,v
retrieving revision 1.16
diff -u -b -u -r1.16 mercury_misc.c
--- mercury_misc.c	1999/03/26 04:44:00	1.16
+++ 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 {
 #ifdef	MR_DEBUG_GOTOS
 		MR_Entry	*entry;
 		entry = MR_prev_entry_by_addr(w);
-		if (entry->e_addr == w) {
+		if (entry->e_addr == w && entry->e_name != NULL) {
 			printf("label %s (%p)\n", entry->e_name, w);
 		} else {
 			printf("label UNKNOWN (%p)\n", w);
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing trial
cvs diff: Diffing util
--------------------------------------------------------------------------
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