Bug 468484 - Minor adjustments to match changes in tamarin, r=gal.

This commit is contained in:
Graydon Hoare 2008-12-10 17:25:46 -08:00
parent 37cfe58e72
commit ba3dc13800
10 changed files with 49 additions and 45 deletions

View File

@ -145,7 +145,7 @@ namespace nanojit
*/ */
Assembler::Assembler(Fragmento* frago) Assembler::Assembler(Fragmento* frago)
: hasLoop(0) : hasLoop(0)
, _frago(frago) , _frago(frago)
, _gc(frago->core()->gc) , _gc(frago->core()->gc)
, _labels(_gc) , _labels(_gc)
, _patches(_gc) , _patches(_gc)
@ -257,12 +257,12 @@ namespace nanojit
setError(ResvFull); setError(ResvFull);
item = 1; item = 1;
} }
Reservation *r = &_resvTable[item]; Reservation *r = &_resvTable[item];
_resvFree = r->arIndex; _resvFree = r->arIndex;
r->reg = UnknownReg; r->reg = UnknownReg;
r->arIndex = 0; r->arIndex = 0;
r->used = 1; r->used = 1;
i->setresv(item); i->setresv(item);
return r; return r;
} }
@ -925,7 +925,7 @@ namespace nanojit
NanoAssertMsgf(error() || _fpuStkDepth == 0,"_fpuStkDepth %d",_fpuStkDepth); NanoAssertMsgf(error() || _fpuStkDepth == 0,"_fpuStkDepth %d",_fpuStkDepth);
internalReset(); // clear the reservation tables and regalloc internalReset(); // clear the reservation tables and regalloc
NanoAssert(!_branchStateMap || _branchStateMap->isEmpty()); NanoAssert( !_branchStateMap || _branchStateMap->isEmpty());
_branchStateMap = 0; _branchStateMap = 0;
#ifdef AVMPLUS_ARM #ifdef AVMPLUS_ARM
@ -1319,7 +1319,6 @@ namespace nanojit
NanoAssert(label->addr == 0 && label->regs.isValid()); NanoAssert(label->addr == 0 && label->regs.isValid());
//evictRegs(~_allocator.free); //evictRegs(~_allocator.free);
intersectRegisterState(label->regs); intersectRegisterState(label->regs);
//asm_align_code();
label->addr = _nIns; label->addr = _nIns;
} }
verbose_only( if (_verbose) { outputAddr=true; asm_output("[%s]", _thisfrag->lirbuf->names->formatRef(ins)); } ) verbose_only( if (_verbose) { outputAddr=true; asm_output("[%s]", _thisfrag->lirbuf->names->formatRef(ins)); } )

View File

@ -331,7 +331,6 @@ namespace nanojit
}; };
// platform specific implementation (see NativeXXX.cpp file) // platform specific implementation (see NativeXXX.cpp file)
void nInit(uint32_t flags);
void nInit(AvmCore *); void nInit(AvmCore *);
Register nRegisterAllocFromSet(int32_t set); Register nRegisterAllocFromSet(int32_t set);
void nRegisterResetAll(RegAlloc& a); void nRegisterResetAll(RegAlloc& a);

View File

