1/* @ajax/wasm-validate: the spec's validation (chapter 3) of a decoded module, for the proposals in
2 * `features` (wasm/types.h): the module's indices, limits, constant expressions, exports, start,
3 * segments, and a type check of every function body with the spec's algorithm (an operand stack of
4 * types and a stack of control frames). An instruction of a proposal that isn't enabled is refused
5 * the way wasmparser refuses it ("SIMD support is not enabled").
6 *
7 * SIMD instructions are decoded but not type-checked: where SIMD is enabled, a function's type
8 * check stops at its first SIMD instruction and the rest of the body is only walked (for
9 * structure and for instructions of proposals that aren't enabled). The interpreter runs no SIMD,
10 * so it never runs such a function. */
11#ifndef WASM_VALIDATE_H
12#define WASM_VALIDATE_H
1314#include "wasm/module.h"
1516#include <stdbool.h>
17#include <stddef.h>
1819typedef struct {
20 bool uses_simd; /* some body holds a SIMD instruction */
21 bool uses_threads; /* a shared memory or an atomic instruction */
22} wasm_validate_report;
2324/* true when m is valid under features; else err holds "<what> (at offset 0x<n>)". report may be NULL. */
25bool wasm_validate(const wasm_module *m, wasm_features features, wasm_validate_report *report, char *err,
26 size_t errlen);
2728/* The proposal names in wasmparser's refusals ("SIMD", "sign extension operations"). */
29const char *wasm_feature_name(wasm_features f);
3031#endif