JSWebAssemblyModule.h [plain text]
#pragma once
#if ENABLE(WEBASSEMBLY)
#include "JSDestructibleObject.h"
#include "JSObject.h"
#include "WasmMemoryMode.h"
#include <wtf/Bag.h>
#include <wtf/Expected.h>
#include <wtf/Forward.h>
#include <wtf/Ref.h>
#include <wtf/text/WTFString.h>
namespace JSC {
namespace Wasm {
class Module;
struct ModuleInformation;
class Plan;
using SignatureIndex = uint64_t;
}
class SymbolTable;
class JSWebAssemblyCodeBlock;
class JSWebAssemblyMemory;
class JSWebAssemblyModule final : public JSNonFinalObject {
public:
using Base = JSNonFinalObject;
static constexpr bool needsDestruction = true;
static void destroy(JSCell*);
template<typename CellType, SubspaceAccess mode>
static IsoSubspace* subspaceFor(VM& vm)
{
return vm.webAssemblyModuleSpace<mode>();
}
DECLARE_EXPORT_INFO;
JS_EXPORT_PRIVATE static JSWebAssemblyModule* createStub(VM&, JSGlobalObject*, Structure*, Expected<RefPtr<Wasm::Module>, String>&&);
static Structure* createStructure(VM&, JSGlobalObject*, JSValue);
const Wasm::ModuleInformation& moduleInformation() const;
SymbolTable* exportSymbolTable() const;
Wasm::SignatureIndex signatureIndexFromFunctionIndexSpace(unsigned functionIndexSpace) const;
JSWebAssemblyCodeBlock* codeBlock(Wasm::MemoryMode mode);
void setCodeBlock(VM&, Wasm::MemoryMode, JSWebAssemblyCodeBlock*);
JS_EXPORT_PRIVATE Wasm::Module& module();
private:
friend class JSWebAssemblyCodeBlock;
JSWebAssemblyModule(VM&, Structure*, Ref<Wasm::Module>&&);
void finishCreation(VM&);
static void visitChildren(JSCell*, SlotVisitor&);
Ref<Wasm::Module> m_module;
WriteBarrier<SymbolTable> m_exportSymbolTable;
WriteBarrier<JSWebAssemblyCodeBlock> m_codeBlocks[Wasm::NumberOfMemoryModes];
};
}
#endif // ENABLE(WEBASSEMBLY)