#ifndef CallLinkStatus_h
#define CallLinkStatus_h
#include "CallLinkInfo.h"
#include "CodeOrigin.h"
#include "CodeSpecializationKind.h"
#include "ConcurrentJITLock.h"
#include "Intrinsic.h"
#include "JSCJSValue.h"
namespace JSC {
class CodeBlock;
class ExecutableBase;
class InternalFunction;
class JSFunction;
class Structure;
struct CallLinkInfo;
class CallLinkStatus {
public:
CallLinkStatus()
: m_executable(0)
, m_structure(0)
, m_couldTakeSlowPath(false)
, m_isProved(false)
{
}
static CallLinkStatus takesSlowPath()
{
CallLinkStatus result;
result.m_couldTakeSlowPath = true;
return result;
}
explicit CallLinkStatus(JSValue);
CallLinkStatus(ExecutableBase* executable, Structure* structure)
: m_executable(executable)
, m_structure(structure)
, m_couldTakeSlowPath(false)
, m_isProved(false)
{
ASSERT(!!executable == !!structure);
}
CallLinkStatus& setIsProved(bool isProved)
{
m_isProved = isProved;
return *this;
}
static CallLinkStatus computeFor(
CodeBlock*, unsigned bytecodeIndex, const CallLinkInfoMap&);
#if ENABLE(JIT)
static CallLinkStatus computeFor(const ConcurrentJITLocker&, CallLinkInfo&);
#endif
typedef HashMap<CodeOrigin, CallLinkStatus, CodeOriginApproximateHash> ContextMap;
static void computeDFGStatuses(CodeBlock* dfgCodeBlock, ContextMap&);
static CallLinkStatus computeFor(
CodeBlock*, CodeOrigin, const CallLinkInfoMap&, const ContextMap&);
bool isSet() const { return m_callTarget || m_executable || m_couldTakeSlowPath; }
bool operator!() const { return !isSet(); }
bool couldTakeSlowPath() const { return m_couldTakeSlowPath; }
bool isClosureCall() const { return m_executable && !m_callTarget; }
JSValue callTarget() const { return m_callTarget; }
JSFunction* function() const;
InternalFunction* internalFunction() const;
Intrinsic intrinsicFor(CodeSpecializationKind) const;
ExecutableBase* executable() const { return m_executable; }
Structure* structure() const { return m_structure; }
bool isProved() const { return m_isProved; }
bool canOptimize() const { return (m_callTarget || m_executable) && !m_couldTakeSlowPath; }
void dump(PrintStream&) const;
private:
void makeClosureCall()
{
ASSERT(!m_isProved);
m_callTarget = JSValue();
}
static CallLinkStatus computeFromLLInt(const ConcurrentJITLocker&, CodeBlock*, unsigned bytecodeIndex);
JSValue m_callTarget;
ExecutableBase* m_executable;
Structure* m_structure;
bool m_couldTakeSlowPath;
bool m_isProved;
};
}
#endif // CallLinkStatus_h