@ -95,7 +95,7 @@ namespace nanojit
if (start) if (start)
_unused = &start->lir[0]; _unused = &start->lir[0];
//buffer_count++; //buffer_count++;
//fprintf(stderr, "LirBuffer %x start %x\n", (int)this, (int)_start); //fprintf(stderr, "LirBuffer %x unused %x\n", (int)this, (int)_unused);
} }
LirBuffer::~LirBuffer() LirBuffer::~LirBuffer()
@ -126,6 +126,7 @@ namespace nanojit
// doesn't include embedded constants nor LIR_skip payload // doesn't include embedded constants nor LIR_skip payload
return _stats.lir; return _stats.lir;
} }
int32_t LirBuffer::byteCount() int32_t LirBuffer::byteCount()
{ {
return ((_pages.size() ? _pages.size()-1 : 0) * sizeof(Page)) + return ((_pages.size() ? _pages.size()-1 : 0) * sizeof(Page)) +
@ -138,9 +139,7 @@ namespace nanojit
if (page) if (page)
_pages.add(page); _pages.add(page);
else else
{
_noMem = 1; _noMem = 1;
}
return page; return page;
} }
@ -1093,8 +1092,8 @@ namespace nanojit
op = LIR_callh; op = LIR_callh;
LInsp args2[MAXARGS*2]; // arm could require 2 args per double LInsp args2[MAXARGS*2]; // arm could require 2 args per double
int32_t j = 0; int32_t j = 0;
int32_t i = 0; int32_t i = 0;
while (j < argc) { while (j < argc) {
argt >>= 2; argt >>= 2;
ArgSize a = ArgSize(argt&3); ArgSize a = ArgSize(argt&3);
if (a == ARGSIZE_F) { if (a == ARGSIZE_F) {
@ -1249,7 +1248,7 @@ namespace nanojit
#ifdef MEMORY_INFO #ifdef MEMORY_INFO
// m_list.set_meminfo_name("LInsHashSet.list"); // m_list.set_meminfo_name("LInsHashSet.list");
#endif #endif
LInsp *list = (LInsp*) gc->Alloc(sizeof(LInsp)*m_cap); LInsp *list = (LInsp*) gc->Alloc(sizeof(LInsp)*m_cap, GC::kZero);
WB(gc, this, &m_list, list); WB(gc, this, &m_list, list);
} }
@ -1343,7 +1342,7 @@ namespace nanojit
void FASTCALL LInsHashSet::grow() void FASTCALL LInsHashSet::grow()
{ {
const uint32_t newcap = m_cap << 1; const uint32_t newcap = m_cap << 1;
LInsp *newlist = (LInsp*) m_gc->Alloc(newcap * sizeof(LInsp)); LInsp *newlist = (LInsp*) m_gc->Alloc(newcap * sizeof(LInsp), GC::kZero);
LInsp *list = m_list; LInsp *list = m_list;
#ifdef MEMORY_INFO #ifdef MEMORY_INFO
// newlist.set_meminfo_name("LInsHashSet.list"); // newlist.set_meminfo_name("LInsHashSet.list");
@ -1550,7 +1549,7 @@ namespace nanojit
} }
void add(LInsp i, LInsp use) { void add(LInsp i, LInsp use) {
if (!i->isconst() && !i->isconstq() && !live.containsKey(i)) { if (!i->isconst() && !i->isconstq() && !live.containsKey(i)) {
NanoAssert(unsigned(i->opcode()) < sizeof(lirNames) / sizeof(lirNames[0])); NanoAssert(size_t(i->opcode()) < sizeof(lirNames) / sizeof(lirNames[0]));
live.put(i,use); live.put(i,use);
} }
} }
@ -1583,7 +1582,7 @@ namespace nanojit
LirReader br(lirbuf); LirReader br(lirbuf);
StackFilter sf(&br, gc, lirbuf, lirbuf->sp); StackFilter sf(&br, gc, lirbuf, lirbuf->sp);
StackFilter r(&sf, gc, lirbuf, lirbuf->rp); StackFilter r(&sf, gc, lirbuf, lirbuf->rp);
int total = 0; int total = 0;
if (lirbuf->state) if (lirbuf->state)
live.add(lirbuf->state, r.pos()); live.add(lirbuf->state, r.pos());
for (LInsp i = r.read(); i != 0; i = r.read()) for (LInsp i = r.read(); i != 0; i = r.read())
@ -1602,7 +1601,7 @@ namespace nanojit
if (live.contains(i)) if (live.contains(i))
{ {
live.retire(i,gc); live.retire(i,gc);
NanoAssert(unsigned(i->opcode()) < sizeof(operandCount) / sizeof(operandCount[0])); NanoAssert(size_t(i->opcode()) < sizeof(operandCount) / sizeof(operandCount[0]));
if (i->isStore()) { if (i->isStore()) {
live.add(i->oprnd2(),i); // base live.add(i->oprnd2(),i); // base
live.add(i->oprnd1(),i); // val live.add(i->oprnd1(),i); // val
@ -1742,7 +1741,7 @@ namespace nanojit
} }
#endif #endif
} else { } else {
NanoAssert(unsigned(ref->opcode()) < sizeof(lirNames) / sizeof(lirNames[0])); NanoAssert(size_t(ref->opcode()) < sizeof(lirNames) / sizeof(lirNames[0]));
copyName(ref, lirNames[ref->opcode()], lircounts.add(ref->opcode())); copyName(ref, lirNames[ref->opcode()], lircounts.add(ref->opcode()));
} }
StringNullTerminatedUTF8 cname(gc, names.get(ref)->name); StringNullTerminatedUTF8 cname(gc, names.get(ref)->name);
@ -2165,11 +2164,11 @@ namespace nanojit
return out->insStorei(v, b, d); return out->insStorei(v, b, d);
} }
LInsp LoadFilter::insCall(const CallInfo *call, LInsp args[]) LInsp LoadFilter::insCall(const CallInfo *ci, LInsp args[])
{ {
if (!call->_cse) if (!ci->_cse)
exprs.clear(); exprs.clear();
return out->insCall(call, args); return out->insCall(ci, args);
} }
LInsp LoadFilter::ins0(LOpcode op) LInsp LoadFilter::ins0(LOpcode op)

