Skip to content

Commit 9860256

Browse files
yamtvickiegpt
authored andcommitted
Add some more comments on WASM_STACK_GUARD_SIZE (bytecodealliance#3341)
Signed-off-by: victoryang00 <[email protected]>
1 parent 78f69d8 commit 9860256

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

core/config.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,9 +455,11 @@
455455
* WASM_STACK_GUARD_SIZE needs to be large enough for:
456456
*
457457
* - native functions
458+
*
458459
* w/o hw bound check, the overhead (aot_call_function etc) + the native
459460
* function itself. as of writing this, the former is about 1000 bytes
460461
* on macOS amd64.
462+
*
461463
* with hw bound check, theoretically, only needs to cover the logic to
462464
* set up the jmp_buf stack.
463465
*
@@ -466,9 +468,20 @@
466468
*
467469
* - w/o hw bound check, the intepreter loop
468470
*
471+
* the classic interpreter wasm_interp_call_func_bytecode alone
472+
* seems to consume about 2600 bytes stack.
473+
* (with the default configuration for macOS/amd64)
474+
*
475+
* libc snprintf (used by eg. wasm_runtime_set_exception) consumes about
476+
* 1600 bytes stack on macOS/amd64, about 2000 bytes on Ubuntu amd64 20.04.
477+
*
469478
* - stack check wrapper functions generated by the aot compiler
470479
* (--stack-bounds-checks=1)
471480
*
481+
* wamrc issues a warning
482+
* "precheck functions themselves consume relatively large amount of stack"
483+
* when it detects wrapper functions requiring more than 1KB.
484+
*
472485
* Note: on platforms with lazy function binding, don't forget to consider
473486
* the symbol resolution overhead on the first call. For example,
474487
* on Ubuntu amd64 20.04, it seems to consume about 1500 bytes.

0 commit comments

Comments
 (0)