[m-rev.] diff: fix more SPARC transient register bugs

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Feb 22 12:14:04 AEDT 2002


Estimated hours taken: 4
Branches: main

runtime/mercury_ml_expand_body.h:
	Fix incorrect handling of transient registers:
	- Delete the incorrect wrapping of
	  MR_restore_transient_hp()/MR_save_transient_hp()
	  around calls to the FUNCTION MR_expand_type_name(),
	  which expects the heap pointer to be saved (if transient);
	  the hp is already saved (if transient) before the call,
	  and trying to restore it immediately after a call to
	  a C function has returned will just fill it with garbage.
	- Wrap MR_restore_transient_hp()/MR_save_transient_hp()
	  around calls to the MACRO MR_make_aligned_string,
	  because it expects the hp register to be valid,
	  and because it can allocate heap.
	
runtime/mercury_ml_expand_body.h:
runtime/mercury_deconstruct.c:
	Add default cases that call MR_fatal_error() to a couple of switch
	statements, to supress gcc warnings about uninitialized variables.

Workspace: /tmp/fjh/mercury
Index: runtime/mercury_deconstruct.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_deconstruct.c,v
retrieving revision 1.6
diff -u -d -r1.6 mercury_deconstruct.c
--- runtime/mercury_deconstruct.c	2002/02/18 07:01:14	1.6
+++ runtime/mercury_deconstruct.c	2002/02/22 01:07:08
@@ -209,6 +209,8 @@
                     break;
                 case MR_SECTAG_VARIABLE:
                     MR_fatal_error("MR_named_arg_num(): unexpected variable");
+                default:
+                    MR_fatal_error("MR_named_arg_num(): invalid sectag_locn");
             }
 
             if (functor_desc->MR_du_functor_arg_names == NULL) {
Index: runtime/mercury_ml_expand_body.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_ml_expand_body.h,v
retrieving revision 1.14
diff -u -d -r1.14 mercury_ml_expand_body.h
--- runtime/mercury_ml_expand_body.h	2002/02/18 07:01:18	1.14
+++ runtime/mercury_ml_expand_body.h	2002/02/22 01:05:44
@@ -151,18 +151,20 @@
 #ifdef  EXPAND_FUNCTOR_FIELD
   #define handle_functor_name(name)                                     \
             do {                                                        \
+                MR_restore_transient_hp();                              \
                 MR_make_aligned_string(expand_info->EXPAND_FUNCTOR_FIELD,\
                     name);                                              \
+                MR_save_transient_hp();                                 \
             } while (0)
   #define handle_noncanonical_name(tci)                                 \
             do {                                                        \
                 MR_ConstString  name;                                   \
                                                                         \
-                MR_restore_transient_hp();                              \
                 name = MR_expand_type_name(tci);                        \
-                MR_save_transient_hp();                                 \
+                MR_restore_transient_hp();                              \
                 MR_make_aligned_string(expand_info->EXPAND_FUNCTOR_FIELD,\
                     name);                                              \
+                MR_save_transient_hp();                                 \
             } while (0)
 #else   /* EXPAND_FUNCTOR_FIELD */
   #define handle_functor_name(name)                                     \
@@ -385,6 +387,9 @@
                         handle_functor_name("<<variable>>");
                         handle_zero_arity_args();
 						return;
+                    default:
+                        MR_fatal_error(MR_STRINGIFY(EXPAND_FUNCTION_NAME)
+                             ": invalid sectag_locn");
 				}
 
                 handle_functor_name(functor_desc->MR_du_functor_name);

-- 
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