JSWebAssemblyTable.h [plain text]
#pragma once
#if ENABLE(WEBASSEMBLY)
#include "JSCPoison.h"
#include "JSDestructibleObject.h"
#include "JSObject.h"
#include "WasmLimits.h"
#include "WasmTable.h"
#include "WebAssemblyWrapperFunction.h"
#include "WebAssemblyFunction.h"
#include <wtf/MallocPtr.h>
#include <wtf/Ref.h>
namespace JSC {
class JSWebAssemblyTable final : public JSDestructibleObject {
public:
typedef JSDestructibleObject Base;
static JSWebAssemblyTable* create(ExecState*, VM&, Structure*, Ref<Wasm::Table>&&);
static Structure* createStructure(VM&, JSGlobalObject*, JSValue);
DECLARE_INFO;
static bool isValidLength(uint32_t length) { return Wasm::Table::isValidLength(length); }
Optional<uint32_t> maximum() const { return m_table->maximum(); }
uint32_t length() const { return m_table->length(); }
uint32_t allocatedLength() const { return m_table->allocatedLength(length()); }
bool grow(uint32_t delta) WARN_UNUSED_RETURN;
JSObject* getFunction(uint32_t);
void clearFunction(uint32_t);
void setFunction(VM&, uint32_t, WebAssemblyFunction*);
void setFunction(VM&, uint32_t, WebAssemblyWrapperFunction*);
Wasm::Table* table() { return m_table.ptr(); }
private:
JSWebAssemblyTable(VM&, Structure*, Ref<Wasm::Table>&&);
void finishCreation(VM&);
static void destroy(JSCell*);
static void visitChildren(JSCell*, SlotVisitor&);
PoisonedRef<JSWebAssemblyTablePoison, Wasm::Table> m_table;
template<typename T>
using PoisonedBarrier = PoisonedWriteBarrier<JSWebAssemblyTablePoison, T>;
MallocPtr<PoisonedBarrier<JSObject>> m_jsFunctions;
};
}
#endif // ENABLE(WEBASSEMBLY)