#pragma once
#if ENABLE(WEBASSEMBLY)
#include "WasmEntryPlan.h"
#include "WasmFunctionCodeBlock.h"
namespace JSC {
class CallLinkInfo;
namespace Wasm {
class LLIntCallee;
class EmbedderEntrypointCallee;
using EmbedderEntrypointCalleeMap = HashMap<uint32_t, RefPtr<EmbedderEntrypointCallee>, DefaultHash<uint32_t>, WTF::UnsignedWithZeroKeyHashTraits<uint32_t>>;
class LLIntPlan final : public EntryPlan {
using Base = EntryPlan;
public:
JS_EXPORT_PRIVATE LLIntPlan(Context*, Vector<uint8_t>&&, AsyncWork, CompletionTask&&);
LLIntPlan(Context*, Ref<ModuleInformation>, const Ref<LLIntCallee>*, CompletionTask&&);
MacroAssemblerCodeRef<B3CompilationPtrTag>&& takeEntryThunks()
{
RELEASE_ASSERT(!failed() && !hasWork());
return WTFMove(m_entryThunks);
}
Vector<Ref<LLIntCallee>>&& takeCallees()
{
RELEASE_ASSERT(!failed() && !hasWork());
return WTFMove(m_calleesVector);
}
EmbedderEntrypointCalleeMap&& takeEmbedderCallees()
{
RELEASE_ASSERT(!failed() && !hasWork());
return WTFMove(m_embedderCallees);
}
bool hasWork() const final
{
return m_state < State::Compiled;
}
void work(CompilationEffort) final;
bool didReceiveFunctionData(unsigned, const FunctionData&) final;
private:
bool prepareImpl() final;
void compileFunction(uint32_t functionIndex) final;
void didCompleteCompilation(const AbstractLocker&) final;
Vector<std::unique_ptr<FunctionCodeBlock>> m_wasmInternalFunctions;
const Ref<LLIntCallee>* m_callees { nullptr };
Vector<Ref<LLIntCallee>> m_calleesVector;
EmbedderEntrypointCalleeMap m_embedderCallees;
MacroAssemblerCodeRef<B3CompilationPtrTag> m_entryThunks;
};
} }
#endif // ENABLE(WEBASSEMBLY)