JSWebAssemblyCodeBlock.h [plain text]
#pragma once
#if ENABLE(WEBASSEMBLY)
#include "CallLinkInfo.h"
#include "JSCPoison.h"
#include "JSCast.h"
#include "PromiseDeferredTimer.h"
#include "Structure.h"
#include "WasmCallee.h"
#include "WasmFormat.h"
#include "WasmModule.h"
#include <wtf/Bag.h>
#include <wtf/PoisonedUniquePtr.h>
#include <wtf/Ref.h>
#include <wtf/Vector.h>
namespace JSC {
class JSWebAssemblyMemory;
namespace Wasm {
class Plan;
}
class JSWebAssemblyCodeBlock final : public JSCell {
public:
typedef JSCell Base;
static const unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal;
static JSWebAssemblyCodeBlock* create(VM&, Ref<Wasm::CodeBlock>, const Wasm::ModuleInformation&);
static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
return Structure::create(vm, globalObject, prototype, TypeInfo(CellType, StructureFlags), info());
}
template<typename CellType>
static IsoSubspace* subspaceFor(VM& vm)
{
return &vm.webAssemblyCodeBlockSpace;
}
Wasm::CodeBlock& codeBlock() { return m_codeBlock.get(); }
MacroAssemblerCodePtr<WasmEntryPtrTag> wasmToEmbedderStub(size_t importFunctionNum) { return m_wasmToJSExitStubs[importFunctionNum].code(); }
void finishCreation(VM&);
void clearJSCallICs(VM&);
bool runnable() const { return !m_errorMessage; }
String errorMessage()
{
ASSERT(!runnable());
return m_errorMessage;
}
void finalizeUnconditionally(VM&);
private:
JSWebAssemblyCodeBlock(VM&, Ref<Wasm::CodeBlock>&&, const Wasm::ModuleInformation&);
DECLARE_EXPORT_INFO;
static const bool needsDestruction = true;
static void destroy(JSCell*);
static void visitChildren(JSCell*, SlotVisitor&);
PoisonedRef<JSWebAssemblyCodeBlockPoison, Wasm::CodeBlock> m_codeBlock;
Vector<MacroAssemblerCodeRef<WasmEntryPtrTag>> m_wasmToJSExitStubs;
Bag<CallLinkInfo> m_callLinkInfos;
String m_errorMessage;
};
}
#endif // ENABLE(WEBASSEMBLY)