[m-rev.] for review: fix test case failures in .rt grades

Zoltan Somogyi zs at cs.mu.OZ.AU
Mon Apr 22 13:34:28 AEST 2002


For review by anyone.

Zoltan.

Fix test case failures involving type_ctor_descs in .rt grades.

The cause of the failures was that the type_ctor_rep for type_ctor_descs (which
happens to be 35) does not fit into a signed 8-bit integer in .rt grades,
since those grade require 2 bits for a primary tag (3 bits on 64-bit machines).

The fix is to make the type_ctor_rep field in type_ctor_infos 16 bits in size.
To maintain alignment, this requires swapping that field with the num_ptags
field.

The second part of this change will remove the bootstrapping code and raise
the binary compatibility version number. That part cannot be committed until
this part has been installed on all our machines.

runtime/mercury_type_info.h:
	Define a new version of the type_ctor_info structure with this swap
	and size increase. Provide backward compatibility for bootstrapping.

library/rtti_implementation.m:
java/runtime/TypeCtorInfo_Struct.m:
	Make the same change.

compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/mlds_to_gcc.m:
	Generate the new type_ctor_info structure.

compiler/llds_out.m:
compiler/mlds_to_c.m:
	Generate a macro that selects the new version of the type_ctor_info
	structure.

compiler/type_ctor_info.m:
	Update the type_ctor_info version number.

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/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/llds_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds_out.m,v
retrieving revision 1.191
diff -u -b -r1.191 llds_out.m
--- compiler/llds_out.m	15 Apr 2002 05:04:04 -0000	1.191
+++ compiler/llds_out.m	19 Apr 2002 03:31:27 -0000
@@ -475,6 +475,8 @@
 		"**\n",
 		"** END_OF_C_GRADE_INFO\n",
 		"*/\n",
+		"\n",
+		"#define MR_BOOTSTRAP_TYPE_CTOR_REP\n",
 		"\n"
 	]).
 
Index: compiler/mlds_to_c.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_c.m,v
retrieving revision 1.126
diff -u -b -r1.126 mlds_to_c.m
--- compiler/mlds_to_c.m	12 Apr 2002 10:06:25 -0000	1.126
+++ compiler/mlds_to_c.m	18 Apr 2002 12:17:44 -0000
@@ -126,6 +126,7 @@
 :- mode mlds_output_hdr_file(in, in, di, uo) is det.
 
 mlds_output_hdr_file(Indent, MLDS) -->
+	io__write_string("#define MR_BOOTSTRAP_TYPE_CTOR_REP\n"),
 	{ MLDS = mlds(ModuleName, AllForeignCode, Imports, Defns) },
 	mlds_output_hdr_start(Indent, ModuleName), io__nl,
 	mlds_output_hdr_imports(Indent, Imports), io__nl,
Index: compiler/mlds_to_gcc.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_gcc.m,v
retrieving revision 1.69
diff -u -b -r1.69 mlds_to_gcc.m
--- compiler/mlds_to_gcc.m	12 Apr 2002 01:24:09 -0000	1.69
+++ compiler/mlds_to_gcc.m	18 Apr 2002 12:12:21 -0000
@@ -2024,8 +2024,8 @@
 build_rtti_type(type_ctor_info, _, GCC_Type) -->
 	% MR_Integer          MR_type_ctor_arity;
 	% MR_int_least8_t     MR_type_ctor_version;
-	% MR_TypeCtorRepInt   MR_type_ctor_rep_CAST_ME;
 	% MR_int_least8_t     MR_type_ctor_num_ptags;         /* if DU */
+	% MR_TypeCtorRepInt   MR_type_ctor_rep_CAST_ME;
 	% MR_ProcAddr         MR_type_ctor_unify_pred;
 	% MR_ProcAddr         MR_type_ctor_compare_pred;
 	% MR_ConstString      MR_type_ctor_module_name;
