From 6cd8c2b33c631b79a66e74c45d89f8f341155914 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 18 Jul 2024 21:41:22 +0900 Subject: [PATCH] Remove a few hardcoded spec test knowledge from the core library tweak the stack sizes in the spec test runner instead. --- core/iwasm/aot/aot_runtime.c | 11 +---------- core/iwasm/interpreter/wasm_runtime.c | 11 +---------- .../spec-test-script/runtest.py | 18 ++++++++++++------ 3 files changed, 14 insertions(+), 26 deletions(-) diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index bfe691ea28..7e8799e05f 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -1748,16 +1748,7 @@ aot_instantiate(AOTModule *module, AOTModuleInstance *parent, /* Initialize the thread related data */ if (stack_size == 0) stack_size = DEFAULT_WASM_STACK_SIZE; -#if WASM_ENABLE_SPEC_TEST != 0 -#if WASM_ENABLE_TAIL_CALL == 0 - if (stack_size < 128 * 1024) - stack_size = 128 * 1024; -#else - /* Some tail-call cases require large operand stack */ - if (stack_size < 10 * 1024 * 1024) - stack_size = 10 * 1024 * 1024; -#endif -#endif + module_inst->default_wasm_stack_size = stack_size; extra->stack_sizes = diff --git a/core/iwasm/interpreter/wasm_runtime.c b/core/iwasm/interpreter/wasm_runtime.c index 0d4d0b37d4..f3b9b2e822 100644 --- a/core/iwasm/interpreter/wasm_runtime.c +++ b/core/iwasm/interpreter/wasm_runtime.c @@ -2990,16 +2990,7 @@ wasm_instantiate(WASMModule *module, WASMModuleInstance *parent, /* Initialize the thread related data */ if (stack_size == 0) stack_size = DEFAULT_WASM_STACK_SIZE; -#if WASM_ENABLE_SPEC_TEST != 0 -#if WASM_ENABLE_TAIL_CALL == 0 - if (stack_size < 128 * 1024) - stack_size = 128 * 1024; -#else - /* Some tail-call cases require large operand stack */ - if (stack_size < 10 * 1024 * 1024) - stack_size = 10 * 1024 * 1024; -#endif -#endif + module_inst->default_wasm_stack_size = stack_size; if (module->malloc_function != (uint32)-1) { diff --git a/tests/wamr-test-suites/spec-test-script/runtest.py b/tests/wamr-test-suites/spec-test-script/runtest.py index 2713c49405..c5d763ef59 100755 --- a/tests/wamr-test-suites/spec-test-script/runtest.py +++ b/tests/wamr-test-suites/spec-test-script/runtest.py @@ -1159,13 +1159,19 @@ def run_wasm_with_repl(wasm_tempfile, aot_tempfile, opts, r): if opts.qemu: tmpfile = f"/tmp/{os.path.basename(tmpfile)}" - if opts.verbose: - cmd_iwasm = [opts.interpreter, "--heap-size=0", "-v=5", "--repl", tmpfile] - else: - cmd_iwasm = [opts.interpreter, "--heap-size=0", "--repl", tmpfile] - + cmd_iwasm = [opts.interpreter, "--heap-size=0", "--repl"] if opts.multi_module: - cmd_iwasm.insert(1, "--module-path=" + (tempfile.gettempdir() if not opts.qemu else "/tmp" )) + cmd_iwasm.append("--module-path=" + (tempfile.gettempdir() if not opts.qemu else "/tmp" )) + if opts.gc: + # our tail-call implementation is known broken. + # work it around by using a huge stack. + # cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/2231 + cmd_iwasm.append("--stack-size=10485760") # 10MB (!) + else: + cmd_iwasm.append("--stack-size=131072") # 128KB + if opts.verbose: + cmd_iwasm.append("-v=5") + cmd_iwasm.append(tmpfile) if opts.qemu: if opts.qemu_firmware == '':