Diff to make non-gc grades work
Thomas Charles CONWAY
conway at cs.mu.oz.au
Tue Feb 11 11:44:50 AEDT 1997
Hi
The following diff fixes some of the problems that prevented the non-gc
grades of the compiler from working correctly.
The change to solutions backs out my earlier change to prevent the
usual heap-reclamation on failure on the solutions heap. This means
that solutions doesn't work for multi-threaded programs at the moment
(which is a moot point since we don't generate multithreaded code yet).
--
Thomas Conway conway at cs.mu.oz.au
AD DEUM ET VINUM "Thomas Tallis is dead, and muic dies." - William Byrd
cvs diff: Diffing .
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing compiler
cvs diff: Diffing compiler/notes
cvs diff: Diffing doc
cvs diff: Diffing library
Index: library/std_util.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/library/std_util.m,v
retrieving revision 1.68
diff -u -r1.68 std_util.m
--- std_util.m 1997/02/10 23:18:14 1.68
+++ std_util.m 1997/02/11 00:22:59
@@ -210,27 +210,6 @@
#include ""imp.h""
#include ""deep_copy.h""
-/*
-** To allow reclaimation of the solutions heap in concurrent
-** computations, we keep a counter of the number of contexts
-** that are inside a call to solutions. When leaving solutions,
-** we check to see if there are any other calls to solutions
-** in progress - if not, then we can truncate the solutions heap
-** back to the start (solutions_heap_zone->min). This approach
-** can fairly easily be extended to handle the PARALLEL case: all
-** we need to do is put a lock on the counter (which must be in
-** shared memory), and have a global array with pointers to all
-** the appropriate data structures so that this Unix process can
-** reset the solutions heaps of all the other processes as well.
-**
-** What we lose is that nested calls to solutions will use more of
-** the solutions heap, because the solutions heap won't get truncated
-** until the outer-most call to solutions returns.
-*/
-
-int *solutions_counter;
-SpinLock *solutions_counter_lock;
-
Declare_entry(do_call_nondet_closure);
Define_extern_entry(mercury__std_util__builtin_solutions_2_0);
@@ -307,24 +286,19 @@
*/
#define saved_hp_fv (framevar(0))
-#define type_info_fv (framevar(1))
-#define list_fv (framevar(2))
+#define saved_solhp_fv (framevar(1))
+#define type_info_fv (framevar(2))
+#define list_fv (framevar(3))
- /* increment the numer of calls to solutions that are in progress */
-
- get_lock(solutions_counter_lock);
- (*solutions_counter)++;
- release_lock(solutions_counter_lock);
-
- /* create a nondet stack frame with four slots,
- and set the failure continuation */
-
- mkframe(""builtin_solutions"", 3,
+ /* create a nondet stack frame with four slots,
+ and set the failure continuation */
+
+ mkframe(""builtin_solutions"", 4,
LABEL(mercury__std_util__builtin_solutions_2_0_i2));
/* setup the framevars */
-
- mark_hp(save_hp_fv);
+ saved_solhp_fv = (Word) solutions_heap_pointer;
+ mark_hp(saved_hp_fv);
type_info_fv = r1;
list_fv = list_empty();
@@ -351,8 +325,8 @@
save_transient_registers();
/* deep copy it to the solutions heap, up to the saved_hp */
- r3 = deep_copy(r1, (Word *) type_info_fv, (Word *) saved_hp_fv,
- heap_zone->top);
+ r3 = deep_copy(r1, (Word *) type_info_fv, (Word *) saved_hp_fv,
+ heap_zone->top);
/* restore the registers */
restore_transient_registers();
@@ -398,24 +372,14 @@
(Word *) saved_solhp_fv, solutions_heap_zone->top);
}
- /*
- ** decrement the number of calls to solutions that are in progress.
- ** If (now that this call has finished) there are no calls still in
- ** progress, then we can reset the solutions heap pointer back to
- ** the start of the solutions heap. Once we support real parallelism
- ** we will need to reset the solutions heap pointers of all the other
- ** solutions heaps too. XXX we still need to work out a good way to
- ** do this.
- */
- get_lock(solutions_counter_lock);
- if (--(*solutions_counter) == 0)
- solutions_heap_pointer = (Word *) solutions_heap_zone->min;
- release_lock(solutions_counter_lock);
-
- /* discard the frame we made */
- succeed_discard();
+ /* reset solutions heap to where it was before call to solutions */
+ solutions_heap_pointer = (Word *) saved_solhp_fv;
+
+ /* discard the frame we made */
+ succeed_discard();
#undef saved_hp_fv
+#undef saved_solhp_fv
#undef type_info_fv
#undef list_fv
cvs diff: Diffing profiler
cvs diff: Diffing runtime
Index: runtime/heap.h
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/heap.h,v
retrieving revision 1.10
diff -u -r1.10 heap.h
--- heap.h 1997/02/09 09:19:26 1.10
+++ heap.h 1997/02/10 07:10:53
@@ -102,11 +102,11 @@
** the set_min_heap_reclamation_point() macro.
*/
#define restore_hp(src) ( \
- LVALUE_CAST(Word,hp) = \
- ( min_heap_reclamation_point < (src) ? \
- (src) : min_heap_reclamation_point ), \
- (void)0 \
- )
+ LVALUE_CAST(Word,hp) = \
+ ( (Word) min_heap_reclamation_point < (src) ? \
+ (src) : (Word) min_heap_reclamation_point ), \
+ (void)0 \
+ )
#define hp_alloc(count) incr_hp(hp,count)
#define hp_alloc_atomic(count) incr_hp_atomic(count)
Index: runtime/memory.c
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/memory.c,v
retrieving revision 1.62
diff -u -r1.62 memory.c
--- memory.c 1997/02/10 06:47:45 1.62
+++ memory.c 1997/02/10 22:00:47
@@ -307,16 +307,17 @@
void init_heap(void)
{
#ifndef CONSERVATIVE_GC
- heap_zone = construct_zone("heap", 1, heap_size, next_offset(),
+ heap_zone = create_zone("heap", 1, heap_size, next_offset(),
heap_zone_size, default_handler);
restore_transient_registers();
hp = heap_zone->min;
save_transient_registers();
- solutions_heap_zone = construct_zone("solutions_heap", 1,
+ solutions_heap_zone = create_zone("solutions_heap", 1,
solutions_heap_size, next_offset(),
solutions_heap_zone_size, default_handler);
+ solutions_heap_pointer = solutions_heap_zone->min;
#endif
}
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/diff
cvs diff: Diffing scripts
cvs diff: Diffing tools
cvs diff: Diffing trial
cvs diff: Diffing util
More information about the developers
mailing list