skip to content
==> include/wasm/validate.h <==
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
13
14#include "wasm/module.h"
15
16#include <stdbool.h>
17#include <stddef.h>
18
19typedef 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;
23
24/* 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);
27
28/* The proposal names in wasmparser's refusals ("SIMD", "sign extension operations"). */
29const char *wasm_feature_name(wasm_features f);
30
31#endif