|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
|
2 * vim: set ts=8 sts=4 et sw=4 tw=99: |
|
3 * This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 #ifndef jit_JSONSpewer_h |
|
8 #define jit_JSONSpewer_h |
|
9 |
|
10 #include "mozilla/NullPtr.h" |
|
11 |
|
12 #include <stdio.h> |
|
13 |
|
14 #include "js/TypeDecls.h" |
|
15 |
|
16 namespace js { |
|
17 namespace jit { |
|
18 |
|
19 class MDefinition; |
|
20 class MInstruction; |
|
21 class MBasicBlock; |
|
22 class MIRGraph; |
|
23 class MResumePoint; |
|
24 class LinearScanAllocator; |
|
25 class LInstruction; |
|
26 |
|
27 class JSONSpewer |
|
28 { |
|
29 private: |
|
30 // Set by beginFunction(); unset by endFunction(). |
|
31 // Used to correctly format output in case of abort during compilation. |
|
32 bool inFunction_; |
|
33 |
|
34 int indentLevel_; |
|
35 bool first_; |
|
36 FILE *fp_; |
|
37 |
|
38 void indent(); |
|
39 |
|
40 void property(const char *name); |
|
41 void beginObject(); |
|
42 void beginObjectProperty(const char *name); |
|
43 void beginListProperty(const char *name); |
|
44 void stringValue(const char *format, ...); |
|
45 void stringProperty(const char *name, const char *format, ...); |
|
46 void integerValue(int value); |
|
47 void integerProperty(const char *name, int value); |
|
48 void endObject(); |
|
49 void endList(); |
|
50 |
|
51 public: |
|
52 JSONSpewer() |
|
53 : inFunction_(false), |
|
54 indentLevel_(0), |
|
55 first_(true), |
|
56 fp_(nullptr) |
|
57 { } |
|
58 ~JSONSpewer(); |
|
59 |
|
60 bool init(const char *path); |
|
61 void beginFunction(JSScript *script); |
|
62 void beginPass(const char * pass); |
|
63 void spewMDef(MDefinition *def); |
|
64 void spewMResumePoint(MResumePoint *rp); |
|
65 void spewMIR(MIRGraph *mir); |
|
66 void spewLIns(LInstruction *ins); |
|
67 void spewLIR(MIRGraph *mir); |
|
68 void spewIntervals(LinearScanAllocator *regalloc); |
|
69 void endPass(); |
|
70 void endFunction(); |
|
71 void finish(); |
|
72 }; |
|
73 |
|
74 } // namespace jit |
|
75 } // namespace js |
|
76 |
|
77 #endif /* jit_JSONSpewer_h */ |