From 1fb845d7ae17e952ae36a603b669bf2b7459f50e Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Mon, 24 Jul 2023 12:57:26 +0200 Subject: [PATCH] Reuse validator allocations --- packages/vm/src/static_analysis.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/vm/src/static_analysis.rs b/packages/vm/src/static_analysis.rs index 3a43140009..f3e5804427 100644 --- a/packages/vm/src/static_analysis.rs +++ b/packages/vm/src/static_analysis.rs @@ -33,12 +33,15 @@ pub fn validate_wasm<'a>( ..Default::default() }); + let mut fun_allocations = Default::default(); for p in Parser::new(0).parse_all(wasm_code) { let p = p?; // validate the payload if let ValidPayload::Func(fv, body) = validator.payload(&p)? { // also validate function bodies - fv.into_validator(Default::default()).validate(&body)?; + let mut fun_validator = fv.into_validator(fun_allocations); + fun_validator.validate(&body)?; + fun_allocations = fun_validator.into_allocations(); } // tell caller about the payload handle_payload(p)?;