[m-dev.] diff: fix for MLDS profiling on release branch

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Feb 12 18:57:35 AEDT 2001


Estimated hours taken: 0.5

Fix a bug that broke profiling in MLDS grades on the release branch
(-rversion-0_10_x).

library/exception.m:
        Define function versions of mercury__exception__builtin_catch_3_p_*.
	This was already done on the main branch, in revision 1.42 of
	exception, for the GCC back-end interface.  But it's also needed
	for profiling, so I merged those changes onto the release branch.

Workspace: /home/venus/fjh/ws-venus/mercury
Index: library/exception.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/exception.m,v
retrieving revision 1.37.2.4
diff -u -d -r1.37.2.4 exception.m
--- library/exception.m	2001/02/06 08:46:05	1.37.2.4
+++ library/exception.m	2001/02/12 07:50:26
@@ -557,8 +557,56 @@
 %
 
 :- pragma c_header_code("
+/* protect against multiple inclusion */
+#ifndef MR_HLC_EXCEPTION_GUARD
+#define MR_HLC_EXCEPTION_GUARD
+
 #ifdef MR_HIGHLEVEL_CODE
 
+  #ifdef MR_USE_GCC_NESTED_FUNCTIONS
+  	#define MR_CONT_PARAMS		MR_NestedCont cont
+  	#define MR_CONT_PARAM_TYPES	MR_NestedCont
+  	#define MR_CONT_ARGS		cont
+  #else
+  	#define MR_CONT_PARAMS		MR_Cont cont, void *cont_env
+  	#define MR_CONT_PARAM_TYPES	MR_Cont, void *
+  	#define MR_CONT_ARGS		cont, cont_env
+  #endif
+
+	/* det */
+	void MR_CALL
+	mercury__exception__builtin_catch_3_p_0(MR_Mercury_Type_Info type_info,
+		MR_Pred pred, MR_Pred handler_pred, MR_Box *output);
+
+	/* semidet */
+	bool MR_CALL
+	mercury__exception__builtin_catch_3_p_1(MR_Mercury_Type_Info type_info,
+		MR_Pred pred, MR_Pred handler_pred, MR_Box *output);
+
+	/* cc_multi */
+	void MR_CALL
+	mercury__exception__builtin_catch_3_p_2(MR_Mercury_Type_Info type_info,
+		MR_Pred pred, MR_Pred handler_pred, MR_Box *output);
+
+	/* cc_nondet */
+	bool MR_CALL
+	mercury__exception__builtin_catch_3_p_3(MR_Mercury_Type_Info type_info,
+		MR_Pred pred, MR_Pred handler_pred, MR_Box *output);
+
+	/* multi */
+	void MR_CALL
+	mercury__exception__builtin_catch_3_p_4(MR_Mercury_Type_Info type_info,
+		MR_Pred pred, MR_Pred handler_pred, MR_Box *output,
+		MR_CONT_PARAMS);
+
+	/* nondet */
+	void MR_CALL
+	mercury__exception__builtin_catch_3_p_5(MR_Mercury_Type_Info type_info,
+		MR_Pred pred, MR_Pred handler_pred, MR_Box *output,
+		MR_CONT_PARAMS);
+
+  #ifndef MR_AVOID_MACROS
+
 	/* det ==> model_det */
 	#define mercury__exception__builtin_catch_3_p_0 \
 		mercury__exception__builtin_catch_model_det
@@ -583,9 +631,10 @@
 	#define mercury__exception__builtin_catch_3_p_5 \
 		mercury__exception__builtin_catch_model_non
 
-	void MR_CALL mercury__exception__builtin_throw_1_p_0(MR_Univ);
+  #endif /* !MR_AVOID_MACROS */
 
 	void MR_CALL mercury__exception__builtin_throw_1_p_0(MR_Univ exception);
+
 	void MR_CALL mercury__exception__builtin_catch_model_det(
 		MR_Mercury_Type_Info type_info, MR_Pred pred,
 		MR_Pred handler_pred, MR_Box *output);
@@ -595,18 +644,86 @@
 	void MR_CALL mercury__exception__builtin_catch_model_non(
 		MR_Mercury_Type_Info type_info, MR_Pred pred,
 		MR_Pred handler_pred, MR_Box *output,
-#ifdef MR_USE_GCC_NESTED_FUNCTIONS
-		MR_NestedCont cont
-#else
-		MR_Cont cont, void *cont_env
-#endif
-	);
+		MR_CONT_PARAMS);
+
 #endif /* MR_HIGHLEVEL_CODE */
