wasmparser/
limits.rs

1/* Copyright 2017 Mozilla Foundation
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16// The following limits are imposed by wasmparser on WebAssembly modules.
17// The limits are agreed upon with other engines for consistency.
18pub const MAX_WASM_TYPES: usize = 1_000_000;
19pub const MAX_WASM_FUNCTIONS: usize = 1_000_000;
20pub const MAX_WASM_EXPORTS: usize = 100_000;
21pub const MAX_WASM_GLOBALS: usize = 1_000_000;
22pub const MAX_WASM_ELEMENT_SEGMENTS: usize = 100_000;
23pub const MAX_WASM_DATA_SEGMENTS: usize = 100_000;
24pub const MAX_WASM_MEMORY32_PAGES: u64 = 65536;
25pub const MAX_WASM_MEMORY64_PAGES: u64 = 1 << 48;
26pub const MAX_WASM_STRING_SIZE: usize = 100_000;
27pub const MAX_WASM_FUNCTION_SIZE: usize = 128 * 1024;
28pub const MAX_WASM_FUNCTION_LOCALS: usize = 50000;
29pub const MAX_WASM_FUNCTION_PARAMS: usize = 1000;
30pub const MAX_WASM_FUNCTION_RETURNS: usize = 1000;
31pub const _MAX_WASM_TABLE_SIZE: usize = 10_000_000;
32pub const MAX_WASM_TABLE_ENTRIES: usize = 10_000_000;
33pub const MAX_WASM_TABLES: usize = 100;
34pub const MAX_WASM_MEMORIES: usize = 100;
35pub const MAX_WASM_TAGS: usize = 1_000_000;
36pub const MAX_WASM_BR_TABLE_SIZE: usize = MAX_WASM_FUNCTION_SIZE;
37
38// Component-related limits
39pub const MAX_WASM_MODULE_SIZE: usize = 1024 * 1024 * 1024; //= 1 GiB
40pub const MAX_WASM_MODULE_TYPE_DECLS: usize = 100_000;
41pub const MAX_WASM_COMPONENT_TYPE_DECLS: usize = 100_000;
42pub const MAX_WASM_INSTANCE_TYPE_DECLS: usize = 100_000;
43pub const MAX_WASM_RECORD_FIELDS: usize = 1000;
44pub const MAX_WASM_VARIANT_CASES: usize = 1000;
45pub const MAX_WASM_TUPLE_TYPES: usize = 1000;
46pub const MAX_WASM_FLAG_NAMES: usize = 1000;
47pub const MAX_WASM_ENUM_CASES: usize = 1000;
48pub const MAX_WASM_UNION_TYPES: usize = 1000;
49pub const MAX_WASM_INSTANTIATION_EXPORTS: usize = 1000;
50pub const MAX_WASM_CANONICAL_OPTIONS: usize = 10;
51pub const MAX_WASM_INSTANTIATION_ARGS: usize = 1000;
52pub const MAX_WASM_START_ARGS: usize = 1000;
53pub const MAX_WASM_TYPE_SIZE: u32 = 1_000_000;
54pub const MAX_WASM_MODULES: usize = 1_000;
55pub const MAX_WASM_COMPONENTS: usize = 1_000;
56pub const MAX_WASM_INSTANCES: usize = 1_000;
57pub const MAX_WASM_VALUES: usize = 1_000;