Use a single lirbuf for the tracer and rewind lirbuf during GC (471821, r=danderson).

This commit is contained in:
Andreas Gal 2009-01-02 10:55:02 -08:00
parent 3256fd407d
commit d8159286c8
5 changed files with 24 additions and 22 deletions

View File

@ -122,6 +122,7 @@ typedef struct JSTraceMonitor {
* JS_ReportOutOfMemory when failing due to runtime limits.
*/
JSBool onTrace;
CLS(nanojit::LirBuffer) lirbuf;
CLS(nanojit::Fragmento) fragmento;
CLS(TraceRecorder) recorder;
uint32 globalShape;

View File

@ -2364,6 +2364,7 @@ class RegExpNativeCompiler {
fail:
if (lirbuf->outOMem() || oom) {
fragmento->clearFrags();
lirbuf->rewind();
} else {
if (!guard) insertGuard(re_chars, re_length);
fragment->blacklist();

View File

@ -2699,9 +2699,6 @@ nanojit::LirNameMap::formatGuard(LIns *i, char *out)
void
nanojit::Fragment::onDestroy()
{
if (root == this && lirbuf && !lirbuf->shared) {
delete lirbuf;
}
delete (TreeInfo *)vmprivate;
}
@ -3011,13 +3008,7 @@ js_RecordTree(JSContext* cx, JSTraceMonitor* tm, Fragment* f, Fragment* outer, u
f->recordAttempts++;
f->root = f;
/* allocate space to store the LIR for this tree */
if (!f->lirbuf) {
f->lirbuf = new (&gc) LirBuffer(tm->fragmento, NULL);
#ifdef DEBUG
f->lirbuf->names = new (&gc) LirNameMap(&gc, NULL, tm->fragmento->labels);
#endif
}
f->lirbuf = tm->lirbuf;
if (f->lirbuf->outOMem()) {
js_FlushJITCache(cx);
@ -4026,6 +4017,10 @@ js_InitJIT(JSTraceMonitor *tm)
Fragmento* fragmento = new (&gc) Fragmento(core, 24);
verbose_only(fragmento->labels = new (&gc) LabelMap(core, NULL);)
tm->fragmento = fragmento;
tm->lirbuf = new (&gc) LirBuffer(fragmento, NULL);
#ifdef DEBUG
tm->lirbuf->names = new (&gc) LirNameMap(&gc, NULL, tm->fragmento->labels);
#endif
tm->globalSlots = new (&gc) SlotList();
tm->globalTypeMap = new (&gc) TypeMap();
tm->recoveryDoublePoolPtr = tm->recoveryDoublePool = new jsval[MAX_NATIVE_STACK_SLOTS];
@ -4035,7 +4030,6 @@ js_InitJIT(JSTraceMonitor *tm)
verbose_only(fragmento->labels = new (&gc) LabelMap(core, NULL);)
tm->reFragmento = fragmento;
tm->reLirBuf = new (&gc) LirBuffer(fragmento, NULL);
tm->reLirBuf->shared = true;
}
InitIMacroCode();
#if !defined XP_WIN
@ -4063,6 +4057,12 @@ js_FinishJIT(JSTraceMonitor *tm)
if (tm->fragmento != NULL) {
JS_ASSERT(tm->globalSlots && tm->globalTypeMap && tm->recoveryDoublePool);
verbose_only(delete tm->fragmento->labels;)
#ifdef DEBUG
delete tm->lirbuf->names;
tm->lirbuf->names = NULL;
#endif
delete tm->lirbuf;
tm->lirbuf = NULL;
delete tm->fragmento;
tm->fragmento = NULL;
delete tm->globalSlots;
@ -4132,6 +4132,7 @@ js_FlushJITCache(JSContext* cx)
delete fragmento->labels;
fragmento->labels = new (&gc) LabelMap(core, NULL);
#endif
tm->lirbuf->rewind();
}
if (cx->fp) {
tm->globalShape = OBJ_SHAPE(JS_GetGlobalForObject(cx, cx->fp->scopeChain));

View File

@ -88,20 +88,13 @@ namespace nanojit
// LCompressedBuffer
LirBuffer::LirBuffer(Fragmento* frago, const CallInfo* functions)
: _frago(frago), _pages(frago->core()->GetGC()), _functions(functions), abi(ABI_FASTCALL), shared(false)
: _frago(frago), _pages(frago->core()->GetGC()), _functions(functions), abi(ABI_FASTCALL)
{
clear();
Page* start = pageAlloc();
if (start)
_unused = &start->lir[0];
//buffer_count++;
//fprintf(stderr, "LirBuffer %x unused %x\n", (int)this, (int)_unused);
rewind();
}
LirBuffer::~LirBuffer()
{
//buffer_count--;
//fprintf(stderr, "~LirBuffer %x start %x\n", (int)this, (int)_start);
clear();
verbose_only(if (names) NJ_DELETE(names);)
_frago = 0;
@ -123,6 +116,13 @@ namespace nanojit
NanoAssert(_nextPage || _noMem);
}
void LirBuffer::rewind()
{
clear();
Page* start = pageAlloc();
_unused = start ? &start->lir[0] : NULL;
}
int32_t LirBuffer::insCount()
{
// doesn't include embedded constants nor LIR_skip payload

View File

@ -693,6 +693,7 @@ namespace nanojit
LirBuffer(Fragmento* frago, const CallInfo* functions);
virtual ~LirBuffer();
void clear();
void rewind();
LInsp next();
bool outOMem() { return _noMem != 0; }
@ -714,8 +715,6 @@ namespace nanojit
LInsp state,param1,sp,rp;
LInsp savedRegs[NumSavedRegs];
bool explicitSavedRegs;
bool shared;
protected:
friend class LirBufWriter;