Diff to runtime for review

Thomas Charles CONWAY conway at cs.mu.oz.au
Wed Feb 12 09:34:52 AEDT 1997


Hi

Fergus, could you please review these changes to the runtime. They don't
affect singlethreaded programs - just various bugfixes that I found when
I started generating multithreaded code.

Thomas
(ps I have a version of the compiler that generates correct code for
det independant parallel conjunctions with no outputs :-)).
-- 
Thomas Conway               				      conway at cs.mu.oz.au
AD DEUM ET VINUM	  			      Every sword has two edges.

cvs diff: Diffing .
Index: context.h
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/context.h,v
retrieving revision 1.3
diff -u -r1.3 context.h
--- context.h	1997/02/08 12:39:12	1.3
+++ context.h	1997/02/10 22:52:05
@@ -251,12 +251,12 @@
 		for (fork_new_context_i = (numslots) ;		\
 				fork_new_context_i > 0 ;	\
 				fork_new_context_i--) {		\
-			*(fork_new_context_context->sp) =	\
+			*(fork_new_context_context->context_sp) = \
 				detstackvar(fork_new_context_i); \
-			fork_new_context_context->sp++;		\
+			fork_new_context_context->context_sp++;	\
 		}						\
-		c->resume = (child);				\
-		schedule(c, (parent));				\
+		fork_new_context_context->resume = (child);	\
+		schedule(fork_new_context_context, (parent));	\
 	} while (0)
 
 #ifndef	CONSERVATIVE_GC
@@ -361,12 +361,14 @@
 #define	SYNC_TERM_COUNTER	1
 #define	SYNC_TERM_PARENT	2
 
+Declare_entry(do_join_and_terminate);
 extern Word	*do_join_and_terminate_sync_term;
 #define join_and_terminate(sync_term)	do {				\
 		do_join_and_terminate_sync_term = (Word *)(sync_term);	\
 		GOTO(ENTRY(do_join_and_terminate));			\
 	} while (0)
 
+Declare_entry(do_join_and_continue);
 extern Word	*do_join_and_continue_sync_term;
 extern Code	*do_join_and_continue_where_to;
 #define join_and_continue(sync_term, where_to)	do {			\
Index: context.mod
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/context.mod,v
retrieving revision 1.3
diff -u -r1.3 context.mod
--- context.mod	1997/02/08 12:39:13	1.3
+++ context.mod	1997/02/11 22:32:01
@@ -36,9 +36,9 @@
 
 Context	*do_schedule_cptr;
 Code	*do_schedule_resume;
-Word     *do_join_and_terminate_syncterm;
-Word     *do_join_and_continue_syncterm;
-Code     *do_join_and_continue_whereto;
+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);
 
@@ -298,29 +298,29 @@
 
 	/*
 	** do_join_and_terminate synchronises with the structure pointed to
-	** by do_join_and_terminate_syncterm, then terminates the current
+	** 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 *syncterm;
+	register Word *sync_term;
 	Context *ctxt;
 
-	syncterm = do_join_and_terminate_syncterm;
+	sync_term = do_join_and_terminate_sync_term;
 
-	get_lock((SpinLock *)&syncterm[SYNC_TERM_LOCK]);
-	if (--(syncterm[SYNC_TERM_COUNTER]) == 0) {
-		assert(syncterm[SYNC_TERM_PARENT] != NULL);
-		release_lock((SpinLock *)&syncterm[SYNC_TERM_LOCK]);
-		ctxt = (Context *) syncterm[SYNC_TERM_PARENT];
+	get_lock((SpinLock *)&sync_term[SYNC_TERM_LOCK]);
+	if (--(sync_term[SYNC_TERM_COUNTER]) == 0) {
+		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 *)&syncterm[SYNC_TERM_LOCK]);
+		release_lock((SpinLock *)&sync_term[SYNC_TERM_LOCK]);
 		delete_context(this_context);
 		runnext();
 	}
@@ -328,27 +328,28 @@
 
 	/*
 	** do_join_and_continue synchronises with the structure pointed to
-	** by do_join_and_continue_syncterm. If we are the last context 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_whereto. If we have to wait for other contexts
+	** 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 *syncterm;
+	register Word *sync_term;
 
-	syncterm = do_join_and_continue_syncterm;
-	get_lock((SpinLock *)&syncterm[SYNC_TERM_LOCK]);
-	if (--(syncterm[SYNC_TERM_COUNTER]) == 0) {
-		assert(syncterm[SYNC_TERM_PARENT] == NULL);
-		release_lock((SpinLock *)&syncterm[SYNC_TERM_LOCK]);
-		GOTO(do_join_and_continue_whereto);
+	sync_term = do_join_and_continue_sync_term;
+
+	get_lock((SpinLock *)&sync_term[SYNC_TERM_LOCK]);
+	if (--(sync_term[SYNC_TERM_COUNTER]) == 0) {
+		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_whereto;
-		syncterm[SYNC_TERM_PARENT] = (Word) this_context;
-		release_lock((SpinLock *)&syncterm[SYNC_TERM_LOCK]);
+		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();
 	}
 }
cvs diff: Diffing machdeps



More information about the developers mailing list