From 22816c122c60f4b336c820d5c5cf8319aef60928 Mon Sep 17 00:00:00 2001 From: Edwin Smith Date: Tue, 4 Aug 2009 13:11:53 -0400 Subject: [PATCH] Bug 509890 - Convert InsList to SeqBuilder<> and Allocator, r=gal. --HG-- extra : rebase_source : 22303e739a0a6669c634595149028872aa7bd334 --- js/src/jsregexp.cpp | 2 +- js/src/jstracer.cpp | 3 ++- js/src/nanojit/Assembler.cpp | 19 ++++++++----------- js/src/nanojit/Assembler.h | 1 - js/src/nanojit/LIR.h | 17 ++++++++++------- js/src/nanojit/nanojit.h | 2 -- 6 files changed, 21 insertions(+), 23 deletions(-) diff --git a/js/src/jsregexp.cpp b/js/src/jsregexp.cpp index 0da64026aac0..7d893ecc24fc 100644 --- a/js/src/jsregexp.cpp +++ b/js/src/jsregexp.cpp @@ -3117,7 +3117,7 @@ class RegExpNativeCompiler { #ifdef NJ_VERBOSE debug_only_stmt( if (js_LogController.lcbits & LC_TMRegexp) { - lir = new (&gc) VerboseWriter(&gc, lir, lirbuf->names, + lir = new (&gc) VerboseWriter(*alloc, lir, lirbuf->names, &js_LogController); } ) diff --git a/js/src/jstracer.cpp b/js/src/jstracer.cpp index 30e22e296ed3..4bfe4af7a2ad 100644 --- a/js/src/jstracer.cpp +++ b/js/src/jstracer.cpp @@ -1710,7 +1710,8 @@ TraceRecorder::TraceRecorder(JSContext* cx, VMSideExit* _anchor, Fragment* _frag debug_only_stmt( if (js_LogController.lcbits & LC_TMRecorder) { lir = verbose_filter - = new (&gc) VerboseWriter(&gc, lir, lirbuf->names, &js_LogController); + = new (&gc) VerboseWriter(*traceMonitor->allocator, lir, + lirbuf->names, &js_LogController); } ) if (nanojit::AvmCore::config.soft_float) diff --git a/js/src/nanojit/Assembler.cpp b/js/src/nanojit/Assembler.cpp index 3f807e02d7de..40f32a72799a 100644 --- a/js/src/nanojit/Assembler.cpp +++ b/js/src/nanojit/Assembler.cpp @@ -55,17 +55,15 @@ namespace nanojit InsList block; bool flushnext; public: - VerboseBlockReader(LirFilter *in, Assembler *a, LirNameMap *n) - : LirFilter(in), assm(a), names(n), block(a->_gc), flushnext(false) + VerboseBlockReader(Allocator& alloc, LirFilter *in, Assembler *a, LirNameMap *n) + : LirFilter(in), assm(a), names(n), block(alloc), flushnext(false) {} void flush() { flushnext = false; if (!block.isEmpty()) { - for (int j=0,n=block.size(); j < n; j++) { - LIns *i = block[j]; - assm->outputf(" %s", names->formatIns(i)); - } + for (Seq* p = block.get(); p != NULL; p = p->tail) + assm->outputf(" %s", names->formatIns(p->head)); block.clear(); } } @@ -732,7 +730,7 @@ namespace nanojit // end of pipeline verbose_only( - VerboseBlockReader vbr(prev, this, frag->lirbuf->names); + VerboseBlockReader vbr(alloc, prev, this, frag->lirbuf->names); if (_logc->lcbits & LC_Assembly) prev = &vbr; ) @@ -927,7 +925,7 @@ namespace nanojit reader->pos()->isop(LIR_ret) || reader->pos()->isop(LIR_xtbl)); - InsList pending_lives(_gc); + InsList pending_lives(alloc); for (LInsp ins = reader->read(); !ins->isop(LIR_start) && !error(); ins = reader->read()) @@ -1429,9 +1427,8 @@ namespace nanojit { // ensure that exprs spanning the loop are marked live at the end of the loop reserveSavedRegs(); - for (int i=0, n=pending_lives.size(); i < n; i++) { - findMemFor(pending_lives[i]); - } + for (Seq* p = pending_lives.get(); p != NULL; p = p->tail) + findMemFor(p->head); /* * TODO: I'm not positive, but I think the following line needs to be * added, otherwise the pending_lives will build up and never get diff --git a/js/src/nanojit/Assembler.h b/js/src/nanojit/Assembler.h index fea452c74ffb..e6d031e08d31 100644 --- a/js/src/nanojit/Assembler.h +++ b/js/src/nanojit/Assembler.h @@ -240,7 +240,6 @@ namespace nanojit Allocator &alloc; CodeAlloc& _codeAlloc; - avmplus::GC* _gc; DWB(Fragment*) _thisfrag; RegAllocMap* _branchStateMap; diff --git a/js/src/nanojit/LIR.h b/js/src/nanojit/LIR.h index 9ee5c605bd29..e7df761f85cb 100644 --- a/js/src/nanojit/LIR.h +++ b/js/src/nanojit/LIR.h @@ -776,6 +776,7 @@ namespace nanojit }; typedef LIns* LInsp; + typedef SeqBuilder InsList; LIns* FASTCALL callArgN(LInsp i, uint32_t n); extern const uint8_t operandCount[]; @@ -936,9 +937,9 @@ namespace nanojit DWB(LirNameMap*) names; LogControl* logc; public: - VerboseWriter(GC *gc, LirWriter *out, + VerboseWriter(Allocator& alloc, LirWriter *out, LirNameMap* names, LogControl* logc) - : LirWriter(out), code(gc), names(names), logc(logc) + : LirWriter(out), code(alloc), names(names), logc(logc) {} LInsp add(LInsp i) { @@ -955,12 +956,14 @@ namespace nanojit void flush() { - int n = code.size(); - if (n) { - for (int i=0; i < n; i++) - logc->printf(" %s\n",names->formatIns(code[i])); + if (!code.isEmpty()) { + int32_t count = 0; + for (Seq* p = code.get(); p != NULL; p = p->tail) { + logc->printf(" %s\n",names->formatIns(p->head)); + count++; + } code.clear(); - if (n > 1) + if (count > 1) logc->printf("\n"); } } diff --git a/js/src/nanojit/nanojit.h b/js/src/nanojit/nanojit.h index e8c8edfb3dd0..e8099c33bad5 100644 --- a/js/src/nanojit/nanojit.h +++ b/js/src/nanojit/nanojit.h @@ -117,11 +117,9 @@ namespace nanojit * ------------------------------------------- */ class Fragment; - class LIns; typedef avmplus::AvmCore AvmCore; typedef avmplus::OSDep OSDep; typedef avmplus::GCSortedMap FragmentMap; - typedef avmplus::List InsList; const uint32_t MAXARGS = 8;