for review: runtime changes
Thomas Charles CONWAY
conway at cs.mu.oz.au
Mon Nov 10 15:15:19 AEDT 1997
Hi
For Fergus/Tyson to review - changes to the runtime (primarily).
--
ZZ:wq!
^X^C
Thomas Conway conway at cs.mu.oz.au
AD DEUM ET VINUM Every sword has two edges.
This diff starts migrating global variables into virtual registers,
removes some junk code to do with parallelism, and renames the
special registers with mr_ prefixes.
compiler/llds_out.m:
rename hp, etc as mr_hp, etc.
library/std_util.m:
rename hp and solutions_heap_pointer.
runtime/*:
- remove old parallelism stuff that will change completely when
we use posix threads.
- rename the various special registers (hp, sp, etc) with a mr_
prefix.
- make the solutions heap pointer and the minimum heap reclaimation
point virtual registers rather than global variables.
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 bytecode
cvs diff: Diffing bytecode/test
cvs diff: Diffing compiler
Index: compiler/llds_out.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/llds_out.m,v
retrieving revision 1.60
diff -u -r1.60 llds_out.m
--- llds_out.m 1997/10/31 00:41:29 1.60
+++ llds_out.m 1997/11/04 02:08:03
@@ -1281,11 +1281,11 @@
:- pred output_live_value_type(live_value_type, io__state, io__state).
:- mode output_live_value_type(in, di, uo) is det.
-output_live_value_type(succip) --> io__write_string("succip").
-output_live_value_type(curfr) --> io__write_string("curfr").
-output_live_value_type(maxfr) --> io__write_string("maxfr").
-output_live_value_type(redoip) --> io__write_string("redoip").
-output_live_value_type(hp) --> io__write_string("hp").
+output_live_value_type(succip) --> io__write_string("mr_succip").
+output_live_value_type(curfr) --> io__write_string("mr_curfr").
+output_live_value_type(maxfr) --> io__write_string("mr_maxfr").
+output_live_value_type(redoip) --> io__write_string("mr_redoip").
+output_live_value_type(hp) --> io__write_string("mr_hp").
output_live_value_type(unwanted) --> io__write_string("unwanted").
output_live_value_type(var(Type, Inst)) -->
io__write_string("var("),
cvs diff: Diffing compiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/Togl-1.2
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing library
Index: library/std_util.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/library/std_util.m,v
retrieving revision 1.108
diff -u -r1.108 std_util.m
--- std_util.m 1997/10/12 13:32:55 1.108
+++ std_util.m 1997/10/29 05:35:06
@@ -594,9 +594,9 @@
temp = (Word) heap_zone; \
heap_zone = solutions_heap_zone; \
LVALUE_CAST(Word, solutions_heap_zone) = temp; \
- temp = (Word) hp; \
- hp = solutions_heap_pointer; \
- LVALUE_CAST(Word, solutions_heap_pointer) = temp; \
+ temp = (Word) mr_hp; \
+ mr_hp = mr_sol_hp; \
+ LVALUE_CAST(Word, mr_sol_hp) = temp; \
} while (0)
/*
@@ -633,7 +633,7 @@
LABEL(mercury__std_util__builtin_aggregate_4_0_i3));
/* save heap states */
- saved_solhp_fv = (Word) solutions_heap_pointer;
+ saved_solhp_fv = (Word) mr_sol_hp;
mark_hp(saved_hp_fv);
#ifdef MR_USE_TRAIL
@@ -734,7 +734,7 @@
builtin_aggregate_output = copied_collection;
/* reset solutions heap to where it was before call to solutions */
- solutions_heap_pointer = (Word *) saved_solhp_fv;
+ mr_sol_hp = (Word *) saved_solhp_fv;
/* discard the frame we made */
succeed_discard();
cvs diff: Diffing lp_solve
cvs diff: Diffing lp_solve/lp_examples
cvs diff: Diffing profiler
cvs diff: Diffing runtime
Index: runtime/call.mod
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/call.mod,v
retrieving revision 1.30
diff -u -r1.30 call.mod
--- call.mod 1997/07/27 15:08:00 1.30
+++ call.mod 1997/11/04 01:28:28
@@ -41,7 +41,7 @@
push(r3); /* The number of output args to unpack */
push(num_in_args + num_extra_args); /* The number of input args */
- push(succip);
+ push(mr_succip);
save_registers();
@@ -68,7 +68,7 @@
{
int i, num_in_args, num_out_args;
- succip = pop(); /* restore succip */
+ mr_succip = pop(); /* restore succip */
num_in_args = pop(); /* restore the input arg counter */
num_out_args = pop(); /* restore the ouput arg counter */
@@ -97,7 +97,7 @@
push(r3); /* The number of output args to unpack */
push(num_in_args + num_extra_args); /* The number of input args */
- push(succip);
+ push(mr_succip);
save_registers();
@@ -140,7 +140,7 @@
{
int i, num_in_args, num_out_args;
- succip = pop(); /* restore succip */
+ mr_succip = pop(); /* restore succip */
num_in_args = pop(); /* restore the input arg counter */
num_out_args = pop(); /* restore the ouput arg counter */
@@ -329,7 +329,7 @@
#ifdef COMPACT_ARGS
tailcall(index_pred, LABEL(mercury__index_2_0));
#else
- push(succip);
+ push(mr_succip);
push(type_arity);
call(index_pred, LABEL(mercury__index_2_0_i1),
LABEL(mercury__index_2_0));
@@ -347,7 +347,7 @@
int type_arity;
type_arity = pop();
- succip = pop();
+ mr_succip = pop();
save_registers();
r3 = virtual_reg(type_arity + 2);
proceed();
@@ -438,7 +438,7 @@
#ifdef COMPACT_ARGS
tailcall(compare_pred, LABEL(mercury__compare_3_3));
#else
- push(succip);
+ push(mr_succip);
push(type_arity);
call(compare_pred, LABEL(mercury__compare_3_0_i1),
LABEL(mercury__compare_3_3));
@@ -456,7 +456,7 @@
int type_arity;
type_arity = pop();
- succip = pop();
+ mr_succip = pop();
save_registers();
r2 = virtual_reg(type_arity + 1);
proceed();
Index: runtime/calls.h
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/calls.h,v
retrieving revision 1.4
diff -u -r1.4 calls.h
--- calls.h 1997/07/27 15:08:02 1.4
+++ calls.h 1997/11/04 22:12:26
@@ -9,7 +9,7 @@
#ifndef CALLS_H
#define CALLS_H
-#include "regs.h" /* for succip */
+#include "regs.h" /* for mr_succip */
#include "goto.h" /* calls are implemented using gotos */
#include "debug.h" /* we need to debug them */
#include "prof.h" /* we need to profile them */
@@ -17,7 +17,7 @@
#define noprof_localcall(label, succ_cont) \
do { \
debugcall(LABEL(label), (succ_cont)); \
- succip = (succ_cont); \
+ mr_succip = (succ_cont); \
set_prof_current_proc(LABEL(label)); \
GOTO_LABEL(label); \
} while (0)
@@ -32,7 +32,7 @@
({ \
__label__ fixup_gp; \
debugcall((proc), (succ_cont)); \
- succip = (&&fixup_gp); \
+ mr_succip = (&&fixup_gp); \
set_prof_current_proc(proc); \
GOTO(proc); \
fixup_gp: \
@@ -44,7 +44,7 @@
({ \
__label__ fixup_gp; \
debugcall((proc), (succ_cont)); \
- succip = (&&fixup_gp); \
+ mr_succip = (&&fixup_gp); \
set_prof_current_proc(proc); \
GOTO(proc); \
fixup_gp: \
@@ -55,7 +55,7 @@
#define noprof_call(proc, succ_cont) \
do { \
debugcall((proc), (succ_cont)); \
- succip = (succ_cont); \
+ mr_succip = (succ_cont); \
set_prof_current_proc(proc); \
GOTO(proc); \
} while (0)
@@ -66,7 +66,7 @@
#define localcall(label, succ_cont, current_label) \
do { \
debugcall(LABEL(label), (succ_cont)); \
- succip = (succ_cont); \
+ mr_succip = (succ_cont); \
PROFILE(LABEL(label), (current_label)); \
set_prof_current_proc(LABEL(label)); \
GOTO_LABEL(label); \
@@ -81,7 +81,7 @@
#define call_localret(proc, succ_cont, current_label) \
do { \
PROFILE((proc), (current_label)); \
- noprof_call_localret(proc, succ_cont); \
+ noprof_call_localret(proc, succ_cont); \
} while (0)
#define call_det_closure(succ_cont, current_label) \
@@ -124,7 +124,7 @@
#define proceed() \
do { \
debugproceed(); \
- GOTO(succip); \
+ GOTO(mr_succip); \
} while (0)
#endif /* not CALLS_H */
Index: runtime/context.h
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/context.h,v
retrieving revision 1.8
diff -u -r1.8 context.h
--- context.h 1997/09/05 23:19:52 1.8
+++ context.h 1997/11/09 23:48:30
@@ -122,7 +122,7 @@
Word *context_hp;
/* saved hp for this context */
- Word *min_heap_reclamation_point;
+ Word *min_hp_rec;
/*
** this pointer marks the minimum value of hp to which we can
** truncate the heap on backtracking. See comments before the
@@ -232,13 +232,6 @@
extern int my_procnum;
extern pid_t my_procid;
-/*
-** The minimum value of hp to which the current context
-** may truncate the heap on backtracking. see the comments
-** below next to the set_min_heap_reclamation_point macro.
-*/
-extern Word *min_heap_reclamation_point;
-
/* do a context switch */
Declare_entry(do_runnext);
#define runnext() GOTO(ENTRY(do_runnext));
@@ -292,7 +285,7 @@
**
** If hp > context_hp, another context has allocated data on the heap since
** we were last scheduled, so the furthest back that we can reclaim is to
-** the current value of hp, so we set min_heap_reclamation_point and the
+** the current value of hp, so we set mr_min_hp_rec and the
** field of the same name in our context structure.
**
** If hp < context_hp, then another context has truncated the heap on failure.
@@ -314,20 +307,18 @@
if (hp != (ctxt)->context_hp \
|| (ctxt)->context_hp == NULL) \
{ \
- min_heap_reclamation_point = hp; \
- (ctxt)->min_heap_reclamation_point = hp;\
+ mr_min_hp_rec = hp; \
+ (ctxt)->min_hp_rec = hp;\
} \
else \
{ \
- min_heap_reclamation_point = \
- (ctxt)->min_heap_reclamation_point;\
+ mr_min_hp_rec = (ctxt)->min_hp_rec; \
} \
} while (0)
#define save_hp_in_context(ctxt) do { \
(ctxt)->context_hp = hp; \
- (ctxt)->min_heap_reclamation_point = \
- min_heap_reclamation_point; \
+ (ctxt)->min_hp_rec = mr_min_hp_rec; \
} while (0)
#else
@@ -347,12 +338,12 @@
#define load_context(cptr) do { \
Context *load_context_c; \
load_context_c = (cptr); \
- succip = load_context_c->context_succip; \
+ mr_succip = load_context_c->context_succip; \
detstack_zone = load_context_c->detstack_zone; \
- sp = load_context_c->context_sp; \
+ mr_sp = load_context_c->context_sp; \
nondetstack_zone = load_context_c->nondetstack_zone; \
- maxfr = load_context_c->context_maxfr; \
- curfr = load_context_c->context_curfr; \
+ mr_maxfr = load_context_c->context_maxfr; \
+ mr_curfr = load_context_c->context_curfr; \
MR_IF_USE_TRAIL( \
MR_trail_zone = load_context_c->trail_zone; \
MR_trail_ptr = load_context_c->context_trail_ptr; \
@@ -365,12 +356,12 @@
#define save_context(cptr) do { \
Context *save_context_c; \
save_context_c = (cptr); \
- save_context_c->context_succip = succip; \
+ save_context_c->context_succip = mr_succip; \
save_context_c->detstack_zone = detstack_zone; \
- save_context_c->context_sp = sp; \
+ save_context_c->context_sp = mr_sp; \
save_context_c->nondetstack_zone = nondetstack_zone; \
- save_context_c->context_maxfr = maxfr; \
- save_context_c->context_curfr = curfr; \
+ save_context_c->context_maxfr = mr_maxfr; \
+ save_context_c->context_curfr = mr_curfr; \
MR_IF_USE_TRAIL( \
save_context_c->trail_zone = MR_trail_zone; \
save_context_c->context_trail_ptr = MR_trail_ptr; \
Index: runtime/context.mod
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/context.mod,v
retrieving revision 1.11
diff -u -r1.11 context.mod
--- context.mod 1997/10/12 13:41:32 1.11
+++ context.mod 1997/11/04 01:34:32
@@ -17,125 +17,21 @@
#include "context.h"
#include "engine.h" /* for `memdebug' */
-#ifdef PARALLEL
-unsigned numprocs = 1;
-#endif
-
-#ifdef PARALLEL
-pid_t *procid;
-AtomicBool *procwaiting;
-#endif
-int my_procnum;
-pid_t my_procid;
-Word *min_heap_reclamation_point;
-
Context *this_context;
-Context **runqueue_ptr;
-Context **free_context_list_ptr;
-SpinLock *runqueue_lock;
-SpinLock *free_context_list_lock;
-
-Context *do_schedule_cptr;
-Code *do_schedule_resume;
-Word *do_join_and_terminate_sync_term;
-Word *do_join_and_continue_sync_term;
-Code *do_join_and_continue_where_to;
-
-static void init_free_context_list(void);
-
-void
-init_processes(void)
-{
- int i;
- pid_t pid;
-
- my_procnum = 0;
- my_procid = getpid();
-
- runqueue_lock = allocate_lock();
- runqueue_ptr = allocate_object(Context *);
- *runqueue_ptr = NULL;
-
-#ifdef PARALLEL
- procid = allocate_array(pid_t, numprocs);
- procwaiting = allocate_array(AtomicBool, numprocs);
- procid[0] = my_procid;
- procwaiting[0] = FALSE;
-
- for (i = 1; i < numprocs; i++) {
- if ((pid = fork()) < 0) {
- fatal_error("failed to fork()");
- }
- if (pid == 0) { /* child */
- my_procnum = i;
- procid[i] = my_procid = getpid();
- procwaiting[i] = FALSE;
- return;
- }
- }
-#endif
-
-}
-
-void
-shutdown_processes(void)
-{
-#ifdef PARALLEL
- /* XXX not yet implemented */
- if (numprocs > 1) {
- fprintf(stderr, "Mercury runtime: shutdown_processes()"
- " not yet implemented\n");
- }
-#endif
-}
+static Context *free_context_list = NULL;
void
init_process_context(void)
{
- /*
- ** Each process has its own heap, in shared memory;
- ** each process may only allocate from its own heap,
- ** although it may access or modify data allocated
- ** by other processes in different heaps.
- */
init_heap();
- if (my_procnum == 0) { /* the original process */
- init_free_context_list();
- this_context = new_context();
- /* load the registers so we don't clobber hp */
- restore_transient_registers();
- load_context(this_context);
- save_transient_registers();
-
- if (memdebug) debug_memory();
- }
-}
-
-static void
-init_free_context_list(void)
-{
- int i;
- Context *tmp;
+ this_context = new_context();
+ /* load the registers so we don't clobber hp */
+ restore_transient_registers();
+ load_context(this_context);
+ save_transient_registers();
- free_context_list_lock = allocate_lock();
- free_context_list_ptr = allocate_object(Context *);
- *free_context_list_ptr = allocate_array(Context, INITIAL_NUM_CONTEXTS);
- tmp = *free_context_list_ptr;
- for (i = 0; i < INITIAL_NUM_CONTEXTS; i++) {
- if (i != INITIAL_NUM_CONTEXTS - 1) {
- tmp[i].next = &(tmp[i+1]);
- } else {
- tmp[i].next = NULL;
- }
- tmp[i].resume = NULL;
- tmp[i].context_succip = NULL;
- tmp[i].detstack_zone = NULL;
- tmp[i].context_sp = NULL;
- tmp[i].nondetstack_zone = NULL;
- tmp[i].context_curfr = NULL;
- tmp[i].context_maxfr = NULL;
- }
+ if (memdebug) debug_memory();
}
Context *
@@ -143,16 +39,18 @@
{
Context *c;
- get_lock(free_context_list_lock);
-
- MR_assert(free_context_list_ptr != NULL);
- if (*free_context_list_ptr == NULL) {
- fatal_error("no free contexts");
+ if (free_context_list == NULL) {
+ c = (Context *) malloc(sizeof(Context));
+ assert(c);
+ c->detstack_zone = NULL;
+ c->nondetstack_zone = NULL;
+#ifdef MR_USE_TRAIL
+ c->trail_zone = NULL;
+#endif
} else {
- c = *free_context_list_ptr;
- *free_context_list_ptr = c->next;
+ c = free_context_list;
+ free_context_list = c->next;
}
- release_lock(free_context_list_lock);
c->next = NULL;
c->resume = NULL;
@@ -201,11 +99,8 @@
void
delete_context(Context *c)
{
- get_lock(free_context_list_lock);
- MR_assert(free_context_list_ptr != NULL);
- c->next = *free_context_list_ptr;
- *free_context_list_ptr = c;
- release_lock(free_context_list_lock);
+ c->next = free_context_list;
+ free_context_list = c;
}
void
@@ -214,184 +109,3 @@
fatal_error("computation floundered");
}
-BEGIN_MODULE(context_module)
-
-BEGIN_CODE
-
- /*
- ** do a context switch: the previous context is assumed to have
- ** been saved or deallocated or whatever.
- */
-do_runnext:
- while(1) {
-#ifdef PARALLEL
- /* If we're running in parallel, then we need to
- ** do some signal magic in order to avoid a race-
- ** condition if we have to suspend, waiting for
- ** the runqueue to become non-empty.
- ** The following algorithm is adapted from
- ** "Advanced Programming in the UNIX Environment",
- ** Stevens:
- ** - use sigprocmask to block SIGUSR1
- ** - obtain the spinlock on the runqueue
- ** - if the runqueue is not empty, get the
- ** next context off the queue, release the
- ** lock and reset the signal mask.
- ** - if the runqueue is empty, mark this process
- ** as waiting, release the lock and then
- ** use sigsuspend to atomically renable SIGUSR1
- ** and suspend the process. When we get a
- ** SIGUSR1 we resume and mark the process as not
- ** waiting, then try again to get a context off
- ** the runqueue.
- ** - this relies on the schedule code to send the
- ** SIGUSR1 signal while it has the spinlock to
- ** ensure that this process will only get sent
- ** a single signal.
- */
- sigset_t newset, oldset, emptyset;
- sigemptyset(&newset);
- sigemptyset(&emptyset);
- sigaddset(&newset, SIGUSR1);
- /* block SIGUSR1 while we're in the critical region */
- sigprocmask(SIG_BLOCK, &newset, &oldset);
-#endif
- get_lock(runqueue_lock);
- if (*runqueue_ptr != NULL) {
- this_context = *runqueue_ptr;
- *runqueue_ptr = (*runqueue_ptr)->next;
- release_lock(runqueue_lock);
-#ifdef PARALLEL
- /* restore the original set of signals */
- sigprocmask(SIG_SETMASK, &oldset, NULL);
-#endif
- load_context(this_context);
- GOTO(this_context->resume);
- }
- else
- {
-#ifdef PARALLEL
- int i;
- bool is_runnable;
-
- procwaiting[my_procnum] = TRUE;
-
- /*
- ** check to see that at least one process
- ** is currently runnable. If none are, then
- ** we've just floundered.
- */
- is_runnable = FALSE;
- for(i = 0; i < numprocs; i++)
- {
- if (procwaiting[i] == FALSE)
- {
- is_runnable = TRUE;
- break;
- }
- }
- if (!is_runnable)
- flounder();
-
-#endif
- release_lock(runqueue_lock);
-#ifdef PARALLEL
- sigsuspend(&emptyset);
- procwaiting[my_procnum] = FALSE;
-#else
- /* if we're not using parallelism, then
- ** the runqueue should never be empty.
- */
- flounder();
-#endif
- }
- }
-
- /*
- ** do_schedule adds the context pointed to by do_schedule_cptr
- ** to the runqueue, signalling a sleeping process to wake it if
- ** the runqueue was previously empty.
- */
-do_schedule:
-{
- Context *old;
-
- get_lock(runqueue_lock);
- old = *runqueue_ptr;
- do_schedule_cptr->next = *runqueue_ptr;
- *runqueue_ptr = do_schedule_cptr;
-#ifdef PARALLEL
- /* Check to see if we need to signal a sleeping process */
- if (old == NULL) {
- int i;
- for(i = 0; i < numprocs; i++) {
- if (procwaiting[i] == TRUE) {
- kill(procid[i], SIGUSR1);
- break;
- }
- }
- }
-#endif
- release_lock(runqueue_lock);
- GOTO(do_schedule_resume);
-}
-
- /*
- ** do_join_and_terminate synchronises with the structure pointed to
- ** by do_join_and_terminate_sync_term, then terminates the current
- ** context and does a context switch. If the current context was the
- ** last context to arrive at the synchronisation point, then we
- ** resume the parent context rather than do a context switch.
- */
-do_join_and_terminate:
-{
- register Word *sync_term;
- Context *ctxt;
-
- sync_term = do_join_and_terminate_sync_term;
-
- get_lock((SpinLock *)&sync_term[SYNC_TERM_LOCK]);
- if (--(sync_term[SYNC_TERM_COUNTER]) == 0) {
- MR_assert(sync_term[SYNC_TERM_PARENT] != NULL);
- release_lock((SpinLock *)&sync_term[SYNC_TERM_LOCK]);
- ctxt = (Context *) sync_term[SYNC_TERM_PARENT];
- delete_context(this_context);
- this_context = ctxt;
- load_context(this_context);
- GOTO(this_context->resume);
- } else {
- release_lock((SpinLock *)&sync_term[SYNC_TERM_LOCK]);
- delete_context(this_context);
- runnext();
- }
-}
-
- /*
- ** do_join_and_continue synchronises with the structure pointed to
- ** by do_join_and_continue_sync_term. If we are the last context to
- ** arrive here, then we branch to the continuation stored in
- ** do_join_and_continue_where_to. If we have to wait for other contexts
- ** to arrive, then we save the current context and store a pointer
- ** to it in the synchronisation term before doing a context switch.
- */
-do_join_and_continue:
-{
- register Word *sync_term;
-
- sync_term = do_join_and_continue_sync_term;
-
- get_lock((SpinLock *)&sync_term[SYNC_TERM_LOCK]);
- if (--(sync_term[SYNC_TERM_COUNTER]) == 0) {
- MR_assert(sync_term[SYNC_TERM_PARENT] == NULL);
- release_lock((SpinLock *)&sync_term[SYNC_TERM_LOCK]);
- GOTO(do_join_and_continue_where_to);
- } else {
- save_context(this_context);
- this_context->resume = do_join_and_continue_where_to;
- sync_term[SYNC_TERM_PARENT] = (Word) this_context;
- release_lock((SpinLock *)&sync_term[SYNC_TERM_LOCK]);
- runnext();
- }
-}
-
-END_MODULE
Index: runtime/engine.h
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/engine.h,v
retrieving revision 1.15
diff -u -r1.15 engine.h
--- engine.h 1997/10/02 01:50:24 1.15
+++ engine.h 1997/11/10 01:39:02
@@ -89,7 +89,7 @@
** - The general-purpose registers r1, r2... are not restored and must
** be saved by the caller.
** - In grades without conservative garbage collection, the caller
- ** must save and restore hp, solutions_heap_pointer, heap_zone
+ ** must save and restore hp, sol_hp, heap_zone
** and solutions_heap_zone.
*/
#define MR_setjmp(setjmp_env, longjmp_label) \
Index: runtime/engine.mod
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/engine.mod,v
retrieving revision 1.44
diff -u -r1.44 engine.mod
--- engine.mod 1997/10/02 01:50:27 1.44
+++ engine.mod 1997/11/04 22:03:10
@@ -61,16 +61,8 @@
make_label("engine_done", LABEL(engine_done));
#endif
- init_processes();
init_process_context();
- if (my_procnum == 0) {
- return;
- } else {
- call_engine(ENTRY(do_runnext));
- /* not reached */
- MR_assert(FALSE);
- }
}
/*---------------------------------------------------------------------------*/
@@ -302,7 +294,7 @@
engine_init_registers(void)
{
restore_transient_registers();
- succip = engine_done;
+ mr_succip = engine_done;
return NULL;
}
@@ -390,8 +382,6 @@
** we don't bother to deallocate memory...
** that will happen automatically on process exit anyway.
*/
-
- shutdown_processes();
}
/*---------------------------------------------------------------------------*/
Index: runtime/heap.h
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/heap.h,v
retrieving revision 1.13
diff -u -r1.13 heap.h
--- heap.h 1997/07/27 15:08:18 1.13
+++ heap.h 1997/11/09 23:48:51
@@ -74,23 +74,23 @@
#define restore_hp(src) ((void)0)
/* we use `hp' as a convenient temporary here */
-#define hp_alloc(count) (incr_hp(hp,(count)), hp += (count), (void)0)
+#define hp_alloc(count) (incr_hp(mr_hp,(count)), mr_hp += (count), (void)0)
#define hp_alloc_atomic(count) \
- (incr_hp_atomic(hp,(count)), hp += (count), (void)0)
+ (incr_hp_atomic(mr_hp,(count)), mr_hp += (count), (void)0)
#else /* not CONSERVATIVE_GC */
#define tag_incr_hp(dest,tag,count) ( \
- (dest) = (Word)mkword(tag, (Word)hp), \
- debugincrhp(count, hp), \
- hp += (count), \
+ (dest) = (Word)mkword(tag, (Word)mr_hp), \
+ debugincrhp(count, mr_hp), \
+ mr_hp += (count), \
heap_overflow_check(), \
(void)0 \
)
#define tag_incr_hp_atomic(dest,tag,count) tag_incr_hp((dest),(tag),(count))
#define mark_hp(dest) ( \
- (dest) = (Word)hp, \
+ (dest) = (Word)mr_hp, \
(void)0 \
)
@@ -101,9 +101,9 @@
** the set_min_heap_reclamation_point() macro.
*/
#define restore_hp(src) ( \
- LVALUE_CAST(Word,hp) = \
- ( (Word) min_heap_reclamation_point < (src) ? \
- (src) : (Word) min_heap_reclamation_point ), \
+ LVALUE_CAST(Word,mr_hp) = \
+ ( (Word) mr_min_hp_rec < (src) ? \
+ (src) : (Word) mr_min_hp_rec ), \
(void)0 \
)
@@ -126,47 +126,47 @@
/* not by the automatically generated code */
#define create1(w1) ( \
hp_alloc(1), \
- hp[-1] = (Word) (w1), \
- debugcr1(hp[-1], hp), \
- /* return */ (Word) (hp - 1) \
+ mr_hp[-1] = (Word) (w1), \
+ debugcr1(mr_hp[-1], mr_hp), \
+ /* return */ (Word) (mr_hp - 1) \
)
/* used only by the hand-written example programs */
/* not by the automatically generated code */
#define create2(w1, w2) ( \
hp_alloc(2), \
- hp[-2] = (Word) (w1), \
- hp[-1] = (Word) (w2), \
- debugcr2(hp[-2], hp[-1], hp), \
- /* return */ (Word) (hp - 2) \
+ mr_hp[-2] = (Word) (w1), \
+ mr_hp[-1] = (Word) (w2), \
+ debugcr2(mr_hp[-2], mr_hp[-1], mr_hp), \
+ /* return */ (Word) (mr_hp - 2) \
)
/* used only by the hand-written example programs */
/* not by the automatically generated code */
#define create3(w1, w2, w3) ( \
hp_alloc(3), \
- hp[-3] = (Word) (w1), \
- hp[-2] = (Word) (w2), \
- hp[-1] = (Word) (w3), \
- /* return */ (Word) (hp - 3) \
+ mr_hp[-3] = (Word) (w1), \
+ mr_hp[-2] = (Word) (w2), \
+ mr_hp[-1] = (Word) (w3), \
+ /* return */ (Word) (mr_hp - 3) \
)
/* used only by the hand-written example programs */
/* not by the automatically generated code */
#define create2_bf(w1) ( \
- hp = hp + 2, \
- hp[-2] = (Word) (w1), \
+ mr_hp = mr_hp + 2, \
+ mr_hp[-2] = (Word) (w1), \
heap_overflow_check(), \
- /* return */ (Word) (hp - 2) \
+ /* return */ (Word) (mr_hp - 2) \
)
/* used only by the hand-written example programs */
/* not by the automatically generated code */
#define create2_fb(w2) ( \
- hp = hp + 2, \
- hp[-1] = (Word) (w2), \
+ mr_hp = mr_hp + 2, \
+ mr_hp[-1] = (Word) (w2), \
heap_overflow_check(), \
- /* return */ (Word) (hp - 2) \
+ /* return */ (Word) (mr_hp - 2) \
)
/*
Index: runtime/memory.c
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/memory.c,v
retrieving revision 1.77
diff -u -r1.77 memory.c
--- memory.c 1997/09/05 23:20:01 1.77
+++ memory.c 1997/11/10 01:40:10
@@ -183,7 +183,6 @@
#ifndef CONSERVATIVE_GC
MemoryZone *heap_zone;
MemoryZone *solutions_heap_zone;
- Word *solutions_heap_pointer;
#endif
#ifndef SPEED
MemoryZone *dumpstack_zone;
@@ -415,13 +414,15 @@
heap_zone_size, default_handler);
restore_transient_registers();
- hp = heap_zone->min;
+ mr_hp = heap_zone->min;
save_transient_registers();
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;
+ restore_transient_registers();
+ mr_sol_hp = solutions_heap_zone->min;
+ save_transient_registers();
#endif
Index: runtime/memory.h
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/memory.h,v
retrieving revision 1.28
diff -u -r1.28 memory.h
--- memory.h 1997/09/05 23:20:04 1.28
+++ memory.h 1997/11/10 01:38:36
@@ -130,7 +130,6 @@
#ifndef CONSERVATIVE_GC
extern MemoryZone *heap_zone;
extern MemoryZone *solutions_heap_zone;
-extern Word *solutions_heap_pointer;
#endif
#ifndef SPEED
Index: runtime/mercury_float.h
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/mercury_float.h,v
retrieving revision 1.6
diff -u -r1.6 mercury_float.h
--- mercury_float.h 1997/07/27 15:08:29 1.6
+++ mercury_float.h 1997/11/04 01:44:10
@@ -27,17 +27,17 @@
#ifdef CONSERVATIVE_GC
#define float_to_word(f) ( \
hp_alloc(FLOAT_WORDS), \
- *(Float *)(void *)(hp - FLOAT_WORDS) = (f), \
- /* return */ (Word) (hp - FLOAT_WORDS) \
+ *(Float *)(void *)(mr_hp - FLOAT_WORDS) = (f), \
+ /* return */ (Word) (mr_hp - FLOAT_WORDS) \
)
#else
/* we need to ensure that what we allocated on the heap is properly
aligned */
#define float_to_word(f) ( \
- ( (Word)hp & (sizeof(Float) - 1) ? hp_alloc(1) : (void)0 ), \
+ ( (Word)mr_hp & (sizeof(Float) - 1) ? hp_alloc(1) : (void)0 ), \
hp_alloc(FLOAT_WORDS), \
- *(Float *)(void *)(hp - FLOAT_WORDS) = (f), \
- /* return */ (Word) (hp - FLOAT_WORDS) \
+ *(Float *)(void *)(mr_hp - FLOAT_WORDS) = (f), \
+ /* return */ (Word) (mr_hp - FLOAT_WORDS) \
)
#endif
Index: runtime/regorder.h
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/regorder.h,v
retrieving revision 1.18
diff -u -r1.18 regorder.h
--- regorder.h 1997/08/23 22:34:18 1.18
+++ regorder.h 1997/11/09 22:01:57
@@ -55,11 +55,20 @@
#define r31 count_usage(R_RN(31), mr35)
#define r32 count_usage(R_RN(32), mr36)
-#define succip LVALUE_CAST(Code *, count_usage(SI_RN, mr1))
-#define hp LVALUE_CAST(Word *, count_usage(HP_RN, mr5))
-#define sp LVALUE_CAST(Word *, count_usage(SP_RN, mr0))
-#define curfr LVALUE_CAST(Word *, count_usage(CF_RN, mr8))
-#define maxfr LVALUE_CAST(Word *, count_usage(MF_RN, mr9))
+#define mr_succip LVALUE_CAST(Code *, count_usage(MR_SI_RN, mr1))
+#define succip mr_succip
+#define mr_hp LVALUE_CAST(Word *, count_usage(MR_HP_RN, mr5))
+#define hp mr_hp
+#define mr_sp LVALUE_CAST(Word *, count_usage(MR_SP_RN, mr0))
+#define sp mr_sp
+#define mr_curfr LVALUE_CAST(Word *, count_usage(MR_CF_RN, mr8))
+#define curfr mr_curfr
+#define mr_maxfr LVALUE_CAST(Word *, count_usage(MR_MF_RN, mr9))
+#define maxfr mr_maxfr
+#define mr_sol_hp LVALUE_CAST(Word *, count_usage(MR_SOL_HP_RN, mr(37)))
+#define mr_min_hp_rec LVALUE_CAST(Word *, count_usage(MR_MIN_HP_REC, mr(38)))
+#define mr_min_sol_hp_rec LVALUE_CAST(Word *, \
+ count_usage(MR_MIN_HP_REC, mr39))
#define MR_trail_ptr count_usage(MR_TRAIL_PTR_RN, MR_trail_ptr_var)
#define MR_ticket_counter \
Index: runtime/regs.h
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/regs.h,v
retrieving revision 1.31
diff -u -r1.31 regs.h
--- regs.h 1997/08/23 22:34:17 1.31
+++ regs.h 1997/11/04 01:18:22
@@ -148,15 +148,18 @@
** print_register_usage_counts() in wrapper.mod.
*/
-#define SI_RN 0
-#define R_RN(n) (n)
-#define ORD_RN MAX_REAL_REG
-#define HP_RN (ORD_RN + 1)
-#define SP_RN (ORD_RN + 2)
-#define CF_RN (ORD_RN + 3)
-#define MF_RN (ORD_RN + 4)
-#define MR_TRAIL_PTR_RN (ORD_RN + 5)
-#define MR_TICKET_COUNTER_RN (ORD_RN + 6)
-#define MAX_RN (ORD_RN + 7)
+#define MR_SI_RN 0
+#define MR_R_RN(n) (n)
+#define MR_ORD_RN MAX_REAL_REG
+#define MR_HP_RN (MR_ORD_RN + 1)
+#define MR_SP_RN (MR_ORD_RN + 2)
+#define MR_CF_RN (MR_ORD_RN + 3)
+#define MR_MF_RN (MR_ORD_RN + 4)
+#define MR_TRAIL_PTR_RN (MR_ORD_RN + 5)
+#define MR_TICKET_COUNTER_RN (MR_ORD_RN + 6)
+#define MR_SOL_HP_RN (MR_ORD_RN + 7)
+#define MR_MIN_HP_REC (MR_ORD_RN + 8)
+#define MR_MIN_SOL_HP_REC (MR_ORD_RN + 9)
+#define MAX_RN (MR_ORD_RN + 10)
#endif /* not REGS_H */
Index: runtime/stacks.h
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/stacks.h,v
retrieving revision 1.9
diff -u -r1.9 stacks.h
--- stacks.h 1997/07/27 15:08:43 1.9
+++ stacks.h 1997/11/04 01:27:46
@@ -17,53 +17,53 @@
/* DEFINITIONS FOR MANIPULATING THE DET STACK */
-#define detstackvar(n) sp[-n]
+#define detstackvar(n) (mr_sp[-n])
#define incr_sp_push_msg(n, msg) \
( \
- debugincrsp(n, sp), \
+ debugincrsp(n, mr_sp), \
dump_push_msg(msg), \
- sp = sp + (n), \
+ mr_sp = mr_sp + (n), \
detstack_overflow_check(), \
(void)0 \
)
#define decr_sp_pop_msg(n) \
( \
- debugdecrsp(n, sp), \
+ debugdecrsp(n, mr_sp), \
dump_pop_msg(), \
- sp = sp - (n), \
+ mr_sp = mr_sp - (n), \
detstack_underflow_check(), \
(void)0 \
)
#define incr_sp(n) ( \
- debugincrsp(n, sp), \
- sp = sp + (n), \
+ debugincrsp(n, mr_sp), \
+ mr_sp = mr_sp + (n), \
detstack_overflow_check(), \
(void)0 \
)
#define decr_sp(n) ( \
- debugdecrsp(n, sp), \
- sp = sp - (n), \
+ debugdecrsp(n, mr_sp), \
+ mr_sp = mr_sp - (n), \
detstack_underflow_check(), \
(void)0 \
)
#define push(w) ( \
- *sp = (Word) (w), \
- debugpush(*sp, sp), \
- sp = sp + 1, \
+ *mr_sp = (Word) (w), \
+ debugpush(*sp, mr_sp), \
+ mr_sp = mr_sp + 1, \
detstack_overflow_check(), \
(void)0 \
)
#define pop() ( \
- sp = sp - 1, \
- debugpop(*sp, sp), \
+ mr_sp = mr_sp - 1, \
+ debugpop(*mr_sp, mr_sp), \
detstack_underflow_check(), \
- /* return */ *sp \
+ /* return */ *mr_sp \
)
/* DEFINITIONS FOR NONDET STACK FRAMES */
@@ -93,12 +93,12 @@
#define bt_succfr(fr) LVALUE_CAST(Word *, ((Word *) (fr))[SUCCFR])
#define bt_var(fr,n) (((Word *) (fr))[SAVEVAL-(n)])
-#define curprednm bt_prednm(curfr)
-#define curredoip bt_redoip(curfr)
-#define curprevfr bt_prevfr(curfr)
-#define cursuccip bt_succip(curfr)
-#define cursuccfr bt_succfr(curfr)
-#define framevar(n) bt_var(curfr,n)
+#define curprednm bt_prednm(mr_curfr)
+#define curredoip bt_redoip(mr_curfr)
+#define curprevfr bt_prevfr(mr_curfr)
+#define curmr_succip bt_succip(mr_curfr)
+#define cursuccfr bt_succfr(mr_curfr)
+#define framevar(n) bt_var(mr_curfr,n)
/* DEFINITIONS FOR MANIPULATING THE NONDET STACK */
@@ -114,13 +114,13 @@
reg Word *prevfr; \
reg Word *succfr; \
\
- prevfr = maxfr; \
- succfr = curfr; \
- maxfr += (NONDET_FIXED_SIZE + numslots);\
- curfr = maxfr; \
+ prevfr = mr_maxfr; \
+ succfr = mr_curfr; \
+ mr_maxfr += (NONDET_FIXED_SIZE + numslots);\
+ mr_curfr = mr_maxfr; \
curredoip = redoip; \
curprevfr = prevfr; \
- cursuccip = succip; \
+ curmr_succip = mr_succip; \
cursuccfr = succfr; \
mkframe_save_prednm(prednm); \
debugmkframe(); \
@@ -140,8 +140,8 @@
reg Word *childfr; \
\
debugsucceed(); \
- childfr = curfr; \
- curfr = cursuccfr; \
+ childfr = mr_curfr; \
+ mr_curfr = cursuccfr; \
GOTO(bt_succip(childfr)); \
} while (0)
@@ -150,17 +150,17 @@
reg Word *childfr; \
\
debugsucceeddiscard(); \
- childfr = curfr; \
- maxfr = curprevfr; \
- curfr = cursuccfr; \
+ childfr = mr_curfr; \
+ mr_maxfr = curprevfr; \
+ mr_curfr = cursuccfr; \
GOTO(bt_succip(childfr)); \
} while (0)
#define fail() do { \
debugfail(); \
- maxfr = curprevfr; \
- curfr = maxfr; \
+ mr_maxfr = curprevfr; \
+ mr_curfr = mr_maxfr; \
nondstack_underflow_check(); \
GOTO(curredoip); \
} while (0)
@@ -168,7 +168,7 @@
#define redo() do { \
debugredo(); \
- curfr = maxfr; \
+ mr_curfr = mr_maxfr; \
GOTO(curredoip); \
} while (0)
Index: runtime/wrapper.mod
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/wrapper.mod,v
retrieving revision 1.81
diff -u -r1.81 wrapper.mod
--- wrapper.mod 1997/10/01 13:22:27 1.81
+++ wrapper.mod 1997/11/04 01:24:06
@@ -830,9 +830,9 @@
BEGIN_CODE
do_interpreter:
- push(hp);
- push(succip);
- push(maxfr);
+ push(mr_hp);
+ push(mr_succip);
+ push(mr_maxfr);
mkframe("interpreter", 1, LABEL(global_fail));
if (program_entry_point == NULL) {
@@ -880,9 +880,9 @@
prof_output_addr_pair_table();
#endif
- maxfr = (Word *) pop();
- succip = (Code *) pop();
- hp = (Word *) pop();
+ mr_maxfr = (Word *) pop();
+ mr_succip = (Code *) pop();
+ mr_hp = (Word *) pop();
#ifndef SPEED
if (finaldebug && detaildebug) {
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/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
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