From 059397bac8c67877da5e030d745c7a31f493fa18 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 8 Jun 2023 21:06:17 +0900 Subject: [PATCH] switch to jinja2 --- ..._locals.wast.in => many_locals.wast.jinja} | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) rename wast/{many_locals.wast.in => many_locals.wast.jinja} (64%) diff --git a/wast/many_locals.wast.in b/wast/many_locals.wast.jinja similarity index 64% rename from wast/many_locals.wast.in rename to wast/many_locals.wast.jinja index addec120..b8be31c0 100644 --- a/wast/many_locals.wast.in +++ b/wast/many_locals.wast.jinja @@ -6,18 +6,22 @@ ;; wasmparser: MAX_WASM_FUNCTION_LOCALS = 50000 ;; https://github.com/bytecodealliance/wasm-tools/blob/5e8639a37260cdc1aab196f5ae5c7ae6427c214f/crates/wasmparser/src/limits.rs#L28 -define(`_repeat',`ifelse(eval($1<=$2),1,`$3`'$0(incr($1),$2,`$3')')')dnl -define(`repeat',`_repeat(1,$1,``$2'')')dnl +;; jinja2 -DNUM=1000000 many_locals.wast.jinja > many_locals1000000.wast +;; jinja2 -DNUM=100000000 many_locals.wast.jinja | wast2json -o many_locals.json - +;; for larger NUM, probably it's simpler to modify LEB128 in the binary. + +{% set NUM = NUM | default(70000) | int %} (module (func (export "func_with_many_locals") (param i32) (result i32) - ;; 70000 locals -repeat(70000,` - (local i32)') - + (local + {% for x in range(NUM) -%} + i32 + {% endfor %} + ) (local.get 0) - (local.set 70000) - (local.get 70000) + (local.set {{NUM}}) + (local.get {{NUM}}) ) )