[Commit] nickle ChangeLog, 1.72, 1.73 compile.c, 1.157,
1.158 execute.c, 1.91, 1.92 gram.y, 1.137, 1.138 sched.c, 1.56,
1.57 value.h, 1.106, 1.107
Keith Packard
commit at keithp.com
Wed Jul 7 00:32:50 PDT 2004
Committed by: keithp
Update of /local/src/CVS/nickle
In directory home.keithp.com:/tmp/cvs-serv19189
Modified Files:
ChangeLog compile.c execute.c gram.y sched.c value.h
Log Message:
2004-07-07 Keith Packard <keithp at keithp.com>
* compile.c: (CompileCountCatches), (CompileCatch), (InstDump):
* execute.c: (ThreadCatches), (ThreadRaise), (ThreadEndCatch),
(ThreadUnwind), (ThreadsRun):
* sched.c: (FarJumpContinuation), (ContinuationTrace):
* value.h:
Parallel catch blocks are peers, not nested. This affects
how FarJump execution inside them happens; in particular,
all of the peer catches are unwound before the handler is
invoked so all jumps from inside use the same NonLocal
data structure. Also added yet more debugging to
continuation execution.
* gram.y:
Allow 'enum switch'
Index: ChangeLog
===================================================================
RCS file: /local/src/CVS/nickle/ChangeLog,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -d -r1.72 -r1.73
--- ChangeLog 19 Jun 2004 19:56:44 -0000 1.72
+++ ChangeLog 7 Jul 2004 07:32:47 -0000 1.73
@@ -1,3 +1,20 @@
+2004-07-07 Keith Packard <keithp at keithp.com>
+
+ * compile.c: (CompileCountCatches), (CompileCatch), (InstDump):
+ * execute.c: (ThreadCatches), (ThreadRaise), (ThreadEndCatch),
+ (ThreadUnwind), (ThreadsRun):
+ * sched.c: (FarJumpContinuation), (ContinuationTrace):
+ * value.h:
+ Parallel catch blocks are peers, not nested. This affects
+ how FarJump execution inside them happens; in particular,
+ all of the peer catches are unwound before the handler is
+ invoked so all jumps from inside use the same NonLocal
+ data structure. Also added yet more debugging to
+ continuation execution.
+
+ * gram.y:
+ Allow 'enum switch'
+
2004-06-19 Keith Packard <keithp at keithp.com>
* execute.c: (ThreadCall):
Index: compile.c
===================================================================
RCS file: /local/src/CVS/nickle/compile.c,v
retrieving revision 1.157
retrieving revision 1.158
diff -u -d -r1.157 -r1.158
--- compile.c 17 Jun 2004 23:53:41 -0000 1.157
+++ compile.c 7 Jul 2004 07:32:47 -0000 1.158
@@ -2054,6 +2054,19 @@
RETURN (obj);
}
+static int
+CompileCountCatches (ExprPtr catches)
+{
+ int c = 0;
+
+ while (catches)
+ {
+ c++;
+ catches = catches->tree.left;
+ }
+ return c;
+}
+
static ObjPtr
CompileCatch (ObjPtr obj, ExprPtr catches, ExprPtr body,
ExprPtr stat, CodePtr code, int nest)
@@ -2149,15 +2162,18 @@
inst->catch.offset = obj->used - catch_inst;
inst->catch.exception = exception;
- obj->nonLocal = NewNonLocal (obj->nonLocal, NonLocalTry, 0);
+ if (!catches->tree.left)
+ obj->nonLocal = NewNonLocal (obj->nonLocal, NonLocalTry, 0);
obj = CompileCatch (obj, catches->tree.left, body, stat, code, nest+1);
- obj->nonLocal = obj->nonLocal->prev;
+ if (!catches->tree.left)
+ obj->nonLocal = obj->nonLocal->prev;
if (!nest)
{
BuildInst (obj, OpEndCatch, inst, stat);
+ inst->ints.value = CompileCountCatches (catches);
/*
* Patch Catch branches inside
*/
@@ -4322,6 +4338,7 @@
ObjDump (inst->obj.obj, indent+1);
break;
case OpEndCatch:
+ FilePrintf (FileStdout, " %d catches", inst->ints.value);
break;
case OpRaise:
FilePrintf (FileStdout, "%A", inst->raise.exception->symbol.name);
Index: execute.c
===================================================================
RCS file: /local/src/CVS/nickle/execute.c,v
retrieving revision 1.91
retrieving revision 1.92
diff -u -d -r1.91 -r1.92
--- execute.c 19 Jun 2004 19:56:44 -0000 1.91
+++ execute.c 7 Jul 2004 07:32:47 -0000 1.92
@@ -581,6 +581,23 @@
}
+#ifdef DEBUG_JUMP
+void
+ThreadCatches (Value thread)
+{
+ CatchPtr catch;
+
+ FilePrintf (FileStdout, "(");
+ for (catch = thread->thread.continuation.catches;
+ catch;
+ catch = catch->continuation.catches)
+ {
+ FilePrintf (FileStdout, "%A ", catch->exception->symbol.name);
+ }
+ FilePrintf (FileStdout, ")\n");
+}
+#endif
+
static Value
ThreadRaise (Value thread, Value value, int argc, SymbolPtr exception, InstPtr *next)
{
@@ -591,7 +608,8 @@
int base = argc - 2;
#ifdef DEBUG_JUMP
- FilePrintf (FileStdout, " Raise: %A\n", exception->symbol.name);
+ FilePrintf (FileStdout, " Raise: %A ", exception->symbol.name);
+ ThreadCatches (thread);
#endif
/*
* Build and array to hold the arguments, this will end up
@@ -609,6 +627,20 @@
RETURN (args);
}
+static void
+ThreadEndCatch (Value thread, int catches)
+{
+#ifdef DEBUG_JUMP
+ FilePrintf (FileStdout, " EndCatch: %d ", catches);
+#endif
+ while (catches--)
+ thread->thread.continuation.catches = thread->thread.continuation.catches->continuation.catches;
+#ifdef DEBUG_JUMP
+ ThreadCatches (thread);
+#endif
+}
+
+
static Value
ThreadExceptionCall (Value thread, InstPtr *next, int *stack)
{
@@ -684,8 +716,22 @@
{
while (twixt--)
thread->thread.continuation.twixts = thread->thread.continuation.twixts->continuation.twixts;
+#ifdef DEBUG_JUMP
+ FilePrintf (FileStdout, " Before unwind: ");
+ ThreadCatches (thread);
+#endif
while (catch--)
+ {
+#ifdef DEBUG_JUMP
+ FilePrintf (FileStdout, " Unwind: %A\n",
+ thread->thread.continuation.catches->exception->symbol.name);
+#endif
thread->thread.continuation.catches = thread->thread.continuation.catches->continuation.catches;
+ }
+#ifdef DEBUG_JUMP
+ FilePrintf (FileStdout, " After unwind: ");
+ ThreadCatches (thread);
+#endif
}
#define ThreadBoxCheck(box,i) (BoxValueGet(box,i) == 0 ? ThreadBoxSetDefault(box,i,0) : 0)
@@ -887,6 +933,10 @@
}
}
+#ifdef DEBUG_INST
+int dump_inst = 0;
+#endif
+
void
ThreadsRun (Value thread, Value lex)
{
@@ -958,8 +1008,11 @@
next = inst + 1;
complete = False;
#ifdef DEBUG_INST
- InstDump (inst, 1, 0, 0, 0);
- FileFlush (FileStdout, True);
+ if (dump_inst)
+ {
+ InstDump (inst, 1, 0, 0, 0);
+ FileFlush (FileStdout, True);
+ }
#endif
switch (inst->base.opCode) {
case OpNoop:
@@ -1300,6 +1353,11 @@
case OpCatch:
if (aborting)
break;
+#ifdef DEBUG_JUMP
+ FilePrintf (FileStdout, " Catch: %A ",
+ inst->catch.exception->symbol.name);
+ ThreadCatches (thread);
+#endif
thread->thread.continuation.catches = NewCatch (thread,
inst->catch.exception);
complete = True;
@@ -1308,7 +1366,7 @@
case OpEndCatch:
if (aborting)
break;
- thread->thread.continuation.catches = thread->thread.continuation.catches->continuation.catches;
+ ThreadEndCatch (thread, inst->ints.value);
complete = True;
break;
case OpRaise:
Index: gram.y
===================================================================
RCS file: /local/src/CVS/nickle/gram.y,v
retrieving revision 1.137
retrieving revision 1.138
diff -u -d -r1.137 -r1.138
--- gram.y 17 Jun 2004 20:46:09 -0000 1.137
+++ gram.y 7 Jul 2004 07:32:47 -0000 1.138
@@ -478,7 +478,7 @@
$$ = NewExprTree(FOR, expr, $7); }
| SWITCH ignorenl namespace_start OP expr CP case_block namespace_end attendnl
{ $$ = NewExprTree (SWITCH, $5, $7); }
- | UNION SWITCH ignorenl namespace_start OP expr CP union_case_block namespace_end attendnl
+ | union_or_enum SWITCH ignorenl namespace_start OP expr CP union_case_block namespace_end attendnl
{ $$ = NewExprTree (UNION, $6, $8); }
| BREAK SEMI
{ $$ = NewExprTree(BREAK, (Expr *) 0, (Expr *) 0); }
@@ -674,6 +674,9 @@
NewExprTree (OC, 0, 0));
}
;
+union_or_enum : UNION
+ | ENUM
+ ;
see_comment :
{ seeComment = 1; }
;
Index: sched.c
===================================================================
RCS file: /local/src/CVS/nickle/sched.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- sched.c 19 Jun 2004 19:56:45 -0000 1.56
+++ sched.c 7 Jul 2004 07:32:47 -0000 1.57
@@ -574,11 +574,19 @@
/*
* Unwind catches
*/
+#ifdef DEBUG_JUMP
+ FilePrintf (FileStdout, "FarJump catches before: ");
+ ThreadCatches (running);
+#endif
catches = farJump->catch;
catch = ret->continuation.catches;
while (catches--)
catch = catch->continuation.catches;
ret->continuation.catches = catch;
+#ifdef DEBUG_JUMP
+ FilePrintf (FileStdout, "FarJump catches after: ");
+ ThreadCatches (running);
+#endif
/*
* Unwind frames
@@ -686,8 +694,9 @@
}
#ifdef DEBUG_JUMP
+int dump_jump = 0;
-static void
+void
ContinuationTrace (char *where, Continuation *continuation, int indent)
{
int s;
@@ -697,6 +706,8 @@
ObjPtr obj = continuation->obj;
InstPtr pc = continuation->pc;
+ if (!dump_jump)
+ return;
TraceIndent (indent);
FilePuts (FileStdout, "*** ");
FilePuts (FileStdout, where);
Index: value.h
===================================================================
RCS file: /local/src/CVS/nickle/value.h,v
retrieving revision 1.106
retrieving revision 1.107
diff -u -d -r1.106 -r1.107
--- value.h 14 Jun 2004 06:43:33 -0000 1.106
+++ value.h 7 Jul 2004 07:32:47 -0000 1.107
@@ -793,7 +793,7 @@
#ifdef DEBUG_JUMP
void ContinuationTrace (char *where, Continuation *continuation, int indent);
-void ContinuationTrace (char *where, Value continuation);
+void ThreadCatches (Value thread);
#endif
/*
More information about the Commit
mailing list