From 163f29e51ba656b3a7d275c3e252345878a00958 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Wed, 1 May 2024 16:15:17 +0900 Subject: [PATCH] Add some more comments on WASM_STACK_GUARD_SIZE (#3380) --- core/config.h | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/core/config.h b/core/config.h index 0a77ec94..87427666 100644 --- a/core/config.h +++ b/core/config.h @@ -470,8 +470,23 @@ * 200 bytes (release build, macOS/amd64) * 2600 bytes (debug build, macOS/amd64) * - * libc snprintf (used by eg. wasm_runtime_set_exception) consumes about - * 1600 bytes stack on macOS/amd64, about 2000 bytes on Ubuntu amd64 20.04. + * - platform-provided functions (eg. libc) + * + * the following are examples of the stack consumptions observed for + * host APIs. + * + * snprintf: (used by eg. wasm_runtime_set_exception) + * - about 1600 bytes on macOS/amd64 + * - about 2000 bytes on Ubuntu amd64 20.04 + * + * gethostbyname: + * - 3KB-6KB on macOS/amd64 + * - 10KB on Ubuntu amd64 20.04 + * + * getaddrinfo: + * - 4KB-17KB on macOS/amd64 + * - 12KB on Ubuntu amd64 20.04 + * - 0.3-1.5KB on NuttX/esp32s3 * * - stack check wrapper functions generated by the aot compiler * (--stack-bounds-checks=1) @@ -480,6 +495,9 @@ * "precheck functions themselves consume relatively large amount of stack" * when it detects wrapper functions requiring more than 1KB. * + * - the ABI-defined red zone. eg. 128 bytes for SYSV x86-64 ABI. + * cf. https://en.wikipedia.org/wiki/Red_zone_(computing) + * * Note: on platforms with lazy function binding, don't forget to consider * the symbol resolution overhead on the first call. For example, * on Ubuntu amd64 20.04, it seems to consume about 1500 bytes.