DFGJITFinalizer.cpp [plain text]
#include "config.h"
#include "DFGJITFinalizer.h"
#if ENABLE(DFG_JIT)
#include "CodeBlock.h"
#include "DFGCommon.h"
#include "DFGPlan.h"
#include "JSCInlines.h"
#include "ProfilerDatabase.h"
namespace JSC { namespace DFG {
JITFinalizer::JITFinalizer(Plan& plan, PassRefPtr<JITCode> jitCode, PassOwnPtr<LinkBuffer> linkBuffer, MacroAssemblerCodePtr withArityCheck)
: Finalizer(plan)
, m_jitCode(jitCode)
, m_linkBuffer(linkBuffer)
, m_withArityCheck(withArityCheck)
{
}
JITFinalizer::~JITFinalizer()
{
}
size_t JITFinalizer::codeSize()
{
return m_linkBuffer->size();
}
bool JITFinalizer::finalize()
{
m_jitCode->initializeCodeRef(
m_linkBuffer->finalizeCodeWithoutDisassembly(), MacroAssemblerCodePtr());
m_plan.codeBlock->setJITCode(m_jitCode);
finalizeCommon();
return true;
}
bool JITFinalizer::finalizeFunction()
{
RELEASE_ASSERT(!m_withArityCheck.isEmptyValue());
m_jitCode->initializeCodeRef(
m_linkBuffer->finalizeCodeWithoutDisassembly(), m_withArityCheck);
m_plan.codeBlock->setJITCode(m_jitCode);
finalizeCommon();
return true;
}
void JITFinalizer::finalizeCommon()
{
#if ENABLE(FTL_JIT)
m_jitCode->optimizeAfterWarmUp(m_plan.codeBlock.get());
#endif // ENABLE(FTL_JIT)
if (m_plan.compilation)
m_plan.vm.m_perBytecodeProfiler->addCompilation(m_plan.compilation);
if (!m_plan.willTryToTierUp)
m_plan.codeBlock->baselineVersion()->m_didFailFTLCompilation = true;
}
} }
#endif // ENABLE(DFG_JIT)