Bug 1147403 part 4 - Extract the printer from the serializer. r=h4writer

This commit is contained in:
Nicolas B. Pierron 2015-05-28 19:26:55 +02:00
parent c3ac0db387
commit c5d0701239
6 changed files with 21 additions and 34 deletions

View File

@ -67,14 +67,6 @@ C1Spewer::endFunction()
{ {
} }
void
C1Spewer::dump(Fprinter& file)
{
if (!out_.hadOutOfMemory())
out_.exportInto(file);
out_.clear();
}
static void static void
DumpDefinition(GenericPrinter& out, MDefinition* def) DumpDefinition(GenericPrinter& out, MDefinition* def)
{ {

View File

@ -11,7 +11,6 @@
#include "NamespaceImports.h" #include "NamespaceImports.h"
#include "jit/JitAllocPolicy.h"
#include "js/RootingAPI.h" #include "js/RootingAPI.h"
#include "vm/Printer.h" #include "vm/Printer.h"
@ -26,11 +25,11 @@ class LNode;
class C1Spewer class C1Spewer
{ {
MIRGraph* graph; MIRGraph* graph;
LSprinter out_; GenericPrinter& out_;
public: public:
explicit C1Spewer(TempAllocator *alloc) explicit C1Spewer(GenericPrinter& out)
: graph(nullptr), out_(alloc->lifoAlloc()) : graph(nullptr), out_(out)
{ } { }
void beginFunction(MIRGraph* graph, JSScript* script); void beginFunction(MIRGraph* graph, JSScript* script);
@ -38,8 +37,6 @@ class C1Spewer
void spewRanges(const char* pass, BacktrackingAllocator* regalloc); void spewRanges(const char* pass, BacktrackingAllocator* regalloc);
void endFunction(); void endFunction();
void dump(Fprinter &file);
private: private:
void spewPass(GenericPrinter& out, MBasicBlock* block); void spewPass(GenericPrinter& out, MBasicBlock* block);
void spewRanges(GenericPrinter& out, BacktrackingAllocator* regalloc, LNode* ins); void spewRanges(GenericPrinter& out, BacktrackingAllocator* regalloc, LNode* ins);

View File

@ -388,13 +388,3 @@ JSONSpewer::endFunction()
endList(); endList();
endObject(); endObject();
} }
void
JSONSpewer::dump(Fprinter& file)
{
if (!out_.hadOutOfMemory())
out_.exportInto(file);
else
file.put("{}");
out_.clear();
}

View File

@ -9,7 +9,6 @@
#include <stdio.h> #include <stdio.h>
#include "jit/JitAllocPolicy.h"
#include "js/TypeDecls.h" #include "js/TypeDecls.h"
#include "vm/Printer.h" #include "vm/Printer.h"
@ -27,7 +26,7 @@ class JSONSpewer
private: private:
int indentLevel_; int indentLevel_;
bool first_; bool first_;
LSprinter out_; GenericPrinter& out_;
void indent(); void indent();
@ -43,10 +42,10 @@ class JSONSpewer
void endList(); void endList();
public: public:
explicit JSONSpewer(TempAllocator *alloc) explicit JSONSpewer(GenericPrinter& out)
: indentLevel_(0), : indentLevel_(0),
first_(true), first_(true),
out_(alloc->lifoAlloc()) out_(out)
{ } { }
void beginFunction(JSScript* script); void beginFunction(JSScript* script);
@ -59,8 +58,6 @@ class JSONSpewer
void spewRanges(BacktrackingAllocator* regalloc); void spewRanges(BacktrackingAllocator* regalloc);
void endPass(); void endPass();
void endFunction(); void endFunction();
void dump(Fprinter& file);
}; };
} // namespace jit } // namespace jit

View File

@ -317,8 +317,15 @@ GraphSpewer::endFunction()
void void
GraphSpewer::dump(Fprinter& c1Out, Fprinter& jsonOut) GraphSpewer::dump(Fprinter& c1Out, Fprinter& jsonOut)
{ {
c1Spewer_.dump(c1Out); if (!c1Printer_.hadOutOfMemory())
jsonSpewer_.dump(jsonOut); c1Printer_.exportInto(c1Out);
c1Printer_.clear();
if (!jsonPrinter_.hadOutOfMemory())
jsonPrinter_.exportInto(jsonOut);
else
jsonOut.put("{}");
jsonPrinter_.clear();
} }
void void

View File

@ -108,14 +108,18 @@ class GraphSpewer
{ {
private: private:
MIRGraph* graph_; MIRGraph* graph_;
LSprinter c1Printer_;
LSprinter jsonPrinter_;
C1Spewer c1Spewer_; C1Spewer c1Spewer_;
JSONSpewer jsonSpewer_; JSONSpewer jsonSpewer_;
public: public:
explicit GraphSpewer(TempAllocator *alloc) explicit GraphSpewer(TempAllocator *alloc)
: graph_(nullptr), : graph_(nullptr),
c1Spewer_(alloc), c1Printer_(alloc->lifoAlloc()),
jsonSpewer_(alloc) jsonPrinter_(alloc->lifoAlloc()),
c1Spewer_(c1Printer_),
jsonSpewer_(jsonPrinter_)
{ } { }
bool isSpewing() const { bool isSpewing() const {