Truly independent web browser
LibWasm: Quote the JS API limits that the parser and validator enforce
Tim Ledbetter25747ed80030
diff --git a/Libraries/LibWasm/Module/src/parser.rs b/Libraries/LibWasm/Module/src/parser.rsindex 9ec8470e0fb..5c11c6b6e7b 100644--- a/Libraries/LibWasm/Module/src/parser.rs+++ b/Libraries/LibWasm/Module/src/parser.rs@@ -20,8 +20,8 @@ use crate::types::{SubType, TableType, TagType, ValType,};-/// The largest a function body may be, its local declarations included, as the JS API's implementation limits say.-/// This bounds how many values the function's operand stack can hold, and so its frame size.+// https://webassembly.github.io/spec/js-api/#limits+// The maximum size of a function body, including locals declarations, is 7,654,321 bytes.const MAX_FUNCTION_SIZE: u32 = 7_654_321;const SECTION_CUSTOM: u8 = 0;diff --git a/Libraries/LibWasm/Module/src/validator.rs b/Libraries/LibWasm/Module/src/validator.rsindex 77bf3d58be2..a094673d97e 100644--- a/Libraries/LibWasm/Module/src/validator.rs+++ b/Libraries/LibWasm/Module/src/validator.rs@@ -139,14 +139,14 @@ impl FunctionInfo {const MEMORY32_MAX_PAGES: u64 = 1 << 16;const MEMORY64_MAX_PAGES: u64 = 1 << 48;-/// The most locals a function may have, its parameters included, as the JS API's implementation limits say. Every-/// local takes a slot of the function's machine stack frame, so this bounds the frame size a module can ask for.-const MAX_FUNCTION_LOCALS: usize = 50_000;+// https://webassembly.github.io/spec/js-api/#limits-/// The most supertypes a type may have above it, as the JS API's implementation limits say. Runtime types hold all of-/// their supertypes, and subtype checks walk them.+// The maximum depth of a defined subtype hierarchy is 63 (where a type defined with no supertype has depth 0).const MAX_SUBTYPING_DEPTH: u32 = 63;+// The maximum number of locals declared in a function, including implicitly declared as parameters, is 50,000.+const MAX_FUNCTION_LOCALS: usize = 50_000;+fn invalid<T>(message: impl Into<String>) -> Result<T> {Err(Error::invalid(message))}