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

This commit is contained in:
Nicolas B. Pierron 2015-05-15 20:19:02 +02:00
Родитель bd088a7a01
Коммит 2b8e638ee8
6 изменённых файлов: 21 добавлений и 34 удалений

Просмотреть файл

@ -68,14 +68,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)
{ {

Просмотреть файл

@ -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 spewIntervals(const char* pass, BacktrackingAllocator* regalloc); void spewIntervals(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 spewIntervals(GenericPrinter& out, BacktrackingAllocator* regalloc, LNode* ins, size_t& nextId); void spewIntervals(GenericPrinter& out, BacktrackingAllocator* regalloc, LNode* ins, size_t& nextId);

Просмотреть файл

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

Просмотреть файл

@ -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 spewIntervals(BacktrackingAllocator* regalloc); void spewIntervals(BacktrackingAllocator* regalloc);
void endPass(); void endPass();
void endFunction(); void endFunction();
void dump(Fprinter& file);
}; };
} // namespace jit } // namespace jit

Просмотреть файл

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

Просмотреть файл

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