From ba3dc138007513a3f72dd6d1ca00bdfffd5dd3aa Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Wed, 10 Dec 2008 17:25:46 -0800 Subject: [PATCH] Bug 468484 - Minor adjustments to match changes in tamarin, r=gal. --- js/src/nanojit/Assembler.cpp | 13 ++++++------- js/src/nanojit/Assembler.h | 1 - js/src/nanojit/LIR.cpp | 27 +++++++++++++-------------- js/src/nanojit/LIR.h | 25 +++++++++---------------- js/src/nanojit/Native.h | 2 +- js/src/nanojit/NativeARM.cpp | 4 ++-- js/src/nanojit/Nativei386.cpp | 1 + js/src/nanojit/RegAlloc.cpp | 1 - js/src/nanojit/avmplus.h | 16 +++++++++++++++- js/src/nanojit/nanojit.h | 4 ++-- 10 files changed, 49 insertions(+), 45 deletions(-) diff --git a/js/src/nanojit/Assembler.cpp b/js/src/nanojit/Assembler.cpp index 93808697572..29ce43298fd 100755 --- a/js/src/nanojit/Assembler.cpp +++ b/js/src/nanojit/Assembler.cpp @@ -70,7 +70,7 @@ namespace nanojit return ins->resv() == 0; } - public: + public: DeadCodeFilter(LirFilter *in, const CallInfo *f) : LirFilter(in), functions(f) {} LInsp read() { for (;;) { @@ -145,7 +145,7 @@ namespace nanojit */ Assembler::Assembler(Fragmento* frago) : hasLoop(0) - , _frago(frago) + , _frago(frago) , _gc(frago->core()->gc) , _labels(_gc) , _patches(_gc) @@ -257,12 +257,12 @@ namespace nanojit setError(ResvFull); item = 1; } - Reservation *r = &_resvTable[item]; + Reservation *r = &_resvTable[item]; _resvFree = r->arIndex; r->reg = UnknownReg; r->arIndex = 0; - r->used = 1; - i->setresv(item); + r->used = 1; + i->setresv(item); return r; } @@ -925,7 +925,7 @@ namespace nanojit NanoAssertMsgf(error() || _fpuStkDepth == 0,"_fpuStkDepth %d",_fpuStkDepth); internalReset(); // clear the reservation tables and regalloc - NanoAssert(!_branchStateMap || _branchStateMap->isEmpty()); + NanoAssert( !_branchStateMap || _branchStateMap->isEmpty()); _branchStateMap = 0; #ifdef AVMPLUS_ARM @@ -1319,7 +1319,6 @@ namespace nanojit NanoAssert(label->addr == 0 && label->regs.isValid()); //evictRegs(~_allocator.free); intersectRegisterState(label->regs); - //asm_align_code(); label->addr = _nIns; } verbose_only( if (_verbose) { outputAddr=true; asm_output("[%s]", _thisfrag->lirbuf->names->formatRef(ins)); } ) diff --git a/js/src/nanojit/Assembler.h b/js/src/nanojit/Assembler.h index 9999ff9227f..7f3e2e24acd 100644 --- a/js/src/nanojit/Assembler.h +++ b/js/src/nanojit/Assembler.h @@ -331,7 +331,6 @@ namespace nanojit }; // platform specific implementation (see NativeXXX.cpp file) - void nInit(uint32_t flags); void nInit(AvmCore *); Register nRegisterAllocFromSet(int32_t set); void nRegisterResetAll(RegAlloc& a); diff --git a/js/src/nanojit/LIR.cpp b/js/src/nanojit/LIR.cpp index e8daa61eef8..622f224b702 100755 --- a/js/src/nanojit/LIR.cpp +++ b/js/src/nanojit/LIR.cpp @@ -95,7 +95,7 @@ namespace nanojit if (start) _unused = &start->lir[0]; //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() @@ -126,6 +126,7 @@ namespace nanojit // doesn't include embedded constants nor LIR_skip payload return _stats.lir; } + int32_t LirBuffer::byteCount() { return ((_pages.size() ? _pages.size()-1 : 0) * sizeof(Page)) + @@ -138,9 +139,7 @@ namespace nanojit if (page) _pages.add(page); else - { _noMem = 1; - } return page; } @@ -1093,8 +1092,8 @@ namespace nanojit op = LIR_callh; LInsp args2[MAXARGS*2]; // arm could require 2 args per double int32_t j = 0; - int32_t i = 0; - while (j < argc) { + int32_t i = 0; + while (j < argc) { argt >>= 2; ArgSize a = ArgSize(argt&3); if (a == ARGSIZE_F) { @@ -1249,7 +1248,7 @@ namespace nanojit #ifdef MEMORY_INFO // m_list.set_meminfo_name("LInsHashSet.list"); #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); } @@ -1343,7 +1342,7 @@ namespace nanojit void FASTCALL LInsHashSet::grow() { 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; #ifdef MEMORY_INFO // newlist.set_meminfo_name("LInsHashSet.list"); @@ -1550,7 +1549,7 @@ namespace nanojit } void add(LInsp i, LInsp use) { 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); } } @@ -1583,7 +1582,7 @@ namespace nanojit LirReader br(lirbuf); StackFilter sf(&br, gc, lirbuf, lirbuf->sp); StackFilter r(&sf, gc, lirbuf, lirbuf->rp); - int total = 0; + int total = 0; if (lirbuf->state) live.add(lirbuf->state, r.pos()); for (LInsp i = r.read(); i != 0; i = r.read()) @@ -1602,7 +1601,7 @@ namespace nanojit if (live.contains(i)) { 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()) { live.add(i->oprnd2(),i); // base live.add(i->oprnd1(),i); // val @@ -1742,7 +1741,7 @@ namespace nanojit } #endif } 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())); } StringNullTerminatedUTF8 cname(gc, names.get(ref)->name); @@ -2165,11 +2164,11 @@ namespace nanojit 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(); - return out->insCall(call, args); + return out->insCall(ci, args); } LInsp LoadFilter::ins0(LOpcode op) diff --git a/js/src/nanojit/LIR.h b/js/src/nanojit/LIR.h index e859eca6b52..042cf1617c3 100644 --- a/js/src/nanojit/LIR.h +++ b/js/src/nanojit/LIR.h @@ -235,7 +235,7 @@ namespace nanojit * * For pointing to instructions further than this range LIR_tramp is used. */ - union + union { u_type u; c_type c; @@ -246,12 +246,7 @@ namespace nanojit }; enum { - callInfoWords = -#ifdef NANOJIT_64BIT - 2 -#else - 1 -#endif + callInfoWords = sizeof(LIns*)/sizeof(u_type) }; uint32_t reference(LIns*) const; @@ -500,7 +495,7 @@ namespace nanojit class LirNameMap MMGC_SUBCLASS_DECL { template - class CountMap : public avmplus::SortedMap { + class CountMap: public avmplus::SortedMap { public: CountMap(avmplus::GC*gc) : avmplus::SortedMap(gc) {} int add(Key k) { @@ -553,12 +548,12 @@ namespace nanojit DWB(LirNameMap*) names; public: VerboseWriter(avmplus::GC *gc, LirWriter *out, LirNameMap* names) - : LirWriter(out), code(gc), names(names) + : LirWriter(out), code(gc), names(names) {} LInsp add(LInsp i) { - if (i) - code.add(i); + if (i) + code.add(i); return i; } @@ -588,7 +583,6 @@ namespace nanojit return add_flush(out->insBranch(v, condition, to)); } - LIns* ins0(LOpcode v) { if (v == LIR_label || v == LIR_start) { flush(); @@ -597,7 +591,7 @@ namespace nanojit } 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) { return v == LIR_2 ? out->ins2(v,a,b) : add(out->ins2(v, a, b)); @@ -714,7 +708,6 @@ namespace nanojit struct { uint32_t lir; // # instructions - uint32_t pages; // pages consumed } _stats; @@ -760,7 +753,7 @@ namespace nanojit LInsp insCall(const CallInfo *call, LInsp args[]); LInsp insGuard(LOpcode op, LInsp cond, LIns *x); LInsp insBranch(LOpcode v, LInsp condition, LInsp to); - LInsp insAlloc(int32_t size); + LInsp insAlloc(int32_t size); // buffer mgmt LInsp skip(size_t); @@ -783,7 +776,7 @@ namespace nanojit public: LirFilter *in; LirFilter(LirFilter *in) : in(in) {} - virtual ~LirFilter() {} + virtual ~LirFilter(){} virtual LInsp read() { return in->read(); diff --git a/js/src/nanojit/Native.h b/js/src/nanojit/Native.h index 3ccf81750cb..da1f6321f8a 100644 --- a/js/src/nanojit/Native.h +++ b/js/src/nanojit/Native.h @@ -100,7 +100,7 @@ namespace nanojit { if (verbose_enabled()) {\ outline[0]='\0';\ if (outputAddr) sprintf(outline, " %10p ",_nIns);\ - else sprintf(outline, " ");\ + else sprintf(outline, " ");\ sprintf(&outline[14], ##__VA_ARGS__);\ Assembler::outputAlign(outline, 45);\ RegAlloc::formatRegisters(_allocator, outline, _thisfrag);\ diff --git a/js/src/nanojit/NativeARM.cpp b/js/src/nanojit/NativeARM.cpp index f8719be61db..9cfd77fa315 100644 --- a/js/src/nanojit/NativeARM.cpp +++ b/js/src/nanojit/NativeARM.cpp @@ -1108,11 +1108,11 @@ Assembler::asm_prep_fcall(Reservation*, LInsp) } 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. // XXX noone actually uses the far param in nj anyway... (always false) - + (void)far; NIns* at = 0; LOpcode condop = cond->opcode(); diff --git a/js/src/nanojit/Nativei386.cpp b/js/src/nanojit/Nativei386.cpp index 05d03dae8ed..1c4cb58b80e 100644 --- a/js/src/nanojit/Nativei386.cpp +++ b/js/src/nanojit/Nativei386.cpp @@ -93,6 +93,7 @@ namespace nanojit void Assembler::nInit(AvmCore* core) { + (void) core; OSDep::getDate(); } diff --git a/js/src/nanojit/RegAlloc.cpp b/js/src/nanojit/RegAlloc.cpp index 2000bcbfaaa..234da13a9ca 100644 --- a/js/src/nanojit/RegAlloc.cpp +++ b/js/src/nanojit/RegAlloc.cpp @@ -121,7 +121,6 @@ namespace nanojit } } } - NanoAssert(a != 0); return a; } diff --git a/js/src/nanojit/avmplus.h b/js/src/nanojit/avmplus.h index 9aef0a6f3ee..57d64f21ae3 100644 --- a/js/src/nanojit/avmplus.h +++ b/js/src/nanojit/avmplus.h @@ -253,10 +253,24 @@ namespace avmplus { static GCHeap heap; public: + /** + * flags to be passed as second argument to alloc + */ + enum AllocFlags + { + kZero=1, + kContainsPointers=2, + kFinalize=4, + kRCObject=8 + }; + static inline void* - Alloc(uint32_t bytes) + Alloc(uint32_t bytes, int flags=kZero) { + if (flags & kZero) return calloc(1, bytes); + else + return malloc(bytes); } static inline void diff --git a/js/src/nanojit/nanojit.h b/js/src/nanojit/nanojit.h index e7e28a9737e..2dfb7e63dd2 100644 --- a/js/src/nanojit/nanojit.h +++ b/js/src/nanojit/nanojit.h @@ -172,12 +172,12 @@ namespace nanojit #define verbose_output if (verbose_enabled()) Assembler::output #define verbose_outputf if (verbose_enabled()) Assembler::outputf #define verbose_enabled() (_verbose) - #define verbose_only(x) x + #define verbose_only(...) __VA_ARGS__ #else #define verbose_output #define verbose_outputf #define verbose_enabled() - #define verbose_only(x) + #define verbose_only(...) #endif /*NJ_VERBOSE*/ #ifdef _DEBUG