[m-rev.] for review: reducing the size of type ctor info structures, part 2

Zoltan Somogyi zs at cs.mu.OZ.AU
Mon Dec 31 14:28:58 AEDT 2001


For review by Fergus or Tyson.

Zoltan.

This is the second half of a change that reduces the size of type_ctor_info
structures, and moves the version number to the start (immediately after the
arity) to make future changes easier.

configure.in:
	Require the use of a compiler that implements the first half of this
	change.

runtime/mercury_bootstrap.h:
	Add synonyms for use until this change is installed on all machines.

runtime/mercury_grade.h:
	Increment the grade version number to prevent linking of code of that
	doesn't understand the new type_ctor_info structure with code that
	requires it.

compiler/llds_out.m:
compiler/mlds_to_c.m:
	Do not emit the #define to select the new type_ctor_info structure,
	since the new structure is now the only one.

runtime/mercury_type_info.h:
	Delete the old versions of the type_ctor_info structure and the
	macros that operate on it.

Diffing .
--- /home/zs/mer/ws28/configure.in	Sat Dec 29 17:02:33 2001
+++ /home/zs/mer/ws30/configure.in	Sun Dec 30 18:42:22 2001
@@ -100,15 +100,21 @@
 		:- pred main(io__state::di, io__state::uo) is det.
 
 		:- implementation.
-		:- import_module int.
         
-		% Check for the builtin function int__unchecked_rem/2.
 		main --> 
-			( { int__unchecked_rem(3, 2) = 1 } ->
+			{ return_rtti_version(Version) },
+			( { Version = 5 } ->
 				print("Hello, world\n")
 			;
 				print("Nope.\n")
 			).
+
+		:- pred return_rtti_version(int::out) is det.
+
+		:- pragma foreign_proc("C", return_rtti_version(Version::out),
+			[will_not_call_mercury], "
+			Version = MR_RTTI_VERSION;
+		").
 EOF
 	if
 		# Test for the `--fullarch' option.
Diffing bindist
Diffing boehm_gc
Diffing boehm_gc/Mac_files
Diffing boehm_gc/cord
Diffing boehm_gc/cord/private
Diffing boehm_gc/doc
Diffing boehm_gc/include
Diffing boehm_gc/include/private
Diffing boehm_gc/tests
Diffing browser
Diffing bytecode
Diffing compiler
--- /home/zs/mer/ws28/compiler/llds_out.m	Sat Dec 29 17:02:54 2001
+++ /home/zs/mer/ws30/compiler/llds_out.m	Sat Dec 29 18:04:08 2001
@@ -452,9 +452,7 @@
 		"** UNBOXED_FLOAT=", UnboxedFloatStr, "\n",
 		"**\n",
 		"** END_OF_C_GRADE_INFO\n",
-		"*/\n",
-		"\n",
-		"\n#define MR_BOOTSTRAP_TYPE_CTOR_VERSION_NO\n"
+		"*/\n"
 	]).
 
 :- pred convert_bool_to_string(bool, string).
--- /home/zs/mer/ws28/compiler/mlds_to_c.m	Sat Dec 29 18:01:43 2001
+++ /home/zs/mer/ws30/compiler/mlds_to_c.m	Mon Dec 31 14:26:22 2001
@@ -123,9 +123,6 @@
 :- mode mlds_output_hdr_file(in, in, di, uo) is det.
 
 mlds_output_hdr_file(Indent, MLDS) -->
-	% XXX for bootstrapping the new type_ctor_info structure.
-	io__write_string("#define MR_BOOTSTRAP_TYPE_CTOR_VERSION_NO\n"),
-
 	{ MLDS = mlds(ModuleName, AllForeignCode, Imports, Defns) },
 	mlds_output_hdr_start(Indent, ModuleName), io__nl,
 	mlds_output_hdr_imports(Indent, Imports), io__nl,
