FTLJITFinalizer.cpp [plain text]
#include "config.h"
#include "FTLJITFinalizer.h"
#if ENABLE(FTL_JIT)
#include "CodeBlockWithJITType.h"
#include "DFGPlan.h"
#include "FTLState.h"
#include "FTLThunks.h"
#include "JSCInlines.h"
#include "ProfilerDatabase.h"
namespace JSC { namespace FTL {
JITFinalizer::JITFinalizer(DFG::Plan& plan)
: Finalizer(plan)
{
}
JITFinalizer::~JITFinalizer()
{
}
size_t JITFinalizer::codeSize()
{
size_t result = 0;
if (b3CodeLinkBuffer)
result += b3CodeLinkBuffer->size();
if (entrypointLinkBuffer)
result += entrypointLinkBuffer->size();
return result;
}
bool JITFinalizer::finalize()
{
return finalizeCommon();
}
bool JITFinalizer::finalizeFunction()
{
return finalizeCommon();
}
bool JITFinalizer::finalizeCommon()
{
bool dumpDisassembly = shouldDumpDisassembly() || Options::asyncDisassembly();
MacroAssemblerCodeRef<JSEntryPtrTag> b3CodeRef =
FINALIZE_CODE_IF(dumpDisassembly, *b3CodeLinkBuffer, JSEntryPtrTag,
"FTL B3 code for %s", toCString(CodeBlockWithJITType(m_plan.codeBlock, JITCode::FTLJIT)).data());
MacroAssemblerCodeRef<JSEntryPtrTag> arityCheckCodeRef = entrypointLinkBuffer
? FINALIZE_CODE_IF(dumpDisassembly, *entrypointLinkBuffer, JSEntryPtrTag,
"FTL entrypoint thunk for %s with B3 generated code at %p", toCString(CodeBlockWithJITType(m_plan.codeBlock, JITCode::FTLJIT)).data(), function)
: MacroAssemblerCodeRef<JSEntryPtrTag>::createSelfManagedCodeRef(b3CodeRef.code());
jitCode->initializeB3Code(b3CodeRef);
jitCode->initializeArityCheckEntrypoint(arityCheckCodeRef);
m_plan.codeBlock->setJITCode(*jitCode);
if (UNLIKELY(m_plan.compilation))
m_plan.vm->m_perBytecodeProfiler->addCompilation(m_plan.codeBlock, *m_plan.compilation);
return true;
}
} }
#endif // ENABLE(FTL_JIT)