[m-dev.] for review again: reorganize label table, reduce executable sizes

Zoltan Somogyi zs at cs.mu.OZ.AU
Fri Jul 3 10:19:08 AEST 1998


> > +in the environment variable MERCURY_OPTIONS
> > +when you run the program to be profiled.
> > + at c (See the environment variables section below.)
> 
> Why is that line commented out?

Because I thought that the sentence above and the following paragraph
gave every detail relevant to profiling; the environment variables section
does not actually have any more information except for the names of the
C system macros (ITIMER_REAL etc).

> > -Currently, the @samp{-Tv} and @samp{-Tp} options don't work on Windows,
> > -so on Windows you must explicitly specify @samp{-Tr}.
> 
> I don't think you should delete that.

I didn't, I moved it to the environment variable section. However, I will leave
it here as well, with a comment in both places about the duplicate maintenance
required.

I made the other changes you suggested, and one other, whose log message
fragment is

	Move the #ifdefs around the -P option, so that programs not
	compiled with MR_THREAD_SAFE will accept but ignore the option,
	instead of aborting with the usage message.

The relative diffs are below.

Zoltan.

--- user_guide.texi.was	Fri Jul  3 11:38:45 1998
+++ user_guide.texi	Fri Jul  3 12:13:11 1998
@@ -1187,10 +1187,13 @@
 
 You can control whether profiling measures
 real (elapsed) time, user time plus system time, or user time only,
-by including the options -Tr, -Tp, or -Tv respectively
+by including the options @samp{-Tr}, @samp{-Tp}, or @samp{-Tv} respectively
 in the environment variable MERCURY_OPTIONS
 when you run the program to be profiled.
 @c (See the environment variables section below.)
+Currently, the @samp{-Tp} and @samp{-Tv} options don't work on Windows,
+so on Windows you must explicitly specify @samp{-Tr}.
+ at c the above sentence is duplicated below
 
 The default is user time plus system time,
 which counts all time spent executing the process,
@@ -2806,7 +2809,12 @@
 @table @code
 
 @c @item -a
+ at c If given force a redo when the entry point procedure succeeds;
+ at c this is useful for benchmarking when this procedure is model_non.
+
 @c @item -c
+ at c Check how much of the space reserved for local variables
+ at c by mercury_engine.c was actually used.
 
 @item -C @var{size}
 Tells the runtime system
@@ -2816,40 +2824,54 @@
 to differ as much as possible modulo this size.
 
 @c @item -d @var{debugflag}
+ at c Sets a low-level debugging flag.
+ at c These flags are consulted only if
+ at c the runtime was compiled with the approriate definitions;
+ at c most of them depend on MR_LOWLEVEL_DEBUG.
+ at c For the meanings of the debugflag parameters,
+ at c see process_options() in mercury_wrapper.c
+ at c and do a grep for the corresponding variable.
 
 @sp 1
 @item -D @var{debugger}
 Enables execution tracing of the program,
 via the internal debugger if @var{debugger} is @samp{i}
 and via the external debugger if @var{debugger} is @samp{e}.
- at c The mdb script works by including -Di in MERCURY_OPTIONS.
+(The mdb script works by including -Di in MERCURY_OPTIONS.)
+The external debugger is not yet available.
 
 @sp 1
 @item -p
-Disables profiling in an executable built in a profiling grade.
+Disables profiling.
+This only has an effect if the executable was built in a profiling grade.
 
 @sp 1
 @item -P @var{num}
 Tells the runtime system to use @var{num} threads
-if the program was build in a parallel grade.
+if the program was built in a parallel grade.
 
- at c @item -r
+ at c @item -r @var{num}
+ at c Repeats execution of the entry point procedure @var{num} times,
+ at c to enable accurate timing.
 
 @sp 1
 @item -s @var{area} @var{size}
-Tells the runtime system to set the size of one area of the runtime system,
-where @var{area} must be one of @samp{h} (standing for heap),
+Sets the size of one of the runtime system's memory areas.
+ at var{area} must be one of @samp{h} (standing for heap),
 @samp{d} (standing for deterministic stack),
 @samp{n} (standing for nondeterministic stack)
-and, in grades with trailing, @samp{t} (standing for trail),
-to @var{size} kilobytes.
+and, in grades with trailing, @samp{t} (standing for trail).
+ at var{size} specifies the size of that area, in kilobytes.
 
 @c @item -t
+ at c Tells the runtime system to measure the time taken by
+ at c the (required number of repetitions of) the program,
+ at c and to print the result of this time measurement.
 
 @sp 1
 @item -T @var{time_method}
