#include "config.h"
#include "FTLOSRExit.h"
#if ENABLE(FTL_JIT)
#include "AirGenerationContext.h"
#include "B3StackmapGenerationParams.h"
#include "B3StackmapValue.h"
#include "CodeBlock.h"
#include "DFGBasicBlock.h"
#include "DFGNode.h"
#include "FTLExitArgument.h"
#include "FTLJITCode.h"
#include "FTLLocation.h"
#include "FTLState.h"
#include "JSCInlines.h"
namespace JSC { namespace FTL {
using namespace B3;
using namespace DFG;
OSRExitDescriptor::OSRExitDescriptor(
DataFormat profileDataFormat, MethodOfGettingAValueProfile valueProfile,
unsigned numberOfArguments, unsigned numberOfLocals)
: m_profileDataFormat(profileDataFormat)
, m_valueProfile(valueProfile)
, m_values(numberOfArguments, numberOfLocals)
{
}
void OSRExitDescriptor::validateReferences(const TrackedReferences& trackedReferences)
{
for (unsigned i = m_values.size(); i--;)
m_values[i].validateReferences(trackedReferences);
for (ExitTimeObjectMaterialization* materialization : m_materializations)
materialization->validateReferences(trackedReferences);
}
Ref<OSRExitHandle> OSRExitDescriptor::emitOSRExit(
State& state, ExitKind exitKind, const NodeOrigin& nodeOrigin, CCallHelpers& jit,
const StackmapGenerationParams& params, unsigned offset)
{
Ref<OSRExitHandle> handle =
prepareOSRExitHandle(state, exitKind, nodeOrigin, params, offset);
handle->emitExitThunk(state, jit);
return handle;
}
Ref<OSRExitHandle> OSRExitDescriptor::emitOSRExitLater(
State& state, ExitKind exitKind, const NodeOrigin& nodeOrigin,
const StackmapGenerationParams& params, unsigned offset)
{
RefPtr<OSRExitHandle> handle =
prepareOSRExitHandle(state, exitKind, nodeOrigin, params, offset);
params.addLatePath(
[handle, &state] (CCallHelpers& jit) {
handle->emitExitThunk(state, jit);
});
return handle.releaseNonNull();
}
Ref<OSRExitHandle> OSRExitDescriptor::prepareOSRExitHandle(
State& state, ExitKind exitKind, const NodeOrigin& nodeOrigin,
const StackmapGenerationParams& params, unsigned offset)
{
unsigned index = state.jitCode->osrExit.size();
OSRExit& exit = state.jitCode->osrExit.alloc(
this, exitKind, nodeOrigin.forExit, nodeOrigin.semantic, nodeOrigin.wasHoisted);
Ref<OSRExitHandle> handle = adoptRef(*new OSRExitHandle(index, exit));
for (unsigned i = offset; i < params.size(); ++i)
exit.m_valueReps.append(params[i]);
exit.m_valueReps.shrinkToFit();
return handle;
}
OSRExit::OSRExit(
OSRExitDescriptor* descriptor, ExitKind exitKind, CodeOrigin codeOrigin,
CodeOrigin codeOriginForExitProfile, bool wasHoisted)
: OSRExitBase(exitKind, codeOrigin, codeOriginForExitProfile, wasHoisted)
, m_descriptor(descriptor)
{
}
CodeLocationJump<JSInternalPtrTag> OSRExit::codeLocationForRepatch(CodeBlock* ftlCodeBlock) const
{
UNUSED_PARAM(ftlCodeBlock);
return m_patchableJump;
}
} }
#endif // ENABLE(FTL_JIT)