diff --git a/simgear/nasal/code.c b/simgear/nasal/code.c index 740b7058..faf534ec 100644 --- a/simgear/nasal/code.c +++ b/simgear/nasal/code.c @@ -24,21 +24,6 @@ struct Globals* globals = 0; static naRef bindFunction(naContext ctx, struct Frame* f, naRef code); -char __name[3000] = { 0 }; -int init = 0; -void getSource(struct Context* c) { - naRef v = naGetSourceFile(c, 0); - init = 1; - if (!IS_NIL(v)) - snprintf(__name, 3000, "%s:%d", naStr_data(v), naGetLine(c, 0)); - else - *__name = 0; -} -char *getName() { - if (init) - return __name; - return "**"; -} #define ERR(c, msg) naRuntimeError((c),(msg)) void naRuntimeError(naContext c, const char* fmt, ...) { @@ -320,7 +305,6 @@ static void checkNamedArgs(naContext ctx, struct naCode* c, struct naHash* h) static struct Frame* setupFuncall(naContext ctx, int nargs, int mcall, int named) { - getSource(ctx); naRef *args, func, code, obj = naNil(); struct Frame* f; int opf = ctx->opTop - nargs; @@ -849,13 +833,9 @@ naRef naGetSourceFile(naContext ctx, int frame) { naRef f; frame = findFrame(ctx, &ctx, frame); - if (frame >= 0) { - f = ctx->fStack[frame].func; - f = PTR(f).func->code; - if (!IS_NIL(f) && PTR(f).code) - return PTR(f).code->srcFile; - } - return naNil(); + f = ctx->fStack[frame].func; + f = PTR(f).func->code; + return PTR(f).code->srcFile; } char* naGetError(naContext ctx) diff --git a/simgear/nasal/gc.c b/simgear/nasal/gc.c index 7c0a9183..5ac9c43c 100644 --- a/simgear/nasal/gc.c +++ b/simgear/nasal/gc.c @@ -1,6 +1,7 @@ #include "nasal.h" #include "data.h" #include "code.h" + #define MIN_BLOCK_SIZE 32 static void reap(struct naPool* p); @@ -11,17 +12,14 @@ struct Block { char* block; struct Block* next; }; + // Must be called with the giant exclusive lock! -extern void global_stamp(); -extern int global_elapsedUSec(); -extern char *getName(); static void freeDead() { int i; for(i=0; indead; i++) naFree(globals->deadBlocks[i]); globals->ndead = 0; - printf("--> freedead (%d) : %d", i, global_elapsedUSec()); } static void marktemps(struct Context* c) @@ -54,7 +52,6 @@ static void garbageCollect() marktemps(c); c = c->nextAll; } - printf("--> garbageCollect: %d ", global_elapsedUSec()); mark(globals->save); mark(globals->save_hash); @@ -63,13 +60,10 @@ static void garbageCollect() mark(globals->argRef); mark(globals->parentsRef); - printf("m> %d", global_elapsedUSec()); - // Finally collect all the freed objects - for (i = 0; i < NUM_NASAL_TYPES; i++) { + for(i=0; ipools[i])); - printf(" p(%d)> %d", i, global_elapsedUSec()); - } + // Make enough space for the dead blocks we need to free during // execution. This works out to 1 spot for every 2 live objects, // which should be limit the number of bottleneck operations @@ -81,7 +75,6 @@ static void garbageCollect() globals->deadBlocks = naAlloc(sizeof(void*) * globals->deadsz); } globals->needGC = 0; - printf(">> %d ", global_elapsedUSec()); } void naModLock() @@ -111,7 +104,6 @@ void naModUnlock() // you think about it). static void bottleneck() { - global_stamp(); struct Globals* g = globals; g->bottleneck = 1; while(g->bottleneck && g->waitCount < g->nThreads - 1) { @@ -119,16 +111,12 @@ static void bottleneck() UNLOCK(); naSemDown(g->sem); LOCK(); g->waitCount--; } - printf("bottleneck wait finished %d usec", global_elapsedUSec()); if(g->waitCount >= g->nThreads - 1) { freeDead(); - //if(g->needGC) - garbageCollect(); + if(g->needGC) garbageCollect(); if(g->waitCount) naSemUp(g->sem, g->waitCount); g->bottleneck = 0; } - char *c = getName(); - printf("bottleneck finished: %d %s\n", global_elapsedUSec(), c); } void naGC() diff --git a/simgear/nasal/misc.c b/simgear/nasal/misc.c index 764d113d..0a5c8615 100644 --- a/simgear/nasal/misc.c +++ b/simgear/nasal/misc.c @@ -65,7 +65,6 @@ naRef naStringValue(naContext c, naRef r) naRef naNew(struct Context* c, int type) { - getSource(c); naRef result; if(c->nfree[type] == 0) c->free[type] = naGC_get(&globals->pools[type], diff --git a/simgear/timing/timestamp.cxx b/simgear/timing/timestamp.cxx index d9a2ef04..fcb56836 100644 --- a/simgear/timing/timestamp.cxx +++ b/simgear/timing/timestamp.cxx @@ -345,13 +345,3 @@ int SGTimeStamp::elapsedUSec() const return static_cast((now - *this).toUSecs()); } -extern "C" { - SGTimeStamp global_timestamp; - void global_stamp() { - global_timestamp.stamp(); - } - extern int global_elapsedUSec() - { - return global_timestamp.elapsedUSec(); - } - } \ No newline at end of file