1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/// Standard 4-byte WebAssembly binary magic header (`\0asm`).
pub const WASM_BINARY_MAGIC: & = &;
/// Standard 4-byte WebAssembly MVP binary version (`1`).
pub const WASM_BINARY_VERSION: & = &;
/// Current euv dynamic WASM host ABI contract version.
pub const WASM_ABI_VERSION: u32 = 1;
/// Default maximum downloadable `.wasm` binary size (`8 MiB`).
pub const WASM_DEFAULT_MAX_BINARY_BYTES: usize = 8 * 1024 * 1024;
/// Default maximum WASM linear memory ceiling (`4 MiB`).
pub const WASM_DEFAULT_MAX_MEMORY_BYTES: usize = 4 * 1024 * 1024;
/// Default per-invocation instruction fuel budget preventing infinite loops.
pub const WASM_DEFAULT_MAX_FUEL: u64 = 100_000;
/// Default network download timeout in milliseconds.
pub const WASM_DEFAULT_TIMEOUT_MS: u64 = 15_000;
/// Default transient download retry attempts before failing or serving cache.
pub const WASM_DEFAULT_MAX_RETRIES: u32 = 2;
/// WASM linear memory page size in bytes (`64 KiB`).
pub const WASM_PAGE_BYTES: usize = 65_536;
/// Exported render entrypoint function name inside dynamic `.wasm` modules.
pub const WASM_EXPORT_RENDER: &str = "euv_render";
/// Exported interactive event handler function name inside dynamic `.wasm` modules.
pub const WASM_EXPORT_ON_EVENT: &str = "euv_on_event";
/// Exported ABI version query function name inside dynamic `.wasm` modules.
pub const WASM_EXPORT_ABI: &str = "euv_abi_version";
/// Host import function emitting a partial `DynamicNodeSpec` JSON buffer from WASM memory.
pub const WASM_IMPORT_EMIT_UI: &str = "euv_emit_ui";
/// Host import function emitting a global `DynamicUpdateBundle` JSON buffer from WASM memory.
pub const WASM_IMPORT_EMIT_BUNDLE: &str = "euv_emit_bundle";
/// Host import function recording a diagnostic log line from WASM memory.
pub const WASM_IMPORT_LOG: &str = "euv_log";
/// Host import module namespace expected by euv dynamic `.wasm` modules.
pub const WASM_IMPORT_MODULE_ENV: &str = "env";
/// Reserved global dynamic WASM root slot identifier.
pub const WASM_GLOBAL_ROOT_SLOT: &str = "__euv_global_wasm_root__";
/// Custom section name carrying optional signed metadata.
pub const WASM_CUSTOM_META_SECTION: &str = "euv.wasm.meta";
/// WebAssembly custom section ID (`0`).
pub const WASM_SEC_CUSTOM: u8 = 0;
/// WebAssembly type section ID (`1`).
pub const WASM_SEC_TYPE: u8 = 1;
/// WebAssembly import section ID (`2`).
pub const WASM_SEC_IMPORT: u8 = 2;
/// WebAssembly function section ID (`3`).
pub const WASM_SEC_FUNCTION: u8 = 3;
/// WebAssembly memory section ID (`5`).
pub const WASM_SEC_MEMORY: u8 = 5;
/// WebAssembly export section ID (`7`).
pub const WASM_SEC_EXPORT: u8 = 7;
/// WebAssembly code section ID (`10`).
pub const WASM_SEC_CODE: u8 = 10;
/// WebAssembly data section ID (`11`).
pub const WASM_SEC_DATA: u8 = 11;
/// WebAssembly opcode: `unreachable`.
pub const OP_UNREACHABLE: u8 = 0x00;
/// WebAssembly opcode: `nop`.
pub const OP_NOP: u8 = 0x01;
/// WebAssembly opcode: `block`.
pub const OP_BLOCK: u8 = 0x02;
/// WebAssembly opcode: `loop`.
pub const OP_LOOP: u8 = 0x03;
/// WebAssembly opcode: `if`.
pub const OP_IF: u8 = 0x04;
/// WebAssembly opcode: `else`.
pub const OP_ELSE: u8 = 0x05;
/// WebAssembly opcode: `end`.
pub const OP_END: u8 = 0x0B;
/// WebAssembly opcode: `br`.
pub const OP_BR: u8 = 0x0C;
/// WebAssembly opcode: `br_if`.
pub const OP_BR_IF: u8 = 0x0D;
/// WebAssembly opcode: `return`.
pub const OP_RETURN: u8 = 0x0F;
/// WebAssembly opcode: `call`.
pub const OP_CALL: u8 = 0x10;
/// WebAssembly opcode: `drop`.
pub const OP_DROP: u8 = 0x1A;
/// WebAssembly opcode: `local.get`.
pub const OP_LOCAL_GET: u8 = 0x20;
/// WebAssembly opcode: `local.set`.
pub const OP_LOCAL_SET: u8 = 0x21;
/// WebAssembly opcode: `i32.load`.
pub const OP_I32_LOAD: u8 = 0x28;
/// WebAssembly opcode: `i32.store`.
pub const OP_I32_STORE: u8 = 0x36;
/// WebAssembly opcode: `i32.const`.
pub const OP_I32_CONST: u8 = 0x41;
/// WebAssembly opcode: `i32.eqz`.
pub const OP_I32_EQZ: u8 = 0x45;
/// WebAssembly opcode: `i32.eq`.
pub const OP_I32_EQ: u8 = 0x46;
/// WebAssembly opcode: `i32.ne`.
pub const OP_I32_NE: u8 = 0x47;
/// WebAssembly opcode: `i32.lt_s`.
pub const OP_I32_LT_S: u8 = 0x48;
/// WebAssembly opcode: `i32.gt_s`.
pub const OP_I32_GT_S: u8 = 0x4A;
/// WebAssembly opcode: `i32.add`.
pub const OP_I32_ADD: u8 = 0x6A;
/// WebAssembly opcode: `i32.sub`.
pub const OP_I32_SUB: u8 = 0x6B;
/// WebAssembly opcode: `i32.mul`.
pub const OP_I32_MUL: u8 = 0x6C;
/// WebAssembly opcode: `i32.div_s`.
pub const OP_I32_DIV_S: u8 = 0x6D;
/// WebAssembly `i32` value type tag (`0x7F`).
pub const WASM_VALTYPE_I32: u8 = 0x7F;
/// WebAssembly function type tag (`0x60`).
pub const WASM_FUNCTYPE_TAG: u8 = 0x60;
/// Signing salt prefix used by `compute_wasm_signature`.
pub const WASM_SIGNATURE_PREFIX: &str = "euv-sig-v1:";
/// Supported `http://` URL scheme prefix for native WASM downloads.
pub const WASM_SCHEME_HTTP: &str = "http://";
/// Supported `file://` URL scheme prefix for local WASM bundles.
pub const WASM_SCHEME_FILE: &str = "file://";
/// Diagnostic message when `WasmDynamicManager` encounters a conflicting interior borrow.
pub const WASM_ERR_MANAGER_BORROW: &str = "manager borrow";
/// Diagnostic message when a WASM binary opcode encounters a value stack underflow.
pub const WASM_ERR_STACK_BINOP: &str = "stack underflow on binop";