Diffing compiler/notes
Diffing debian
Diffing deep_profiler
Diffing deep_profiler/notes
Diffing doc
Diffing extras
Diffing extras/aditi
Diffing extras/cgi
Diffing extras/complex_numbers
Diffing extras/complex_numbers/samples
Diffing extras/complex_numbers/tests
Diffing extras/concurrency
Diffing extras/curs
Diffing extras/curs/samples
Diffing extras/curses
Diffing extras/curses/sample
Diffing extras/dynamic_linking
Diffing extras/graphics
Diffing extras/graphics/mercury_opengl
Diffing extras/graphics/mercury_tcltk
Diffing extras/graphics/samples
Diffing extras/graphics/samples/calc
Diffing extras/graphics/samples/maze
Diffing extras/graphics/samples/pent
Diffing extras/lazy_evaluation
Diffing extras/lex
Diffing extras/lex/samples
Diffing extras/logged_output
Diffing extras/moose
Diffing extras/moose/samples
Diffing extras/morphine
Diffing extras/morphine/non-regression-tests
Diffing extras/morphine/scripts
Diffing extras/morphine/source
Diffing extras/odbc
Diffing extras/posix
Diffing extras/quickcheck
Diffing extras/quickcheck/tutes
Diffing extras/references
Diffing extras/references/samples
Diffing extras/references/tests
Diffing extras/stream
Diffing extras/trailed_update
Diffing extras/trailed_update/samples
Diffing extras/trailed_update/tests
Diffing extras/xml
Diffing extras/xml/samples
Diffing java
Diffing library
Diffing profiler
Diffing robdd
Diffing runtime
--- /home/zs/mer/ws28/runtime/mercury_bootstrap.h	Sat Dec 29 17:03:38 2001
+++ /home/zs/mer/ws30/runtime/mercury_bootstrap.h	Sat Dec 29 22:43:36 2001
@@ -20,6 +20,14 @@
 ** but you can disable it by defining MR_NO_BACKWARDS_COMPAT.
 */
 
+/*
+** The next two #defines are needed for bootstrapping the new type constructor
+** structure.
+*/
+
+#define MR_TypeCtorInfo_struct  MR_TypeCtorInfo_Struct
+#define MR_NewTypeCtorInfo_struct  MR_TypeCtorInfo_Struct
+
 #ifndef MR_NO_BACKWARDS_COMPAT
 
 /* 
--- /home/zs/mer/ws28/runtime/mercury_grade.h	Mon Jun 25 15:33:40 2001
+++ /home/zs/mer/ws30/runtime/mercury_grade.h	Sat Dec 29 18:04:55 2001
@@ -52,7 +52,7 @@
 ** RTTI version number.
 */
 
-#define MR_GRADE_PART_0	v3_
+#define MR_GRADE_PART_0	v4_
 
 #ifdef MR_HIGHLEVEL_CODE
 
--- /home/zs/mer/ws28/runtime/mercury_type_info.h	Sat Dec 29 23:10:02 2001
+++ /home/zs/mer/ws30/runtime/mercury_type_info.h	Sat Dec 29 23:09:40 2001
@@ -83,16 +83,7 @@
 */
 
 #define MR_TYPE_CTOR_INFO_CHECK_RTTI_VERSION_RANGE(typector)    \
-    assert(typector->type_ctor_old_version == MR_RTTI_VERSION__CLEAN_LAYOUT \
-	|| typector->type_ctor_old_version == MR_RTTI_VERSION__VERSION_NO)
-
-/*---------------------------------------------------------------------------*/
-
-#ifdef	MR_BOOTSTRAP_TYPE_CTOR_VERSION_NO
-  #define	MR_TypeCtorInfo_Struct	MR_NewTypeCtorInfo_Struct
-#else
-  #define	MR_TypeCtorInfo_Struct	MR_OldTypeCtorInfo_Struct
-#endif
+    assert(typector->type_ctor_old_version == MR_RTTI_VERSION__VERSION_NO)
 
 /*---------------------------------------------------------------------------*/
 
