[m-rev.] for review: stack segments

Zoltan Somogyi zs at csse.unimelb.edu.au
Tue Oct 31 14:10:24 AEDT 2006


On 31-Oct-2006, Peter Wang <wangp at students.csse.unimelb.edu.au> wrote:
> The rest looked fine, but some files had an inconsistent mix of tabs and
> spaces so indentation was off when viewed with the default tab size.

That is because the diff was created with diff -b, so when the old code
has been changed from tabs to spaces, it shows the old, tabbed line. (This
is preferable to having the substantive changes buried in lots of lines
that differ only in indentation.)

Here is a prospective interdiff addressing all your points; I will bootcheck
it in several grades tonight.

Zoltan.

Diffing .
Diffing analysis
Diffing bindist
Diffing boehm_gc
Diffing boehm_gc/Mac_files
Diffing boehm_gc/cord
Diffing boehm_gc/cord/private
Diffing boehm_gc/doc
Diffing boehm_gc/include
Diffing boehm_gc/include/private
Diffing boehm_gc/libatomic_ops-1.2
Diffing boehm_gc/libatomic_ops-1.2/doc
Diffing boehm_gc/libatomic_ops-1.2/src
Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops
Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps
Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc
Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/hpc
Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/ibmc
Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/icc
Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/msftc
Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/sunc
Diffing boehm_gc/libatomic_ops-1.2/tests
Diffing boehm_gc/tests
Diffing boehm_gc/windows-untested
Diffing boehm_gc/windows-untested/vc60
Diffing boehm_gc/windows-untested/vc70
Diffing boehm_gc/windows-untested/vc71
Diffing browser
Diffing bytecode
Diffing compiler
--- /home/zs/mer/ws8/compiler/options.m	2006-10-28 01:58:23.000000000 +1000
+++ options.m	2006-10-31 13:28:55.000000000 +1100
@@ -3579,7 +3579,7 @@
         "--extend-stacks-when-needed",
         "\tSpecify that code that increments a stack pointer must",
         "\textend the stack when this is needed.",
-        "--stack-segments-needed",
+        "--stack-segments",
         "\tSpecify that code that increments a stack pointer must allocate",
         "\ta new stack segment when the limit on the old one is reached."
     ]),
