]>
git.saurik.com Git - apple/javascriptcore.git/blob - dfg/DFGAvailability.h
2 * Copyright (C) 2013 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 DFGAvailability_h
27 #define DFGAvailability_h
31 #include "DFGFlushedAt.h"
32 #include "DFGVariableAccessData.h"
34 namespace JSC
{ namespace DFG
{
42 , m_flushedAt(DeadFlush
)
46 explicit Availability(Node
* node
)
48 , m_flushedAt(ConflictingFlush
)
52 explicit Availability(FlushedAt flushedAt
)
53 : m_node(unavailableMarker())
54 , m_flushedAt(flushedAt
)
58 Availability(Node
* node
, FlushedAt flushedAt
)
60 , m_flushedAt(flushedAt
)
64 static Availability
unavailable()
66 return Availability(unavailableMarker(), FlushedAt(ConflictingFlush
));
69 Availability
withFlush(FlushedAt flush
) const
71 return Availability(m_node
, flush
);
74 Availability
withNode(Node
* node
) const
76 return Availability(node
, m_flushedAt
);
79 Availability
withUnavailableNode() const
81 return withNode(unavailableMarker());
84 bool nodeIsUndecided() const { return !m_node
; }
85 bool nodeIsUnavailable() const { return m_node
== unavailableMarker(); }
87 bool hasNode() const { return !nodeIsUndecided() && !nodeIsUnavailable(); }
91 ASSERT(!nodeIsUndecided());
92 ASSERT(!nodeIsUnavailable());
96 FlushedAt
flushedAt() const { return m_flushedAt
; }
98 bool operator!() const { return nodeIsUnavailable() && flushedAt().format() == ConflictingFlush
; }
100 bool operator==(const Availability
& other
) const
102 return m_node
== other
.m_node
103 && m_flushedAt
== other
.m_flushedAt
;
106 Availability
merge(const Availability
& other
) const
109 mergeNodes(m_node
, other
.m_node
),
110 m_flushedAt
.merge(other
.m_flushedAt
));
113 void dump(PrintStream
&) const;
114 void dumpInContext(PrintStream
&, DumpContext
*) const;
117 static Node
* mergeNodes(Node
* a
, Node
* b
)
125 return unavailableMarker();
128 static Node
* unavailableMarker()
130 return bitwise_cast
<Node
*>(static_cast<intptr_t>(1));
134 FlushedAt m_flushedAt
;
137 } } // namespace JSC::DFG
139 #endif // ENABLE(DFG_JIT)
141 #endif // DFGAvailability_h