@@ -332,8 +323,6 @@
   #define MR_special_func_type(NAME, ARITY) \
 	MR_PASTE2(MR_, MR_PASTE2(NAME, MR_PASTE2(Func_, ARITY)))
 
-  #ifdef MR_BOOTSTRAP_TYPE_CTOR_VERSION_NO
-
     #define MR_define_type_ctor_info(module, type, arity, type_rep)	      \
 	const struct MR_TypeCtorInfo_Struct				      \
 		MR_type_ctor_info_name(module, type, arity) =		      \
@@ -357,33 +346,6 @@
 		-1							      \
 	}
 
-  #else	/* MR_BOOTSTRAP_TYPE_CTOR_VERSION_NO */
-
-    #define MR_define_type_ctor_info(module, type, arity, type_rep)	      \
-	const struct MR_TypeCtorInfo_Struct				      \
-		MR_type_ctor_info_name(module, type, arity) =		      \
-	{								      \
-		arity,							      \
-		(MR_Box) MR_type_ctor_info_func_name(module, type, arity,     \
-				do_unify),				      \
-		(MR_Box) MR_type_ctor_info_func_name(module, type, arity,     \
-				do_unify),				      \
-		(MR_Box) MR_type_ctor_info_func_name(module, type, arity,     \
-				do_compare),				      \
-		type_rep,						      \
-		NULL,							      \
-		NULL,							      \
-		MR_STRINGIFY(module),					      \
-		MR_STRINGIFY(type),					      \
-		MR_RTTI_VERSION,					      \
-		{ 0 },							      \
-		{ 0 },							      \
-		-1,							      \
-		-1							      \
-	}
-
-  #endif /* MR_BOOTSTRAP_TYPE_CTOR_VERSION_NO */
-
 #endif /* MR_HIGHLEVEL_CODE */
 
 /*---------------------------------------------------------------------------*/
