WasmModuleInformation.h [plain text]
#pragma once
#if ENABLE(WEBASSEMBLY)
#include "WasmFormat.h"
namespace JSC { namespace Wasm {
struct ModuleInformation : public ThreadSafeRefCounted<ModuleInformation> {
size_t functionIndexSpaceSize() const { return importFunctionSignatureIndices.size() + internalFunctionSignatureIndices.size(); }
bool isImportedFunctionFromFunctionIndexSpace(size_t functionIndex) const
{
ASSERT(functionIndex < functionIndexSpaceSize());
return functionIndex < importFunctionSignatureIndices.size();
}
SignatureIndex signatureIndexFromFunctionIndexSpace(size_t functionIndex) const
{
return isImportedFunctionFromFunctionIndexSpace(functionIndex)
? importFunctionSignatureIndices[functionIndex]
: internalFunctionSignatureIndices[functionIndex - importFunctionSignatureIndices.size()];
}
uint32_t importFunctionCount() const { return importFunctionSignatureIndices.size(); }
uint32_t internalFunctionCount() const { return internalFunctionSignatureIndices.size(); }
ModuleInformation(Vector<uint8_t>&& sourceBytes)
: source(WTFMove(sourceBytes))
{
}
JS_EXPORT_PRIVATE ~ModuleInformation();
const Vector<uint8_t> source;
Vector<Import> imports;
Vector<SignatureIndex> importFunctionSignatureIndices;
Vector<SignatureIndex> internalFunctionSignatureIndices;
Vector<Ref<Signature>> usedSignatures;
MemoryInformation memory;
Vector<FunctionLocationInBinary> functionLocationInBinary;
Vector<Export> exports;
std::optional<uint32_t> startFunctionIndexSpace;
Vector<Segment::Ptr> data;
Vector<Element> elements;
TableInformation tableInformation;
Vector<Global> globals;
unsigned firstInternalGlobal { 0 };
Vector<CustomSection> customSections;
NameSection nameSection;
};
} }
#endif // ENABLE(WEBASSEMBLY)