From 2b8e638ee80f4316555305d57d246d608be20a83 Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Fri, 15 May 2015 20:19:02 +0200 Subject: [PATCH] Bug 1147403 part 4 - Extract the printer from the serializer. r=h4writer --- js/src/jit/C1Spewer.cpp | 8 -------- js/src/jit/C1Spewer.h | 9 +++------ js/src/jit/JSONSpewer.cpp | 10 ---------- js/src/jit/JSONSpewer.h | 9 +++------ js/src/jit/JitSpewer.cpp | 11 +++++++++-- js/src/jit/JitSpewer.h | 8 ++++++-- 6 files changed, 21 insertions(+), 34 deletions(-) diff --git a/js/src/jit/C1Spewer.cpp b/js/src/jit/C1Spewer.cpp index 8cb6f026cce4..c8b4a769dbef 100644 --- a/js/src/jit/C1Spewer.cpp +++ b/js/src/jit/C1Spewer.cpp @@ -68,14 +68,6 @@ C1Spewer::endFunction() { } -void -C1Spewer::dump(Fprinter& file) -{ - if (!out_.hadOutOfMemory()) - out_.exportInto(file); - out_.clear(); -} - static void DumpDefinition(GenericPrinter& out, MDefinition* def) { diff --git a/js/src/jit/C1Spewer.h b/js/src/jit/C1Spewer.h index 084d6ddf65ef..1f93827e3450 100644 --- a/js/src/jit/C1Spewer.h +++ b/js/src/jit/C1Spewer.h @@ -11,7 +11,6 @@ #include "NamespaceImports.h" -#include "jit/JitAllocPolicy.h" #include "js/RootingAPI.h" #include "vm/Printer.h" @@ -26,11 +25,11 @@ class LNode; class C1Spewer { MIRGraph* graph; - LSprinter out_; + GenericPrinter& out_; public: - explicit C1Spewer(TempAllocator *alloc) - : graph(nullptr), out_(alloc->lifoAlloc()) + explicit C1Spewer(GenericPrinter& out) + : graph(nullptr), out_(out) { } void beginFunction(MIRGraph* graph, JSScript* script); @@ -38,8 +37,6 @@ class C1Spewer void spewIntervals(const char* pass, BacktrackingAllocator* regalloc); void endFunction(); - void dump(Fprinter &file); - private: void spewPass(GenericPrinter& out, MBasicBlock* block); void spewIntervals(GenericPrinter& out, BacktrackingAllocator* regalloc, LNode* ins, size_t& nextId); diff --git a/js/src/jit/JSONSpewer.cpp b/js/src/jit/JSONSpewer.cpp index 0c07350c3a4e..0754c6f5c11a 100644 --- a/js/src/jit/JSONSpewer.cpp +++ b/js/src/jit/JSONSpewer.cpp @@ -398,13 +398,3 @@ JSONSpewer::endFunction() endList(); endObject(); } - -void -JSONSpewer::dump(Fprinter& file) -{ - if (!out_.hadOutOfMemory()) - out_.exportInto(file); - else - file.put("{}"); - out_.clear(); -} diff --git a/js/src/jit/JSONSpewer.h b/js/src/jit/JSONSpewer.h index 2fd77fdfd9c6..b7516e6c6c83 100644 --- a/js/src/jit/JSONSpewer.h +++ b/js/src/jit/JSONSpewer.h @@ -9,7 +9,6 @@ #include -#include "jit/JitAllocPolicy.h" #include "js/TypeDecls.h" #include "vm/Printer.h" @@ -27,7 +26,7 @@ class JSONSpewer private: int indentLevel_; bool first_; - LSprinter out_; + GenericPrinter& out_; void indent(); @@ -43,10 +42,10 @@ class JSONSpewer void endList(); public: - explicit JSONSpewer(TempAllocator *alloc) + explicit JSONSpewer(GenericPrinter& out) : indentLevel_(0), first_(true), - out_(alloc->lifoAlloc()) + out_(out) { } void beginFunction(JSScript* script); @@ -59,8 +58,6 @@ class JSONSpewer void spewIntervals(BacktrackingAllocator* regalloc); void endPass(); void endFunction(); - - void dump(Fprinter& file); }; } // namespace jit diff --git a/js/src/jit/JitSpewer.cpp b/js/src/jit/JitSpewer.cpp index 941934a47be0..2ad82ed2c978 100644 --- a/js/src/jit/JitSpewer.cpp +++ b/js/src/jit/JitSpewer.cpp @@ -317,8 +317,15 @@ GraphSpewer::endFunction() void GraphSpewer::dump(Fprinter& c1Out, Fprinter& jsonOut) { - c1Spewer_.dump(c1Out); - jsonSpewer_.dump(jsonOut); + if (!c1Printer_.hadOutOfMemory()) + c1Printer_.exportInto(c1Out); + c1Printer_.clear(); + + if (!jsonPrinter_.hadOutOfMemory()) + jsonPrinter_.exportInto(jsonOut); + else + jsonOut.put("{}"); + jsonPrinter_.clear(); } void diff --git a/js/src/jit/JitSpewer.h b/js/src/jit/JitSpewer.h index 184914deb4e7..2076e7cf3a3e 100644 --- a/js/src/jit/JitSpewer.h +++ b/js/src/jit/JitSpewer.h @@ -108,14 +108,18 @@ class GraphSpewer { private: MIRGraph* graph_; + LSprinter c1Printer_; + LSprinter jsonPrinter_; C1Spewer c1Spewer_; JSONSpewer jsonSpewer_; public: explicit GraphSpewer(TempAllocator *alloc) : graph_(nullptr), - c1Spewer_(alloc), - jsonSpewer_(alloc) + c1Printer_(alloc->lifoAlloc()), + jsonPrinter_(alloc->lifoAlloc()), + c1Spewer_(c1Printer_), + jsonSpewer_(jsonPrinter_) { } bool isSpewing() const {