[m-dev.] diff: simplify MR_trace_real interface

Zoltan Somogyi zs at cs.mu.OZ.AU
Wed Sep 29 14:33:19 AEST 1999


Estimated hours taken: 3

Simplify the interface between the runtime system and the trace subsystem
by centralizing processing in the trace subsystem. Previously, the lookup
of the stack slots containing the depth and the call event numbers were
done in the runtime; now it is done in the trace subsystem.

runtime/mercury_wrapper.[ch]:
runtime/mercury_trace_base.[ch]:
runtime/mercury_init.h:
	Change the signature of MR_trace_{real,fake} and of the function
	pointer that points to one of them, to remove the depth and call
	sequence number arguments.

	This removes duplicated code from MR_trace and MR_trace_struct
	to compute those arguments. By removing the need for some argument
	shuffling as well, it ought to make the code faster. (The depth
	and sequence number are now usually used only inside MR_trace_real;
	they are only passed to other functions if the event requires
	interaction.)

trace/mercury_trace.c:
	Move the code for computing the depth and call sequence number here.

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/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 profiler
cvs diff: Diffing runtime
Index: runtime/mercury_init.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_init.h,v
retrieving revision 1.15
diff -u -b -r1.15 mercury_init.h
--- mercury_init.h	1999/05/30 03:54:53	1.15
+++ mercury_init.h	1999/09/21 02:06:40
@@ -148,11 +148,11 @@
 
 /* in runtime/mercury_trace_base.c */
 extern	Code	*MR_trace_fake(const MR_Stack_Layout_Label *, MR_Trace_Port,
-			Unsigned, Unsigned, const char *, int);
+			const char *, int);
 
 /* in trace/mercury_trace.c */
 extern	Code	*MR_trace_real(const MR_Stack_Layout_Label *, MR_Trace_Port,
-			Unsigned, Unsigned, const char *, int);
+			const char *, int);
 
 /* in trace/mercury_trace_tables.c */
 extern	void	MR_register_module_layout_real(const MR_Module_Layout *);
Index: runtime/mercury_trace_base.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_trace_base.c,v
retrieving revision 1.18
diff -u -b -r1.18 mercury_trace_base.c
--- mercury_trace_base.c	1999/09/27 05:20:50	1.18
+++ mercury_trace_base.c	1999/09/29 02:45:20
@@ -105,111 +105,29 @@
 Code *
 MR_trace_struct(const MR_Trace_Call_Info *trace_call_info)
 {
-	/*
-	** You can change the 0 to 1 in the #if if you suspect that
-	** MR_trace and MR_trace_struct have diverged.
-	*/
-
-#if 0
-
-	return MR_trace(trace_call_info->MR_trace_sll,
-		trace_call_info->MR_trace_port,
-		trace_call_info->MR_trace_path,
-		trace_call_info->MR_trace_max_r_num);
-
-#else
-
-	const MR_Stack_Layout_Label	*layout;
-	Integer				maybe_from_full;
-	Unsigned			seqno;
-	Unsigned			depth;
-
-	/*
-	** WARNING WARNING WARNING
-	**
-	** The code of this function is duplicated from MR_trace,
-	** modulo references to the arguments. Any changes here
-	** must also be done there as well.
-	**
-	** This duplication is for efficiency.
-	*/
-
 	if (! MR_trace_enabled) {
 		return NULL;
 	}
-
-	/* in case MR_sp or MR_curfr is transient */
-	restore_transient_registers();
-
-	layout = trace_call_info->MR_trace_sll;
-	maybe_from_full = layout->MR_sll_entry->MR_sle_maybe_from_full;
-	if (MR_DETISM_DET_STACK(layout->MR_sll_entry->MR_sle_detism)) {
-		if (maybe_from_full > 0 && ! MR_stackvar(maybe_from_full)) {
-			return NULL;
-		}
-
-		seqno = (Unsigned) MR_call_num_stackvar(MR_sp);
-		depth = (Unsigned) MR_call_depth_stackvar(MR_sp);
-	} else {
-		if (maybe_from_full > 0 && ! MR_framevar(maybe_from_full)) {
-			return NULL;
-		}
 
-		seqno = (Unsigned) MR_call_num_framevar(MR_curfr);
-		depth = (Unsigned) MR_call_depth_framevar(MR_curfr);
-	}
-
-	return (*MR_trace_func_ptr)(layout, trace_call_info->MR_trace_port,
-			seqno, depth, trace_call_info->MR_trace_path,
+	return (*MR_trace_func_ptr)(trace_call_info->MR_trace_sll,
+			trace_call_info->MR_trace_port,
+			trace_call_info->MR_trace_path,
 			trace_call_info->MR_trace_max_r_num);
-
-#endif
 }
 
 Code *
 MR_trace(const MR_Stack_Layout_Label *layout, MR_Trace_Port port,
-	const char * path, int max_r_num)
+	const char *path, int max_r_num)
 {
 	Integer		maybe_from_full;
 	Unsigned	seqno;
 	Unsigned	depth;
 
-	/*
-	** WARNING WARNING WARNING
-	**
-	** The code of this function is duplicated in MR_trace_struct,
-	** modulo references to the arguments. Any changes here
-	** must also be done there as well.
-	**
-	** This duplication is for efficiency.
-	*/
-
 	if (! MR_trace_enabled) {
 		return NULL;
 	}
-
-	/* in case MR_sp or MR_curfr is transient */
-	restore_transient_registers();
-
-	maybe_from_full = layout->MR_sll_entry->MR_sle_maybe_from_full;
-	if (MR_DETISM_DET_STACK(layout->MR_sll_entry->MR_sle_detism)) {
-		if (maybe_from_full > 0 && ! MR_stackvar(maybe_from_full)) {
-			return NULL;
-		}
-
-		seqno = (Unsigned) MR_call_num_stackvar(MR_sp);
-		depth = (Unsigned) MR_call_depth_stackvar(MR_sp);
-	} else {
-		if (maybe_from_full > 0 && ! MR_framevar(maybe_from_full)) {
-			return NULL;
-		}
-
-		seqno = (Unsigned) MR_call_num_framevar(MR_curfr);
-		depth = (Unsigned) MR_call_depth_framevar(MR_curfr);
-	}
 
-	return (*MR_trace_func_ptr)(layout, port, seqno, depth,
-			path, max_r_num);
+	return (*MR_trace_func_ptr)(layout, port, path, max_r_num);
 }
 
 void