Diffing compiler/notes
Diffing debian
Diffing debian/patches
Diffing deep_profiler
Diffing deep_profiler/notes
Diffing doc
Diffing extras
Diffing extras/cgi
Diffing extras/complex_numbers
Diffing extras/complex_numbers/samples
Diffing extras/complex_numbers/tests
Diffing extras/concurrency
Diffing extras/curs
Diffing extras/curs/samples
Diffing extras/curses
Diffing extras/curses/sample
Diffing extras/dynamic_linking
Diffing extras/error
Diffing extras/gator
Diffing extras/gator/generations
Diffing extras/gator/generations/1
Diffing extras/graphics
Diffing extras/graphics/easyx
Diffing extras/graphics/easyx/samples
Diffing extras/graphics/mercury_glut
Diffing extras/graphics/mercury_opengl
Diffing extras/graphics/mercury_tcltk
Diffing extras/graphics/samples
Diffing extras/graphics/samples/calc
Diffing extras/graphics/samples/gears
Diffing extras/graphics/samples/maze
Diffing extras/graphics/samples/pent
Diffing extras/lazy_evaluation
Diffing extras/lex
Diffing extras/lex/samples
Diffing extras/lex/tests
Diffing extras/logged_output
Diffing extras/moose
Diffing extras/moose/samples
Diffing extras/moose/tests
Diffing extras/morphine
Diffing extras/morphine/non-regression-tests
Diffing extras/morphine/scripts
Diffing extras/morphine/source
Diffing extras/odbc
Diffing extras/posix
Diffing extras/quickcheck
Diffing extras/quickcheck/tutes
Diffing extras/references
Diffing extras/references/samples
Diffing extras/references/tests
Diffing extras/solver_types
Diffing extras/solver_types/library
Diffing extras/stream
Diffing extras/trailed_update
Diffing extras/trailed_update/samples
Diffing extras/trailed_update/tests
Diffing extras/windows_installer_generator
Diffing extras/windows_installer_generator/sample
Diffing extras/windows_installer_generator/sample/images
Diffing extras/xml
Diffing extras/xml/samples
Diffing extras/xml_stylesheets
Diffing java
Diffing java/runtime
Diffing library
Diffing mdbcomp
Diffing profiler
Diffing robdd
Diffing runtime
--- /home/zs/mer/ws8/runtime/mercury_context.c	2006-10-29 13:05:02.000000000 +1100
+++ mercury_context.c	2006-10-31 13:59:57.000000000 +1100
@@ -161,8 +161,8 @@
     if (c->MR_ctxt_nondetstack_zone == NULL) {
         if (gen != NULL) {
             c->MR_ctxt_nondetstack_zone = MR_create_zone("gen_nondetstack",
-                    0, MR_gen_nonstack_size, MR_next_offset(),
-                    MR_gen_nonstack_zone_size, MR_default_handler);
+                    0, MR_gen_nondetstack_size, MR_next_offset(),
+                    MR_gen_nondetstack_zone_size, MR_default_handler);
         } else {
             c->MR_ctxt_nondetstack_zone = MR_create_zone(nondetstack_name,
                     0, nondetstack_size, MR_next_offset(),
--- /home/zs/mer/ws8/runtime/mercury_memory.c	2006-10-29 13:04:24.000000000 +1100
+++ mercury_memory.c	2006-10-31 13:58:58.000000000 +1100
@@ -1,4 +1,7 @@
 /*
+** vim: ts=4 sw=4 expandtab
+*/
+/*
 ** Copyright (C) 1994-2000,2002-2004, 2006 The University of Melbourne.
 ** This file may only be copied under the terms of the GNU Library General
 ** Public License - see the file COPYING.LIB in the Mercury distribution.
@@ -116,8 +119,9 @@
 {
 	static MR_bool already_initialized = MR_FALSE;
 
-	if (already_initialized != MR_FALSE)
+    if (already_initialized != MR_FALSE) {
 		return;
+    }
 
 	already_initialized = MR_TRUE;
 
@@ -140,52 +144,30 @@
 	MR_debug_heap_zone_size	 = 0;
 	MR_heap_margin_size	 = 0;
 #else
-	MR_heap_size		 = MR_round_up(MR_heap_size * 1024,
-					MR_unit);
-	MR_heap_zone_size	 = MR_round_up(MR_heap_zone_size * 1024,
-					MR_unit);
-	MR_solutions_heap_size	 = MR_round_up(MR_solutions_heap_size * 1024,
-					MR_unit);
-	MR_solutions_heap_zone_size = MR_round_up(
-					MR_solutions_heap_zone_size * 1024, 
-					MR_unit);
-	MR_global_heap_size	 = MR_round_up(MR_global_heap_size * 1024,
-					MR_unit);
-	MR_global_heap_zone_size = MR_round_up(MR_global_heap_zone_size * 1024,
-					MR_unit);
-	MR_debug_heap_size	 = MR_round_up(MR_debug_heap_size * 1024,
-					MR_unit);
-	MR_debug_heap_zone_size	 = MR_round_up(MR_debug_heap_zone_size * 1024,
-					MR_unit);
+    MR_kilobytes_to_bytes_and_round_up(MR_heap_size);
+    MR_kilobytes_to_bytes_and_round_up(MR_heap_zone_size);
+    MR_kilobytes_to_bytes_and_round_up(MR_solutions_heap_size);
+    MR_kilobytes_to_bytes_and_round_up(MR_solutions_heap_zone_size);
+    MR_kilobytes_to_bytes_and_round_up(MR_global_heap_size);
+    MR_kilobytes_to_bytes_and_round_up(MR_global_heap_zone_size);
+    MR_kilobytes_to_bytes_and_round_up(MR_debug_heap_size);
+    MR_kilobytes_to_bytes_and_round_up(MR_debug_heap_zone_size);
 	/* Note that there's no need for the heap margin to be rounded up */
 	MR_heap_margin_size	 = MR_heap_margin_size * 1024;
 #endif
-	MR_detstack_size	 = MR_round_up(MR_detstack_size * 1024,
-					MR_unit);
-	MR_small_detstack_size	 = MR_round_up(MR_small_detstack_size * 1024,
-					MR_unit);
-	MR_detstack_zone_size	 = MR_round_up(MR_detstack_zone_size * 1024,
-					MR_unit);
-	MR_nondetstack_size	 = MR_round_up(MR_nondetstack_size * 1024,
-					MR_unit);
-	MR_small_nondetstack_size= MR_round_up(MR_small_nondetstack_size * 1024,
-					MR_unit);
-	MR_nondetstack_zone_size = MR_round_up(MR_nondetstack_zone_size * 1024,
-					MR_unit);
+    MR_kilobytes_to_bytes_and_round_up(MR_detstack_size);
+    MR_kilobytes_to_bytes_and_round_up(MR_small_detstack_size);
+    MR_kilobytes_to_bytes_and_round_up(MR_detstack_zone_size);
+    MR_kilobytes_to_bytes_and_round_up(MR_nondetstack_size);
+    MR_kilobytes_to_bytes_and_round_up(MR_small_nondetstack_size);
+    MR_kilobytes_to_bytes_and_round_up(MR_nondetstack_zone_size);
 #ifdef	MR_USE_MINIMAL_MODEL_STACK_COPY
-	MR_genstack_size	 = MR_round_up(MR_genstack_size * 1024,
-					MR_unit);
-	MR_genstack_zone_size	 = MR_round_up(
-					MR_genstack_zone_size * 1024,
-					MR_unit);
-	MR_cutstack_size	 = MR_round_up(MR_cutstack_size * 1024,
-					MR_unit);
-	MR_cutstack_zone_size	 = MR_round_up(MR_cutstack_zone_size * 1024,
-					MR_unit);
-	MR_pnegstack_size	 = MR_round_up(MR_pnegstack_size * 1024,
-					MR_unit);
-	MR_pnegstack_zone_size	 = MR_round_up(MR_pnegstack_zone_size * 1024,
-					MR_unit);
+    MR_kilobytes_to_bytes_and_round_up(MR_genstack_size);
+    MR_kilobytes_to_bytes_and_round_up(MR_genstack_zone_size);
+    MR_kilobytes_to_bytes_and_round_up(MR_cutstack_size);
+    MR_kilobytes_to_bytes_and_round_up(MR_cutstack_zone_size);
+    MR_kilobytes_to_bytes_and_round_up(MR_pnegstack_size);
+    MR_kilobytes_to_bytes_and_round_up(MR_pnegstack_zone_size);
 #else
 	MR_genstack_size	 = 0;
 	MR_genstack_zone_size	 = 0;
@@ -196,28 +178,20 @@
 #endif
 
 #ifdef	MR_USE_MINIMAL_MODEL_OWN_STACKS
-	MR_gen_detstack_size	 = MR_round_up(MR_gen_detstack_size * 1024,
-					MR_unit);
-	MR_gen_nonstack_size	 = MR_round_up(MR_gen_nonstack_size * 1024,
-					MR_unit);
-	MR_gen_detstack_zone_size = MR_round_up(
-					MR_gen_detstack_zone_size * 1024,
-					MR_unit);
-	MR_gen_nonstack_zone_size = MR_round_up(
-					MR_gen_nonstack_zone_size * 1024,
-					MR_unit);
+    MR_kilobytes_to_bytes_and_round_up(MR_gen_detstack_size);
+    MR_kilobytes_to_bytes_and_round_up(MR_gen_nondetstack_size);
+    MR_kilobytes_to_bytes_and_round_up(MR_gen_detstack_zone_size);
+    MR_kilobytes_to_bytes_and_round_up(MR_gen_nondetstack_zone_size);
 #else
 	MR_gen_detstack_size	 = 0;
-	MR_gen_nonstack_size	 = 0;
+    MR_gen_nondetstack_size      = 0;
 	MR_gen_detstack_zone_size = 0;
-	MR_gen_nonstack_zone_size = 0;
+    MR_gen_nondetstack_zone_size = 0;
 #endif
 
 #ifdef	MR_USE_TRAIL
-	MR_trail_size		 = MR_round_up(MR_trail_size * 1024,
-					MR_unit);
-	MR_trail_zone_size	 = MR_round_up(MR_trail_zone_size * 1024,
-					MR_unit);
+    MR_kilobytes_to_bytes_and_round_up(MR_trail_size);
+    MR_kilobytes_to_bytes_and_round_up(MR_trail_zone_size);
 #else
 	MR_trail_size		 = 0;
 	MR_trail_zone_size	 = 0;
@@ -257,6 +231,10 @@
 	}
 #endif
 
+    if (MR_stack_margin_size >= MR_detstack_size) {
+        MR_fatal_error("MR_init_memory: stack margin size far too big");
+    }
+
 	MR_init_zones();
 
 } /* end MR_init_memory() */
