Revert GC instrumentation committed by mistake as part of "SGTimeStamp elapsedUSec"

This reverts commit 0b114ac5cd, reversing
changes made to 39eb9837e9.
This commit is contained in:
Richard Harrison
2019-05-27 18:48:48 +02:00
parent 5486ca3b4a
commit 9ac3c1a394
4 changed files with 8 additions and 51 deletions

View File

@@ -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)

View File

@@ -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; i<globals->ndead; 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; i<NUM_NASAL_TYPES; i++)
reap(&(globals->pools[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()

View File

@@ -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],

View File

@@ -345,13 +345,3 @@ int SGTimeStamp::elapsedUSec() const
return static_cast<int>((now - *this).toUSecs());
}
extern "C" {
SGTimeStamp global_timestamp;
void global_stamp() {
global_timestamp.stamp();
}
extern int global_elapsedUSec()
{
return global_timestamp.elapsedUSec();
}
}