diff: Various fixes for stack layouts.

Tyson Dowd trd at cs.mu.oz.au
Tue Jan 6 16:59:13 AEDT 1998


Hi,

This doesn't really need much of a review, it's just cleaning up
for stack traces.

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


Estimated hours taken: 3

Various changes to get stack traces working, and simplify their
implementation.

library/mercury_builtin.m:
runtime/mercury_type_info.c:
	Remove initialization of pred base_type_info from mercury_builtin.m
	and put it into mercury_type_info.c where it belongs.

runtime/mercury_accurate_gc.h:
runtime/mercury_goto.h:
	Fix defintions so that stack traces will work correctly.
	Remove the address from internal stack layouts, it was
	unnecessary and difficult to initialize in a consistent way
	with the entry address.

runtime/mercury_label.c:
	Remove the hack to get labels to work, since it's no
	longer required.

runtime/mercury_wrapper.c:
	Add initialization of stack layouts for some labels that
	got missed somehow during the renaming of files in the
	runtime.


Index: library/mercury_builtin.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/library/mercury_builtin.m,v
retrieving revision 1.88
diff -u -r1.88 mercury_builtin.m
--- mercury_builtin.m	1997/12/19 03:10:26	1.88
+++ mercury_builtin.m	1998/01/05 06:23:17
@@ -670,8 +670,6 @@
 	MR_INIT_BUILTIN_BASE_TYPE_INFO(
 		mercury_data___base_type_info_float_0, _float_);
 	MR_INIT_BUILTIN_BASE_TYPE_INFO(
-		mercury_data___base_type_info_pred_0, _pred_);
-	MR_INIT_BUILTIN_BASE_TYPE_INFO(
 		mercury_data___base_type_info_character_0, _character_);
 	MR_INIT_BUILTIN_BASE_TYPE_INFO(
 		mercury_data___base_type_info_string_0, _string_);
@@ -700,6 +698,7 @@
 :- external(unsafe_promise_unique/2).
 :- pragma c_code("
 Define_extern_entry(mercury__unsafe_promise_unique_2_0);
+MR_MAKE_STACK_LAYOUT_ENTRY(mercury__unsafe_promise_unique_2_0);
 
 BEGIN_MODULE(unsafe_promise_unique_module)
 	init_entry(mercury__unsafe_promise_unique_2_0);
Index: runtime/mercury_accurate_gc.h
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/mercury_accurate_gc.h,v
retrieving revision 1.3
diff -u -r1.3 mercury_accurate_gc.h
--- mercury_accurate_gc.h	1997/12/03 07:26:09	1.3
+++ mercury_accurate_gc.h	1998/01/06 03:54:31
@@ -165,12 +165,10 @@
 #ifdef MR_USE_STACK_LAYOUTS
  #define MR_MAKE_STACK_LAYOUT_INTERNAL_WITH_ENTRY(l, e)			\
  const struct mercury_data__stack_layout__##l##_struct {		\
-	Code * f1;							\
-	const Word * f2;						\
-	Integer f3;							\
-	const Word * f4;						\
+	const Word * f1;						\
+	Integer f2;							\
+	const Word * f3;						\
  } mercury_data__stack_layout__##l = {					\
-	ENTRY(l),							\
 	(const Word *) &mercury_data__stack_layout__##e,		\
 	(Integer) -1,		/* Unknown number of live values */	\
 	(const Word *) NULL	/* No list of live valeus */		\
@@ -195,15 +193,13 @@
 ** and the reference to the entry for this label.
 */ 
 #ifdef MR_USE_STACK_LAYOUTS
- #define MR_MAKE_STACK_LAYOUT_INTERNAL(l, x)				\
- const struct mercury_data__stack_layout__##l##_i##x##_struct {		\
-	Code * f1;							\
-	const Word * f2;						\
-	Integer f3;							\
-	const Word * f4;						\
- } mercury_data__stack_layout__##l##_i##x = {				\
-	ENTRY(l),							\
-	(const Word *) &mercury_data__stack_layout__##l,		\
+ #define MR_MAKE_STACK_LAYOUT_INTERNAL(e, x)				\
+ const struct mercury_data__stack_layout__##e##_i##x##_struct {		\
+	const Word * f1;						\
+	Integer f2;							\
+	const Word * f3;						\
+ } mercury_data__stack_layout__##e##_i##x = {				\
+	(const Word *) &mercury_data__stack_layout__##e,		\
 	(Integer) -1,		/* Unknown number of live values */	\
 	(const Word *) NULL	/* No list of live valeus */		\
  };
@@ -217,14 +213,12 @@
 ** XXX ought to use a MR_Entry_Stack_Layout and MR_Cont_Stack_Layout
 ** struct to make it easier to access the fields.
 */
-#define MR_CONT_STACK_LAYOUT_GET_LABEL_ADDRESS(s)		\
-		((Code *) field(0, (s), 0))
 
 #define MR_ENTRY_STACK_LAYOUT_GET_LABEL_ADDRESS(s)		\
-		MR_CONT_STACK_LAYOUT_GET_LABEL_ADDRESS(s)
+		((Code *) field(0, (s), 0))
 
 #define MR_CONT_STACK_LAYOUT_GET_ENTRY_LAYOUT(s)		\
-		(field(0, (s), 1))
+		(field(0, (s), 0))
 
 #define MR_ENTRY_STACK_LAYOUT_GET_NUM_SLOTS(s)			\
 		(field(0, (s), 1))
