]>
git.saurik.com Git - apple/javascriptcore.git/blob - dfg/DFGAdjacencyList.h
2 * Copyright (C) 2011 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 DFGAdjacencyList_h
27 #define DFGAdjacencyList_h
29 #include <wtf/Platform.h>
33 #include "DFGCommon.h"
36 namespace JSC
{ namespace DFG
{
45 AdjacencyList(Kind kind
)
50 if (kind
== Variable
) {
51 m_words
[0].m_encodedWord
= UINT_MAX
;
52 m_words
[1].m_encodedWord
= UINT_MAX
;
56 AdjacencyList(Kind kind
, NodeIndex child1
, NodeIndex child2
, NodeIndex child3
)
61 ASSERT_UNUSED(kind
, kind
== Fixed
);
62 initialize(child1
, child2
, child3
);
65 AdjacencyList(Kind kind
, unsigned firstChild
, unsigned numChildren
)
70 ASSERT_UNUSED(kind
, kind
== Variable
);
71 setFirstChild(firstChild
);
72 setNumChildren(numChildren
);
75 const Edge
& child(unsigned i
) const
78 ASSERT(m_kind
== Fixed
);
82 Edge
& child(unsigned i
)
85 ASSERT(m_kind
== Fixed
);
89 void setChild(unsigned i
, Edge nodeUse
)
92 ASSERT(m_kind
== Fixed
);
96 Edge
child1() const { return child(0); }
97 Edge
child2() const { return child(1); }
98 Edge
child3() const { return child(2); }
100 Edge
& child1() { return child(0); }
101 Edge
& child2() { return child(1); }
102 Edge
& child3() { return child(2); }
104 void setChild1(Edge nodeUse
) { setChild(0, nodeUse
); }
105 void setChild2(Edge nodeUse
) { setChild(1, nodeUse
); }
106 void setChild3(Edge nodeUse
) { setChild(2, nodeUse
); }
108 Edge
child1Unchecked() const { return m_words
[0]; }
110 void initialize(Edge child1
, Edge child2
, Edge child3
)
117 void initialize(NodeIndex child1
, NodeIndex child2
, NodeIndex child3
)
119 initialize(Edge(child1
), Edge(child2
), Edge(child3
));
122 unsigned firstChild() const
124 ASSERT(m_kind
== Variable
);
125 return m_words
[0].m_encodedWord
;
127 void setFirstChild(unsigned firstChild
)
129 ASSERT(m_kind
== Variable
);
130 m_words
[0].m_encodedWord
= firstChild
;
133 unsigned numChildren() const
135 ASSERT(m_kind
== Variable
);
136 return m_words
[1].m_encodedWord
;
138 void setNumChildren(unsigned numChildren
)
140 ASSERT(m_kind
== Variable
);
141 m_words
[1].m_encodedWord
= numChildren
;
151 } } // namespace JSC::DFG
153 #endif // ENABLE(DFG_JIT)
155 #endif // DFGAdjacencyList_h