|
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_IonAnalysis_h |
|
8 #define jit_IonAnalysis_h |
|
9 |
|
10 #ifdef JS_ION |
|
11 |
|
12 // This file declares various analysis passes that operate on MIR. |
|
13 |
|
14 #include "jit/IonAllocPolicy.h" |
|
15 #include "jit/MIR.h" |
|
16 |
|
17 namespace js { |
|
18 namespace jit { |
|
19 |
|
20 class MIRGenerator; |
|
21 class MIRGraph; |
|
22 |
|
23 bool |
|
24 SplitCriticalEdges(MIRGraph &graph); |
|
25 |
|
26 enum Observability { |
|
27 ConservativeObservability, |
|
28 AggressiveObservability |
|
29 }; |
|
30 |
|
31 bool |
|
32 EliminatePhis(MIRGenerator *mir, MIRGraph &graph, Observability observe); |
|
33 |
|
34 bool |
|
35 EliminateDeadResumePointOperands(MIRGenerator *mir, MIRGraph &graph); |
|
36 |
|
37 bool |
|
38 EliminateDeadCode(MIRGenerator *mir, MIRGraph &graph); |
|
39 |
|
40 bool |
|
41 ApplyTypeInformation(MIRGenerator *mir, MIRGraph &graph); |
|
42 |
|
43 bool |
|
44 MakeMRegExpHoistable(MIRGraph &graph); |
|
45 |
|
46 bool |
|
47 RenumberBlocks(MIRGraph &graph); |
|
48 |
|
49 bool |
|
50 BuildDominatorTree(MIRGraph &graph); |
|
51 |
|
52 bool |
|
53 BuildPhiReverseMapping(MIRGraph &graph); |
|
54 |
|
55 void |
|
56 AssertBasicGraphCoherency(MIRGraph &graph); |
|
57 |
|
58 void |
|
59 AssertGraphCoherency(MIRGraph &graph); |
|
60 |
|
61 void |
|
62 AssertExtendedGraphCoherency(MIRGraph &graph); |
|
63 |
|
64 bool |
|
65 EliminateRedundantChecks(MIRGraph &graph); |
|
66 |
|
67 bool |
|
68 UnsplitEdges(LIRGraph *lir); |
|
69 |
|
70 class MDefinition; |
|
71 |
|
72 // Simple linear sum of the form 'n' or 'x + n'. |
|
73 struct SimpleLinearSum |
|
74 { |
|
75 MDefinition *term; |
|
76 int32_t constant; |
|
77 |
|
78 SimpleLinearSum(MDefinition *term, int32_t constant) |
|
79 : term(term), constant(constant) |
|
80 {} |
|
81 }; |
|
82 |
|
83 SimpleLinearSum |
|
84 ExtractLinearSum(MDefinition *ins); |
|
85 |
|
86 bool |
|
87 ExtractLinearInequality(MTest *test, BranchDirection direction, |
|
88 SimpleLinearSum *plhs, MDefinition **prhs, bool *plessEqual); |
|
89 |
|
90 struct LinearTerm |
|
91 { |
|
92 MDefinition *term; |
|
93 int32_t scale; |
|
94 |
|
95 LinearTerm(MDefinition *term, int32_t scale) |
|
96 : term(term), scale(scale) |
|
97 { |
|
98 } |
|
99 }; |
|
100 |
|
101 // General linear sum of the form 'x1*n1 + x2*n2 + ... + n' |
|
102 class LinearSum |
|
103 { |
|
104 public: |
|
105 LinearSum(TempAllocator &alloc) |
|
106 : terms_(alloc), |
|
107 constant_(0) |
|
108 { |
|
109 } |
|
110 |
|
111 LinearSum(const LinearSum &other) |
|
112 : terms_(other.terms_.allocPolicy()), |
|
113 constant_(other.constant_) |
|
114 { |
|
115 terms_.appendAll(other.terms_); |
|
116 } |
|
117 |
|
118 bool multiply(int32_t scale); |
|
119 bool add(const LinearSum &other); |
|
120 bool add(MDefinition *term, int32_t scale); |
|
121 bool add(int32_t constant); |
|
122 |
|
123 int32_t constant() const { return constant_; } |
|
124 size_t numTerms() const { return terms_.length(); } |
|
125 LinearTerm term(size_t i) const { return terms_[i]; } |
|
126 |
|
127 void print(Sprinter &sp) const; |
|
128 void dump(FILE *) const; |
|
129 void dump() const; |
|
130 |
|
131 private: |
|
132 Vector<LinearTerm, 2, IonAllocPolicy> terms_; |
|
133 int32_t constant_; |
|
134 }; |
|
135 |
|
136 bool |
|
137 AnalyzeNewScriptProperties(JSContext *cx, JSFunction *fun, |
|
138 types::TypeObject *type, HandleObject baseobj, |
|
139 Vector<types::TypeNewScript::Initializer> *initializerList); |
|
140 |
|
141 bool |
|
142 AnalyzeArgumentsUsage(JSContext *cx, JSScript *script); |
|
143 |
|
144 } // namespace jit |
|
145 } // namespace js |
|
146 |
|
147 #endif // JS_ION |
|
148 |
|
149 #endif /* jit_IonAnalysis_h */ |