@@ -264,10 +242,9 @@
 /*---------------------------------------------------------------------------*/
 
 /*
-** These routines allocate memory that will NOT be scanned by the
-** conservative garbage collector.  You MUST NOT uses these to
-** store pointers into GC'ed memory.
-** 
+** These routines allocate memory that will NOT be scanned by the conservative
+** garbage collector. You MUST NOT use these to store pointers into GC'ed
+** memory.
 */
 
 void *
@@ -318,9 +295,9 @@
 ** These routines allocate memory that will be scanned by the
 ** conservative garbage collector.
 **
-** XXX This is inefficient.  If MR_BOEHM_GC is enabled,
-** we should set `GC_oom_fn' (see boehm_gc/gc.h) rather than
-** testing the return value from GC_MALLOC() or GC_MALLOC_UNCOLLECTABLE().
+** XXX This is inefficient. If MR_BOEHM_GC is enabled, we should set
+** `GC_oom_fn' (see boehm_gc/gc.h) rather than testing the return value
+** from GC_MALLOC() or GC_MALLOC_UNCOLLECTABLE().
 */
 
 void *
--- /home/zs/mer/ws8/runtime/mercury_memory.h	2004-12-15 17:57:50.000000000 +1100
+++ mercury_memory.h	2006-10-31 13:51:03.000000000 +1100
@@ -5,8 +5,8 @@
 */
 
 /*
-** mercury_memory.h - 	general memory-allocation related stuff for the
-**			Mercury runtime.
+** mercury_memory.h:
+** general memory-allocation related stuff for the Mercury runtime.
 **
 ** This defines the different memory areas used by the Mercury runtime,
 ** including the det & nondet stacks, the heap (and solutions heap),
@@ -44,6 +44,18 @@
 #define MR_round_up(amount, align)	((((amount) - 1) | ((align) - 1)) + 1)
 
 /* 
+** MR_kilobytes_to_bytes_and_round_up(var) takes an original value in var
+** which represents an memory size measured in kilobytes, and converts it to
+** a memory size measured in bytes, and then rounds it up to be the next
+** multiple of MR_unit.
+*/
+
+#define MR_kilobytes_to_bytes_and_round_up(var)				\
+	do {								\
+		var = MR_round_up(var * 1024, MR_unit);			\
+	} while (0)
+
+/*
 ** For these functions, see the comments in mercury_memory.c and 
 ** mercury_engine.c 
 */