@@ -2044,9 +2044,9 @@
 	build_struct_type("MR_TypeCtorInfo_Struct",
 		['MR_Integer'		- "MR_type_ctor_arity",
 		 'MR_int_least8_t'	- "MR_type_ctor_version",
-		 % MR_TypeCtorRepInt is typedef'd to be MR_int_least8_t
-		 'MR_int_least8_t'	- "MR_type_ctor_rep_CAST_ME",
 		 'MR_int_least8_t'	- "MR_type_ctor_num_ptags",
+		 % MR_TypeCtorRepInt is typedef'd to be MR_int_least16_t
+		 'MR_int_least16_t'	- "MR_type_ctor_rep_CAST_ME",
 		 MR_ProcAddr		- "MR_type_ctor_unify_pred",
 		 MR_ProcAddr		- "MR_type_ctor_compare_pred",
 		 'MR_ConstString'	- "MR_type_ctor_module_name",
Index: compiler/rtti_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/rtti_out.m,v
retrieving revision 1.28
diff -u -b -r1.28 rtti_out.m
--- compiler/rtti_out.m	17 Apr 2002 05:31:37 -0000	1.28
+++ compiler/rtti_out.m	18 Apr 2002 12:19:49 -0000
@@ -400,10 +400,10 @@
 	io__write_string(",\n\t"),
 	io__write_int(Version),
 	io__write_string(",\n\t"),
+	io__write_int(NumPtags),
+	io__write_string(",\n\t"),
 	{ rtti__type_ctor_rep_to_string(CtorRep, CtorRepStr) },
 	io__write_string(CtorRepStr),
-	io__write_string(",\n\t"),
-	io__write_int(NumPtags),
 	io__write_string(",\n\t"),
 	output_maybe_static_code_addr(UnifyCA),
 	io__write_string(",\n\t"),
Index: compiler/rtti_to_mlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/rtti_to_mlds.m,v
retrieving revision 1.30
diff -u -b -r1.30 rtti_to_mlds.m
--- compiler/rtti_to_mlds.m	12 Apr 2002 01:24:13 -0000	1.30
+++ compiler/rtti_to_mlds.m	18 Apr 2002 12:21:28 -0000
@@ -239,8 +239,8 @@
 	Init = init_struct([
 		gen_init_int(TypeArity),
 		gen_init_int(Version),
-		gen_init_type_ctor_rep(CtorRep),
 		gen_init_int(NumPtags),
+		gen_init_type_ctor_rep(CtorRep),
 		gen_init_maybe_proc_id(ModuleInfo, UnifyProc),
 		gen_init_maybe_proc_id(ModuleInfo, CompareProc),
 		gen_init_string(TypeModuleName),
Index: compiler/type_ctor_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/type_ctor_info.m,v
retrieving revision 1.24
diff -u -b -r1.24 type_ctor_info.m
--- compiler/type_ctor_info.m	12 Apr 2002 01:24:13 -0000	1.24
+++ compiler/type_ctor_info.m	18 Apr 2002 12:20:24 -0000
@@ -227,7 +227,7 @@
 
 :- func type_ctor_info_rtti_version = int.
 
-type_ctor_info_rtti_version = 6.
+type_ctor_info_rtti_version = 7.
 
 %---------------------------------------------------------------------------%
 %---------------------------------------------------------------------------%
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
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/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
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/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/stream
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing java
cvs diff: Diffing java/library
cvs diff: Diffing java/runtime
Index: java/runtime/TypeCtorInfo_Struct.java
===================================================================
RCS file: /home/mercury1/repository/mercury/java/runtime/TypeCtorInfo_Struct.java,v
retrieving revision 1.1
diff -u -b -r1.1 TypeCtorInfo_Struct.java
--- java/runtime/TypeCtorInfo_Struct.java	11 Feb 2002 06:31:32 -0000	1.1
+++ java/runtime/TypeCtorInfo_Struct.java	19 Apr 2002 05:03:36 -0000
@@ -10,8 +10,8 @@
     
 	public int                              arity;
 	public int                              type_ctor_version;
-	public mercury.runtime.TypeCtorRep      type_ctor_rep;
 	public int                              type_ctor_num_ptags; // if DU
+	public mercury.runtime.TypeCtorRep      type_ctor_rep;
 	public mercury.runtime.MethodPtr        unify_pred;
 	public mercury.runtime.MethodPtr        compare_pred;
 	public java.lang.String                 type_ctor_module_name;
cvs diff: Diffing library
Index: library/rtti_implementation.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/rtti_implementation.m,v
retrieving revision 1.15
diff -u -b -r1.15 rtti_implementation.m
--- library/rtti_implementation.m	27 Mar 2002 05:18:46 -0000	1.15
+++ library/rtti_implementation.m	19 Apr 2002 05:02:37 -0000
@@ -1025,8 +1025,8 @@
 	enum type_ctor_info_field_nums {
 		type_ctor_arity 	= 0,
 		// type_ctor_version	= 1,
-		type_ctor_rep		= 2,
-		type_ctor_num_ptags	= 3,
+		type_ctor_num_ptags	= 2,
+		type_ctor_rep		= 3,
 		type_ctor_unify_pred 	= 4,
 		type_ctor_compare_pred	= 5,
 		type_ctor_module_name	= 6,
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
Index: runtime/mercury_type_info.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_type_info.h,v
retrieving revision 1.89
diff -u -b -r1.89 mercury_type_info.h
--- runtime/mercury_type_info.h	12 Apr 2002 01:24:25 -0000	1.89
+++ runtime/mercury_type_info.h	19 Apr 2002 09:31:35 -0000
@@ -71,12 +71,13 @@
 ** compiler/type_ctor_info.m.
 */
 
-#define MR_RTTI_VERSION                 MR_RTTI_VERSION__COMPACT
+#define MR_RTTI_VERSION                 MR_RTTI_VERSION__REP
 #define MR_RTTI_VERSION__INITIAL        2
 #define MR_RTTI_VERSION__USEREQ         3
 #define MR_RTTI_VERSION__CLEAN_LAYOUT   4
 #define MR_RTTI_VERSION__VERSION_NO     5
 #define MR_RTTI_VERSION__COMPACT        6
+#define MR_RTTI_VERSION__REP            7
 
 /*
 ** Check that the RTTI version is in a sensible range.
@@ -87,7 +88,17 @@
 */
 
 #define MR_TYPE_CTOR_INFO_CHECK_RTTI_VERSION_RANGE(typector)    \
-    assert(typector->MR_type_ctor_version == MR_RTTI_VERSION__COMPACT)
+    ( assert(typector->MR_type_ctor_version == MR_RTTI_VERSION__COMPACT) \
+    || assert(typector->MR_type_ctor_version == MR_RTTI_VERSION__REP))
+
+#ifdef  MR_BOOTSTRAP_TYPE_CTOR_REP
+  #define MR_TypeCtorInfo_Struct  MR_NewTypeCtorInfo_Struct
+#else
+  #define MR_TypeCtorInfo_Struct  MR_OldTypeCtorInfo_Struct
+#endif
+
+typedef const struct MR_NewTypeCtorInfo_Struct             *MR_NewTypeCtorInfo;
+typedef const struct MR_OldTypeCtorInfo_Struct             *MR_OldTypeCtorInfo;
 
 /*---------------------------------------------------------------------------*/
 
@@ -517,9 +528,18 @@
 ** We cannot put enums into structures as bit fields. To avoid wasting space,
 ** we put MR_TypeCtorRepInts into structures instead of MR_TypeCtorReps
 ** themselves.
+**
+** We need more than eight bits for a TypeCtorRep. The number of different
+** TypeCtorRep values requires six bits to differentiate them, and in .rt
+** grades on 64-bit machines we need another three bits for a primary tag
+** value.
 */
 
-typedef MR_int_least8_t         MR_TypeCtorRepInt;
+#ifdef  MR_BOOTSTRAP_TYPE_CTOR_REP
+  typedef MR_int_least16_t  MR_TypeCtorRepInt;
+#else
+  typedef MR_int_least8_t   MR_TypeCtorRepInt;
+#endif
 
 /*
 ** This macro is intended to be used for the initialization of an array
@@ -940,9 +960,19 @@
     ** A type_ctor_info describes the structure of a particular
     ** type constructor.  One of these is generated for every
     ** `:- type' declaration.
+    **
+    ** A change in the TypeCtorInfo structure also requires changes
+    ** in
+    **
+    **      compiler/rtti_out.m
+    **      compiler/mlds_to_gcc.m
+    **      library/rtti_implementation.m
+    **      java/runtime/TypeCtorInfo_Struct.java
+    **
+    ** as well as the macros below.
     */
 
-struct MR_TypeCtorInfo_Struct {
+struct MR_OldTypeCtorInfo_Struct {
     MR_Integer          MR_type_ctor_arity;
     MR_int_least8_t     MR_type_ctor_version;
     MR_TypeCtorRepInt   MR_type_ctor_rep_CAST_ME;
@@ -962,8 +992,41 @@
 */
 };
 
+/*
+** The type of the MR_type_ctor_rep_CAST_ME field should be returned
+** to MR_TypeCtorRepInt when bootstrapping is complete.
+*/
+
+struct MR_NewTypeCtorInfo_Struct {
+    MR_Integer          MR_type_ctor_arity;
+    MR_int_least8_t     MR_type_ctor_version;
+    MR_int_least8_t     MR_type_ctor_num_ptags;         /* if DU */
+    MR_int_least16_t    MR_type_ctor_rep_CAST_ME;
+    MR_ProcAddr         MR_type_ctor_unify_pred;
+    MR_ProcAddr         MR_type_ctor_compare_pred;
+    MR_ConstString      MR_type_ctor_module_name;
+    MR_ConstString      MR_type_ctor_name;
+    MR_TypeFunctors     MR_type_ctor_functors;
+    MR_TypeLayout       MR_type_ctor_layout;
+    MR_int_least32_t    MR_type_ctor_num_functors;
+
+/*
+** The following fields will be added later, once we can exploit them:
+**  union MR_TableNode_Union    **type_std_table;
+**  MR_ProcAddr         prettyprinter;
+*/
+};
+
 #define MR_type_ctor_rep(tci)                                               \
-    ((MR_TypeCtorRep) (tci)->MR_type_ctor_rep_CAST_ME)
+    ((MR_TypeCtorRep)                                                       \
+    ((tci)->MR_type_ctor_version == MR_RTTI_VERSION__REP) ?                 \
+        (((MR_NewTypeCtorInfo) (tci))->MR_type_ctor_rep_CAST_ME) :          \
+        (((MR_OldTypeCtorInfo) (tci))->MR_type_ctor_rep_CAST_ME))
+
+#define MR_type_ctor_num_ptags(tci)                                         \
+    (((tci)->MR_type_ctor_version == MR_RTTI_VERSION__REP) ?                \
+        (((MR_NewTypeCtorInfo) (tci))->MR_type_ctor_num_ptags) :            \
+        (((MR_OldTypeCtorInfo) (tci))->MR_type_ctor_num_ptags))
 
 #define MR_type_ctor_module_name(tci)                                       \
     ((tci)->MR_type_ctor_module_name)
@@ -1010,9 +1073,9 @@
 #define MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_BODY(m, n, a, cr, u, c)        \
     {                                                                   \
         a,                                                              \
-        MR_RTTI_VERSION__COMPACT,                                       \
-        cr,                                                             \
+        MR_RTTI_VERSION__REP,                                           \
         -1,                                                             \
+        cr,                                                             \
         MR_MAYBE_STATIC_CODE(MR_ENTRY(u)),                              \
         MR_MAYBE_STATIC_CODE(MR_ENTRY(c)),                              \
         MR_string_const(MR_STRINGIFY(m), sizeof(MR_STRINGIFY(m))-1),    \
@@ -1072,9 +1135,9 @@
         MR_type_ctor_info_name(module, type, arity) =                   \
     {                                                                   \
         arity,                                                          \
-        MR_RTTI_VERSION__COMPACT,                                       \
-        type_rep,                                                       \
+        MR_RTTI_VERSION__REP,                                           \
         -1,                                                             \
+        type_rep,                                                       \
         (MR_Box) MR_type_ctor_info_func_name(module, type, arity,       \
                         do_unify),                                      \
         (MR_Box) MR_type_ctor_info_func_name(module, type, arity,       \
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 samples/solutions
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
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/general/structure_reuse
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/recompilation
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
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list