diff: fix little bootstrapping problem.

Tyson Dowd trd at cs.mu.OZ.AU
Tue Aug 4 18:47:15 AEST 1998


Hi,

Here's my fix for the bootstapping problem of type_info/1.

This seems to work ok.

===================================================================


Estimated hours taken: 1

Fix a bootstrapping problem.

runtime/Mmakefile:
runtime/mercury_bootstrap.c:
	Add definitions that are generated in stage 1 compiler, but
	not stage 2.  Since runtime is a library, they will be linked
	only if they are not generated. 

	When the compilers are installed everywhere, this code can
	be moved into library/mercury_private_builtin.m.


Index: runtime/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/Mmakefile,v
retrieving revision 1.34
diff -u -r1.34 Mmakefile
--- Mmakefile	1998/07/28 03:09:54	1.34
+++ Mmakefile	1998/08/04 08:01:39
@@ -98,6 +98,7 @@
 CFILES		= 	\
 			mercury_accurate_gc.c	\
 			mercury_agc_debug.c	\
+			mercury_bootstrap.c	\
 			mercury_context.c	\
 			mercury_deep_copy.c	\
 			mercury_dlist.c		\
Index: runtime/mercury_bootstrap.c
===================================================================
RCS file: mercury_bootstrap.c
diff -N mercury_bootstrap.c
--- /dev/null	Wed May 28 10:49:58 1997
+++ mercury_bootstrap.c	Tue Aug  4 18:16:55 1998
@@ -0,0 +1,132 @@
+/*
+** Copyright (C) 1998 The University of Melbourne.
+** This file may only be copied under the terms of the GNU Library General
+** Public License - see the file COPYING.LIB in the Mercury distribution.
+*/
+
+/*
+** mercury_bootstrap.c -
+**	Defintions that may be used for bootstrapping purposes.
+**
+**	Because the runtime is linked as a library, symbols can be
+**	safely defined here -- if there is a duplicate symbol
+**	generated by the compiler, it will not link this module into
+**	the executable.  If the symbol is not generated by the compiler,
+**	it will link with the definition in this file.
+**	
+**	Most of the time this file will	be empty.
+**	It should not be used for more than one bootstrapping problem
+**	at a time.
+*/
+
+#include "mercury_imp.h"
+
+/*
+** Bootstrapping the hand-defintion of private_builtin:type_info/1
+** means that the stage 1 compiler has a compiler generated definition,
+** while stage 2 doesn't.
+*/
+
+Define_extern_entry(mercury____Unify___private_builtin__type_info_1_0);
+Define_extern_entry(mercury____Index___private_builtin__type_info_1_0);
+Define_extern_entry(mercury____Compare___private_builtin__type_info_1_0);
+
+extern const struct
+	mercury_data_private_builtin__base_type_layout_type_info_1_struct 
+	mercury_data_private_builtin__base_type_layout_type_info_1;
+extern const struct
+	mercury_data_private_builtin__base_type_functors_type_info_1_struct
+	mercury_data_private_builtin__base_type_functors_type_info_1;
+
+MR_STATIC_CODE_CONST struct
+mercury_data_private_builtin__base_type_info_type_info_1_struct {
+	Integer f1;
+	Code *f2;
+	Code *f3;
+	Code *f4;
+	const Word *f5;
+	const Word *f6;
+	const Word *f7;
+	const Word *f8;
+} mercury_data_private_builtin__base_type_info_type_info_1 = {
+	((Integer) 1),
+	MR_MAYBE_STATIC_CODE(ENTRY(
+		mercury____Unify___private_builtin__type_info_1_0)),
+	MR_MAYBE_STATIC_CODE(ENTRY(
+		mercury____Index___private_builtin__type_info_1_0)),
+	MR_MAYBE_STATIC_CODE(ENTRY(
+		mercury____Compare___private_builtin__type_info_1_0)),
+	(const Word *) &
+		mercury_data_private_builtin__base_type_layout_type_info_1,
+	(const Word *) &
+		mercury_data_private_builtin__base_type_functors_type_info_1,
+	(const Word *) string_const("private_builtin", 15),
+	(const Word *) string_const("type_info", 9)
+};
+
+
+const struct mercury_data_private_builtin__base_type_layout_type_info_1_struct {
+	TYPE_LAYOUT_FIELDS
+} mercury_data_private_builtin__base_type_layout_type_info_1 = {
+	make_typelayout_for_all_tags(TYPELAYOUT_CONST_TAG, 
+		mkbody(TYPELAYOUT_TYPEINFO_VALUE))
+};
+
+const struct mercury_data_private_builtin__base_type_functors_type_info_1_struct {
+	Integer f1;
+} mercury_data_private_builtin__base_type_functors_type_info_1 = {
+	MR_TYPEFUNCTORS_SPECIAL
+};
+
+
+MR_MAKE_STACK_LAYOUT_ENTRY(mercury____Unify___private_builtin__type_info_1_0);
+MR_MAKE_STACK_LAYOUT_ENTRY(mercury____Index___private_builtin__type_info_1_0);
+MR_MAKE_STACK_LAYOUT_ENTRY(mercury____Compare___private_builtin__type_info_1_0);
+BEGIN_MODULE(type_info_module)
+Define_entry(mercury____Unify___private_builtin__type_info_1_0);
+{
+	/*
+	** Unification for type_info.
+	**
+	** The two inputs are in the registers named by unify_input[12].
+	** The success/failure indication should go in unify_output.
+	*/
+	int comp;
+	save_transient_registers();
+	comp = MR_compare_type_info(unify_input1, unify_input2);
+	restore_transient_registers();
+	unify_output = (comp == COMPARE_EQUAL);
+	proceed();
+}
+
+Define_entry(mercury____Index___private_builtin__type_info_1_0);
+	index_output = -1;
+	proceed();
+
+Define_entry(mercury____Compare___private_builtin__type_info_1_0);
+{
+	/*
+	** Comparison for type_info:
+	**
+	** The two inputs are in the registers named by compare_input[12].
+	** The result should go in compare_output.
+	*/
+	int comp;
+	save_transient_registers();
+	comp = MR_compare_type_info(unify_input1, unify_input2);
+	restore_transient_registers();
+	compare_output = comp;
+	proceed();
+}
+END_MODULE
+
+/* Ensure that the initialization code for the above module gets run. */
+/*
+INIT sys_init_type_info_module
+*/
+extern ModuleFunc type_info_module;
+void sys_init_type_info_module(void); /* suppress gcc -Wmissing-decl warning */
+void sys_init_type_info_module(void) {
+	type_info_module();
+}
+


-- 
       Tyson Dowd           # There isn't any reason why Linux can't be
                            # implemented as an enterprise computing solution.
     trd at cs.mu.oz.au        # Find out what you've been missing while you've
http://www.cs.mu.oz.au/~trd # been rebooting Windows NT. -- InfoWorld, 1998.



More information about the developers mailing list