#ifndef DFGBasicBlock_h
#define DFGBasicBlock_h
#if ENABLE(DFG_JIT)
#include "DFGAbstractValue.h"
#include "DFGBranchDirection.h"
#include "DFGNode.h"
#include "DFGVariadicFunction.h"
#include "Operands.h"
#include <wtf/OwnPtr.h>
#include <wtf/Vector.h>
namespace JSC { namespace DFG {
class Graph;
typedef Vector <BlockIndex, 2> PredecessorList;
struct BasicBlock : Vector<Node*, 8> {
BasicBlock(unsigned bytecodeBegin, unsigned numArguments, unsigned numLocals)
: bytecodeBegin(bytecodeBegin)
, isOSRTarget(false)
, cfaHasVisited(false)
, cfaShouldRevisit(false)
, cfaFoundConstants(false)
, cfaDidFinish(true)
, cfaBranchDirection(InvalidBranchDirection)
#if !ASSERT_DISABLED
, isLinked(false)
#endif
, isReachable(false)
, variablesAtHead(numArguments, numLocals)
, variablesAtTail(numArguments, numLocals)
, valuesAtHead(numArguments, numLocals)
, valuesAtTail(numArguments, numLocals)
{
}
~BasicBlock()
{
}
void ensureLocals(unsigned newNumLocals)
{
variablesAtHead.ensureLocals(newNumLocals);
variablesAtTail.ensureLocals(newNumLocals);
valuesAtHead.ensureLocals(newNumLocals);
valuesAtTail.ensureLocals(newNumLocals);
}
size_t numNodes() const { return phis.size() + size(); }
Node* node(size_t i) const
{
if (i < phis.size())
return phis[i];
return at(i - phis.size());
}
bool isPhiIndex(size_t i) const { return i < phis.size(); }
bool isInPhis(Node* node) const
{
for (size_t i = 0; i < phis.size(); ++i) {
if (phis[i] == node)
return true;
}
return false;
}
bool isInBlock(Node* myNode) const
{
for (size_t i = 0; i < numNodes(); ++i) {
if (node(i) == myNode)
return true;
}
return false;
}
#define DFG_DEFINE_APPEND_NODE(templatePre, templatePost, typeParams, valueParamsComma, valueParams, valueArgs) \
templatePre typeParams templatePost Node* appendNode(Graph&, SpeculatedType valueParamsComma valueParams);
DFG_VARIADIC_TEMPLATE_FUNCTION(DFG_DEFINE_APPEND_NODE)
#undef DFG_DEFINE_APPEND_NODE
unsigned bytecodeBegin;
bool isOSRTarget;
bool cfaHasVisited;
bool cfaShouldRevisit;
bool cfaFoundConstants;
bool cfaDidFinish;
BranchDirection cfaBranchDirection;
#if !ASSERT_DISABLED
bool isLinked;
#endif
bool isReachable;
Vector<Node*> phis;
PredecessorList m_predecessors;
Operands<Node*, NodePointerTraits> variablesAtHead;
Operands<Node*, NodePointerTraits> variablesAtTail;
Operands<AbstractValue> valuesAtHead;
Operands<AbstractValue> valuesAtTail;
};
struct UnlinkedBlock {
BlockIndex m_blockIndex;
bool m_needsNormalLinking;
bool m_needsEarlyReturnLinking;
UnlinkedBlock() { }
explicit UnlinkedBlock(BlockIndex blockIndex)
: m_blockIndex(blockIndex)
, m_needsNormalLinking(true)
, m_needsEarlyReturnLinking(false)
{
}
};
} }
#endif // ENABLE(DFG_JIT)
#endif // DFGBasicBlock_h