]>
git.saurik.com Git - apple/javascriptcore.git/blob - dfg/DFGUseKind.h
ebf99dae600c8825d22cbac63822d15b5560035a
2 * Copyright (C) 2013-2015 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
31 #include "DFGNodeFlags.h"
32 #include "SpeculatedType.h"
33 #include <wtf/PrintStream.h>
35 namespace JSC
{ namespace DFG
{
38 // The DFG has 3 representations of values used:
40 // 1. The JSValue representation for a JSValue that must be stored in a GP
41 // register (or a GP register pair), and follows rules for boxing and unboxing
42 // that allow the JSValue to be stored as either fully boxed JSValues, or
43 // unboxed Int32, Booleans, Cells, etc. in 32-bit as appropriate.
44 UntypedUse
, // UntypedUse must come first (value 0).
61 StringOrStringObjectUse
,
67 // 2. The Double representation for an unboxed double value that must be stored
71 DoubleRepMachineIntUse
,
73 // 3. The Int52 representation for an unboxed integer value that must be stored
77 LastUseKind
// Must always be the last entry in the enum, as it is used to denote the number of enum elements.
80 inline SpeculatedType
typeFilterFor(UseKind useKind
)
89 return SpecMachineInt
;
91 return SpecInt32
| SpecInt52AsDouble
;
93 return SpecBytecodeNumber
;
95 return SpecBytecodeRealNumber
;
97 return SpecFullDouble
;
98 case DoubleRepRealUse
:
99 return SpecDoubleReal
;
100 case DoubleRepMachineIntUse
:
101 return SpecInt52AsDouble
;
112 return SpecFinalObject
;
113 case ObjectOrOtherUse
:
114 return SpecObject
| SpecOther
;
116 return SpecStringIdent
;
120 case StringObjectUse
:
121 return SpecStringObject
;
122 case StringOrStringObjectUse
:
123 return SpecString
| SpecStringObject
;
124 case NotStringVarUse
:
125 return ~SpecStringVar
;
133 RELEASE_ASSERT_NOT_REACHED();
138 inline bool shouldNotHaveTypeCheck(UseKind kind
)
153 inline bool mayHaveTypeCheck(UseKind kind
)
155 return !shouldNotHaveTypeCheck(kind
);
158 inline bool isNumerical(UseKind kind
)
167 case DoubleRepRealUse
:
169 case DoubleRepMachineIntUse
:
176 inline bool isDouble(UseKind kind
)
180 case DoubleRepRealUse
:
181 case DoubleRepMachineIntUse
:
188 inline bool isCell(UseKind kind
)
199 case StringObjectUse
:
200 case StringOrStringObjectUse
:
207 // Returns true if it uses structure in a way that could be clobbered by
208 // things that change the structure.
209 inline bool usesStructure(UseKind kind
)
212 case StringObjectUse
:
213 case StringOrStringObjectUse
:
220 // Returns true if we've already guaranteed the type
221 inline bool alreadyChecked(UseKind kind
, SpeculatedType type
)
223 // If the check involves the structure then we need to know more than just the type to be sure
224 // that the check is done.
225 if (usesStructure(kind
))
228 return !(type
& ~typeFilterFor(kind
));
231 inline UseKind
useKindForResult(NodeFlags result
)
233 ASSERT(!(result
& ~NodeResultMask
));
235 case NodeResultInt52
:
237 case NodeResultDouble
:
244 } } // namespace JSC::DFG
248 void printInternal(PrintStream
&, JSC::DFG::UseKind
);
252 #endif // ENABLE(DFG_JIT)
254 #endif // DFGUseKind_h