[m-dev.] for review: fix broken mdb

Tyson Dowd trd at cs.mu.OZ.AU
Thu Jul 15 11:41:24 AEST 1999


Hi,

Fergus, here is a fix for the failing debugger.

I haven't actually tested that it fixes this problem, but this
change is necessary anyway.

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


Estimated hours taken: 4

Fix a bug that was causing the compiler to fail the debugger
tests with an unknown layout error.  std_util:type_info/0 needs
to be defined by hand so we can tell the RTTI system that it is
a type_info.

compiler/type_util.m:
	Add std_util:type_info/0 to the hand defined types.
	This is different to private_builtin:type_info/1 which
	was already there.  It was type_info/0 that the debugger
	was failing on.

library/builtin.m:
	Move the type_ctor_info for c_pointer back into this module.
	It should have finished bootstrapping by now.

library/std_util.m:
	Define type_ctor_info as (abstractly) equivalent to a type_info
	instead of equivalent to a c_pointer.  This will allow this type
	to be handled by the garbage collector or debugger.

runtime/mercury_bootstrap.c:
	Move the RTTI info for c_pointer out of this module.
	Add the type_ctor_info for type_info/0 as it is now a hand
	defined type.

tests/hard_coded/higher_order_type_manip.exp:
	Fix expected test results not that type_ctor_info is equivalent
	to type_info/0.
	


Index: compiler/type_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/type_util.m,v
retrieving revision 1.69
diff -u -r1.69 type_util.m
--- type_util.m	1999/07/08 08:15:18	1.69
+++ type_util.m	1999/07/12 22:21:16
@@ -308,6 +308,7 @@
 
 type_id_is_hand_defined(qualified(unqualified("builtin"), "c_pointer") - 0).
 type_id_is_hand_defined(qualified(unqualified("std_util"), "univ") - 0).
+type_id_is_hand_defined(qualified(unqualified("std_util"), "type_info") - 0).
 type_id_is_hand_defined(qualified(unqualified("array"), "array") - 1).
 type_id_is_hand_defined(qualified(PrivateBuiltin, "type_info") - 1) :-
 	mercury_private_builtin_module(PrivateBuiltin).
Index: library/builtin.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/builtin.m,v
retrieving revision 1.17
diff -u -r1.17 builtin.m
--- builtin.m	1999/07/06 06:31:56	1.17
+++ builtin.m	1999/07/12 21:36:32
@@ -949,6 +949,30 @@
 Define_extern_entry(mercury____Index___builtin__c_pointer_0_0);
 Define_extern_entry(mercury____Compare___builtin__c_pointer_0_0);
 
+
+const struct mercury_data_builtin__type_ctor_info_c_pointer_0_struct {
+        Integer f1;
+	Code * f2;
+	Code * f3;
+	Code * f4;
+	Integer f5;
+	Word * f6;
+	Word * f7;
+	Word * f8;
+	Word * f9;
+}  mercury_data_builtin__type_ctor_info_c_pointer_0 = {
+	(Integer) 0,
+	ENTRY(mercury____Unify___builtin__c_pointer_0_0),
+	ENTRY(mercury____Index___builtin__c_pointer_0_0),
+	ENTRY(mercury____Compare___builtin__c_pointer_0_0),
+	MR_TYPECTOR_REP_C_POINTER,
+	(Word *) &mercury_data_builtin__type_ctor_functors_c_pointer_0,
+	(Word *) &mercury_data_builtin__type_ctor_layout_c_pointer_0,
+	string_const(""builtin"", 7),
+	string_const(""c_pointer"", 9)
+};
+
+
 BEGIN_MODULE(unify_c_pointer_module)
 	init_entry(mercury____Unify___builtin__c_pointer_0_0);
 	init_entry(mercury____Index___builtin__c_pointer_0_0);
Index: library/std_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/std_util.m,v
retrieving revision 1.151
diff -u -r1.151 std_util.m
--- std_util.m	1999/07/07 15:19:41	1.151
+++ std_util.m	1999/07/12 22:21:39
@@ -1322,10 +1322,10 @@
 ").
 
 
