[m-dev.] For review: Using MR_TypeCtorInfo for generated type_ctor_infos

Warwick Harvey wharvey at cs.monash.edu.au
Tue Aug 10 14:38:23 AEST 1999


Fergus wrote:
> On 09-Aug-1999, Warwick Harvey <wharvey at cs.monash.edu.au> wrote:
> > +	/* For bootstrapping */
> > +#define mercury_data___type_ctor_info_pred_0_struct MR_TypeCtorInfo_struct
> > +#define mercury_data___type_ctor_info_func_0_struct MR_TypeCtorInfo_struct
> 
> Shouldn't that go in runtime/mercury_bootstrap.h rather than
> in library/std_util.m?

Yes.  I've also moved some similar definitions from
library/private_builtin.m.  Plus I discovered some more MR_DECLARE_STRUCTs
of type_ctor_infos which should be changed (they would have caused errors if
these #defines were ever deleted).  Since this change is now needed in
multiple places (I'd only noticed it before in library/std_util.m), I've
introduced an alternative macro for declaring type_ctor_info structs,
MR_DECLARE_TYPE_CTOR_INFO_STRUCT, and used it for declaring these, rather
than the "manual" definition I had used in library/std_util.m.

MR_DECLARE_STRUCT doesn't appear to have been used for anything other than
type_ctor_infos, but I've left it around anyway.

I'm currently bootchecking the updated change.  Once that's done, I plan to
install it and use it to start another bootcheck with
`MR_NO_BACKWARDS_COMPAT' defined.  Hopefully that will work and I won't find
anything else I've missed.  :-(

I've included some diffs of the changed bits below, plus an updated log
message.

Warwick

Index: extras/exceptions/exception.m
===================================================================
RCS file: /home/mercury1/repository/mercury/extras/exceptions/exception.m,v
retrieving revision 1.4
diff -u -r1.4 exception.m
--- exception.m 1999/06/09 07:12:55     1.4
+++ exception.m 1999/08/10 04:22:27
@@ -466,7 +466,8 @@
        #include <assert.h>
        #include ""mercury_deep_copy.h""

-       MR_DECLARE_STRUCT(mercury_data_std_util__type_ctor_info_univ_0);
+       MR_DECLARE_TYPE_CTOR_INFO_STRUCT( \
+                       mercury_data_std_util__type_ctor_info_univ_0);
 ").

 :- pragma c_code("
Index: library/std_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/std_util.m,v
retrieving revision 1.152
diff -u -r1.152 std_util.m
--- std_util.m  1999/07/19 04:51:00     1.152
+++ std_util.m  1999/08/10 04:22:28
@@ -1451,8 +1441,8 @@
        ** Several predicates use these (the MR_TYPE_CTOR_INFO_IS_HO_*
        ** macros need access to these addresses).
        */
-MR_DECLARE_STRUCT(mercury_data___type_ctor_info_pred_0);
-MR_DECLARE_STRUCT(mercury_data___type_ctor_info_func_0);
+MR_DECLARE_TYPE_CTOR_INFO_STRUCT(mercury_data___type_ctor_info_pred_0);
+MR_DECLARE_TYPE_CTOR_INFO_STRUCT(mercury_data___type_ctor_info_func_0);


 ").
Index: runtime/mercury_bootstrap.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_bootstrap.h,v
retrieving revision 1.6
diff -u -r1.6 mercury_bootstrap.h
--- mercury_bootstrap.h 1999/04/30 04:25:38     1.6
+++ mercury_bootstrap.h 1999/08/10 02:19:53
@@ -214,6 +214,25 @@
 #define mercury_data_private_builtin__base_type_info_type_info_1_struct \
        mercury_data_private_builtin__type_ctor_info_type_info_1_struct
 
+
+/*
+** These definitions are needed to bootstrap the change of all
+** type_ctor_info structures to use the MR_TypeCtorInfo type.
+*/
+
+#define mercury_data___type_ctor_info_int_0_struct \
+       MR_TypeCtorInfo_struct
+#define mercury_data___type_ctor_info_string_0_struct \
+       MR_TypeCtorInfo_struct
+#define mercury_data___type_ctor_info_float_0_struct \
+       MR_TypeCtorInfo_struct
+#define mercury_data___type_ctor_info_character_0_struct \
+       MR_TypeCtorInfo_struct
+#define mercury_data___type_ctor_info_pred_0_struct \
+       MR_TypeCtorInfo_struct
+#define mercury_data___type_ctor_info_func_0_struct \
+       MR_TypeCtorInfo_struct
+
 #endif /* not MR_NO_BACKWARDS_COMPAT */
 
 #endif /* MERCURY_BOOTSTRAP_H */
Index: runtime/mercury_deep_copy.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_deep_copy.c,v
retrieving revision 1.13
diff -u -r1.13 mercury_deep_copy.c
--- mercury_deep_copy.c 1999/03/22 08:09:01     1.13
+++ mercury_deep_copy.c 1999/08/10 04:22:28
@@ -18,8 +18,8 @@
 #include "mercury_memory.h"


-MR_DECLARE_STRUCT(mercury_data___type_ctor_info_pred_0);
-MR_DECLARE_STRUCT(mercury_data___type_ctor_info_func_0);
+MR_DECLARE_TYPE_CTOR_INFO_STRUCT(mercury_data___type_ctor_info_pred_0);
+MR_DECLARE_TYPE_CTOR_INFO_STRUCT(mercury_data___type_ctor_info_func_0);

 /*
 ** deep_copy(): see mercury_deep_copy.h for documentation.
Index: runtime/mercury_tabling.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_tabling.c,v
retrieving revision 1.7
diff -u -r1.7 mercury_tabling.c
--- mercury_tabling.c   1999/07/06 06:32:17     1.7
+++ mercury_tabling.c   1999/08/10 04:22:28
@@ -447,8 +447,8 @@
 ** This part defines the MR_table_type() function.
 */

-MR_DECLARE_STRUCT(mercury_data___type_ctor_info_pred_0);
-MR_DECLARE_STRUCT(mercury_data___type_ctor_info_func_0);
+MR_DECLARE_TYPE_CTOR_INFO_STRUCT(mercury_data___type_ctor_info_pred_0);
+MR_DECLARE_TYPE_CTOR_INFO_STRUCT(mercury_data___type_ctor_info_func_0);

 /*
 ** Due to the depth of the control here, we'll use 4 space indentation.
Index: runtime/mercury_type_info.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_type_info.h,v
retrieving revision 1.23
diff -u -r1.23 mercury_type_info.h
--- mercury_type_info.h 1999/07/06 06:32:19     1.23
+++ mercury_type_info.h 1999/08/10 04:22:28
@@ -134,6 +134,8 @@

 #define MR_DECLARE_STRUCT(T)                   \
        extern const struct T##_struct T
+#define MR_DECLARE_TYPE_CTOR_INFO_STRUCT(T)                    \
+       extern const struct MR_TypeCtorInfo_struct T

 /*
 ** Typelayouts for builtins are often defined as X identical



And here's an updated log message:

Estimated hours taken: 16

Changed all type_ctor_info structures to use the MR_TypeCtorInfo type.  This
is primarily to reduce the number of conflicts when merging independent
changes to the type_ctor_info structures.  As part of this, changed the type
of `string_const' to be `String' rather than `Word *', to avoid type errors
in the initialisers for compiler-generated type_ctor_infos.

compiler/llds_out.m:
	Don't emit definitions for type_ctor_info structs; instead use
	`MR_TypeCtorInfo_struct'.
	Removed a couple of casts of `string_const's to type `String', since
	they are no longer necessary.

compiler/llds.m:
	Changed the entries for `string_const' and `multi_string_const' in
	llds__const_type/2 to be `string' rather than `data_ptr'.

library/array.m:
library/builtin.m:
library/private_builtin.m:
library/std_util.m:
runtime/mercury_bootstrap.c:
runtime/mercury_type_info.c:
	Changed all the hand-defined type_ctor_info structures to just use
	`MR_TypeCtorInfo_struct', and added appropriate casts to the
	initialisers.  This included removing what appears to have been the
	last vestiges of `USE_TYPE_LAYOUT' conditionals since their use was
	so broken that it would probably be easier to re-implement the same
	functionality from scratch than to debug and rebuild on what was left.

runtime/mercury_type_info.h:
	Introduced `struct MR_TypeCtorInfo_struct' as the name of the
	(previously anonymous) struct which `MR_TypeCtorInfo' was a pointer
	to.
	Introduced `MR_DECLARE_TYPE_CTOR_INFO_STRUCT' for declaring
	type_ctor_info structures, since `MR_DECLARE_STRUCT' generates
	old-style names for type_ctor_infos.

runtime/mercury_deep_copy.c:
runtime/mercury_tabling.c:
library/std_util.m:
extras/exceptions/exception.m:
	Changed some uses of `MR_DECLARE_STRUCT' to use
	`MR_DECLARE_TYPE_CTOR_INFO_STRUCT' instead.

runtime/mercury_bootstrap.h:
	Added some `#define's of some old type_ctor_info type names to be
	`MR_TypeCtorInfo_struct', so that during bootstrapping the type
	names generated by the old version of the compiler work with the new
	scheme used in the manual definitions.

runtime/mercury_string.h:
	Changed the type of the macro `string_const/2'.  It used to cast to
	`Word *', now it casts to `String'.

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