Bug 471602 part 1: make regexp compiler use one shared LIR buffer, r=gal

This commit is contained in:
David Mandelin 2008-12-31 16:41:33 -08:00
parent 67cd92d2ce
commit 90baccb99f
5 changed files with 11 additions and 4 deletions

View File

@ -97,6 +97,7 @@ typedef struct JSGSNCache {
namespace nanojit {
class Fragment;
class Fragmento;
class LirBuffer;
}
class TraceRecorder;
extern "C++" { template<typename T> class Queue; }
@ -132,6 +133,7 @@ typedef struct JSTraceMonitor {
/* Fragmento for the regular expression compiler. This is logically
* a distinct compiler but needs to be managed in exactly the same
* way as the real tracing Fragmento. */
CLS(nanojit::LirBuffer) reLirBuf;
CLS(nanojit::Fragmento) reFragmento;
/* Keep a list of recorders we need to abort on cache flush. */

View File

@ -2053,6 +2053,7 @@ class RegExpNativeCompiler {
JSRegExp* re;
CompilerState* cs; /* RegExp to compile */
Fragment* fragment;
LirBuffer* lirbuf;
LirWriter* lir;
LirBufWriter* lirBufWriter; /* for skip */
@ -2424,8 +2425,7 @@ GetNativeRegExp(JSContext* cx, JSRegExp* re)
return NULL;
} else {
fragment = fragmento->getAnchor(hash);
fragment->lirbuf = new (&gc) LirBuffer(fragmento, NULL);
/* required to have the onDestroy method delete the lirbuf. */
fragment->lirbuf = JS_TRACE_MONITOR(cx).reLirBuf;
fragment->root = fragment;
}

View File

@ -2699,7 +2699,7 @@ nanojit::LirNameMap::formatGuard(LIns *i, char *out)
void
nanojit::Fragment::onDestroy()
{
if (root == this) {
if (root == this && lirbuf && !lirbuf->shared) {
delete lirbuf;
}
delete (TreeInfo *)vmprivate;
@ -4034,6 +4034,8 @@ js_InitJIT(JSTraceMonitor *tm)
Fragmento* fragmento = new (&gc) Fragmento(core, 20);
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
@ -4071,6 +4073,7 @@ js_FinishJIT(JSTraceMonitor *tm)
tm->recoveryDoublePool = tm->recoveryDoublePoolPtr = NULL;
}
if (tm->reFragmento != NULL) {
delete tm->reLirBuf;
verbose_only(delete tm->reFragmento->labels;)
delete tm->reFragmento;
}

View File

@ -88,7 +88,7 @@ namespace nanojit
// LCompressedBuffer
LirBuffer::LirBuffer(Fragmento* frago, const CallInfo* functions)
: _frago(frago), _pages(frago->core()->GetGC()), _functions(functions), abi(ABI_FASTCALL)
: _frago(frago), _pages(frago->core()->GetGC()), _functions(functions), abi(ABI_FASTCALL), shared(false)
{
clear();
Page* start = pageAlloc();

View File

@ -714,6 +714,8 @@ namespace nanojit
LInsp state,param1,sp,rp;
LInsp savedRegs[NumSavedRegs];
bool explicitSavedRegs;
bool shared;
protected:
friend class LirBufWriter;