Bug 510545 - Convert LInsHashSet to use Allocator instead of GC, r=gal.

--HG--
extra : rebase_source : 233cf623b49f030ca083ba250294e00b61afdac5
This commit is contained in:
Edwin Smith 2009-08-06 09:41:07 -04:00
parent 8c08ec6bc0
commit c06be23043
3 changed files with 24 additions and 33 deletions

View File

@ -1746,7 +1746,7 @@ TraceRecorder::TraceRecorder(JSContext* cx, VMSideExit* _anchor, Fragment* _frag
lir = float_filter = new (&gc) SoftFloatFilter(lir);
else
float_filter = 0;
lir = cse_filter = new (&gc) CseFilter(lir, &gc);
lir = cse_filter = new (&gc) CseFilter(lir, *traceMonitor->allocator);
lir = expr_filter = new (&gc) ExprFilter(lir);
lir = func_filter = new (&gc) FuncFilter(lir);
lir->ins0(LIR_start);

View File

@ -109,8 +109,7 @@ namespace nanojit
#endif /* NJ_PROFILE */
// LCompressedBuffer
LirBuffer::LirBuffer(Allocator& alloc)
:
LirBuffer::LirBuffer(Allocator& alloc) :
#ifdef NJ_VERBOSE
names(NULL),
#endif
@ -1110,19 +1109,11 @@ namespace nanojit
return hash;
}
LInsHashSet::LInsHashSet(GC* gc) :
m_used(0), m_cap(kInitialCap), m_gc(gc)
LInsHashSet::LInsHashSet(Allocator& alloc) :
m_cap(kInitialCap), alloc(alloc)
{
#ifdef MEMORY_INFO
// m_list.set_meminfo_name("LInsHashSet.list");
#endif
LInsp *list = (LInsp*) gc->Alloc(sizeof(LInsp)*m_cap, GC::kZero);
WB(gc, this, &m_list, list);
}
LInsHashSet::~LInsHashSet()
{
m_gc->Free(m_list);
m_list = new (alloc) LInsp[m_cap];
clear();
}
void LInsHashSet::clear() {
@ -1230,11 +1221,9 @@ namespace nanojit
void FASTCALL LInsHashSet::grow()
{
const uint32_t newcap = m_cap << 1;
LInsp *newlist = (LInsp*) m_gc->Alloc(newcap * sizeof(LInsp), GC::kZero);
LInsp *newlist = new (alloc) LInsp[newcap];
VMPI_memset(newlist, 0, newcap * sizeof(LInsp));
LInsp *list = m_list;
#ifdef MEMORY_INFO
// newlist.set_meminfo_name("LInsHashSet.list");
#endif
for (uint32_t i=0, n=m_cap; i < n; i++) {
LInsp name = list[i];
if (!name) continue;
@ -1242,8 +1231,7 @@ namespace nanojit
newlist[j] = name;
}
m_cap = newcap;
m_gc->Free(list);
WB(m_gc, this, &m_list, newlist);
m_list = newlist;
}
uint32_t FASTCALL LInsHashSet::find(LInsp name, uint32_t hash, const LInsp *list, uint32_t cap)
@ -1863,8 +1851,8 @@ namespace nanojit
#endif
CseFilter::CseFilter(LirWriter *out, GC *gc)
: LirWriter(out), exprs(gc) {}
CseFilter::CseFilter(LirWriter *out, Allocator& alloc)
: LirWriter(out), exprs(alloc) {}
LIns* CseFilter::insImm(int32_t imm)
{
@ -2133,7 +2121,7 @@ namespace nanojit
#endif /* FEATURE_NANOJIT */
#if defined(NJ_VERBOSE)
LabelMap::LabelMap(nanojit::Allocator& a, LogControl *logc)
LabelMap::LabelMap(Allocator& a, LogControl *logc)
: allocator(a), names(a), logc(logc), end(buf)
{}

View File

@ -1036,7 +1036,7 @@ namespace nanojit
LInsp *m_list;
uint32_t m_used, m_cap;
GC* m_gc;
Allocator& alloc;
static uint32_t FASTCALL hashcode(LInsp i);
uint32_t FASTCALL find(LInsp name, uint32_t hash, const LInsp *list, uint32_t cap);
@ -1044,8 +1044,8 @@ namespace nanojit
void FASTCALL grow();
public:
LInsHashSet(GC* gc);
~LInsHashSet();
LInsHashSet(Allocator&);
LInsp find32(int32_t a, uint32_t &i);
LInsp find64(uint64_t a, uint32_t &i);
LInsp find1(LOpcode v, LInsp a, uint32_t &i);
@ -1069,7 +1069,7 @@ namespace nanojit
{
public:
LInsHashSet exprs;
CseFilter(LirWriter *out, GC *gc);
CseFilter(LirWriter *out, Allocator&);
LIns* insImm(int32_t imm);
LIns* insImmq(uint64_t q);
LIns* ins0(LOpcode v);
@ -1084,7 +1084,7 @@ namespace nanojit
class LirBuffer
{
public:
LirBuffer(Allocator&);
LirBuffer(Allocator& alloc);
void clear();
uintptr_t makeRoom(size_t szB); // make room for an instruction
@ -1144,7 +1144,7 @@ namespace nanojit
}
// LirWriter interface
LInsp insLoad(LOpcode op, LInsp base, int32_t disp);
LInsp insLoad(LOpcode op, LInsp base, int32_t disp);
LInsp insStorei(LInsp o1, LInsp o2, int32_t disp);
LInsp ins0(LOpcode op);
LInsp ins1(LOpcode op, LInsp o1);
@ -1181,7 +1181,9 @@ namespace nanojit
LInsp _i; // current instruction that this decoder is operating on.
public:
LirReader(LInsp i) : LirFilter(0), _i(i) { }
LirReader(LInsp i) : LirFilter(0), _i(i) {
NanoAssert(_i);
}
virtual ~LirReader() {}
// LirReader i/f
@ -1220,8 +1222,9 @@ namespace nanojit
void clear(LInsp p);
public:
LoadFilter(LirWriter *out, GC *gc)
: LirWriter(out), exprs(gc) { }
LoadFilter(LirWriter *out, Allocator& alloc)
: LirWriter(out), sp(NULL), rp(NULL), exprs(alloc)
{ }
LInsp ins0(LOpcode);
LInsp insLoad(LOpcode, LInsp base, int32_t disp);