-If the executable is in a grade that includes time profiling,
-specifies what time is counted in the profile.
+If the executable was compiled in a grade that includes time profiling,
+this option specifies what time is counted in the profile.
 @var{time_method} must have one of the following values:
 
 @sp 1
@@ -2866,9 +2888,15 @@
 @sp 1
 Currently, the @samp{-Tp} and @samp{-Tv} options don't work on Windows,
 so on Windows you must explicitly specify @samp{-Tr}.
+ at c the above sentence is duplicated above
 
 @c @item -x
+ at c Tells the Boehm collector not to perform any garbage collection.
+
 @c @item -z @var{area} @var{size}
+ at c Sets the size of the redzone on one of the runtime system's memory areas.
+ at c The @var{area} and @var{size} parameters have the same meaning
+ at c as they do for the @samp{-s} option.
 
 @end table
 
diff -u JUL3/mercury_label.c ./mercury_label.c
--- JUL3/mercury_label.c	Fri Jul  3 11:59:22 1998
+++ ./mercury_label.c	Fri Jul  3 12:00:30 1998
@@ -75,7 +75,8 @@
 		entry_array_next = 0;
 		entry_array_size = INIT_ENTRY_SIZE;
 		entry_array_sorted = TRUE;
-		entry_array = malloc(entry_array_size * sizeof(MR_Entry));
+		entry_array = checked_malloc(entry_array_size
+					* sizeof(MR_Entry));
 #endif
 
 		init_table(internal_addr_table);
@@ -176,7 +177,7 @@
 	if (entry_array[lo].e_addr < addr) {
 		return &entry_array[lo];
 	} else {
-		return &entry_array[lo-1];
+		return &entry_array[lo - 1];
 	}
 }
 
diff -u JUL3/mercury_label.h ./mercury_label.h
--- JUL3/mercury_label.h	Fri Jul  3 11:59:22 1998
+++ ./mercury_label.h	Fri Jul  3 12:01:50 1998
@@ -59,14 +59,14 @@
 extern	void		MR_do_init_label_tables(void);
 
 #ifdef	MR_NEED_ENTRY_LABEL_INFO
-extern	void		MR_insert_entry_label(const char *name, Code *addr,
+  extern void		MR_insert_entry_label(const char *name, Code *addr,
 				const MR_Stack_Layout_Entry *entry_layout);
 #else
-#define	MR_insert_entry_label(n, a, l)	/* nothing */
+  #define MR_insert_entry_label(n, a, l)	/* nothing */
 #endif	/* not MR_NEED_ENTRY_LABEL_INFO */
 
 #ifdef	MR_NEED_ENTRY_LABEL_ARRAY
-extern	MR_Entry	*MR_prev_entry_by_addr(const Code *addr);
+  extern MR_Entry	*MR_prev_entry_by_addr(const Code *addr);
 #endif	/* MR_NEED_ENTRY_LABEL_ARRAY */
 
 extern	void		MR_insert_internal_label(const char *name, Code *addr,
diff -u JUL3/mercury_table.c ./mercury_table.c
--- JUL3/mercury_table.c	Fri Jul  3 11:59:23 1998
+++ ./mercury_table.c	Fri Jul  3 12:02:01 1998
@@ -131,7 +131,7 @@
 
 	for (i = 0; i < table->ta_size; i++) {
 		for_list (ptr, table->ta_store[i]) {
-			(*f)(ldata(ptr));
+			f(ldata(ptr));
 		}
 	}
 }
diff -u JUL3/mercury_wrapper.c ./mercury_wrapper.c
--- JUL3/mercury_wrapper.c	Fri Jul  3 11:59:23 1998
+++ ./mercury_wrapper.c	Fri Jul  3 12:13:49 1998
@@ -567,16 +567,16 @@
 			MR_profiling = FALSE;
 			break;
 
-#ifdef	MR_THREAD_SAFE
 		case 'P':
-				if (sscanf(optarg, "%u", &MR_num_threads) != 1)
-					usage();
-				
-				if (MR_num_threads < 1)
-					usage();
+#ifdef	MR_THREAD_SAFE
+			if (sscanf(optarg, "%u", &MR_num_threads) != 1)
+				usage();
+
+			if (MR_num_threads < 1)
+				usage();
 
-				break;
 #endif
+			break;
 
 		case 'r':	
 			if (sscanf(optarg, "%d", &repeats) != 1)



More information about the developers mailing list