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

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

@ -2270,7 +2270,7 @@ enumerateNextChars(JSContext *cx, RENode *node, CharSet &set)
class RegExpNativeCompiler { class RegExpNativeCompiler {
private: private:
VMAllocator tempAlloc; VMAllocator& tempAlloc;
JSContext* cx; JSContext* cx;
JSRegExp* re; JSRegExp* re;
CompilerState* cs; /* RegExp to compile */ CompilerState* cs; /* RegExp to compile */
@ -3103,7 +3103,13 @@ class RegExpNativeCompiler {
public: public:
RegExpNativeCompiler(JSContext* cx, JSRegExp* re, CompilerState* cs, Fragment* fragment) 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() 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, TraceRecorder::TraceRecorder(JSContext* cx, VMSideExit* _anchor, Fragment* _fragment,
TreeInfo* ti, unsigned stackSlots, unsigned ngslots, JSTraceType* typeMap, TreeInfo* ti, unsigned stackSlots, unsigned ngslots, JSTraceType* typeMap,
VMSideExit* innermostNestedGuard, jsbytecode* outer, uint32 outerArgc) VMSideExit* innermostNestedGuard, jsbytecode* outer, uint32 outerArgc)
: whichTreesToTrash(&tempAlloc), : tempAlloc(*JS_TRACE_MONITOR(cx).tempAlloc),
whichTreesToTrash(&tempAlloc),
cfgMerges(&tempAlloc) cfgMerges(&tempAlloc)
{ {
JS_ASSERT(!_fragment->vmprivate && ti && cx->fp->regs->pc == (jsbytecode*)_fragment->ip); 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++) for (unsigned int i = 0; i < whichTreesToTrash.length(); i++)
TrashTree(cx, whichTreesToTrash[i]); TrashTree(cx, whichTreesToTrash[i]);
} }
/* Purge the tempAlloc used during recording. */
tempAlloc.reset();
#ifdef DEBUG #ifdef DEBUG
debug_only_stmt( delete verbose_filter; ) debug_only_stmt( delete verbose_filter; )
delete sanity_filter_1; delete sanity_filter_1;
@ -7199,6 +7204,8 @@ js_InitJIT(JSTraceMonitor *tm)
JS_ASSERT(!tm->dataAlloc && !tm->codeAlloc); JS_ASSERT(!tm->dataAlloc && !tm->codeAlloc);
tm->dataAlloc = new VMAllocator(); tm->dataAlloc = new VMAllocator();
tm->tempAlloc = new VMAllocator();
tm->reTempAlloc = new VMAllocator();
tm->codeAlloc = new CodeAlloc(); tm->codeAlloc = new CodeAlloc();
tm->flush(); tm->flush();
verbose_only( tm->branches = NULL; ) verbose_only( tm->branches = NULL; )
@ -7316,6 +7323,16 @@ js_FinishJIT(JSTraceMonitor *tm)
delete tm->dataAlloc; delete tm->dataAlloc;
tm->dataAlloc = NULL; tm->dataAlloc = NULL;
} }
if (tm->tempAlloc) {
delete tm->tempAlloc;
tm->tempAlloc = NULL;
}
if (tm->reTempAlloc) {
delete tm->reTempAlloc;
tm->reTempAlloc = NULL;
}
} }
void void

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

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