View File

@ -246,12 +246,7 @@ namespace nanojit
}; };
enum { enum {
callInfoWords = callInfoWords = sizeof(LIns*)/sizeof(u_type)
#ifdef NANOJIT_64BIT
2
#else
1
#endif
}; };
uint32_t reference(LIns*) const; uint32_t reference(LIns*) const;
@ -500,7 +495,7 @@ namespace nanojit
class LirNameMap MMGC_SUBCLASS_DECL class LirNameMap MMGC_SUBCLASS_DECL
{ {
template <class Key> template <class Key>
class CountMap : public avmplus::SortedMap<Key, int, avmplus::LIST_NonGCObjects> { class CountMap: public avmplus::SortedMap<Key, int, avmplus::LIST_NonGCObjects> {
public: public:
CountMap(avmplus::GC*gc) : avmplus::SortedMap<Key, int, avmplus::LIST_NonGCObjects>(gc) {} CountMap(avmplus::GC*gc) : avmplus::SortedMap<Key, int, avmplus::LIST_NonGCObjects>(gc) {}
int add(Key k) { int add(Key k) {
@ -557,8 +552,8 @@ namespace nanojit
{} {}
LInsp add(LInsp i) { LInsp add(LInsp i) {
if (i) if (i)
code.add(i); code.add(i);
return i; return i;
} }
@ -588,7 +583,6 @@ namespace nanojit
return add_flush(out->insBranch(v, condition, to)); return add_flush(out->insBranch(v, condition, to));
} }
LIns* ins0(LOpcode v) { LIns* ins0(LOpcode v) {
if (v == LIR_label || v == LIR_start) { if (v == LIR_label || v == LIR_start) {
flush(); flush();
@ -597,7 +591,7 @@ namespace nanojit
} }
LIns* ins1(LOpcode v, LInsp a) { LIns* ins1(LOpcode v, LInsp a) {
return isRet(v) ? add_flush(out->ins1(v, a)) : add(out->ins1(v, a)); return isRet(v) ? add_flush(out->ins1(v, a)) : add(out->ins1(v, a));
} }
LIns* ins2(LOpcode v, LInsp a, LInsp b) { LIns* ins2(LOpcode v, LInsp a, LInsp b) {
return v == LIR_2 ? out->ins2(v,a,b) : add(out->ins2(v, a, b)); return v == LIR_2 ? out->ins2(v,a,b) : add(out->ins2(v, a, b));
@ -714,7 +708,6 @@ namespace nanojit
struct struct
{ {
uint32_t lir; // # instructions uint32_t lir; // # instructions
uint32_t pages; // pages consumed
} }
_stats; _stats;
@ -760,7 +753,7 @@ namespace nanojit
LInsp insCall(const CallInfo *call, LInsp args[]); LInsp insCall(const CallInfo *call, LInsp args[]);
LInsp insGuard(LOpcode op, LInsp cond, LIns *x); LInsp insGuard(LOpcode op, LInsp cond, LIns *x);
LInsp insBranch(LOpcode v, LInsp condition, LInsp to); LInsp insBranch(LOpcode v, LInsp condition, LInsp to);
LInsp insAlloc(int32_t size); LInsp insAlloc(int32_t size);
// buffer mgmt // buffer mgmt
LInsp skip(size_t); LInsp skip(size_t);
@ -783,7 +776,7 @@ namespace nanojit
public: public:
LirFilter *in; LirFilter *in;
LirFilter(LirFilter *in) : in(in) {} LirFilter(LirFilter *in) : in(in) {}
virtual ~LirFilter() {} virtual ~LirFilter(){}
virtual LInsp read() { virtual LInsp read() {
return in->read(); return in->read();

View File

@ -100,7 +100,7 @@ namespace nanojit {
if (verbose_enabled()) {\ if (verbose_enabled()) {\
outline[0]='\0';\ outline[0]='\0';\
if (outputAddr) sprintf(outline, " %10p ",_nIns);\ if (outputAddr) sprintf(outline, " %10p ",_nIns);\
else sprintf(outline, " ");\ else sprintf(outline, " ");\
sprintf(&outline[14], ##__VA_ARGS__);\ sprintf(&outline[14], ##__VA_ARGS__);\
Assembler::outputAlign(outline, 45);\ Assembler::outputAlign(outline, 45);\
RegAlloc::formatRegisters(_allocator, outline, _thisfrag);\ RegAlloc::formatRegisters(_allocator, outline, _thisfrag);\

View File

@ -1108,11 +1108,11 @@ Assembler::asm_prep_fcall(Reservation*, LInsp)
} }
NIns* NIns*
Assembler::asm_branch(bool branchOnFalse, LInsp cond, NIns* targ, bool /*far*/) Assembler::asm_branch(bool branchOnFalse, LInsp cond, NIns* targ, bool far)
{ {
// ignore far -- we figure this out on our own. // ignore far -- we figure this out on our own.
// XXX noone actually uses the far param in nj anyway... (always false) // XXX noone actually uses the far param in nj anyway... (always false)
(void)far;
NIns* at = 0; NIns* at = 0;
LOpcode condop = cond->opcode(); LOpcode condop = cond->opcode();

View File

@ -93,6 +93,7 @@ namespace nanojit
void Assembler::nInit(AvmCore* core) void Assembler::nInit(AvmCore* core)
{ {
(void) core;
OSDep::getDate(); OSDep::getDate();
} }

View File

@ -121,7 +121,6 @@ namespace nanojit
} }
} }
} }
NanoAssert(a != 0); NanoAssert(a != 0);
return a; return a;
} }

View File

@ -253,10 +253,24 @@ namespace avmplus {
static GCHeap heap; static GCHeap heap;
public: public:
/**
* flags to be passed as second argument to alloc
*/
enum AllocFlags
{
kZero=1,
kContainsPointers=2,
kFinalize=4,
kRCObject=8
};
static inline void* static inline void*
Alloc(uint32_t bytes) Alloc(uint32_t bytes, int flags=kZero)
{ {
if (flags & kZero)
return calloc(1, bytes); return calloc(1, bytes);
else
return malloc(bytes);
} }
static inline void static inline void

View File

@ -172,12 +172,12 @@ namespace nanojit
#define verbose_output if (verbose_enabled()) Assembler::output #define verbose_output if (verbose_enabled()) Assembler::output
#define verbose_outputf if (verbose_enabled()) Assembler::outputf #define verbose_outputf if (verbose_enabled()) Assembler::outputf
#define verbose_enabled() (_verbose) #define verbose_enabled() (_verbose)
#define verbose_only(x) x #define verbose_only(...) __VA_ARGS__
#else #else
#define verbose_output #define verbose_output
#define verbose_outputf #define verbose_outputf
#define verbose_enabled() #define verbose_enabled()
#define verbose_only(x) #define verbose_only(...)
#endif /*NJ_VERBOSE*/ #endif /*NJ_VERBOSE*/
#ifdef _DEBUG #ifdef _DEBUG