[m-dev.] diff: partial fix for MLDS profiling bug

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Jan 30 02:44:09 AEDT 2001


Estimated hours taken: 2

Fix a bug that broke profiling in MLDS grades.
(Note that profiling is still broken in MLDS grades,
due to some other bug(s) that still remain.)

library/array.m:
library/builtin.m:
runtime/mercury.c:
	Delete some unnecessary and harmful calls to MR_init_entry()
	for procedures for which we were already automatically
	generating calls to MR_init_entry().  The duplicate calls
	broke profiling, since the profiler aborts if it detects
	duplicate entries in the Prof.Decl file.

library/array.m:
library/builtin.m:
library/private_builtin.m:
library/std_util.m:
library/exception.m:
runtime/mercury.c:
	Document empty initialization functions better.

Workspace: /mnt/hg/home/hg/fjh/mercury
Index: library/array.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/array.m,v
retrieving revision 1.82
diff -u -d -r1.82 array.m
--- library/array.m	2001/01/12 14:08:46	1.82
+++ library/array.m	2001/01/29 15:07:36
@@ -336,8 +336,6 @@
 
 :- pragma foreign_decl("C", "
 #ifdef MR_HIGHLEVEL_CODE
-  #include ""mercury_goto.h""	/* for MR_init_entry */
-
   bool MR_CALL mercury__array__do_unify__array_1_0(
   	MR_Mercury_Type_Info type_info, MR_Box x, MR_Box y);
   bool MR_CALL mercury__array____Unify____array_1_0(
@@ -355,11 +353,17 @@
 
 MR_define_type_ctor_info(array, array, 1, MR_TYPECTOR_REP_ARRAY);
 
+/* forward decl, to suppress gcc -Wmissing-decl warning */
 void sys_init_array_module_builtins(void);
-void sys_init_array_module_builtins(void) {
-	MR_init_entry(mercury__array____Unify____array_1_0);
-	MR_init_entry(mercury__array____Compare____array_1_0);
-	return;
+
+/*
+** This empty initialization function is needed just to
+** match the one that we use for LLDS grades.
+*/
+void
+sys_init_array_module_builtins(void)
+{
+	/* no initialization needed */
 }
 
 bool MR_CALL
Index: library/builtin.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/builtin.m,v
retrieving revision 1.50
diff -u -d -r1.50 builtin.m
--- library/builtin.m	2001/01/01 04:03:49	1.50
+++ library/builtin.m	2001/01/29 15:07:36
@@ -281,8 +281,20 @@
 :- pragma foreign_code("C", "
 
 #ifdef MR_HIGHLEVEL_CODE
-void sys_init_builtin_types_module(void); /* suppress gcc warning */
-void sys_init_builtin_types_module(void) { return; }
+
+/* forward decl, to suppress gcc -Wmissing-decl warning */
+void sys_init_builtin_types_module(void);
+
+/*
+** This empty initialization function is needed just to
+** match the one that we use for LLDS grades.
+*/
+void
+sys_init_builtin_types_module(void)
+{
+	/* no initialization needed */
+}
+
 #else
 
 MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_NOCM(builtin, int, 0,
@@ -963,11 +975,17 @@
 	mercury__builtin__copy_2_p_0(type_info, x, y);
 }
 
+/* forward decl, to suppress gcc -Wmissing-decl warning */
 void sys_init_copy_module(void);
-void sys_init_copy_module(void)
+
+/*
+** This empty initialization function is needed just to
+** match the one that we use for LLDS grades.
+*/
+void
+sys_init_copy_module(void)
 {
-	MR_init_entry(mercury__builtin__copy_2_p_0);
-	MR_init_entry(mercury__builtin__copy_2_p_1);
+	/* no initialization needed */
 }
 
 #else /* ! MR_HIGHLEVEL_CODE */
@@ -1026,8 +1044,20 @@
 :- pragma c_code("
 
 #ifdef MR_HIGHLEVEL_CODE
+
+/* forward decl, to suppress gcc -Wmissing-decl warning */
 void sys_init_unify_c_pointer_module(void);
-void sys_init_unify_c_pointer_module(void) { return; }
+
+/*
+** This empty initialization function is needed just to
+** match the one that we use for LLDS grades.
+*/
+void
+sys_init_unify_c_pointer_module(void)
+{
+	/* no initialization needed */
+}
+
 #else
 
 MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_PRED(builtin, c_pointer, 0,
Index: library/exception.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/exception.m,v
retrieving revision 1.41
diff -u -d -r1.41 exception.m
--- library/exception.m	2001/01/18 01:19:03	1.41
+++ library/exception.m	2001/01/29 15:04:24
@@ -1003,8 +1003,23 @@
 
 :- pragma c_code("
 #ifdef MR_HIGHLEVEL_CODE
+
 void mercury_sys_init_exceptions(void);
 void mercury_sys_init_exceptions(void) { return; }
+
+/* forward decl, to suppress gcc -Wmissing-decl warning */
+void mercury_sys_init_exceptions(void);
+
+/*
+** This empty initialization function is needed just to
+** match the one that we use for LLDS grades.
+*/
+void
+mercury_sys_init_exceptions(void)
+{
+	/* no initialization needed */
+}
+
 #else
 
 /*
Index: library/private_builtin.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/private_builtin.m,v
retrieving revision 1.67
diff -u -d -r1.67 private_builtin.m
--- library/private_builtin.m	2001/01/18 06:05:43	1.67
+++ library/private_builtin.m	2001/01/29 15:02:41
@@ -350,8 +350,20 @@
 :- pragma foreign_code("C", "
 
 #ifdef MR_HIGHLEVEL_CODE
-void sys_init_type_info_module(void); /* suppress gcc -Wmissing-decl warning */
-void sys_init_type_info_module(void) { return; }
+
+/* forward decl, to suppress gcc -Wmissing-decl warning */
+void sys_init_type_info_module(void);
+
+/*
+** This empty initialization function is needed just to
+** match the one that we use for LLDS grades.
+*/
+void
+sys_init_type_info_module(void)
+{
+	/* no initialization needed */
+}
+
 #else
 
 	/*
Index: library/std_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/std_util.m,v
retrieving revision 1.219
diff -u -d -r1.219 std_util.m
--- library/std_util.m	2001/01/17 01:35:00	1.219
+++ library/std_util.m	2001/01/29 15:03:25
@@ -1233,8 +1233,20 @@
 :- pragma foreign_code("C", "
 
 #ifdef MR_HIGHLEVEL_CODE
-void sys_init_unify_type_desc_module(void); /* suppress gcc -Wmissing-decl warning */
-void sys_init_unify_type_desc_module(void) { return; }
+
+/* forward decl, to suppress gcc -Wmissing-decl warning */
+void sys_init_unify_type_desc_module(void);
+
+/*
+** This empty initialization function is needed just to
+** match the one that we use for LLDS grades.
+*/
+void
+sys_init_unify_type_desc_module(void)
+{
+	/* no initialization needed */
+}
+
 #else
 
 MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(std_util, type_desc, 0,
Index: runtime/mercury.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury.c,v
retrieving revision 1.23
diff -u -d -r1.23 mercury.c
--- runtime/mercury.c	2001/01/22 16:08:03	1.23
+++ runtime/mercury.c	2001/01/29 15:23:43
@@ -892,47 +892,53 @@
 INIT mercury_sys_init_mercury_hlc
 ENDINIT
 */
+
+/* forward decl, to suppress gcc -Wmissing-decl warning. */
 void mercury_sys_init_mercury_hlc(void);
-void mercury_sys_init_mercury_hlc(void)
-{
-	MR_init_entry(mercury__builtin__unify_2_p_0);
-	MR_init_entry(mercury__builtin__compare_3_p_0);
-	MR_init_entry(mercury__builtin__compare_3_p_1);
-	MR_init_entry(mercury__builtin__compare_3_p_2);
-	MR_init_entry(mercury__builtin__compare_3_p_3);
 
+void
+mercury_sys_init_mercury_hlc(void)
+{
+	/*
+	** We need to call MR_init_entry() for the unification and comparison
+	** predicates for builtin types.  Note that we don't need to do this
+	** for types such as `c_pointer' which are declared in the library;
+	** this is only needed for types which are automatically predefined
+	** by the type checker.
+	*/
+	
 	MR_init_entry(mercury__builtin____Unify____int_0_0);
 	MR_init_entry(mercury__builtin____Unify____string_0_0);
 	MR_init_entry(mercury__builtin____Unify____float_0_0);
 	MR_init_entry(mercury__builtin____Unify____character_0_0);
 	MR_init_entry(mercury__builtin____Unify____void_0_0);
-	MR_init_entry(mercury__builtin____Unify____c_pointer_0_0);
 	MR_init_entry(mercury__builtin____Unify____func_0_0);
 	MR_init_entry(mercury__builtin____Unify____pred_0_0);
-	MR_init_entry(mercury__std_util____Unify____type_desc_0_0);
-	MR_init_entry(mercury__private_builtin____Unify____type_ctor_info_1_0);
-	MR_init_entry(mercury__private_builtin____Unify____type_info_1_0);
-	MR_init_entry(mercury__private_builtin____Unify____typeclass_info_1_0);
-	MR_init_entry(mercury__private_builtin____Unify____base_typeclass_info_1_0);
 
 	MR_init_entry(mercury__builtin____Compare____int_0_0);
 	MR_init_entry(mercury__builtin____Compare____string_0_0);
 	MR_init_entry(mercury__builtin____Compare____float_0_0);
 	MR_init_entry(mercury__builtin____Compare____character_0_0);
 	MR_init_entry(mercury__builtin____Compare____void_0_0);
-	MR_init_entry(mercury__builtin____Compare____c_pointer_0_0);
 	MR_init_entry(mercury__builtin____Compare____func_0_0);
 	MR_init_entry(mercury__builtin____Compare____pred_0_0);
-	MR_init_entry(mercury__std_util____Compare____type_desc_0_0);
-	MR_init_entry(mercury__private_builtin____Compare____type_ctor_info_1_0);
-	MR_init_entry(mercury__private_builtin____Compare____type_info_1_0);
-	MR_init_entry(mercury__private_builtin____Compare____typeclass_info_1_0);
-	MR_init_entry(mercury__private_builtin____Compare____base_typeclass_info_1_0);
 }
 
 /*---------------------------------------------------------------------------*/
 
-#else
+#else /* ! MR_HIGHLEVEL_CODE */
+
+/* suppress gcc -Wmissing-decl warn */
 void mercury_sys_init_mercury_hlc(void);
-void mercury_sys_init_mercury_hlc(void) { return; }
-#endif /* MR_HIGHLEVEL_CODE */
+
+/*
+** This empty initialization function is needed only
+** to match the one that we use for MLDS grades.
+*/
+void
+mercury_sys_init_mercury_hlc(void)
+{
+	/* no initialization needed */
+}
+
+#endif /* ! MR_HIGHLEVEL_CODE */

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