@@ -58,29 +70,28 @@
 /*---------------------------------------------------------------------------*/
 
 /*
-** MR_malloc() and MR_realloc() are like the standard C
-** malloc() and realloc() functions, except that the return values
-** are checked.
-**
-** Structures allocated with MR_malloc() and MR_realloc()
-** must NOT contain pointers into GC'ed memory, because those
-** pointers will never be traced by the conservative GC.
-** Use MR_GC_malloc() or MR_GC_malloc_uncollectable() for that.
+** MR_malloc() and MR_realloc() are like the standard C malloc() and realloc()
+** functions, except that the return values are checked.
+**
+** Structures allocated with MR_malloc() and MR_realloc() must NOT contain
+** pointers into GC'ed memory, because those pointers will never be traced
+** by the conservative GC. ** Use MR_GC_malloc() or
+** MR_GC_malloc_uncollectable() for that.
 **
 ** MR_NEW(type):
-**	allocates space for an object of the specified type.
+**	Allocates space for an object of the specified type.
 **
 ** MR_NEW_ARRAY(type, num):
-**	allocates space for an array of objects of the specified type.
+**	Allocates space for an array of objects of the specified type.
 **
 ** MR_RESIZE_ARRAY(ptr, type, num):
-**	resizes the array, as with realloc().
+**	Resizes the array, as with realloc().
 **
 ** MR_malloc(bytes):
-**	allocates the given number of bytes.
+**	Allocates the given number of bytes.
 **
 ** MR_free(ptr):
-**	deallocates the memory.
+**	Deallocates the memory.
 */
 
 extern	void	*MR_malloc(size_t n);
@@ -114,30 +124,29 @@
 **	is not GC-traced.  Nor is thread-local storage.
 **
 ** MR_GC_NEW_UNCOLLECTABLE(type):
-**	allocates space for an object of the specified type.
-**	The object will not be garbage collected even if it is
-**	not reference or only referenced from thread-local
-**	storage or storage allocated with malloc().
-**	It should be explicitly deallocated with MR_GC_free().
+**	Allocates space for an object of the specified type.
+**	The object will not be garbage collected even if it is not referenced,
+**	or only referenced from thread-local storage or storage allocated
+**	with malloc(). It should be explicitly deallocated with MR_GC_free().
 **
 ** MR_GC_NEW_ARRAY(type, num):
-**	allocates space for an array of objects of the specified type.
+**	Allocates space for an array of objects of the specified type.
 **
 ** MR_GC_RESIZE_ARRAY(ptr, type, num):
-**	resizes the array, as with realloc().
+**	Resizes the array, as with realloc().
 **
 ** MR_GC_malloc(bytes):
-**	allocates the given number of bytes.
+**	Allocates the given number of bytes.
 **	If conservative GC is enabled, the memory will be garbage collected
 **	when it is no longer referenced from GC-traced memory (see above).
 **
 ** MR_GC_malloc_uncollectable(bytes):
-**	allocates the given number of bytes.
+**	Allocates the given number of bytes.
 **	The memory will not be garbage collected, and so
 **	it should be explicitly deallocated using MR_GC_free().
 **
 ** MR_GC_free(ptr):
-**	deallocates the memory.
+**	Deallocates the memory.
 */
 
 extern	void	*MR_GC_malloc(size_t num_bytes);
@@ -184,9 +193,8 @@
 /*---------------------------------------------------------------------------*/
 
 /*
-** Users need to call MR_add_root() for any global variable which
-** contains pointers to the Mercury heap.  This information is only
-** used for agc grades.
+** Users need to call MR_add_root() for any global variable which contains
+** pointers to the Mercury heap. This information is only used for agc grades.
 */
 #ifdef MR_NATIVE_GC
   #define MR_add_root(root_ptr, type_info) \
--- /home/zs/mer/ws8/runtime/mercury_memory_zones.h	2006-10-30 08:11:45.000000000 +1100
+++ mercury_memory_zones.h	2006-10-31 13:29:10.000000000 +1100
@@ -260,7 +260,7 @@
 extern	void		MR_debug_memory_zone(FILE *fp, MR_MemoryZone *zone);
 
 /*
-** Return the given zone to tyhe list of free zones.
+** Return the given zone to the list of free zones.
 */
 
 extern	void		MR_unget_zone(MR_MemoryZone *zone);
