michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * vim: set ts=8 sts=4 et sw=4 tw=99: michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef jit_JSONSpewer_h michael@0: #define jit_JSONSpewer_h michael@0: michael@0: #include "mozilla/NullPtr.h" michael@0: michael@0: #include michael@0: michael@0: #include "js/TypeDecls.h" michael@0: michael@0: namespace js { michael@0: namespace jit { michael@0: michael@0: class MDefinition; michael@0: class MInstruction; michael@0: class MBasicBlock; michael@0: class MIRGraph; michael@0: class MResumePoint; michael@0: class LinearScanAllocator; michael@0: class LInstruction; michael@0: michael@0: class JSONSpewer michael@0: { michael@0: private: michael@0: // Set by beginFunction(); unset by endFunction(). michael@0: // Used to correctly format output in case of abort during compilation. michael@0: bool inFunction_; michael@0: michael@0: int indentLevel_; michael@0: bool first_; michael@0: FILE *fp_; michael@0: michael@0: void indent(); michael@0: michael@0: void property(const char *name); michael@0: void beginObject(); michael@0: void beginObjectProperty(const char *name); michael@0: void beginListProperty(const char *name); michael@0: void stringValue(const char *format, ...); michael@0: void stringProperty(const char *name, const char *format, ...); michael@0: void integerValue(int value); michael@0: void integerProperty(const char *name, int value); michael@0: void endObject(); michael@0: void endList(); michael@0: michael@0: public: michael@0: JSONSpewer() michael@0: : inFunction_(false), michael@0: indentLevel_(0), michael@0: first_(true), michael@0: fp_(nullptr) michael@0: { } michael@0: ~JSONSpewer(); michael@0: michael@0: bool init(const char *path); michael@0: void beginFunction(JSScript *script); michael@0: void beginPass(const char * pass); michael@0: void spewMDef(MDefinition *def); michael@0: void spewMResumePoint(MResumePoint *rp); michael@0: void spewMIR(MIRGraph *mir); michael@0: void spewLIns(LInstruction *ins); michael@0: void spewLIR(MIRGraph *mir); michael@0: void spewIntervals(LinearScanAllocator *regalloc); michael@0: void endPass(); michael@0: void endFunction(); michael@0: void finish(); michael@0: }; michael@0: michael@0: } // namespace jit michael@0: } // namespace js michael@0: michael@0: #endif /* jit_JSONSpewer_h */