[m-dev.] diff: make the runtime compile in agc grades

Zoltan Somogyi zs at cs.mu.OZ.AU
Mon Mar 5 14:48:15 AEDT 2001


runtime/mercury_accurate_gc.c:
runtime/mercury_agc_debug.c:
	Minor changes to bring these files up to date in changes in the rest of
	the runtime. These changes make the runtime compile in accurate gc
	grades.

Zoltan.

cvs diff: Diffing .
Index: mercury_accurate_gc.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_accurate_gc.c,v
retrieving revision 1.11
diff -u -b -r1.11 mercury_accurate_gc.c
--- mercury_accurate_gc.c	2001/01/18 01:19:05	1.11
+++ mercury_accurate_gc.c	2001/02/20 14:46:02
@@ -19,6 +19,7 @@
 /*
 ** Function prototypes.
 */
+
 static	void	garbage_collect(MR_Code *saved_success,
 			MR_Word *stack_pointer,
 			MR_Word *max_frame, MR_Word *current_frame);
@@ -33,6 +34,7 @@
 /*
 ** Global variables (only used in this module, however).
 */
+
 static MR_Code	*saved_success = (MR_Code *) NULL;
 static MR_Word	*saved_success_location = (MR_Word *) NULL;
 static bool	gc_scheduled = FALSE;
@@ -43,11 +45,9 @@
 
 /* The last root on the list */
 static MR_RootList last_root = NULL;
-
 
-Define_extern_entry(mercury__garbage_collect_0_0);
+MR_define_extern_entry(mercury__garbage_collect_0_0);
 
-
 /*
 ** MR_schedule_agc:
 ** 	Schedule garbage collection.  
@@ -62,6 +62,7 @@
 ** 	by information associated with the continuation label
 ** 	that the code will return to).
 */
+
 void
 MR_schedule_agc(MR_Code *pc_at_signal, MR_Word *sp_at_signal, 
 	MR_Word *curfr_at_signal)
@@ -199,8 +200,8 @@
 #endif
 }
 
-BEGIN_MODULE(native_gc)
-BEGIN_CODE
+MR_BEGIN_MODULE(native_gc)
+MR_BEGIN_CODE
 
 /*
 ** Our garbage collection entry label.
@@ -208,7 +209,7 @@
 ** It saves the registers -- we use the saved registers
 ** for garbage collection and leave the real ones alone.
 */
-Define_entry(mercury__garbage_collect_0_0);
+MR_define_entry(mercury__garbage_collect_0_0);
 
         /* record that the collector is running */
 	gc_running = TRUE;
@@ -223,7 +224,7 @@
 	MR_proceed();
 	MR_fatal_error("Unreachable code reached");
 
-END_MODULE
+MR_END_MODULE
 
 /*---------------------------------------------------------------------------*/
 
@@ -247,9 +248,9 @@
     bool                            top_frame = TRUE;
     MR_MemoryList                   allocated_memory_cells = NULL;
     MR_Word                         *old_hp, *new_hp;
-    MR_Proc_Layout	            *proc_layout;
+    const MR_Proc_Layout	    *proc_layout;
     MR_Word                         *first_stack_pointer;
-    MR_Word                         *first_current_frame,
+    MR_Word                         *first_current_frame;
     MR_Word                         *first_max_frame;
 
     old_heap = MR_ENGINE(heap_zone);
@@ -313,8 +314,6 @@
     fprintf(stderr, "MR_virtual_hp: %lx\n", (long) MR_virtual_hp);
 #endif
 
-
-
     /*
     ** For each stack frame ...
     */
@@ -402,7 +401,7 @@
         result = MR_stack_walk_step(proc_layout, &label_layout,
             (MR_Word **) &stack_pointer, &current_frame, &problem);
 
-        if (result == STEP_ERROR_BEFORE || result == STEP_ERROR_AFTER) {
+        if (result == MR_STEP_ERROR_BEFORE || result == MR_STEP_ERROR_AFTER) {
             MR_fatal_error(problem);
         } 
 */
@@ -415,13 +414,11 @@
         top_frame = FALSE;
     } while (label_layout != NULL); /* end for each stack frame... */
 
-
     /* 
     ** New code for nondet.
     ** XXX Will we need correct value of stack_pointer?
     */ 
     
-
     while (max_frame > MR_nondet_stack_trace_bottom) {
 	bool registers_valid;
 	int frame_size;
@@ -458,7 +455,7 @@
 
 		/* 
 		** XXX We must pass NULL since the registers have not
-		** been saved This is probably a bug; Tyson should look
+		** been saved. This is probably a bug; Tyson should look
 		** into it
 		*/
 		type_params = MR_materialize_typeinfos_base(label_layout,
@@ -500,7 +497,6 @@
 	max_frame = MR_prevfr_slot(max_frame);
     }
     
-
     /*
     ** Copy any roots that are not on the stack.
     */
@@ -540,11 +536,10 @@
         (long) ((char *) old_hp - (char *) old_heap->min) -
         ((char *) MR_virtual_hp - (char *) new_heap->min));
 