--- /home/zs/mer/ws8/runtime/mercury_stack_trace.c	2006-10-30 16:27:26.000000000 +1100
+++ mercury_stack_trace.c	2006-10-31 13:30:05.000000000 +1100
@@ -318,7 +318,7 @@
         return MR_STEP_OK;
     }
 
-#ifndef MR_HIGHLEVEL_CODE
+#if !defined(MR_HIGHLEVEL_CODE) && defined(MR_STACK_SEGMENTS)
     if (success == MR_ENTRY(MR_pop_detstack_segment)) {
         success = (MR_Code *) MR_based_stackvar(*stack_trace_sp_ptr, 2);
         *stack_trace_sp_ptr = (MR_Word *)
@@ -328,7 +328,7 @@
         *stack_trace_curfr_ptr = (MR_Word *)
             MR_based_framevar(*stack_trace_curfr_ptr, 1);
     }
-#endif /* MR_HIGHLEVEL_CODE */
+#endif /* !MR_HIGHLEVEL_CODE && MR_STACK_SEGMENTS */
 
     label = MR_lookup_internal_by_addr(success);
     if (label == NULL) {
--- /home/zs/mer/ws8/runtime/mercury_stacks.c	2006-10-30 17:02:27.000000000 +1100
+++ mercury_stacks.c	2006-10-31 13:41:37.000000000 +1100
@@ -201,15 +201,6 @@
 
 #ifdef  MR_STACK_SEGMENTS
 
-/*
-** These three global variables are used in the MR_detstack_extend_and_check
-** and MR_nondetstack_extend_and_check macros and nowhere else.
-*/
-
-MR_Code *MR_post_extend_succip;
-MR_Word *MR_pre_extend_maxfr;
-MR_Word *MR_pre_extend_curfr;
-
 MR_declare_entry(MR_pop_detstack_segment);
 MR_declare_entry(MR_pop_nondetstack_segment);
 
@@ -224,10 +215,7 @@
     new_zone = MR_create_zone("detstack_segment", 0, MR_detstack_size, 0,
         MR_detstack_zone_size, MR_default_handler);
 
-    list = GC_MALLOC_UNCOLLECTABLE(sizeof(MR_MemoryZones));
-    if (list == NULL) {
-        MR_fatal_error("cannot allocate new det stack segment");
-    }
+    list = MR_GC_NEW_UNCOLLECTABLE(sizeof(MR_MemoryZones));
 
 #ifdef  MR_DEBUG_STACK_SEGMENTS
     printf("create new det segment: old zone: %p, old sp %p\n",
@@ -249,7 +237,6 @@
     MR_incr_sp_leaf(2);
     MR_stackvar(1) = (MR_Word) old_sp;
     MR_stackvar(2) = (MR_Word) MR_succip;
-    MR_post_extend_succip = MR_ENTRY(MR_pop_detstack_segment);
 
     MR_incr_sp_leaf(n);
 
@@ -259,7 +246,7 @@
     printf("new sp: ");
     MR_printdetstack(MR_sp);
     printf("new succip: ");
-    MR_printlabel(stdout, MR_post_extend_succip);
+    MR_printlabel(stdout, MR_ENTRY(MR_pop_detstack_segment));
 #endif
 
     return MR_sp;
@@ -277,10 +264,7 @@
     new_zone = MR_create_zone("nondetstack_segment", 0, MR_nondetstack_size, 0,
         MR_nondetstack_zone_size, MR_default_handler);
 
-    list = GC_MALLOC_UNCOLLECTABLE(sizeof(MR_MemoryZones));
-    if (list == NULL) {
-        MR_fatal_error("cannot allocate new nondet stack segment");
-    }
+    list = MR_GC_NEW_UNCOLLECTABLE(sizeof(MR_MemoryZones));
 
 #ifdef  MR_DEBUG_STACK_SEGMENTS
     printf("create new nondet segment: old zone: %p, old maxfr %p\n",
@@ -302,7 +286,6 @@
 
     MR_mkframe("new_nondetstack_segment", 1, MR_ENTRY(MR_do_fail));
     MR_framevar(1) = (MR_Word) old_maxfr;
-    MR_post_extend_succip = MR_ENTRY(MR_pop_nondetstack_segment);
 
     MR_maxfr_word = (MR_Word) (MR_maxfr + (MR_NONDET_FIXED_SIZE + (n)));
 
@@ -312,7 +295,7 @@
     printf("new maxfr: ");
     MR_printnondetstack(MR_maxfr);
     printf("new succip: ");
-    MR_printlabel(stdout, MR_post_extend_succip);
+    MR_printlabel(stdout, MR_ENTRY(MR_pop_nondetstack_segment));
 #endif
 
     return MR_maxfr;
@@ -353,7 +336,7 @@
     MR_CONTEXT(MR_ctxt_detstack_zone) = list->MR_zones_head;
     MR_CONTEXT(MR_ctxt_prev_detstack_zones) = list->MR_zones_tail;
     MR_CONTEXT(MR_ctxt_sp) = orig_sp;
-    GC_FREE(list);
+    MR_GC_FREE(list);
 
 #ifdef  MR_DEBUG_STACK_SEGMENTS
     printf("restore old det segment: new zone %p, new sp %p\n",
@@ -396,7 +379,7 @@
     MR_CONTEXT(MR_ctxt_nondetstack_zone) = list->MR_zones_head;
     MR_CONTEXT(MR_ctxt_prev_nondetstack_zones) = list->MR_zones_tail;
     MR_CONTEXT(MR_ctxt_maxfr) = orig_maxfr;
-    GC_FREE(list);
+    MR_GC_FREE(list);
 
 #ifdef  MR_DEBUG_STACK_SEGMENTS
     printf("restore old nondet segment: new zone %p, new maxfr %p\n",
--- /home/zs/mer/ws8/runtime/mercury_stacks.h	2006-10-29 13:20:29.000000000 +1100
+++ mercury_stacks.h	2006-10-31 13:42:28.000000000 +1100
@@ -86,7 +86,7 @@
                 MR_save_registers();                                          \
                 new_sp = MR_new_detstack_segment(MR_sp, n);                   \
                 MR_restore_registers();                                       \
-                MR_succip_word = (MR_Word) MR_post_extend_succip;             \
+                MR_succip_word = (MR_Word) MR_ENTRY(MR_pop_detstack_segment); \
             }                                                                 \
             MR_sp_word = (MR_Word) new_sp;                                    \
         } while (0)
@@ -96,7 +96,7 @@
             MR_sp_word = (MR_Word) (MR_sp + (n));                             \
         } while (0)
 
-  #define MR_nondetstack_extend_and_check(n, prevfr, succfr)                  \
+  #define MR_nondetstack_extend_and_check(n)                                  \
         do {                                                                  \
             MR_Word *new_maxfr;                                               \
             MR_Word *threshold;                                               \
@@ -107,25 +107,15 @@
             incr = MR_NONDET_FIXED_SIZE + (n);                                \
             new_maxfr = MR_maxfr + incr;                                      \
             if (new_maxfr > threshold) {                                      \
-                MR_pre_extend_maxfr = MR_maxfr;                               \
-                MR_pre_extend_curfr = MR_curfr;                               \
                 MR_save_registers();                                          \
                 new_maxfr = MR_new_nondetstack_segment(MR_maxfr, incr);       \
                 MR_restore_registers();                                       \
-                MR_succip_word = (MR_Word) MR_post_extend_succip;             \
-                prevfr = MR_pre_extend_maxfr;                                 \
-                succfr = MR_pre_extend_curfr;                                 \
-            } else {                                                          \
-                prevfr = MR_maxfr;                                            \
-                succfr = MR_curfr;                                            \
+                MR_succip_word =                                              \
+                    (MR_Word) MR_ENTRY(MR_pop_nondetstack_segment);           \
             }                                                                 \
             MR_maxfr_word = (MR_Word) new_maxfr;                              \
         } while (0)
 
-  extern    MR_Code         *MR_post_extend_succip;
-  extern    MR_Word         *MR_pre_extend_maxfr;
-  extern    MR_Word         *MR_pre_extend_curfr;
-
   extern    MR_Word         *MR_new_detstack_segment(MR_Word *sp, int n);
   extern    MR_Word         *MR_new_nondetstack_segment(MR_Word *maxfr, int n);
 
@@ -141,10 +131,8 @@
             MR_sp_word = (MR_Word) (MR_sp + (n));                             \
         } while (0)
 
-  #define MR_nondetstack_extend_and_check(n, prevfr, succfr)                  \
+  #define MR_nondetstack_extend_and_check(n)                                  \
         do {                                                                  \
-            prevfr = MR_maxfr;                                                \
-            succfr = MR_curfr;                                                \
             MR_maxfr_word = (MR_Word)                                         \
                 (MR_maxfr + (MR_NONDET_FIXED_SIZE + (n)));                    \
         } while (0)
@@ -362,7 +350,9 @@
         MR_Word *prevfr;                                                      \
         MR_Word *succfr;                                                      \
                                                                               \
-        MR_nondetstack_extend_and_check(numslots, prevfr, succfr);            \
+        prevfr = MR_maxfr;                                                    \
+        succfr = MR_curfr;                                                    \
+        MR_nondetstack_extend_and_check(numslots);                            \
         MR_nondetstack_post_extend_check();                                   \
         MR_curfr_word = MR_maxfr_word;                                        \
         MR_prevfr_slot_word(MR_curfr) = (MR_Word) prevfr;                     \
--- /home/zs/mer/ws8/runtime/mercury_wrapper.c	2006-10-30 16:49:57.000000000 +1100
+++ mercury_wrapper.c	2006-10-31 14:01:09.000000000 +1100
@@ -108,7 +108,7 @@
 size_t      MR_cutstack_size =             8 * sizeof(MR_Word);
 size_t      MR_pnegstack_size =            8 * sizeof(MR_Word);
 size_t      MR_gen_detstack_size =        16 * sizeof(MR_Word);
-size_t      MR_gen_nonstack_size =        16 * sizeof(MR_Word);
+size_t      MR_gen_nondetstack_size =     16 * sizeof(MR_Word);
 
 /*
 ** size of the redzones at the end of data areas, in kilobytes
@@ -143,7 +143,7 @@
 size_t      MR_cutstack_zone_size =        4 * sizeof(MR_Word);
 size_t      MR_pnegstack_zone_size =       4 * sizeof(MR_Word);
 size_t      MR_gen_detstack_zone_size =    4 * sizeof(MR_Word);
-size_t      MR_gen_nonstack_zone_size =    4 * sizeof(MR_Word);
+size_t      MR_gen_nondetstack_zone_size = 4 * sizeof(MR_Word);
 
 /*
 ** MR_heap_margin_size is used for accurate GC with the MLDS->C back-end.
@@ -1052,12 +1052,12 @@
     MR_PNEGSTACK_SIZE_KWORDS,
     MR_GEN_DETSTACK_SIZE,
     MR_GEN_DETSTACK_SIZE_KWORDS,
-    MR_GEN_NONSTACK_SIZE,
-    MR_GEN_NONSTACK_SIZE_KWORDS,
+    MR_GEN_NONDETSTACK_SIZE,
+    MR_GEN_NONDETSTACK_SIZE_KWORDS,
     MR_GEN_DETSTACK_REDZONE_SIZE,
     MR_GEN_DETSTACK_REDZONE_SIZE_KWORDS,
-    MR_GEN_NONSTACK_REDZONE_SIZE,
-    MR_GEN_NONSTACK_REDZONE_SIZE_KWORDS,
+    MR_GEN_NONDETSTACK_REDZONE_SIZE,
+    MR_GEN_NONDETSTACK_REDZONE_SIZE_KWORDS,
     MR_MAX_CONTEXTS_PER_THREAD,
     MR_MDB_TTY,
     MR_MDB_IN,
@@ -1135,14 +1135,15 @@
     { "pnegstack-size-kwords",          1, 0, MR_PNEGSTACK_SIZE_KWORDS },
     { "gen-detstack-size",              1, 0, MR_GEN_DETSTACK_SIZE },
     { "gen-detstack-size-kwords",       1, 0, MR_GEN_DETSTACK_SIZE_KWORDS },
-    { "gen-nonstack-size",              1, 0, MR_GEN_NONSTACK_SIZE },
-    { "gen-nonstack-size-kwords",       1, 0, MR_GEN_NONSTACK_SIZE_KWORDS },
+    { "gen-nondetstack-size",           1, 0, MR_GEN_NONDETSTACK_SIZE },
+    { "gen-nondetstack-size-kwords",    1, 0, MR_GEN_NONDETSTACK_SIZE_KWORDS },
     { "gen-detstack-zone-size",         1, 0, MR_GEN_DETSTACK_REDZONE_SIZE },
     { "gen-detstack-zone-size-kwords", 
             1, 0, MR_GEN_DETSTACK_REDZONE_SIZE_KWORDS },
-    { "gen-nonstack-zone-size",         1, 0, MR_GEN_NONSTACK_REDZONE_SIZE },
-    { "gen-nonstack-zone-size-kwords",
-            1, 0, MR_GEN_NONSTACK_REDZONE_SIZE_KWORDS },
+    { "gen-nondetstack-zone-size",
+        1, 0, MR_GEN_NONDETSTACK_REDZONE_SIZE },
+    { "gen-nondetstack-zone-size-kwords",
+        1, 0, MR_GEN_NONDETSTACK_REDZONE_SIZE_KWORDS },
     { "max-contexts-per-thread",        1, 0, MR_MAX_CONTEXTS_PER_THREAD },
     { "mdb-tty",                        1, 0, MR_MDB_TTY },
     { "mdb-in",                         1, 0, MR_MDB_IN },
@@ -1464,20 +1465,20 @@
                 MR_gen_detstack_size = size * sizeof(MR_Word);
                 break;
 
-            case MR_GEN_NONSTACK_SIZE:
+            case MR_GEN_NONDETSTACK_SIZE:
                 if (sscanf(MR_optarg, "%lu", &size) != 1) {
                     MR_usage();
                 }
 
-                MR_gen_nonstack_size = size;
+                MR_gen_nondetstack_size = size;
                 break;
 
-            case MR_GEN_NONSTACK_SIZE_KWORDS:
+            case MR_GEN_NONDETSTACK_SIZE_KWORDS:
                 if (sscanf(MR_optarg, "%lu", &size) != 1) {
                     MR_usage();
                 }
 
-                MR_gen_nonstack_size = size * sizeof(MR_Word);
+                MR_gen_nondetstack_size = size * sizeof(MR_Word);
                 break;
 
             case MR_GEN_DETSTACK_REDZONE_SIZE:
@@ -1496,20 +1497,20 @@
                 MR_gen_detstack_zone_size = size * sizeof(MR_Word);
                 break;
 
-            case MR_GEN_NONSTACK_REDZONE_SIZE:
+            case MR_GEN_NONDETSTACK_REDZONE_SIZE:
                 if (sscanf(MR_optarg, "%lu", &size) != 1) {
                     MR_usage();
                 }
 
-                MR_gen_nonstack_zone_size = size;
+                MR_gen_nondetstack_zone_size = size;
                 break;
 
-            case MR_GEN_NONSTACK_REDZONE_SIZE_KWORDS:
+            case MR_GEN_NONDETSTACK_REDZONE_SIZE_KWORDS:
                 if (sscanf(MR_optarg, "%lu", &size) != 1) {
                     MR_usage();
                 }
 
-                MR_gen_nonstack_zone_size = size * sizeof(MR_Word);
+                MR_gen_nondetstack_zone_size = size * sizeof(MR_Word);
                 break;
 
             case MR_MAX_CONTEXTS_PER_THREAD:
--- /home/zs/mer/ws8/runtime/mercury_wrapper.h	2006-10-29 12:56:21.000000000 +1100
+++ mercury_wrapper.h	2006-10-31 13:59:23.000000000 +1100
@@ -205,7 +205,7 @@
 extern	size_t		MR_cutstack_size;
 extern	size_t		MR_pnegstack_size;
 extern	size_t		MR_gen_detstack_size;
-extern	size_t		MR_gen_nonstack_size;
+extern	size_t		MR_gen_nondetstack_size;
 
 /* sizes of the red zones */
 extern	size_t		MR_heap_zone_size;
@@ -219,7 +219,7 @@
 extern	size_t		MR_cutstack_zone_size;
 extern	size_t		MR_pnegstack_zone_size;
 extern	size_t		MR_gen_detstack_zone_size;
-extern	size_t		MR_gen_nonstack_zone_size;
+extern	size_t		MR_gen_nondetstack_zone_size;
 
 /* heap margin for MLDS->C accurate GC (documented in mercury_wrapper.c) */
 extern	size_t		MR_heap_margin_size;
Diffing runtime/GETOPT
Diffing runtime/machdeps
Diffing samples
Diffing samples/c_interface
Diffing samples/c_interface/c_calls_mercury
Diffing samples/c_interface/cplusplus_calls_mercury
Diffing samples/c_interface/mercury_calls_c
Diffing samples/c_interface/mercury_calls_cplusplus
Diffing samples/c_interface/mercury_calls_fortran
Diffing samples/c_interface/simpler_c_calls_mercury
Diffing samples/c_interface/simpler_cplusplus_calls_mercury
Diffing samples/diff
Diffing samples/muz
Diffing samples/rot13
Diffing samples/solutions
Diffing samples/tests
Diffing samples/tests/c_interface
Diffing samples/tests/c_interface/c_calls_mercury
Diffing samples/tests/c_interface/cplusplus_calls_mercury
Diffing samples/tests/c_interface/mercury_calls_c
Diffing samples/tests/c_interface/mercury_calls_cplusplus
Diffing samples/tests/c_interface/mercury_calls_fortran
Diffing samples/tests/c_interface/simpler_c_calls_mercury
Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
Diffing samples/tests/diff
Diffing samples/tests/muz
Diffing samples/tests/rot13
Diffing samples/tests/solutions
Diffing samples/tests/toplevel
Diffing scripts
--- /home/zs/mer/ws8/scripts/final_grade_options.sh-subr	2006-10-28 02:07:28.000000000 +1000
+++ final_grade_options.sh-subr	2006-10-31 13:42:15.000000000 +1100
@@ -45,7 +45,7 @@
 #	(they are alternative ways of doing the same thing)
 #
 case $extend_stacks,$stack_segments in true,true)
-	echo "--extend-stacks and --stack-segments are not compatible" 1>&2
+	echo "--extend-stacks-when-needed and --stack-segments are not compatible" 1>&2
 	exit 1 ;;
 esac
 
Diffing slice
Diffing tests
Diffing tests/benchmarks
Diffing tests/debugger
Diffing tests/debugger/declarative
Diffing tests/dppd
Diffing tests/general
Diffing tests/general/accumulator
Diffing tests/general/string_format
Diffing tests/general/structure_reuse
Diffing tests/grade_subdirs
Diffing tests/hard_coded
Diffing tests/hard_coded/exceptions
Diffing tests/hard_coded/purity
Diffing tests/hard_coded/sub-modules
Diffing tests/hard_coded/typeclasses
Diffing tests/invalid
Diffing tests/invalid/purity
Diffing tests/misc_tests
Diffing tests/mmc_make
Diffing tests/mmc_make/lib
Diffing tests/par_conj
Diffing tests/recompilation
Diffing tests/tabling
Diffing tests/term
Diffing tests/trailing
Diffing tests/valid
Diffing tests/warnings
Diffing tools
Diffing trace
Diffing util
Diffing vim
Diffing vim/after
Diffing vim/ftplugin
Diffing vim/syntax
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list