#include "config.h"
#include "FTLState.h"
#if ENABLE(FTL_JIT)
#include "CodeBlockWithJITType.h"
#include "FTLForOSREntryJITCode.h"
#include "FTLJITCode.h"
#include "FTLJITFinalizer.h"
#include <llvm/InitializeLLVM.h>
#include <stdio.h>
#if ENABLE(FTL_NATIVE_CALL_INLINING)
#include "InlineRuntimeSymbolTable.h"
#endif
namespace JSC { namespace FTL {
using namespace DFG;
State::State(Graph& graph)
: graph(graph)
, context(llvm->ContextCreate())
, module(0)
, function(0)
, generatedFunction(0)
, handleStackOverflowExceptionStackmapID(UINT_MAX)
, handleExceptionStackmapID(UINT_MAX)
, capturedStackmapID(UINT_MAX)
, varargsSpillSlotsStackmapID(UINT_MAX)
, unwindDataSection(0)
, unwindDataSectionSize(0)
{
#if ENABLE(FTL_NATIVE_CALL_INLINING)
#define SYMBOL_TABLE_ADD(symbol, file) \
symbolTable.fastAdd(symbol, file);
FOR_EACH_LIBRARY_SYMBOL(SYMBOL_TABLE_ADD)
#undef SYMBOL_TABLE_ADD
#endif
switch (graph.m_plan.mode) {
case FTLMode: {
jitCode = adoptRef(new JITCode());
break;
}
case FTLForOSREntryMode: {
RefPtr<ForOSREntryJITCode> code = adoptRef(new ForOSREntryJITCode());
code->initializeEntryBuffer(graph.m_vm, graph.m_profiledBlock->m_numCalleeRegisters);
code->setBytecodeIndex(graph.m_plan.osrEntryBytecodeIndex);
jitCode = code;
break;
}
default:
RELEASE_ASSERT_NOT_REACHED();
break;
}
graph.m_plan.finalizer = std::make_unique<JITFinalizer>(graph.m_plan);
finalizer = static_cast<JITFinalizer*>(graph.m_plan.finalizer.get());
}
State::~State()
{
llvm->ContextDispose(context);
}
void State::dumpState(const char* when)
{
dumpState(module, when);
}
void State::dumpState(LModule module, const char* when)
{
dataLog("LLVM IR for ", CodeBlockWithJITType(graph.m_codeBlock, FTL::JITCode::FTLJIT), " ", when, ":\n");
dumpModule(module);
}
} }
#endif // ENABLE(FTL_JIT)