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
This commit is contained in:
Edwin Smith 2009-08-04 14:18:38 -04:00
Родитель ffdcbd766e
Коммит 8a4fea3af0
5 изменённых файлов: 16 добавлений и 25 удалений

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

@ -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 {

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

@ -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;

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

@ -239,7 +239,7 @@ namespace nanojit
return r->used ? r : 0;
}
Allocator &alloc;
Allocator& alloc;
CodeAlloc& _codeAlloc;
DWB(Fragment*) _thisfrag;
RegAllocMap* _branchStateMap;

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

@ -123,7 +123,6 @@ namespace nanojit
LirBuffer::~LirBuffer()
{
clear();
verbose_only(if (names) NJ_DELETE(names);)
}
void LirBuffer::clear()

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

@ -882,14 +882,14 @@ namespace nanojit
const char *format(const void *p);
};
class LirNameMap MMGC_SUBCLASS_DECL
class LirNameMap
{
Allocator& alloc;
template <class Key>
class CountMap: public avmplus::SortedMap<Key, int, avmplus::LIST_NonGCObjects> {
class CountMap: public HashMap<Key, int> {
public:
CountMap(GC*gc) : avmplus::SortedMap<Key, int, avmplus::LIST_NonGCObjects>(gc) {}
CountMap(Allocator& alloc) : HashMap<Key, int>(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<LInsp, Entry*, avmplus::LIST_NonGCObjects> names;
HashMap<LInsp, Entry*> 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();