]>
Commit | Line | Data |
---|---|---|
93a37866 | 1 | /* |
81345200 | 2 | * Copyright (C) 2013, 2014 Apple Inc. All rights reserved. |
93a37866 A |
3 | * |
4 | * Redistribution and use in source and binary forms, with or without | |
5 | * modification, are permitted provided that the following conditions | |
6 | * are met: | |
7 | * 1. Redistributions of source code must retain the above copyright | |
8 | * notice, this list of conditions and the following disclaimer. | |
9 | * 2. Redistributions in binary form must reproduce the above copyright | |
10 | * notice, this list of conditions and the following disclaimer in the | |
11 | * documentation and/or other materials provided with the distribution. | |
12 | * | |
13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | |
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR | |
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | |
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
24 | */ | |
25 | ||
26 | #ifndef DFGUseKind_h | |
27 | #define DFGUseKind_h | |
28 | ||
93a37866 A |
29 | #if ENABLE(DFG_JIT) |
30 | ||
81345200 | 31 | #include "DFGNodeFlags.h" |
93a37866 A |
32 | #include "SpeculatedType.h" |
33 | #include <wtf/PrintStream.h> | |
34 | ||
35 | namespace JSC { namespace DFG { | |
36 | ||
37 | enum UseKind { | |
38 | UntypedUse, | |
39 | Int32Use, | |
40 | KnownInt32Use, | |
81345200 A |
41 | Int52RepUse, |
42 | MachineIntUse, | |
93a37866 | 43 | NumberUse, |
81345200 A |
44 | DoubleRepUse, |
45 | DoubleRepRealUse, | |
46 | DoubleRepMachineIntUse, | |
93a37866 A |
47 | BooleanUse, |
48 | CellUse, | |
49 | KnownCellUse, | |
50 | ObjectUse, | |
81345200 | 51 | FinalObjectUse, |
93a37866 | 52 | ObjectOrOtherUse, |
81345200 | 53 | StringIdentUse, |
93a37866 A |
54 | StringUse, |
55 | KnownStringUse, | |
56 | StringObjectUse, | |
57 | StringOrStringObjectUse, | |
81345200 | 58 | NotStringVarUse, |
93a37866 A |
59 | NotCellUse, |
60 | OtherUse, | |
81345200 | 61 | MiscUse, |
93a37866 A |
62 | LastUseKind // Must always be the last entry in the enum, as it is used to denote the number of enum elements. |
63 | }; | |
64 | ||
81345200 | 65 | inline SpeculatedType typeFilterFor(UseKind useKind) |
93a37866 A |
66 | { |
67 | switch (useKind) { | |
68 | case UntypedUse: | |
81345200 | 69 | return SpecFullTop; |
93a37866 A |
70 | case Int32Use: |
71 | case KnownInt32Use: | |
72 | return SpecInt32; | |
81345200 A |
73 | case Int52RepUse: |
74 | return SpecMachineInt; | |
75 | case MachineIntUse: | |
76 | return SpecInt32 | SpecInt52AsDouble; | |
93a37866 | 77 | case NumberUse: |
81345200 A |
78 | return SpecBytecodeNumber; |
79 | case DoubleRepUse: | |
80 | return SpecFullDouble; | |
81 | case DoubleRepRealUse: | |
82 | return SpecDoubleReal; | |
83 | case DoubleRepMachineIntUse: | |
84 | return SpecInt52AsDouble; | |
93a37866 A |
85 | case BooleanUse: |
86 | return SpecBoolean; | |
87 | case CellUse: | |
88 | case KnownCellUse: | |
89 | return SpecCell; | |
90 | case ObjectUse: | |
91 | return SpecObject; | |
81345200 A |
92 | case FinalObjectUse: |
93 | return SpecFinalObject; | |
93a37866 A |
94 | case ObjectOrOtherUse: |
95 | return SpecObject | SpecOther; | |
81345200 A |
96 | case StringIdentUse: |
97 | return SpecStringIdent; | |
93a37866 A |
98 | case StringUse: |
99 | case KnownStringUse: | |
100 | return SpecString; | |
101 | case StringObjectUse: | |
102 | return SpecStringObject; | |
103 | case StringOrStringObjectUse: | |
104 | return SpecString | SpecStringObject; | |
81345200 A |
105 | case NotStringVarUse: |
106 | return ~SpecStringVar; | |
93a37866 A |
107 | case NotCellUse: |
108 | return ~SpecCell; | |
109 | case OtherUse: | |
110 | return SpecOther; | |
81345200 A |
111 | case MiscUse: |
112 | return SpecMisc; | |
93a37866 A |
113 | default: |
114 | RELEASE_ASSERT_NOT_REACHED(); | |
81345200 | 115 | return SpecFullTop; |
93a37866 A |
116 | } |
117 | } | |
118 | ||
81345200 A |
119 | inline bool shouldNotHaveTypeCheck(UseKind kind) |
120 | { | |
121 | switch (kind) { | |
122 | case UntypedUse: | |
123 | case KnownInt32Use: | |
124 | case KnownCellUse: | |
125 | case KnownStringUse: | |
126 | case Int52RepUse: | |
127 | case DoubleRepUse: | |
128 | return true; | |
129 | default: | |
130 | return false; | |
131 | } | |
132 | } | |
133 | ||
134 | inline bool mayHaveTypeCheck(UseKind kind) | |
135 | { | |
136 | return !shouldNotHaveTypeCheck(kind); | |
137 | } | |
138 | ||
139 | inline bool isNumerical(UseKind kind) | |
93a37866 A |
140 | { |
141 | switch (kind) { | |
142 | case Int32Use: | |
143 | case KnownInt32Use: | |
93a37866 | 144 | case NumberUse: |
81345200 A |
145 | case Int52RepUse: |
146 | case DoubleRepUse: | |
147 | case DoubleRepRealUse: | |
148 | case MachineIntUse: | |
149 | case DoubleRepMachineIntUse: | |
150 | return true; | |
151 | default: | |
152 | return false; | |
153 | } | |
154 | } | |
155 | ||
156 | inline bool isDouble(UseKind kind) | |
157 | { | |
158 | switch (kind) { | |
159 | case DoubleRepUse: | |
160 | case DoubleRepRealUse: | |
161 | case DoubleRepMachineIntUse: | |
162 | return true; | |
163 | default: | |
164 | return false; | |
165 | } | |
166 | } | |
167 | ||
168 | inline bool isCell(UseKind kind) | |
169 | { | |
170 | switch (kind) { | |
171 | case CellUse: | |
172 | case KnownCellUse: | |
173 | case ObjectUse: | |
174 | case FinalObjectUse: | |
175 | case StringIdentUse: | |
176 | case StringUse: | |
177 | case KnownStringUse: | |
178 | case StringObjectUse: | |
179 | case StringOrStringObjectUse: | |
93a37866 A |
180 | return true; |
181 | default: | |
182 | return false; | |
183 | } | |
184 | } | |
185 | ||
81345200 A |
186 | // Returns true if it uses structure in a way that could be clobbered by |
187 | // things that change the structure. | |
188 | inline bool usesStructure(UseKind kind) | |
189 | { | |
190 | switch (kind) { | |
191 | case StringObjectUse: | |
192 | case StringOrStringObjectUse: | |
193 | return true; | |
194 | default: | |
195 | return false; | |
196 | } | |
197 | } | |
198 | ||
199 | inline UseKind useKindForResult(NodeFlags result) | |
200 | { | |
201 | ASSERT(!(result & ~NodeResultMask)); | |
202 | switch (result) { | |
203 | case NodeResultInt52: | |
204 | return Int52RepUse; | |
205 | case NodeResultDouble: | |
206 | return DoubleRepUse; | |
207 | default: | |
208 | return UntypedUse; | |
209 | } | |
210 | } | |
211 | ||
93a37866 A |
212 | } } // namespace JSC::DFG |
213 | ||
214 | namespace WTF { | |
215 | ||
216 | void printInternal(PrintStream&, JSC::DFG::UseKind); | |
217 | ||
218 | } // namespace WTF | |
219 | ||
220 | #endif // ENABLE(DFG_JIT) | |
221 | ||
222 | #endif // DFGUseKind_h | |
223 |