@@ -229,7 +147,7 @@
 
 Code *
 MR_trace_fake(const MR_Stack_Layout_Label *layout, MR_Trace_Port port,
-	Unsigned seqno, Unsigned depth, const char * path, int max_r_num)
+	const char *path, int max_r_num)
 {
 	MR_tracing_not_enabled();
 	/*NOTREACHED*/
Index: runtime/mercury_trace_base.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_trace_base.h,v
retrieving revision 1.8
diff -u -b -r1.8 mercury_trace_base.h
--- mercury_trace_base.h	1999/09/20 08:17:04	1.8
+++ mercury_trace_base.h	1999/09/21 02:06:41
@@ -83,7 +83,7 @@
 extern	Code	*MR_trace_struct(const MR_Trace_Call_Info *trace_call_info);
 
 extern	Code	*MR_trace_fake(const MR_Stack_Layout_Label *, MR_Trace_Port,
-			Unsigned, Unsigned, const char *, int);
+			const char *, int);
 
 /*
 ** MR_trace_init() is called from mercury_runtime_init()
Index: runtime/mercury_wrapper.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_wrapper.c,v
retrieving revision 1.43
diff -u -b -r1.43 mercury_wrapper.c
--- mercury_wrapper.c	1999/09/27 05:20:53	1.43
+++ mercury_wrapper.c	1999/09/28 08:13:45
@@ -184,7 +184,7 @@
 Code	*MR_library_trace_browser;
 
 Code	*(*MR_trace_func_ptr)(const MR_Stack_Layout_Label *, MR_Trace_Port,
-		Unsigned, Unsigned, const char *, int);
+		const char *, int);
 
 void	(*MR_register_module_layout)(const MR_Module_Layout *);
 
Index: runtime/mercury_wrapper.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_wrapper.h,v
retrieving revision 1.22
diff -u -b -r1.22 mercury_wrapper.h
--- mercury_wrapper.h	1999/05/30 03:54:56	1.22
+++ mercury_wrapper.h	1999/09/21 02:06:41
@@ -109,8 +109,7 @@
 */
 
 extern	Code		*(*MR_trace_func_ptr)(const MR_Stack_Layout_Label *,
-				MR_Trace_Port, Unsigned, Unsigned,
-				const char *, int);
+				MR_Trace_Port, const char *, int);
 
 extern	void		(*MR_register_module_layout)(const MR_Module_Layout *);
 
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/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
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
Index: trace/mercury_trace.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace.c,v
retrieving revision 1.12
diff -u -b -r1.12 mercury_trace.c
--- mercury_trace.c	1999/09/15 17:53:41	1.12
+++ mercury_trace.c	1999/09/29 02:46:01
@@ -57,8 +57,7 @@
 };
 
 Code 		*MR_trace_real(const MR_Stack_Layout_Label *layout,
-			MR_Trace_Port port, Unsigned seqno, Unsigned depth,
-			const char *path, int max_r_num);
+			MR_Trace_Port port, const char *path, int max_r_num);
 static	Code	*MR_trace_event(MR_Trace_Cmd_Info *cmd, bool interactive,
 			const MR_Stack_Layout_Label *layout,
 			MR_Trace_Port port, Unsigned seqno, Unsigned depth,
@@ -81,11 +80,34 @@
 
 Code *
 MR_trace_real(const MR_Stack_Layout_Label *layout, MR_Trace_Port port,
-	Unsigned seqno, Unsigned depth, const char *path, int max_r_num)
+	const char *path, int max_r_num)
 {
+	Integer		maybe_from_full;
+	Unsigned	seqno;
+	Unsigned	depth;
 	MR_Spy_Action	action;
 	bool		match;
 
+	/* in case MR_sp or MR_curfr is transient */
+	restore_transient_registers();
+
+	maybe_from_full = layout->MR_sll_entry->MR_sle_maybe_from_full;
+	if (MR_DETISM_DET_STACK(layout->MR_sll_entry->MR_sle_detism)) {
+		if (maybe_from_full > 0 && ! MR_stackvar(maybe_from_full)) {
+			return NULL;
+		}
+
+		seqno = (Unsigned) MR_call_num_stackvar(MR_sp);
+		depth = (Unsigned) MR_call_depth_stackvar(MR_sp);
+	} else {
+		if (maybe_from_full > 0 && ! MR_framevar(maybe_from_full)) {
+			return NULL;
+		}
+
+		seqno = (Unsigned) MR_call_num_framevar(MR_curfr);
+		depth = (Unsigned) MR_call_depth_framevar(MR_curfr);
+	}
+
 	MR_trace_event_number++;
 
 #ifdef	MR_TRACE_HISTOGRAM
@@ -459,4 +481,3 @@
 	*succeeded = FALSE;
 	return 0;
 }
-
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