+
+#endif /* MR_HLC_EXCEPTION_GUARD */
 ").
 
 :- pragma c_code("
 #ifdef MR_HIGHLEVEL_CODE
 
+/*
+** We also need to provide definitions of these builtins
+** as functions rather than as macros.  This is needed
+** (a) in case we take their address, and (b) for the
+** GCC back-end interface.
+*/
+
+#undef mercury__exception__builtin_catch_3_p_0
+#undef mercury__exception__builtin_catch_3_p_1
+#undef mercury__exception__builtin_catch_3_p_2
+#undef mercury__exception__builtin_catch_3_p_3
+#undef mercury__exception__builtin_catch_3_p_4
+#undef mercury__exception__builtin_catch_3_p_5
+
+/* det ==> model_det */
+void MR_CALL
+mercury__exception__builtin_catch_3_p_0(MR_Mercury_Type_Info type_info,
+	MR_Pred pred, MR_Pred handler_pred, MR_Box *output)
+{
+	mercury__exception__builtin_catch_model_det(type_info,
+		pred, handler_pred, output);
+}
+
+/* semidet ==> model_semi */
+bool MR_CALL
+mercury__exception__builtin_catch_3_p_1(MR_Mercury_Type_Info type_info,
+	MR_Pred pred, MR_Pred handler_pred, MR_Box *output)
+{
+	return mercury__exception__builtin_catch_model_semi(type_info,
+		pred, handler_pred, output);
+}
+
+/* cc_multi ==> model_det */
+void MR_CALL
+mercury__exception__builtin_catch_3_p_2(MR_Mercury_Type_Info type_info,
+	MR_Pred pred, MR_Pred handler_pred, MR_Box *output)
+{
+	mercury__exception__builtin_catch_model_det(type_info,
+		pred, handler_pred, output);
+}
+
+/* cc_nondet ==> model_semi */
+bool MR_CALL
+mercury__exception__builtin_catch_3_p_3(MR_Mercury_Type_Info type_info,
+	MR_Pred pred, MR_Pred handler_pred, MR_Box *output)
+{
+	return mercury__exception__builtin_catch_model_semi(type_info,
+		pred, handler_pred, output);
+}
+
+/* multi ==> model_non */
+void MR_CALL
+mercury__exception__builtin_catch_3_p_4(MR_Mercury_Type_Info type_info,
+	MR_Pred pred, MR_Pred handler_pred, MR_Box *output,
+	MR_CONT_PARAMS)
+{
+	mercury__exception__builtin_catch_model_non(type_info,
+		pred, handler_pred, output, MR_CONT_ARGS);
+}
+
+/* multi ==> model_non */
+void MR_CALL
+mercury__exception__builtin_catch_3_p_5(MR_Mercury_Type_Info type_info,
+	MR_Pred pred, MR_Pred handler_pred, MR_Box *output,
+	MR_CONT_PARAMS)
+{
+	mercury__exception__builtin_catch_model_non(type_info,
+		pred, handler_pred, output, MR_CONT_ARGS);
+}
+
 /*---------------------------------------------------------------------------*/
 
 static void
@@ -629,31 +746,16 @@
 	return (*code)((void *) closure, result);
 }
 
-#ifdef MR_USE_GCC_NESTED_FUNCTIONS
-
-static void
-ML_call_goal_non(MR_Mercury_Type_Info type_info,
-	MR_Pred closure, MR_Box *result, MR_NestedCont cont)
-{
-	typedef void MR_CALL NondetFuncType(void *, MR_Box *, MR_NestedCont);
-	NondetFuncType *code = (NondetFuncType *)
-		MR_field(MR_mktag(0), closure, (MR_Integer) 1);
-	(*code)((void *) closure, result, cont);
-}
-
-#else
-
 static void
 ML_call_goal_non(MR_Mercury_Type_Info type_info,
-	MR_Pred closure, MR_Box *result, MR_Cont cont, void *cont_env)
+	MR_Pred closure, MR_Box *result, MR_CONT_PARAMS)
 {
-	typedef void MR_CALL NondetFuncType(void *, MR_Box *, MR_Cont, void *);
+	typedef void MR_CALL NondetFuncType(void *, MR_Box *,
+		MR_CONT_PARAM_TYPES);
 	NondetFuncType *code = (NondetFuncType *)
 		MR_field(MR_mktag(0), closure, (MR_Integer) 1);
-	(*code)((void *) closure, result, cont, cont_env);
+	(*code)((void *) closure, result, MR_CONT_ARGS);
 }
-
-#endif
 
 /*---------------------------------------------------------------------------*/
 

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- 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