for review: fix MR_LOWLEVEL_DEBUG

Zoltan Somogyi zs at cs.mu.OZ.AU
Mon Jul 6 15:16:37 AEST 1998


This is for review by Tom.

runtime/mercury_engine.h:
runtime/mercury_overflow.h:
runtime/mercury_misc.c:
	Fix things so that the runtime can be compiled with MR_LOWLEVEL_DEBUG.

Zoltan.

Index: mercury_engine.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_engine.h,v
retrieving revision 1.6
diff -u -u -r1.6 mercury_engine.h
--- mercury_engine.h	1998/06/18 04:30:43	1.6
+++ mercury_engine.h	1998/07/06 07:04:36
@@ -243,6 +243,8 @@
 
 #endif	/* !MR_THREAD_SAFE */
 
+#define	MR_CONTEXT(x)		MR_ENGINE(context).x
+
 #ifndef CONSERVATIVE_GC
   #define IF_NOT_CONSERVATIVE_GC(x)	x
 #else
Index: mercury_overflow.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_overflow.h,v
retrieving revision 1.3
diff -u -u -r1.3 mercury_overflow.h
--- mercury_overflow.h	1998/03/16 12:23:35	1.3
+++ mercury_overflow.h	1998/07/06 07:13:23
@@ -24,54 +24,54 @@
 #include "mercury_regs.h"
 #include "mercury_misc.h"	/* for fatal_error() */
 
-#define	heap_overflow_check()					\
-			(					\
-				IF (MR_hp >= heap_zone->top,(	\
-					fatal_error("heap overflow") \
-				)),				\
-				IF (MR_hp > heap_zone->max,(	\
-					heap_zone->max = MR_hp	\
-				)),				\
-				(void)0				\
-			)
+#define	heap_overflow_check()						\
+		(							\
+			IF (MR_hp >= MR_ENGINE(heap_zone)->top,(	\
+				fatal_error("heap overflow")		\
+			)),						\
+			IF (MR_hp > MR_ENGINE(heap_zone)->max,(		\
+				MR_ENGINE(heap_zone)->max = MR_hp	\
+			)),						\
+			(void)0						\
+		)
 
-#define	detstack_overflow_check()				\
-			(					\
-				IF (MR_sp >= detstack_zone->top,(	\
-					fatal_error("stack overflow") \
-				)),				\
-				IF (MR_sp > detstack_zone->max,(	\
-					detstack_zone->max = MR_sp	\
-				)),				\
-				(void)0				\
-			)
+#define	detstack_overflow_check()					\
+		(							\
+			IF (MR_sp >= MR_CONTEXT(detstack_zone)->top,(	\
+				fatal_error("stack overflow")		\
+			)),						\
+			IF (MR_sp > MR_CONTEXT(detstack_zone)->max,(	\
+				MR_CONTEXT(detstack_zone)->max = MR_sp	\
+			)),						\
+			(void)0						\
+		)
 
-#define	detstack_underflow_check()				\
-			(					\
-				IF (MR_sp < detstack_zone->min,(		\
-					fatal_error("stack underflow") \
-				)),				\
-				(void)0				\
-			)
+#define	detstack_underflow_check()					\
+		(							\
+			IF (MR_sp < MR_CONTEXT(detstack_zone)->min,(	\
+				fatal_error("stack underflow")		\
+			)),						\
+			(void)0						\
+		)
 
-#define	nondstack_overflow_check()				\
-			(					\
-				IF (MR_maxfr >= nondetstack_zone->top,(	\
-					fatal_error("nondetstack overflow") \
-				)),				\
-				IF (MR_maxfr > nondetstack_zone->max,(	\
-					nondetstack_zone->max = MR_maxfr	\
-				)),				\
-				(void)0				\
-			)
+#define	nondstack_overflow_check()					\
+		(							\
+			IF (MR_maxfr >= MR_CONTEXT(nondetstack_zone)->top,( \
+				fatal_error("nondetstack overflow")	\
+			)),						\
+			IF (MR_maxfr > MR_CONTEXT(nondetstack_zone)->max,( \
+				MR_CONTEXT(nondetstack_zone)->max = MR_maxfr \
+			)),						\
+			(void)0						\
+		)
 
-#define	nondstack_underflow_check()				\
-			(					\
-				IF (MR_maxfr < nondetstack_zone->min,(	\
-					fatal_error("nondetstack underflow") \
-				)),				\
-				(void)0				\
-			)
+#define	nondstack_underflow_check()					\
+		(							\
+			IF (MR_maxfr < MR_CONTEXT(nondetstack_zone)->min,( \
+				fatal_error("nondetstack underflow")	\
+			)),						\
+			(void)0						\
+		)
 
 #endif /* MR_CHECK_FOR_OVERFLOW */
 
