From: andy Date: Mon, 22 Dec 2003 19:27:51 +0000 (+0000) Subject: Parse/GC interaction fixed. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=5aac63d9f5a305c44683b784eb0225edaa124d38;p=simgear.git Parse/GC interaction fixed. Remove the OP_NEWARGS "optimization" (it wasn't). --- diff --git a/simgear/nasal/code.c b/simgear/nasal/code.c index 9333c88f..3bd1e5ab 100644 --- a/simgear/nasal/code.c +++ b/simgear/nasal/code.c @@ -102,8 +102,6 @@ static void initContext(struct Context* c) for(i=0; ifStack[i].args = naNil(); - c->argPool = naNewVector(c); - // Note we can't use naNewVector() for this; it requires that // temps exist first. c->temps = naObj(T_VEC, naGC_get(&(c->pools[T_VEC]))); @@ -138,7 +136,6 @@ void naGarbageCollect() for(i=0; i < c->opTop; i++) naGC_mark(c->opStack[i]); - naGC_mark(c->argPool); naGC_mark(c->temps); naGC_mark(c->save); @@ -465,7 +462,6 @@ static void run1(struct Context* ctx, struct Frame* f, naRef code) ctx->opTop = f->bp; // restore the correct stack frame! ctx->fTop--; ctx->fStack[ctx->fTop].args.ref.ptr.vec->size = 0; - naVec_append(ctx->argPool, ctx->fStack[ctx->fTop].args); PUSH(ctx, a); break; case OP_LINE: @@ -483,10 +479,6 @@ static void run1(struct Context* ctx, struct Frame* f, naRef code) case OP_BREAK: // restore stack state (FOLLOW WITH JMP!) ctx->opTop = ctx->markStack[--ctx->markTop]; break; - case OP_NEWARGS: // push a new function arg vector - PUSH(ctx, (naVec_size(ctx->argPool) ? - naVec_removelast(ctx->argPool) : naNewVector(ctx))); - break; default: ERR(ctx, "BUG: bad opcode"); } diff --git a/simgear/nasal/code.h b/simgear/nasal/code.h index 89c07fe9..7e9c7653 100644 --- a/simgear/nasal/code.h +++ b/simgear/nasal/code.h @@ -16,7 +16,7 @@ enum { OP_PUSHCONST, OP_PUSHONE, OP_PUSHZERO, OP_PUSHNIL, OP_POP, OP_DUP, OP_XCHG, OP_INSERT, OP_EXTRACT, OP_MEMBER, OP_SETMEMBER, OP_LOCAL, OP_SETLOCAL, OP_NEWVEC, OP_VAPPEND, OP_NEWHASH, OP_HAPPEND, - OP_LINE, OP_MARK, OP_UNMARK, OP_BREAK, OP_NEWARGS + OP_LINE, OP_MARK, OP_UNMARK, OP_BREAK }; struct Frame { @@ -41,10 +41,6 @@ struct Context { int markTop; int done; - // Vector of arguments vectors. A LIFO cache, basically, to avoid - // thrashing the GC just for function call arguments. - naRef argPool; - // Constants naRef meRef; naRef argRef; diff --git a/simgear/nasal/codegen.c b/simgear/nasal/codegen.c index 2f2b6baa..e75f75f5 100644 --- a/simgear/nasal/codegen.c +++ b/simgear/nasal/codegen.c @@ -163,7 +163,7 @@ static void genFuncall(struct Parser* p, struct Token* t) } else { genExpr(p, LEFT(t)); } - emit(p, OP_NEWARGS); + emit(p, OP_NEWVEC); if(RIGHT(t)) genList(p, RIGHT(t)); emit(p, op); } diff --git a/simgear/nasal/parse.c b/simgear/nasal/parse.c index a17452c4..920d7342 100644 --- a/simgear/nasal/parse.c +++ b/simgear/nasal/parse.c @@ -489,6 +489,9 @@ naRef naParseCode(struct Context* c, naRef srcFile, int firstLine, struct Token* t; struct Parser p; + // Protect from garbage collection + naVec_append(c->temps, srcFile); + // Catch parser errors here. *errLine = 0; if(setjmp(p.jumpHandle)) { @@ -520,6 +523,7 @@ naRef naParseCode(struct Context* c, naRef srcFile, int firstLine, // Clean up our mess naParseDestroy(&p); + naVec_append(c->temps, codeObj); return codeObj; }