2 * Copyright (C) 2013, 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.
32 #include "DFGNodeAllocator.h"
33 #include "DFGPromotedHeapLocation.h"
34 #include "JSCInlines.h"
36 namespace JSC
{ namespace DFG
{
38 bool MultiPutByOffsetData::writesStructures() const
40 for (unsigned i
= variants
.size(); i
--;) {
41 if (variants
[i
].writesStructures())
47 bool MultiPutByOffsetData::reallocatesStorage() const
49 for (unsigned i
= variants
.size(); i
--;) {
50 if (variants
[i
].reallocatesStorage())
56 void BranchTarget::dump(PrintStream
& out
) const
63 if (count
== count
) // If the count is not NaN, then print it.
64 out
.print("/w:", count
);
67 unsigned Node::index() const
69 return NodeAllocator::allocatorOf(this)->indexOf(this);
72 bool Node::hasVariableAccessData(Graph
& graph
)
76 return graph
.m_form
!= SSA
;
90 ASSERT(!(flags() & NodeHasVarArgs
));
92 children
= children
.justChecks();
94 setOpAndDefaultFlags(Check
);
97 void Node::convertToIdentity()
99 RELEASE_ASSERT(child1());
100 RELEASE_ASSERT(!child2());
101 NodeFlags result
= canonicalResultRepresentation(this->result());
102 setOpAndDefaultFlags(Identity
);
106 void Node::convertToIdentityOn(Node
* child
)
109 child1() = child
->defaultEdge();
110 NodeFlags output
= canonicalResultRepresentation(this->result());
111 NodeFlags input
= canonicalResultRepresentation(child
->result());
112 if (output
== input
) {
113 setOpAndDefaultFlags(Identity
);
118 case NodeResultDouble
:
119 setOpAndDefaultFlags(DoubleRep
);
121 case NodeResultInt52
:
122 child1().setUseKind(Int52RepUse
);
125 child1().setUseKind(NumberUse
);
128 RELEASE_ASSERT_NOT_REACHED();
131 case NodeResultInt52
:
132 setOpAndDefaultFlags(Int52Rep
);
134 case NodeResultDouble
:
135 child1().setUseKind(DoubleRepMachineIntUse
);
138 child1().setUseKind(MachineIntUse
);
141 RELEASE_ASSERT_NOT_REACHED();
145 setOpAndDefaultFlags(ValueRep
);
147 case NodeResultDouble
:
148 child1().setUseKind(DoubleRepUse
);
150 case NodeResultInt52
:
151 child1().setUseKind(Int52RepUse
);
154 RELEASE_ASSERT_NOT_REACHED();
158 RELEASE_ASSERT_NOT_REACHED();
163 void Node::convertToPutHint(const PromotedLocationDescriptor
& descriptor
, Node
* base
, Node
* value
)
166 m_opInfo
= descriptor
.imm1().m_value
;
167 m_opInfo2
= descriptor
.imm2().m_value
;
168 child1() = base
->defaultEdge();
169 child2() = value
->defaultEdge();
173 void Node::convertToPutStructureHint(Node
* structure
)
175 ASSERT(m_op
== PutStructure
);
176 ASSERT(structure
->castConstant
<Structure
*>() == transition()->next
);
177 convertToPutHint(StructurePLoc
, child1().node(), structure
);
180 void Node::convertToPutByOffsetHint()
182 ASSERT(m_op
== PutByOffset
);
184 PromotedLocationDescriptor(NamedPropertyPLoc
, storageAccessData().identifierNumber
),
185 child2().node(), child3().node());
188 void Node::convertToPutClosureVarHint()
190 ASSERT(m_op
== PutClosureVar
);
192 PromotedLocationDescriptor(ClosureVarPLoc
, scopeOffset().offset()),
193 child1().node(), child2().node());
196 PromotedLocationDescriptor
Node::promotedLocationDescriptor()
198 return PromotedLocationDescriptor(static_cast<PromotedLocationKind
>(m_opInfo
), m_opInfo2
);
201 } } // namespace JSC::DFG
206 using namespace JSC::DFG
;
208 void printInternal(PrintStream
& out
, SwitchKind kind
)
212 out
.print("SwitchImm");
215 out
.print("SwitchChar");
218 out
.print("SwitchString");
221 out
.print("SwitchCell");
224 RELEASE_ASSERT_NOT_REACHED();
227 void printInternal(PrintStream
& out
, Node
* node
)
233 out
.print("@", node
->index());
234 if (node
->hasDoubleResult())
235 out
.print("<Double>");
236 else if (node
->hasInt52Result())
237 out
.print("<Int52>");
242 #endif // ENABLE(DFG_JIT)