Reset: Nasal additions to force GC, clear saved refs.
This commit is contained in:
@@ -765,6 +765,14 @@ void naSave(naContext ctx, naRef obj)
|
|||||||
naVec_append(globals->save, obj);
|
naVec_append(globals->save, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void naClearSaved()
|
||||||
|
{
|
||||||
|
naContext c;
|
||||||
|
c = naNewContext();
|
||||||
|
globals->save = naNewVector(c);
|
||||||
|
naFreeContext(c);
|
||||||
|
}
|
||||||
|
|
||||||
int naStackDepth(naContext ctx)
|
int naStackDepth(naContext ctx)
|
||||||
{
|
{
|
||||||
return ctx ? ctx->fTop + naStackDepth(ctx->callChild): 0;
|
return ctx ? ctx->fTop + naStackDepth(ctx->callChild): 0;
|
||||||
|
|||||||
@@ -118,6 +118,15 @@ static void bottleneck()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void naGC()
|
||||||
|
{
|
||||||
|
LOCK();
|
||||||
|
globals->needGC = 1;
|
||||||
|
bottleneck();
|
||||||
|
UNLOCK();
|
||||||
|
naCheckBottleneck();
|
||||||
|
}
|
||||||
|
|
||||||
void naCheckBottleneck()
|
void naCheckBottleneck()
|
||||||
{
|
{
|
||||||
if(globals->bottleneck) { LOCK(); bottleneck(); UNLOCK(); }
|
if(globals->bottleneck) { LOCK(); bottleneck(); UNLOCK(); }
|
||||||
|
|||||||
@@ -42,10 +42,16 @@ naContext naSubContext(naContext super);
|
|||||||
void naSetUserData(naContext c, void* p);
|
void naSetUserData(naContext c, void* p);
|
||||||
void* naGetUserData(naContext c) GCC_PURE;
|
void* naGetUserData(naContext c) GCC_PURE;
|
||||||
|
|
||||||
|
// run GC now (may block)
|
||||||
|
void naGC();
|
||||||
|
|
||||||
// "Save" this object in the context, preventing it (and objects
|
// "Save" this object in the context, preventing it (and objects
|
||||||
// referenced by it) from being garbage collected.
|
// referenced by it) from being garbage collected.
|
||||||
void naSave(naContext ctx, naRef obj);
|
void naSave(naContext ctx, naRef obj);
|
||||||
|
|
||||||
|
// Drop all saved references
|
||||||
|
void naClearSaved();
|
||||||
|
|
||||||
// Similar, but the object is automatically released when the
|
// Similar, but the object is automatically released when the
|
||||||
// context next runs native bytecode. Useful for saving off C-space
|
// context next runs native bytecode. Useful for saving off C-space
|
||||||
// temporaries to protect them before passing back into a naCall.
|
// temporaries to protect them before passing back into a naCall.
|
||||||
|
|||||||
Reference in New Issue
Block a user