Bug 517083 - Fix performance regression, r=dvander.

--HG--
extra : rebase_source : 57e132434da8c652c41ffa889aa2002eeeb4698c
This commit is contained in:
Graydon Hoare 2009-09-23 15:12:58 -07:00
Родитель 1008018047
Коммит 01fc78dda8
4 изменённых файлов: 35 добавлений и 6 удалений

10
js/src/jscntxt.h Normal file → Executable file
Просмотреть файл

@ -155,8 +155,9 @@ struct JSTraceMonitor {
*/
JSContext *tracecx;
CLS(VMAllocator) dataAlloc; // A chunk allocator for LIR.
CLS(nanojit::CodeAlloc) codeAlloc; // A general allocator for native code.
CLS(VMAllocator) dataAlloc; /* A chunk allocator for LIR. */
CLS(VMAllocator) tempAlloc; /* A temporary chunk allocator. */
CLS(nanojit::CodeAlloc) codeAlloc; /* An allocator for native code. */
CLS(nanojit::Assembler) assembler;
CLS(nanojit::LirBuffer) lirbuf;
CLS(nanojit::LirBuffer) reLirBuf;
@ -197,6 +198,11 @@ struct JSTraceMonitor {
*/
CLS(REHashMap) reFragments;
/*
* A temporary allocator for RE recording.
*/
CLS(VMAllocator) reTempAlloc;
/* Keep a list of recorders we need to abort on cache flush. */
CLS(TraceRecorder) abortStack;

Просмотреть файл

@ -2270,7 +2270,7 @@ enumerateNextChars(JSContext *cx, RENode *node, CharSet &set)
class RegExpNativeCompiler {
private:
VMAllocator tempAlloc;
VMAllocator& tempAlloc;
JSContext* cx;
JSRegExp* re;
CompilerState* cs; /* RegExp to compile */
@ -3103,7 +3103,13 @@ class RegExpNativeCompiler {
public:
RegExpNativeCompiler(JSContext* cx, JSRegExp* re, CompilerState* cs, Fragment* fragment)
: cx(cx), re(re), cs(cs), fragment(fragment), lir(NULL), lirBufWriter(NULL) { }
: tempAlloc(*JS_TRACE_MONITOR(cx).reTempAlloc), cx(cx),
re(re), cs(cs), fragment(fragment), lir(NULL), lirBufWriter(NULL) { }
~RegExpNativeCompiler() {
/* Purge the tempAlloc used during recording. */
tempAlloc.reset();
}
JSBool compile()
{

19
js/src/jstracer.cpp Normal file → Executable file
Просмотреть файл

@ -2140,7 +2140,8 @@ JS_REQUIRES_STACK
TraceRecorder::TraceRecorder(JSContext* cx, VMSideExit* _anchor, Fragment* _fragment,
TreeInfo* ti, unsigned stackSlots, unsigned ngslots, JSTraceType* typeMap,
VMSideExit* innermostNestedGuard, jsbytecode* outer, uint32 outerArgc)
: whichTreesToTrash(&tempAlloc),
: tempAlloc(*JS_TRACE_MONITOR(cx).tempAlloc),
whichTreesToTrash(&tempAlloc),
cfgMerges(&tempAlloc)
{
JS_ASSERT(!_fragment->vmprivate && ti && cx->fp->regs->pc == (jsbytecode*)_fragment->ip);
@ -2292,6 +2293,10 @@ TraceRecorder::~TraceRecorder()
for (unsigned int i = 0; i < whichTreesToTrash.length(); i++)
TrashTree(cx, whichTreesToTrash[i]);
}
/* Purge the tempAlloc used during recording. */
tempAlloc.reset();
#ifdef DEBUG
debug_only_stmt( delete verbose_filter; )
delete sanity_filter_1;
@ -7199,6 +7204,8 @@ js_InitJIT(JSTraceMonitor *tm)
JS_ASSERT(!tm->dataAlloc && !tm->codeAlloc);
tm->dataAlloc = new VMAllocator();
tm->tempAlloc = new VMAllocator();
tm->reTempAlloc = new VMAllocator();
tm->codeAlloc = new CodeAlloc();
tm->flush();
verbose_only( tm->branches = NULL; )
@ -7316,6 +7323,16 @@ js_FinishJIT(JSTraceMonitor *tm)
delete tm->dataAlloc;
tm->dataAlloc = NULL;
}
if (tm->tempAlloc) {
delete tm->tempAlloc;
tm->tempAlloc = NULL;
}
if (tm->reTempAlloc) {
delete tm->reTempAlloc;
tm->reTempAlloc = NULL;
}
}
void

Просмотреть файл

@ -691,7 +691,7 @@ enum TypeConsensus
};
class TraceRecorder {
VMAllocator tempAlloc;
VMAllocator& tempAlloc;
JSContext* cx;
JSTraceMonitor* traceMonitor;
JSObject* globalObj;