js/src/jit/JSONSpewer.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit/JSONSpewer.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,77 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     1.5 + * vim: set ts=8 sts=4 et sw=4 tw=99:
     1.6 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef jit_JSONSpewer_h
    1.11 +#define jit_JSONSpewer_h
    1.12 +
    1.13 +#include "mozilla/NullPtr.h"
    1.14 +
    1.15 +#include <stdio.h>
    1.16 +
    1.17 +#include "js/TypeDecls.h"
    1.18 +
    1.19 +namespace js {
    1.20 +namespace jit {
    1.21 +
    1.22 +class MDefinition;
    1.23 +class MInstruction;
    1.24 +class MBasicBlock;
    1.25 +class MIRGraph;
    1.26 +class MResumePoint;
    1.27 +class LinearScanAllocator;
    1.28 +class LInstruction;
    1.29 +
    1.30 +class JSONSpewer
    1.31 +{
    1.32 +  private:
    1.33 +    // Set by beginFunction(); unset by endFunction().
    1.34 +    // Used to correctly format output in case of abort during compilation.
    1.35 +    bool inFunction_;
    1.36 +
    1.37 +    int indentLevel_;
    1.38 +    bool first_;
    1.39 +    FILE *fp_;
    1.40 +
    1.41 +    void indent();
    1.42 +
    1.43 +    void property(const char *name);
    1.44 +    void beginObject();
    1.45 +    void beginObjectProperty(const char *name);
    1.46 +    void beginListProperty(const char *name);
    1.47 +    void stringValue(const char *format, ...);
    1.48 +    void stringProperty(const char *name, const char *format, ...);
    1.49 +    void integerValue(int value);
    1.50 +    void integerProperty(const char *name, int value);
    1.51 +    void endObject();
    1.52 +    void endList();
    1.53 +
    1.54 +  public:
    1.55 +    JSONSpewer()
    1.56 +      : inFunction_(false),
    1.57 +        indentLevel_(0),
    1.58 +        first_(true),
    1.59 +        fp_(nullptr)
    1.60 +    { }
    1.61 +    ~JSONSpewer();
    1.62 +
    1.63 +    bool init(const char *path);
    1.64 +    void beginFunction(JSScript *script);
    1.65 +    void beginPass(const char * pass);
    1.66 +    void spewMDef(MDefinition *def);
    1.67 +    void spewMResumePoint(MResumePoint *rp);
    1.68 +    void spewMIR(MIRGraph *mir);
    1.69 +    void spewLIns(LInstruction *ins);
    1.70 +    void spewLIR(MIRGraph *mir);
    1.71 +    void spewIntervals(LinearScanAllocator *regalloc);
    1.72 +    void endPass();
    1.73 +    void endFunction();
    1.74 +    void finish();
    1.75 +};
    1.76 +
    1.77 +} // namespace jit
    1.78 +} // namespace js
    1.79 +
    1.80 +#endif /* jit_JSONSpewer_h */

mercurial