Index: mercury_misc.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_misc.c,v
retrieving revision 1.8
diff -u -u -r1.8 mercury_misc.c
--- mercury_misc.c	1998/07/03 02:35:17	1.8
+++ mercury_misc.c	1998/07/06 07:06:01
@@ -233,9 +233,9 @@
 	for(i=1; i<=8; i++) {
 		x = (Integer) get_reg(i);
 #ifndef CONSERVATIVE_GC
-		if ( (Integer) heap_zone->min <= x
-				&& x < (Integer) heap_zone->top) {
-			x -= (Integer) heap_zone->min;
+		if ((Integer) MR_ENGINE(heap_zone)->min <= x
+				&& x < (Integer) MR_ENGINE(heap_zone)->top) {
+			x -= (Integer) MR_ENGINE(heap_zone)->min;
 		}
 #endif
 		printf("%8lx ", (long) x);
@@ -274,7 +274,8 @@
 {
 #ifndef CONSERVATIVE_GC
 	printf("ptr 0x%p, offset %3ld words\n",
-		(const void *) h, (long) (Integer) (h - heap_zone->min));
+		(const void *) h,
+		(long) (Integer) (h - MR_ENGINE(heap_zone)->min));
 #else
 	printf("ptr 0x%p\n",
 		(const void *) h);
@@ -286,7 +287,8 @@
 printdetstack(const Word *s)
 {
 	printf("ptr 0x%p, offset %3ld words\n",
-		(const void *) s, (long) (Integer) (s - detstack_zone->min));
+		(const void *) s,
+		(long) (Integer) (s - MR_CONTEXT(detstack_zone)->min));
 	return;
 }
 
@@ -295,12 +297,14 @@
 {
 #ifndef	MR_DEBUG_NONDET_STACK
 	printf("ptr 0x%p, offset %3ld words\n",
-		(const void *) s, (long) (Integer) (s - nondetstack_zone->min));
+		(const void *) s,
+		(long) (Integer) (s - MR_CONTEXT(nondetstack_zone)->min));
 #else
-	if (s > nondetstack_zone->min) {
+	if (s > MR_CONTEXT(nondetstack_zone)->min) {
 		printf("ptr 0x%p, offset %3ld words, procedure %s\n",
 			(const void *) s, 
-			(long) (Integer) (s - nondetstack_zone->min),
+			(long) (Integer)
+				(s - MR_CONTEXT(nondetstack_zone)->min),
 			(const char *) s[PREDNM]);
 	} else {
 		/*
@@ -309,7 +313,8 @@
 		*/
 		printf("ptr 0x%p, offset %3ld words\n",
 			(const void *) s, 
-			(long) (Integer) (s - nondetstack_zone->min));
+			(long) (Integer)
+				(s - MR_CONTEXT(nondetstack_zone)->min));
 	}
 #endif
 	return;
@@ -322,7 +327,7 @@
 
 	printf("frame at ptr 0x%p, offset %3ld words\n",
 		(const void *) fr, 
-		(long) (Integer) (fr - nondetstack_zone->min));
+		(long) (Integer) (fr - MR_CONTEXT(nondetstack_zone)->min));
 #ifdef	MR_DEBUG_NONDET_STACK
 	printf("\t predname  %s\n", bt_prednm(fr));
 #endif
@@ -345,7 +350,8 @@
 	reg	Word	*fr;
 
 	printf("\nnondstack dump\n");
-	for (fr = maxfr; fr > nondetstack_zone->min; fr = bt_prevfr(fr)) {
+	for (fr = maxfr; fr > MR_CONTEXT(nondetstack_zone)->min;
+			fr = bt_prevfr(fr)) {
 		dumpframe(fr);
 	}
 	return;
@@ -390,8 +396,8 @@
 		value = (Integer) get_reg(i+1);
 
 #ifndef	CONSERVATIVE_GC
-		if ((Integer) heap_zone->min <= value
-				&& value < (Integer) heap_zone->top) {
+		if ((Integer) MR_ENGINE(heap_zone)->min <= value &&
+				value < (Integer) MR_ENGINE(heap_zone)->top) {
 			printf("(heap) ");
 		}
 #endif
@@ -467,9 +473,11 @@
 	return p;
 }
 
-/* XXX will need to modify this to kill other threads if MR_THREAD_SAFE
- * (and cleanup resources, etc....)
- */
+/*
+** XXX will need to modify this to kill other threads if MR_THREAD_SAFE
+** (and cleanup resources, etc....)
+*/
+
 void 
 fatal_error(const char *message) {
 	fprintf(stderr, "Mercury runtime: %s\n", message);
@@ -499,4 +507,3 @@
 {
 	HASH_STRING_FUNC_BODY
 }
-



More information about the developers mailing list