-
 #endif
 
     /* Reset the redzone on the old heap */
-    reset_redzone(old_heap);
+    MR_reset_redzone(old_heap);
 
 #ifdef MR_DEBUG_AGC_COLLECTION
     fprintf(stderr, "garbage_collect() done.\n\n");
@@ -562,6 +557,7 @@
 ** 	forwarding pointers in the old copy of the data, if
 ** 	it is on the old heap).
 */
+
 static void
 copy_long_value(MR_Long_Lval locn, MR_TypeInfo type_info, bool copy_regs,
 	MR_Word *stack_pointer, MR_Word *current_frame)
@@ -572,7 +568,7 @@
 	switch (MR_LONG_LVAL_TYPE(locn)) {
 		case MR_LONG_LVAL_TYPE_R:
 			if (copy_regs) {
-				MR_virtual_reg(locn_num) = agc_deep_copy(
+				MR_virtual_reg(locn_num) = MR_agc_deep_copy(
 					&MR_virtual_reg(locn_num), type_info,
 					MR_ENGINE(heap_zone2->min),
 					MR_ENGINE(heap_zone2->hardmax));
@@ -637,8 +633,8 @@
 		case MR_SHORT_LVAL_TYPE_R:
 			if (copy_regs) {
 				locn_num = MR_SHORT_LVAL_NUMBER(locn);
-				virtual_reg(locn_num) = agc_deep_copy(
-					&virtual_reg(locn_num), type_info,
+				MR_virtual_reg(locn_num) = MR_agc_deep_copy(
+					&MR_virtual_reg(locn_num), type_info,
 					MR_ENGINE(heap_zone2->min),
 					MR_ENGINE(heap_zone2->hardmax));
 			}
@@ -647,7 +643,7 @@
 		case MR_SHORT_LVAL_TYPE_STACKVAR:
 			locn_num = MR_SHORT_LVAL_NUMBER(locn);
 			MR_based_stackvar(stack_pointer, locn_num) =
-				agc_deep_copy(&MR_based_stackvar(
+				MR_agc_deep_copy(&MR_based_stackvar(
 						stack_pointer,locn_num),
 					type_info, MR_ENGINE(heap_zone2->min),
 					MR_ENGINE(heap_zone2->hardmax));
@@ -656,26 +652,28 @@
 		case MR_SHORT_LVAL_TYPE_FRAMEVAR:
 			locn_num = MR_SHORT_LVAL_NUMBER(locn);
 			MR_based_framevar(current_frame, locn_num) =
-				agc_deep_copy(
-				&MR_based_framevar(current_frame, locn_num),
+				MR_agc_deep_copy(
+					&MR_based_framevar(current_frame,
+						locn_num),
 				type_info,
 				MR_ENGINE(heap_zone2->min),
 				MR_ENGINE(heap_zone2->hardmax));
 			break;
 
 		default:
-			fatal_error("Unknown MR_Short_Lval_Type in copy_short_value");
+			MR_fatal_error("Unknown MR_Short_Lval_Type "
+				"in copy_short_value");
 			break;
 	}
 }
 
-
 /*
 ** garbage_collect_roots:
 ** 
 ** 	Copies the extra roots.  The roots are overwritten
 ** 	with the new data.
 */
+
 static void
 garbage_collect_roots(void) 
 {
@@ -695,6 +693,7 @@
 ** 
 ** 	Adds a new root to the extra roots.
 */
+
 void
 MR_agc_add_root(MR_Word *root_addr, MR_TypeInfo type_info)
 {
Index: mercury_agc_debug.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_agc_debug.c,v
retrieving revision 1.14
diff -u -b -r1.14 mercury_agc_debug.c
--- mercury_agc_debug.c	2001/01/18 01:19:05	1.14
+++ mercury_agc_debug.c	2001/02/20 14:51:30
@@ -21,12 +21,12 @@
 static	void	dump_long_value(MR_Long_Lval locn, MR_MemoryZone *heap_zone,
 			MR_Word * stack_pointer, MR_Word *current_frame,
 			bool do_regs);
-static	void	dump_short_value(MR_Short_Lval locn, MemoryZone *heap_zone,
-			Word * stack_pointer, Word *current_frame,
+static	void	dump_short_value(MR_Short_Lval locn, MR_MemoryZone *heap_zone,
+			MR_Word * stack_pointer, MR_Word *current_frame,
 			bool do_regs);
 static  void	dump_live_variables(const MR_Label_Layout *layout, 
-			MemoryZone *heap_zone, bool top_frame,
-			Word *stack_pointer, Word *current_frame);
+			MR_MemoryZone *heap_zone, bool top_frame,
+			MR_Word *stack_pointer, MR_Word *current_frame);
 
 /*---------------------------------------------------------------------------*/
 
@@ -70,8 +70,8 @@
 }
 
 void
-MR_agc_dump_nondet_stack_frames(MR_Internal *label, MemoryZone *heap_zone,
-	Word *stack_pointer, Word *current_frame, Word *max_frame)
+MR_agc_dump_nondet_stack_frames(MR_Internal *label, MR_MemoryZone *heap_zone,
+	MR_Word *stack_pointer, MR_Word *current_frame, MR_Word *max_frame)
 {
 	Code *success_ip;
 	int frame_size;
@@ -86,7 +86,7 @@
 			fprintf(stderr, "%p: nondet temp\n", max_frame);
 			fprintf(stderr, " redoip: ");
 			fflush(NULL);
-			printlabel(MR_redoip_slot(max_frame));
+			MR_printlabel(stderr, MR_redoip_slot(max_frame));
 			fflush(NULL);
 			fprintf(stderr, " redofr: %p\n",
 				MR_redofr_slot(max_frame));
@@ -104,7 +104,7 @@
 			fprintf(stderr, "%p: nondet temp\n", max_frame);
 			fprintf(stderr, " redoip: ");
 			fflush(NULL);
-			printlabel(MR_redoip_slot(max_frame));
+			MR_printlabel(stderr, MR_redoip_slot(max_frame));
 			fflush(NULL);
 			fprintf(stderr, " redofr: %p\n",
 				MR_redofr_slot(max_frame));
@@ -128,13 +128,13 @@
 			fprintf(stderr, "%p: nondet ordinary\n", max_frame);
 			fprintf(stderr, " redoip: ");
 			fflush(NULL);
-			printlabel(MR_redoip_slot(max_frame));
+			MR_printlabel(stderr, MR_redoip_slot(max_frame));
 			fflush(NULL);
 			fprintf(stderr, " redofr: %p\n",
 				MR_redofr_slot(max_frame));
 			fprintf(stderr, " succip: ");
 			fflush(NULL);
-			printlabel(MR_succip_slot(max_frame));
+			MR_printlabel(stderr, MR_succip_slot(max_frame));
 			fflush(NULL);
 			fprintf(stderr, " succfr: %p\n",
 				MR_succfr_slot(max_frame));
@@ -166,8 +166,10 @@
 #ifdef NATIVE_GC
 	MR_Word saved_regs[MR_MAX_FAKE_REG];
 	int i, short_var_count, long_var_count;
-	MR_Word *type_params, type_info, value;
-	MR_Proc_Layout *entry_layout;
+	MR_Word			*type_params;
+	MR_TypeInfo		type_info;
+	MR_Word			value;
+	const MR_Proc_Layout	*entry_layout;
 	const MR_Label_Layout *layout;
 	const MR_Code *success_ip;
 	bool top_frame = TRUE;
@@ -227,8 +229,8 @@
 
 static void
 dump_live_variables(const MR_Label_Layout *label_layout, 
-		MemoryZone *heap_zone, bool top_frame,
-		Word *stack_pointer, Word *current_frame)
+	MR_MemoryZone *heap_zone, bool top_frame,
+	MR_Word *stack_pointer, MR_Word *current_frame)
 {
 	int short_var_count, long_var_count, i;
 	MR_TypeInfo type_info;
@@ -397,9 +399,10 @@
 			break;
 	}
 	if (have_value) {
-		if (value >= (Word) heap_zone->min && 
-				value < (Word) heap_zone->hardmax) {
-			difference = (Word *) value - (Word *) heap_zone->min;
+		if (value >= (MR_Word) heap_zone->min &&
+				value < (MR_Word) heap_zone->hardmax) {
+			difference = (MR_Word *) value -
+				(MR_Word *) heap_zone->min;
 			fprintf(stderr, "\thp[%d]\t(%lx)", difference,
 				(long) value);
 		} else {
@@ -410,12 +413,12 @@
 }
 
 static void
-dump_short_value(MR_Short_Lval locn, MemoryZone *heap_zone, Word *stack_pointer,
-	Word *current_frame, bool do_regs)
+dump_short_value(MR_Short_Lval locn, MR_MemoryZone *heap_zone,
+	MR_Word *stack_pointer, MR_Word *current_frame, bool do_regs)
 {
 #ifdef NATIVE_GC
 	int	locn_num;
-	Word	value = 0;
+	MR_Word	value = 0;
 	int	difference;
 	bool 	have_value = FALSE;
 
@@ -423,7 +426,7 @@
 	switch (MR_SHORT_LVAL_TYPE(locn)) {
 		case MR_SHORT_LVAL_TYPE_R:
 			if (do_regs) {
-				value = virtual_reg(locn_num);
+				value = MR_virtual_reg(locn_num);
 				have_value = TRUE;
 				fprintf(stderr, "r%d\t", locn_num);
 			} else {
cvs diff: Diffing GETOPT
cvs diff: Diffing machdeps
--------------------------------------------------------------------------
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