[m-rev.] diff: fix sparc register window bug

Fergus Henderson fjh at cs.mu.OZ.AU
Wed Feb 13 17:31:40 AEDT 2002


Estimated hours taken: 2
Branches: main

runtime/mercury_unify_compare_body.h:
runtime/mercury_ho_call.c:
	Call MR_save_transient_registers() and MR_restore_transient_registers()
	when calling or returning from C functions.
	Wrap MR_save_transient_hp() and MR_restore_transient_hp()
	around a call to MR_create_type_info_maybe_existq().

Workspace: /home/ceres/fjh/mercury
Index: runtime/mercury_ho_call.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_ho_call.c,v
retrieving revision 1.49
diff -u -d -r1.49 mercury_ho_call.c
--- runtime/mercury_ho_call.c	28 Jan 2002 17:27:58 -0000	1.49
+++ runtime/mercury_ho_call.c	13 Feb 2002 06:22:48 -0000
@@ -417,11 +417,14 @@
 
 #define initialize()							\
 	do {								\
-		(void) 0; /* do nothing */				\
-	} while(0)
+		MR_restore_transient_registers();			\
+	} while (0)
 
 #define return_answer(answer)						\
-	return (answer)
+	do {								\
+		MR_save_transient_registers();				\
+		return (answer);					\
+	} while (0)
 
 #define	tailcall_user_pred()						\
 	do {								\
@@ -452,17 +455,19 @@
 static MR_Word
 MR_generic_compare(MR_TypeInfo type_info, MR_Word x, MR_Word y)
 {
-
 #define	DECLARE_LOCALS							\
 	MR_TypeCtorInfo	type_ctor_info;
 
 #define initialize()							\
 	do {								\
-		(void) 0; /* do nothing */				\
-	} while(0)
+		MR_restore_transient_registers();			\
+	} while (0)
 
 #define return_answer(answer)						\
-	return (answer)
+	do {								\
+		MR_restore_transient_registers();			\
+		return (answer);					\
+	} while (0)
 
 #define	tailcall_user_pred()						\
 	do {								\
Index: runtime/mercury_unify_compare_body.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_unify_compare_body.h,v
retrieving revision 1.16
diff -u -d -r1.16 mercury_unify_compare_body.h
--- runtime/mercury_unify_compare_body.h	30 Jan 2002 05:09:03 -0000	1.16
+++ runtime/mercury_unify_compare_body.h	13 Feb 2002 06:22:48 -0000
@@ -238,7 +238,9 @@
                                 y_data_value[locns[i].MR_exist_arg_num],
                                 locns[i].MR_exist_offset_in_tci);
                         }
+			MR_save_transient_registers();
                         result = MR_compare_type_info(x_ti, y_ti);
+			MR_restore_transient_registers();
                         if (result != MR_COMPARE_EQUAL) {
   #ifdef  select_compare_code
                             return_answer(result);
@@ -255,23 +257,29 @@
                     MR_TypeInfo arg_type_info;
 
                     if (MR_arg_type_may_contain_var(functor_desc, i)) {
+		        MR_save_transient_hp();
                         arg_type_info = MR_create_type_info_maybe_existq(
                             MR_TYPEINFO_GET_FIRST_ORDER_ARG_VECTOR(type_info),
                             functor_desc->MR_du_functor_arg_types[i],
                             x_data_value, functor_desc);
+		        MR_restore_transient_hp();
                     } else {
                         arg_type_info = (MR_TypeInfo)
                             functor_desc->MR_du_functor_arg_types[i];
                     }
   #ifdef  select_compare_code
+		    MR_save_transient_registers();
                     result = MR_generic_compare(arg_type_info,
                         x_data_value[cur_slot], y_data_value[cur_slot]);
+		    MR_restore_transient_registers();
                     if (result != MR_COMPARE_EQUAL) {
                         return_answer(result);
                     }
   #else
+		    MR_save_transient_registers();
                     result = MR_generic_unify(arg_type_info,
                         x_data_value[cur_slot], y_data_value[cur_slot]);
+		    MR_restore_transient_registers();
                     if (! result) {
                         return_answer(FALSE);
                     }
@@ -386,14 +394,18 @@
                                             type_info)[i + 1];
 
 #ifdef  select_compare_code
+		    MR_save_transient_registers();
                     result = MR_generic_compare(arg_type_info,
                                 ((MR_Word *) x)[i], ((MR_Word *) y)[i]);
+		    MR_restore_transient_registers();
                     if (result != MR_COMPARE_EQUAL) {
                         return_answer(result);
                     }
 #else
+		    MR_save_transient_registers();
                     result = MR_generic_unify(arg_type_info,
                                 ((MR_Word *) x)[i], ((MR_Word *) y)[i]);
+		    MR_restore_transient_registers();
                     if (! result) {
                         return_answer(FALSE);
                     }

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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