@@ -988,36 +950,19 @@
     ** `:- type' declaration.
     */
 
-struct MR_OldTypeCtorInfo_Struct {
-    MR_Integer          arity;
-    MR_ProcAddr         old_unify_pred;
-    MR_ProcAddr         unify_pred;
-    MR_ProcAddr         compare_pred;
-    MR_TypeCtorRep      type_ctor_rep;
-    MR_ProcAddr         unused1;	/* spare */
-    MR_ProcAddr         unused2;	/* spare */
-    MR_ConstString      type_ctor_module_name;
-    MR_ConstString      type_ctor_name;
-    MR_Integer          type_ctor_old_version;
-    MR_TypeFunctors     type_functors;
-    MR_TypeLayout       type_layout;
-    MR_int_least32_t    type_ctor_num_functors;
-    MR_int_least8_t     type_ctor_num_ptags;		/* if DU */
-};
-
-struct MR_NewTypeCtorInfo_Struct {
+struct MR_TypeCtorInfo_Struct {
     MR_Integer          arity;
     MR_int_least8_t     MR_type_ctor_version;
     MR_TypeCtorRepInt   MR_type_ctor_rep_CAST_ME;
-    MR_int_least8_t     MR_type_ctor_new_num_ptags;	/* if DU */
+    MR_int_least8_t     MR_type_ctor_num_ptags;		/* if DU */
     MR_ProcAddr         unify_pred;
     MR_ProcAddr         compare_pred;
-    MR_Integer          MR_type_ctor_old_rep_CAST_ME;	/* will be unused */
+    MR_Integer          MR_type_ctor_old_rep_CAST_ME;	/* unused */
     MR_ProcAddr         MR_unused1;	/* spare */
     MR_ProcAddr         MR_unused2;	/* spare */
     MR_ConstString      type_ctor_module_name;
     MR_ConstString      type_ctor_name;
-    MR_Integer          MR_type_ctor_old_version;	/* will be unused */
+    MR_Integer          MR_type_ctor_old_version;	/* unused */
     MR_TypeFunctors     type_functors;
     MR_TypeLayout       type_layout;
     MR_int_least32_t    type_ctor_num_functors;
@@ -1030,8 +975,7 @@
 };
 
 #define	MR_type_ctor_rep(type_ctor_info)			\
-		((MR_TypeCtorRep) ((const struct MR_NewTypeCtorInfo_Struct *) \
-			(type_ctor_info))->MR_type_ctor_old_rep_CAST_ME)
+		((MR_TypeCtorRep) ((type_ctor_info))->MR_type_ctor_rep_CAST_ME)
 
 /*---------------------------------------------------------------------------*/
 
@@ -1060,8 +1004,6 @@
 #define MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_TYPE				\
     MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_Struct
 
-#ifdef	MR_BOOTSTRAP_TYPE_CTOR_VERSION_NO
-
 #define MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_BODY(m, n, a, cr, u, c)	\
     {									\
 	a,								\
@@ -1080,28 +1022,6 @@
 	{ 0 },								\
 	-1								\
     }
-
-#else
-
-#define MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_BODY(m, n, a, cr, u, c)	\
-    {									\
-	a,								\
-	MR_MAYBE_STATIC_CODE(MR_ENTRY(u)),				\
-	MR_MAYBE_STATIC_CODE(MR_ENTRY(u)),				\
-	MR_MAYBE_STATIC_CODE(MR_ENTRY(c)),				\
-	cr,								\
-	NULL,								\
-	NULL,								\
-	MR_string_const(MR_STRINGIFY(m), sizeof(MR_STRINGIFY(m))-1),	\
-	MR_string_const(MR_STRINGIFY(n), sizeof(MR_STRINGIFY(n))-1),	\
-	MR_RTTI_VERSION__CLEAN_LAYOUT,					\
-	{ 0 },								\
-	{ 0 },								\
-	-1,								\
-	-1								\
-    }
-
-#endif
 
 #define MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_PRED(m, n, a, cr, u, c)	\
 	MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_FULL(m, m, n, a, cr, u, c)
Diffing runtime/GETOPT
Diffing runtime/machdeps
Diffing samples
Diffing samples/c_interface
Diffing samples/c_interface/c_calls_mercury
Diffing samples/c_interface/cplusplus_calls_mercury
Diffing samples/c_interface/mercury_calls_c
Diffing samples/c_interface/mercury_calls_cplusplus
Diffing samples/c_interface/mercury_calls_fortran
Diffing samples/c_interface/simpler_c_calls_mercury
Diffing samples/c_interface/simpler_cplusplus_calls_mercury
Diffing samples/diff
Diffing samples/muz
Diffing samples/rot13
Diffing samples/solutions
Diffing samples/tests
Diffing samples/tests/c_interface
Diffing samples/tests/c_interface/c_calls_mercury
Diffing samples/tests/c_interface/cplusplus_calls_mercury
Diffing samples/tests/c_interface/mercury_calls_c
Diffing samples/tests/c_interface/mercury_calls_cplusplus
Diffing samples/tests/c_interface/mercury_calls_fortran
Diffing samples/tests/c_interface/simpler_c_calls_mercury
Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
Diffing samples/tests/diff
Diffing samples/tests/muz
Diffing samples/tests/rot13
Diffing samples/tests/solutions
Diffing samples/tests/toplevel
Diffing scripts
Diffing tests
Diffing tests/benchmarks
Diffing tests/debugger
Diffing tests/debugger/declarative
Diffing tests/dppd
Diffing tests/general
Diffing tests/general/accumulator
Diffing tests/general/structure_reuse
Diffing tests/hard_coded
Diffing tests/hard_coded/exceptions
Diffing tests/hard_coded/purity
Diffing tests/hard_coded/sub-modules
Diffing tests/hard_coded/typeclasses
Diffing tests/invalid
Diffing tests/invalid/purity
Diffing tests/misc_tests
Diffing tests/recompilation
Diffing tests/tabling
Diffing tests/term
Diffing tests/valid
Diffing tests/warnings
Diffing tools
Diffing trace
Diffing util
--------------------------------------------------------------------------
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