Index: runtime/mercury_goto.h
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/mercury_goto.h,v
retrieving revision 1.4
diff -u -r1.4 mercury_goto.h
--- mercury_goto.h	1998/01/01 10:56:14	1.4
+++ mercury_goto.h	1998/01/06 04:03:23
@@ -11,6 +11,7 @@
 
 #include "mercury_types.h"	/* for `Code *' */
 #include "mercury_debug.h"	/* for debuggoto() */
+#include "mercury_accurate_gc.h"
 
 #define paste(a,b) a##b
 #define stringify(string) #string
@@ -33,20 +34,21 @@
 ** accurate garbage collection.
 */
 
-#if defined(SPEED) && !defined(DEBUG_GOTOS)
+#if defined(SPEED) && !defined(DEBUG_GOTOS) && !defined(NATIVE_GC)
 #define	make_label(n, a, l)	/* nothing */
 #else
 #define	make_label(n, a, l)	make_entry(n, a, l)
 #endif
 
-#if defined(SPEED) && !defined(DEBUG_GOTOS) && !defined(PROFILE_CALLS)
+#if defined(SPEED) && !defined(DEBUG_GOTOS) && !defined(PROFILE_CALLS) \
+			&& !defined(NATIVE_GC)
 #define make_local(n, a, l)	/* nothing */
 #else 
 #define make_local(n, a, l)	make_entry(n, a, l)
 #endif
 
 #if defined(SPEED) && !defined(DEBUG_LABELS) && !defined(DEBUG_GOTOS) \
-			&& !defined(PROFILE_CALLS)
+			&& !defined(PROFILE_CALLS) && !defined(NATIVE_GC)
 #define make_entry(n, a, l)	/* nothing */
 #else
 #define make_entry(n, a, l)	insert_entry(n, a, MR_STACK_LAYOUT(l))
@@ -513,14 +515,14 @@
 	label:	\
 	{
   #define init_local(label)	make_local(stringify(label), &&label, label)
+  #define Define_label(label)	Define_local(label)
+  #define Declare_label(label)	/* no declaration required */
   #ifdef NATIVE_GC
-   #define Declare_label(label)	Define_extern_entry(label)
-   #define Define_label(label)	Define_entry(label)
+   #define init_label(label)	\
+	make_label(stringify(label), &&entry(label), label)
   #else
-   #define Declare_label(label)	/* no declaration required */
-   #define Define_label(label)	Define_local(label)
+   #define init_label(label)	make_label(stringify(label), &&label, label)
   #endif
-  #define init_label(label)	make_label(stringify(label), &&label, label)
 
   #define LOCAL(label)		(&&entry(label))
   #define LABEL(label)		(&&entry(label))
Index: runtime/mercury_label.c
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/mercury_label.c,v
retrieving revision 1.4
diff -u -r1.4 mercury_label.c
--- mercury_label.c	1997/12/05 15:56:40	1.4
+++ mercury_label.c	1998/01/06 04:02:15
@@ -57,20 +57,6 @@
 
 	do_init_entries();
 
-
-#ifdef MR_USE_STACK_LAYOUTS
-	/* 
-	** The succip will be set to the address stored in the
-	** layout info. For some reason, this is different to
-	** the address passed to insert_entry.
-	** XXX This should be fixed.
-	*/
-	addr = entry_layout_info[0];
-#endif /* MR_USE_STACK_LAYOUTS */
-
-
-
-
 	entry = make(Label);
 	entry->e_name  = name;
 	entry->e_addr  = addr;
Index: runtime/mercury_type_info.c
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/mercury_type_info.c,v
retrieving revision 1.3
diff -u -r1.3 mercury_type_info.c
--- mercury_type_info.c	1997/12/03 07:26:22	1.3
+++ mercury_type_info.c	1998/01/05 06:23:17
@@ -157,4 +157,8 @@
 	mercury__builtin_unify_pred_module();
 	mercury__builtin_index_pred_module();
 	mercury__builtin_compare_pred_module();
+
+	MR_INIT_BUILTIN_BASE_TYPE_INFO(
+		mercury_data___base_type_info_pred_0, _pred_);
 }
+
Index: runtime/mercury_wrapper.c
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/mercury_wrapper.c,v
retrieving revision 1.4
diff -u -r1.4 mercury_wrapper.c
--- mercury_wrapper.c	1997/12/05 15:56:50	1.4
+++ mercury_wrapper.c	1998/01/05 06:23:17
@@ -866,6 +866,11 @@
 Declare_label(global_fail);
 Declare_label(all_done);
 
+MR_MAKE_STACK_LAYOUT_ENTRY(do_interpreter);
+MR_MAKE_STACK_LAYOUT_INTERNAL_WITH_ENTRY(global_success, do_interpreter);
+MR_MAKE_STACK_LAYOUT_INTERNAL_WITH_ENTRY(global_fail, do_interpreter);
+MR_MAKE_STACK_LAYOUT_INTERNAL_WITH_ENTRY(all_done, do_interpreter);
+
 BEGIN_MODULE(interpreter_module)
 	init_entry(do_interpreter);
 	init_label(global_success);


-- 
       Tyson Dowd           # If I'm unusually agressive in this email, it's
                            # probably because USENET has been down here for
     trd at cs.mu.oz.au        # over a week, and I'm missing my usual dosage
http://www.cs.mu.oz.au/~trd # of flamewars. My apologies in advance.



More information about the developers mailing list