2 * Copyright (C) 2014 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.
26 #ifndef DFGPureValue_h
27 #define DFGPureValue_h
33 namespace JSC
{ namespace DFG
{
43 PureValue(NodeType op
, const AdjacencyList
& children
, uintptr_t info
)
45 , m_children(children
.sanitized())
48 ASSERT(!(defaultFlags(op
) & NodeHasVarArgs
));
51 PureValue(NodeType op
, const AdjacencyList
& children
, const void* ptr
)
52 : PureValue(op
, children
, bitwise_cast
<uintptr_t>(ptr
))
56 PureValue(NodeType op
, const AdjacencyList
& children
)
57 : PureValue(op
, children
, static_cast<uintptr_t>(0))
61 PureValue(Node
* node
, uintptr_t info
)
62 : PureValue(node
->op(), node
->children
, info
)
66 PureValue(Node
* node
, const void* ptr
)
67 : PureValue(node
->op(), node
->children
, ptr
)
72 : PureValue(node
->op(), node
->children
)
76 PureValue(WTF::HashTableDeletedValueType
)
82 bool operator!() const { return m_op
== LastNodeType
&& !m_info
; }
84 NodeType
op() const { return m_op
; }
85 const AdjacencyList
& children() const { return m_children
; }
86 uintptr_t info() const { return m_info
; }
90 return WTF::IntHash
<int>::hash(static_cast<int>(m_op
)) + m_children
.hash() + m_info
;
93 bool operator==(const PureValue
& other
) const
95 return m_op
== other
.m_op
96 && m_children
== other
.m_children
97 && m_info
== other
.m_info
;
100 bool isHashTableDeletedValue() const
102 return m_op
== LastNodeType
&& m_info
;
105 void dump(PrintStream
& out
) const;
109 AdjacencyList m_children
;
113 struct PureValueHash
{
114 static unsigned hash(const PureValue
& key
) { return key
.hash(); }
115 static bool equal(const PureValue
& a
, const PureValue
& b
) { return a
== b
; }
116 static const bool safeToCompareToEmptyOrDeleted
= true;
119 } } // namespace JSC::DFG
123 template<typename T
> struct DefaultHash
;
124 template<> struct DefaultHash
<JSC::DFG::PureValue
> {
125 typedef JSC::DFG::PureValueHash Hash
;
128 template<typename T
> struct HashTraits
;
129 template<> struct HashTraits
<JSC::DFG::PureValue
> : SimpleClassHashTraits
<JSC::DFG::PureValue
> {
130 static const bool emptyValueIsZero
= false;
135 namespace JSC
{ namespace DFG
{
137 typedef HashMap
<PureValue
, Node
*> PureMap
;
138 typedef HashMap
<PureValue
, Vector
<Node
*>> PureMultiMap
;
140 } } // namespace JSC::DFG
142 #endif // ENABLE(DFG_JIT)
144 #endif // DFGPureValue_h