#ifndef wasm_cranelift_baldrapi_h
#define wasm_cranelift_baldrapi_h
#include <inttypes.h>
#include <stdbool.h>
#include <stddef.h>
#include "wasm/WasmConstants.h"
namespace js {
namespace wasm {
struct FuncCompileInput;
class GlobalDesc;
struct FuncTypeWithId;
struct TableDesc;
struct ModuleEnvironment;
} }
struct CraneliftStaticEnvironment {
bool hasSse2;
bool hasSse3;
bool hasSse41;
bool hasSse42;
bool hasPopcnt;
bool hasAvx;
bool hasBmi1;
bool hasBmi2;
bool hasLzcnt;
size_t staticMemoryBound;
size_t memoryGuardSize;
size_t instanceTlsOffset;
size_t interruptTlsOffset;
size_t cxTlsOffset;
size_t realmCxOffset;
size_t realmTlsOffset;
size_t realmFuncImportTlsOffset;
inline CraneliftStaticEnvironment();
};
struct CraneliftModuleEnvironment {
const js::wasm::ModuleEnvironment* env;
uint32_t min_memory_length;
explicit inline CraneliftModuleEnvironment(
const js::wasm::ModuleEnvironment& env);
};
struct CraneliftFuncCompileInput {
const uint8_t* bytecode;
size_t bytecodeSize;
uint32_t index;
uint32_t offset_in_module;
explicit inline CraneliftFuncCompileInput(const js::wasm::FuncCompileInput&);
};
struct CraneliftMetadataEntry {
enum Which {
DirectCall,
IndirectCall,
Trap,
MemoryAccess,
SymbolicAccess
} which;
uint32_t offset; uint32_t srcLoc; size_t extra;
};
struct CraneliftCompiledFunc {
size_t numMetadata;
const CraneliftMetadataEntry* metadatas;
size_t framePushed;
bool containsCalls;
size_t codeSize;
const uint8_t* code;
};
struct BD_ConstantValue {
js::wasm::TypeCode t;
union {
int32_t i32;
int64_t i64;
float f32;
double f64;
} u;
};
struct BD_ValType {
uint32_t packed;
};
enum class BD_SymbolicAddress {
MemoryGrow,
MemorySize,
FloorF32,
FloorF64,
CeilF32,
CeilF64,
NearestF32,
NearestF64,
TruncF32,
TruncF64,
Limit
};
extern "C" {
js::wasm::TypeCode env_unpack(BD_ValType type);
const js::wasm::FuncTypeWithId* env_function_signature(
const CraneliftModuleEnvironment* env, size_t funcIndex);
size_t env_func_import_tls_offset(const CraneliftModuleEnvironment* env,
size_t funcIndex);
bool env_func_is_import(const CraneliftModuleEnvironment* env,
size_t funcIndex);
const js::wasm::FuncTypeWithId* env_signature(
const CraneliftModuleEnvironment* env, size_t sigIndex);
const js::wasm::TableDesc* env_table(const CraneliftModuleEnvironment* env,
size_t tableIndex);
const js::wasm::GlobalDesc* env_global(const CraneliftModuleEnvironment* env,
size_t globalIndex);
bool global_isConstant(const js::wasm::GlobalDesc*);
bool global_isIndirect(const js::wasm::GlobalDesc*);
BD_ConstantValue global_constantValue(const js::wasm::GlobalDesc*);
js::wasm::TypeCode global_type(const js::wasm::GlobalDesc*);
size_t global_tlsOffset(const js::wasm::GlobalDesc*);
size_t table_tlsOffset(const js::wasm::TableDesc*);
size_t funcType_numArgs(const js::wasm::FuncTypeWithId*);
const BD_ValType* funcType_args(const js::wasm::FuncTypeWithId*);
js::wasm::TypeCode funcType_retType(const js::wasm::FuncTypeWithId*);
js::wasm::FuncTypeIdDescKind funcType_idKind(const js::wasm::FuncTypeWithId*);
size_t funcType_idImmediate(const js::wasm::FuncTypeWithId*);
size_t funcType_idTlsOffset(const js::wasm::FuncTypeWithId*);
}
#endif