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
DumpDefinition(GenericPrinter& out, MDefinition* def)
{

View File

@ -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 spewRanges(const char* pass, BacktrackingAllocator* regalloc);
void endFunction();
void dump(Fprinter &file);
private:
void spewPass(GenericPrinter& out, MBasicBlock* block);
void spewRanges(GenericPrinter& out, BacktrackingAllocator* regalloc, LNode* ins);

View File

@ -388,13 +388,3 @@ JSONSpewer::endFunction()
endList();
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 "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 spewRanges(BacktrackingAllocator* regalloc);
void endPass();
void endFunction();
void dump(Fprinter& file);
};
} // namespace jit

View File

@ -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

View File

@ -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 {