JSWebAssemblyModule.h [plain text]
#pragma once
#if ENABLE(WEBASSEMBLY)
#include "JSCPoison.h"
#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 = uint32_t;
}
class SymbolTable;
class JSWebAssemblyCodeBlock;
class JSWebAssemblyMemory;
class WebAssemblyToJSCallee;
class JSWebAssemblyModule final : public JSDestructibleObject {
public:
typedef JSDestructibleObject Base;
DECLARE_EXPORT_INFO;
JS_EXPORT_PRIVATE static JSWebAssemblyModule* createStub(VM&, ExecState*, 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;
WebAssemblyToJSCallee* callee() const;
JSWebAssemblyCodeBlock* codeBlock(Wasm::MemoryMode mode);
void setCodeBlock(VM&, Wasm::MemoryMode, JSWebAssemblyCodeBlock*);
const Vector<uint8_t>& source() const;
JS_EXPORT_PRIVATE Wasm::Module& module();
private:
friend class JSWebAssemblyCodeBlock;
JSWebAssemblyModule(VM&, Structure*, Ref<Wasm::Module>&&);
void finishCreation(VM&);
static void destroy(JSCell*);
static void visitChildren(JSCell*, SlotVisitor&);
PoisonedRef<JSWebAssemblyModulePoison, Wasm::Module> m_module;
template<typename T>
using PoisonedBarrier = PoisonedWriteBarrier<JSWebAssemblyModulePoison, T>;
PoisonedBarrier<SymbolTable> m_exportSymbolTable;
PoisonedBarrier<JSWebAssemblyCodeBlock> m_codeBlocks[Wasm::NumberOfMemoryModes];
PoisonedBarrier<WebAssemblyToJSCallee> m_callee;
};
}
#endif // ENABLE(WEBASSEMBLY)