From 8a4fea3af0ee49f5a7d0034cbe4c107f50a125b8 Mon Sep 17 00:00:00 2001 From: Edwin Smith Date: Tue, 4 Aug 2009 14:18:38 -0400 Subject: [PATCH] Bug 510078 - Convert LirNameMap to HashMap<> and Allocator, r=gal. * * * Don't allocate CodeAlloc with GC and dont extend GCFinalizedObject (bug 506390 r=tharwood+) * Change PageMgr::CodeAlloc from pointer to embedded instance. * Assembler takes CodeAlloc& now, like it already does for Allocator& * PoolObject.cpp|h now use VMCFG_NANOJIT instead of (deprecated) FEATURE_NANOJIT (both #defines are equivalent) --HG-- extra : rebase_source : 90847a654d7f669a4c2ac364dd9aae7be38cae77 --- js/src/jsregexp.cpp | 5 +---- js/src/jstracer.cpp | 11 +++-------- js/src/nanojit/Assembler.h | 2 +- js/src/nanojit/LIR.cpp | 1 - js/src/nanojit/LIR.h | 22 +++++++++++----------- 5 files changed, 16 insertions(+), 25 deletions(-) diff --git a/js/src/jsregexp.cpp b/js/src/jsregexp.cpp index 625102bc87ba..8b594a6027e0 100644 --- a/js/src/jsregexp.cpp +++ b/js/src/jsregexp.cpp @@ -3164,14 +3164,11 @@ class RegExpNativeCompiler { if (alloc.outOfMemory() || oom || js_OverfullFragmento(tm, fragmento)) { fragmento->clearFrags(); -#ifdef DEBUG - delete lirbuf->names; -#endif tm->reCodeAlloc->sweep(); alloc.reset(); #ifdef DEBUG fragmento->labels = new (alloc) LabelMap(alloc, &js_LogController); - lirbuf->names = new (&gc) LirNameMap(&gc, alloc, fragmento->labels); + lirbuf->names = new (alloc) LirNameMap(alloc, fragmento->labels); #endif lirbuf->clear(); } else { diff --git a/js/src/jstracer.cpp b/js/src/jstracer.cpp index 95d50921fe8e..9abab6485646 100644 --- a/js/src/jstracer.cpp +++ b/js/src/jstracer.cpp @@ -3364,10 +3364,6 @@ FlushJITCache(JSContext* cx) } } -#ifdef DEBUG - delete tm->lirbuf->names; -#endif - tm->allocator->reset(); tm->codeAlloc->sweep(); @@ -3376,7 +3372,7 @@ FlushJITCache(JSContext* cx) JS_ASSERT(fragmento->labels); Allocator& alloc = *tm->allocator; fragmento->labels = new (alloc) LabelMap(alloc, &js_LogController); - tm->lirbuf->names = new (&gc) LirNameMap(&gc, alloc, tm->fragmento->labels); + tm->lirbuf->names = new (alloc) LirNameMap(alloc, tm->fragmento->labels); #endif tm->lirbuf->clear(); @@ -6434,7 +6430,7 @@ js_InitJIT(JSTraceMonitor *tm) tm->fragmento = fragmento; tm->lirbuf = new (&gc) LirBuffer(alloc); #ifdef DEBUG - tm->lirbuf->names = new (&gc) LirNameMap(&gc, alloc, tm->fragmento->labels); + tm->lirbuf->names = new (alloc) LirNameMap(alloc, tm->fragmento->labels); #endif for (size_t i = 0; i < MONITOR_N_GLOBAL_STATES; ++i) { tm->globalStates[i].globalShape = -1; @@ -6463,7 +6459,7 @@ js_InitJIT(JSTraceMonitor *tm) tm->reFragmento = fragmento; tm->reLirBuf = new (&gc) LirBuffer(reAlloc); #ifdef DEBUG - tm->reLirBuf->names = new (&gc) LirNameMap(&gc, reAlloc, fragmento->labels); + tm->reLirBuf->names = new (reAlloc) LirNameMap(reAlloc, fragmento->labels); #endif } #if !defined XP_WIN @@ -6493,7 +6489,6 @@ js_FinishJIT(JSTraceMonitor *tm) if (tm->fragmento != NULL) { JS_ASSERT(tm->reservedDoublePool); #ifdef DEBUG - delete tm->lirbuf->names; tm->lirbuf->names = NULL; #endif delete tm->lirbuf; diff --git a/js/src/nanojit/Assembler.h b/js/src/nanojit/Assembler.h index 2c2d855d5fc7..5de394843274 100644 --- a/js/src/nanojit/Assembler.h +++ b/js/src/nanojit/Assembler.h @@ -239,7 +239,7 @@ namespace nanojit return r->used ? r : 0; } - Allocator &alloc; + Allocator& alloc; CodeAlloc& _codeAlloc; DWB(Fragment*) _thisfrag; RegAllocMap* _branchStateMap; diff --git a/js/src/nanojit/LIR.cpp b/js/src/nanojit/LIR.cpp index b41dca683a01..a756e59ffbf8 100644 --- a/js/src/nanojit/LIR.cpp +++ b/js/src/nanojit/LIR.cpp @@ -123,7 +123,6 @@ namespace nanojit LirBuffer::~LirBuffer() { clear(); - verbose_only(if (names) NJ_DELETE(names);) } void LirBuffer::clear() diff --git a/js/src/nanojit/LIR.h b/js/src/nanojit/LIR.h index 71774c31a4a5..7c6595ccbf35 100644 --- a/js/src/nanojit/LIR.h +++ b/js/src/nanojit/LIR.h @@ -882,14 +882,14 @@ namespace nanojit const char *format(const void *p); }; - class LirNameMap MMGC_SUBCLASS_DECL + class LirNameMap { Allocator& alloc; template - class CountMap: public avmplus::SortedMap { + class CountMap: public HashMap { public: - CountMap(GC*gc) : avmplus::SortedMap(gc) {} + CountMap(Allocator& alloc) : HashMap(alloc) {} int add(Key k) { int c = 1; if (containsKey(k)) { @@ -908,17 +908,17 @@ namespace nanojit Entry(char* n) : name(n) {} char* name; }; - avmplus::SortedMap names; + HashMap names; LabelMap *labels; void formatImm(int32_t c, char *buf); public: - LirNameMap(GC *gc, Allocator& alloc, LabelMap *r) + LirNameMap(Allocator& alloc, LabelMap *lm) : alloc(alloc), - lircounts(gc), - funccounts(gc), - names(gc), - labels(r) + lircounts(alloc), + funccounts(alloc), + names(alloc), + labels(lm) {} void addName(LInsp i, const char *s); @@ -932,7 +932,7 @@ namespace nanojit class VerboseWriter : public LirWriter { InsList code; - DWB(LirNameMap*) names; + LirNameMap* names; LogControl* logc; public: VerboseWriter(Allocator& alloc, LirWriter *out, @@ -1090,7 +1090,7 @@ namespace nanojit uintptr_t makeRoom(size_t szB); // make room for an instruction debug_only (void validate() const;) - verbose_only(DWB(LirNameMap*) names;) + verbose_only(LirNameMap* names;) int32_t insCount(); size_t byteCount();