-	% A type_ctor_info is represented as a pointer to a type_ctor_info,
-	% except for higher-order types, which are represented using
-	% small integers.  See runtime/type_info.h.
-:- type type_ctor_info == c_pointer.  
+	% A type_ctor_info is really just a subtype of type_info,
+	% but we should hide this from users as it is an implementation
+	% detail.
+:- type type_ctor_info == type_info.  
 
 :- pragma c_code(type_of(_Value::unused) = (TypeInfo::out),
 	will_not_call_mercury, " 
Index: runtime/mercury_bootstrap.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_bootstrap.c,v
retrieving revision 1.14
diff -u -r1.14 mercury_bootstrap.c
--- mercury_bootstrap.c	1999/07/06 06:32:14	1.14
+++ mercury_bootstrap.c	1999/07/12 21:33:58
@@ -22,25 +22,30 @@
 #include "mercury_imp.h"
 
 MR_MODULE_STATIC_OR_EXTERN
-const struct mercury_data_builtin__type_ctor_layout_c_pointer_0_struct_bootstrap {
+const struct mercury_data_std_util__type_ctor_layout_type_info_0_struct
+{
 	TYPE_LAYOUT_FIELDS
-} mercury_data_builtin__type_ctor_layout_c_pointer_0_bootstrap = {
+} mercury_data_std_util__type_ctor_layout_type_info_0_bootstrap = {
 	make_typelayout_for_all_tags(TYPE_CTOR_LAYOUT_CONST_TAG, 
-		mkbody(MR_TYPE_CTOR_LAYOUT_C_POINTER_VALUE))
+		mkbody(MR_TYPE_CTOR_LAYOUT_TYPEINFO_VALUE))
 };
 
 MR_MODULE_STATIC_OR_EXTERN
-const struct mercury_data_builtin__type_ctor_functors_c_pointer_0_struct_bootstrap {
+const struct
+mercury_data_std_util__type_ctor_functors_type_info_0_struct {
 	Integer f1;
-} mercury_data_builtin__type_ctor_functors_c_pointer_0_bootstrap = {
+} mercury_data_std_util__type_ctor_functors_type_info_0_bootstrap = {
 	MR_TYPE_CTOR_FUNCTORS_SPECIAL
 };
 
-Declare_entry(mercury____Unify___builtin__c_pointer_0_0_bootstrap);
-Declare_entry(mercury____Index___builtin__c_pointer_0_0_bootstrap);
-Declare_entry(mercury____Compare___builtin__c_pointer_0_0_bootstrap);
 
-const struct mercury_data_builtin__type_ctor_info_c_pointer_0_struct {
+Define_extern_entry(mercury____Unify___std_util__type_info_0_0_bootstrap);
+Define_extern_entry(mercury____Index___std_util__type_info_0_0_bootstrap);
+Define_extern_entry(mercury____Compare___std_util__type_info_0_0_bootstrap);
+
+
+
+const struct mercury_data_std_util__type_ctor_info_type_info_0_struct {
 	Integer f1;
 	Code * f2;
 	Code * f3;
@@ -50,59 +55,71 @@
 	Word * f7;
 	Word * f8;
 	Word * f9;
-}  mercury_data_builtin__type_ctor_info_c_pointer_0 = {
+}  mercury_data_std_util__type_ctor_info_type_info_0 = {
 	(Integer) 0,
-	ENTRY(mercury____Unify___builtin__c_pointer_0_0_bootstrap),
-	ENTRY(mercury____Index___builtin__c_pointer_0_0_bootstrap),
-	ENTRY(mercury____Compare___builtin__c_pointer_0_0_bootstrap),
-	MR_TYPECTOR_REP_C_POINTER,
-	(Word *) &mercury_data_builtin__type_ctor_functors_c_pointer_0_bootstrap,
-	(Word *) &mercury_data_builtin__type_ctor_layout_c_pointer_0_bootstrap,
-	string_const("builtin", 7),
-	string_const("c_pointer", 9)
+	ENTRY(mercury____Unify___std_util__type_info_0_0_bootstrap),
+	ENTRY(mercury____Index___std_util__type_info_0_0_bootstrap),
+	ENTRY(mercury____Compare___std_util__type_info_0_0_bootstrap),
+	(Integer) 15,
+	(Word *) &mercury_data_std_util__type_ctor_functors_type_info_0_bootstrap,
+	(Word *) &mercury_data_std_util__type_ctor_layout_type_info_0_bootstrap,
+	string_const("std_util", 8),
+	string_const("type_info", 9)
 };
 
-Define_extern_entry(mercury____Unify___builtin__c_pointer_0_0_bootstrap);
-Define_extern_entry(mercury____Index___builtin__c_pointer_0_0_bootstrap);
-Define_extern_entry(mercury____Compare___builtin__c_pointer_0_0_bootstrap);
-
-BEGIN_MODULE(unify_c_pointer_module_bootstrap)
-	init_entry(mercury____Unify___builtin__c_pointer_0_0_bootstrap);
-	init_entry(mercury____Index___builtin__c_pointer_0_0_bootstrap);
-	init_entry(mercury____Compare___builtin__c_pointer_0_0_bootstrap);
 
+BEGIN_MODULE(unify_univ_module_bootstrap)
+	init_entry(mercury____Unify___std_util__type_info_0_0_bootstrap);
+	init_entry(mercury____Index___std_util__type_info_0_0_bootstrap);
+	init_entry(mercury____Compare___std_util__type_info_0_0_bootstrap);
 BEGIN_CODE
-Define_entry(mercury____Unify___builtin__c_pointer_0_0_bootstrap);
+Define_entry(mercury____Unify___std_util__type_info_0_0_bootstrap);
+{
 	/*
-	** For c_pointer, we assume that equality and comparison
-	** can be based on object identity (i.e. using address comparisons).
-	** This is correct for types like io__stream, and necessary since
-	** the io__state contains a map(io__stream, filename).
-	** However, it might not be correct in general...
+	** 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.
 	*/
-	r1 = (r1 == r2);
+	int	comp;
+
+	save_transient_registers();
+	comp = MR_compare_type_info(r1, r2);
+	restore_transient_registers();
+	r1 = (comp == COMPARE_EQUAL);
 	proceed();
+}
 
-Define_entry(mercury____Index___builtin__c_pointer_0_0_bootstrap);
+Define_entry(mercury____Index___std_util__type_info_0_0_bootstrap);
 	r1 = -1;
 	proceed();
 
-Define_entry(mercury____Compare___builtin__c_pointer_0_0_bootstrap);
-	r1 = (r1 == r2 ? COMPARE_EQUAL :
-			  r1 < r2 ? COMPARE_LESS :
-			  COMPARE_GREATER);
+Define_entry(mercury____Compare___std_util__type_info_0_0_bootstrap);
+{
+	/*
+	** 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(r1, r2);
+	restore_transient_registers();
+	r1 = comp;
 	proceed();
+}
 
 END_MODULE
 
 /* Ensure that the initialization code for the above module gets run. */
 /*
-INIT sys_init_unify_c_pointer_module_bootstrap
+INIT sys_init_unify_univ_module_bootstrap
 */
-
-extern ModuleFunc unify_c_pointer_module_bootstrap;
-void sys_init_unify_c_pointer_module_bootstrap(void);
-	/* duplicate declaration to suppress gcc -Wmissing-decl warning */
-void sys_init_unify_c_pointer_module_bootstrap(void) {
-	unify_c_pointer_module_bootstrap();
+extern ModuleFunc unify_univ_module;
+void sys_init_unify_univ_module_bootstrap(void); /* suppress gcc -Wmissing-decl warning */
+void sys_init_unify_univ_module_bootstrap(void) {
+	unify_univ_module_bootstrap();
 }
+
Index: tests/hard_coded/higher_order_type_manip.exp
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/higher_order_type_manip.exp,v
retrieving revision 1.2
diff -u -r1.2 higher_order_type_manip.exp
--- higher_order_type_manip.exp	1997/08/05 04:38:17	1.2
+++ higher_order_type_manip.exp	1999/07/15 01:21:11
@@ -1,5 +1,5 @@
 func(std_util:type_info) = string
-pred(std_util:type_info, c_pointer, list:list(std_util:type_info))
+pred(std_util:type_info, std_util:type_info, list:list(std_util:type_info))
 int
 higher_order_type_manip:container(list:list(int))
 higher_order_type_manip:container(pred(io:state, io:state))


-- 
       Tyson Dowd           # 
                            #  Surreal humour isn't eveyone's cup of fur.
     trd at cs.mu.oz.au        # 
http://www.cs.mu.oz.au/~trd #
--------------------------------------------------------------------------
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