[m-dev.] for review: time profiling for the MLDS

Peter Ross peter.ross at miscrit.be
Thu Aug 3 20:17:39 AEST 2000


Hi,

For trd to review.

===================================================================


Estimated hours taken: 1

Get time profiling working for the MLDS backend.

compiler/mlds_to_c.m:
    If time profiling is turned on output an instruction to record which
    procedure we are in at the start of each procedure and any reentry
    points to the procedure.
    
runtime/mercury.h:
    Include the correct header files when time profiling is enabled.

runtime/mercury_prof.h:
    Define MR_set_prof_current_proc.


Index: compiler/mlds_to_c.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_c.m,v
retrieving revision 1.47
diff -u -r1.47 mlds_to_c.m
--- compiler/mlds_to_c.m	2000/08/02 14:13:05	1.47
+++ compiler/mlds_to_c.m	2000/08/03 10:05:34
@@ -1165,6 +1165,7 @@
 		io__write_string("{\n"),
 
 		{ FuncInfo = func_info(Name, Signature) },
+		mlds_maybe_output_time_profile_instr(Context, Indent + 1, Name),
 
 		%
 		% If the procedure body contains any optimizable tailcalls,
@@ -1979,7 +1980,8 @@
 			mlds_indent(Context, Indent + 1),
 			io__write_string("return;\n")
 		;
-			[]
+			mlds_maybe_output_time_profile_instr(Context,
+					Indent + 1, Name)
 		),
 		mlds_indent(Indent),
 		io__write_string("}\n")
@@ -2150,6 +2152,28 @@
 		mlds_output_bracketed_rval(CalleeFuncRval),
 		io__write_string(", "),
 		mlds_output_fully_qualified_name(CallerName),
+		io__write_string(");\n")
+	;
+		[]
+	).
+
+	%
+	% If time profiling is turned on output an instruction which
+	% informs the runtime which procedure we are currently located
+	% in.
+	%
+:- pred mlds_maybe_output_time_profile_instr(mlds__context::in,
+		indent::in, mlds__qualified_entity_name::in,
+		io__state::di, io__state::uo) is det.
+
+mlds_maybe_output_time_profile_instr(Context, Indent, Name) -->
+	globals__io_lookup_bool_option(profile_time, ProfileTime),
+	(
+		{ ProfileTime = yes }
+	->
+		mlds_indent(Context, Indent),
+		io__write_string("MR_set_prof_current_proc("),
+		mlds_output_fully_qualified_name(Name),
 		io__write_string(");\n")
 	;
 		[]
Index: runtime/mercury.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury.h,v
retrieving revision 1.16
diff -u -r1.16 mercury.h
--- runtime/mercury.h	2000/08/02 14:13:11	1.16
+++ runtime/mercury.h	2000/08/03 10:05:57
@@ -35,15 +35,16 @@
   #endif
 #endif
 
-#ifdef PROFILE_CALLS
-  #include "mercury_prof.h"		/* for MR_prof_call_profile */
+#if defined(PROFILE_CALLS) || defined(PROFILE_TIME)
+  #include "mercury_prof.h"		/* for MR_prof_call_profile	*/
+					/* and MR_set_prof_current_proc	*/
 #endif
 
 #ifdef PROFILE_MEMORY
   #include "mercury_heap_profile.h"	/* for MR_record_allocation */
 #endif
 
-#if defined(PROFILE_CALLS) || defined(PROFILE_MEMORY)
+#if defined(PROFILE_CALLS) || defined(PROFILE_MEMORY) || defined(PROFILE_TIME)
   #include "mercury_goto.h"		/* for MR_init_entry */
 #endif
 
Index: runtime/mercury_prof.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_prof.h,v
retrieving revision 1.4
diff -u -r1.4 mercury_prof.h
--- runtime/mercury_prof.h	2000/08/02 14:13:12	1.4
+++ runtime/mercury_prof.h	2000/08/03 10:05:58
@@ -37,6 +37,7 @@
 ** being executed when a profiling interrupt occurs.
 */
 
+#define MR_set_prof_current_proc(target)	set_prof_current_proc(target)
 #ifdef PROFILE_TIME
   #define set_prof_current_proc(target)		\
 		(MR_prof_current_proc = (target))

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