From df76a0585f2badb30aa90ccfb52fa9fa33a00784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20S=C3=B8rvig?= Date: Fri, 26 Aug 2022 09:49:52 +0200 Subject: wasm: set ALLOW_MEMORY_GROWTH for multi-threaded builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Unify the settings for single-threaded and multi-threaded builds; Qt now always enables heap growth by default. This means we don't have to reserve a large (1GB) fixed memory size, but can instead set the smaller (50 MB) initial memory size, like the single-threaded build does. Enabling threads + memory growth can potentially cause a performance regression when accessing heap memory from JavaScript (https://github.com/WebAssembly/design/issues/1271). We leave it for the application to decide if this applies, and if the switch to fixed memory should be made. Change-Id: I96988b072506456685086e55aca4007a146bd70f Reviewed-by: Alexandru Croitor Reviewed-by: MikoĊ‚aj Boc Reviewed-by: Lorn Potter --- mkspecs/features/wasm/wasm.prf | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'mkspecs') diff --git a/mkspecs/features/wasm/wasm.prf b/mkspecs/features/wasm/wasm.prf index 5e6501ed99..5b7dbaf493 100644 --- a/mkspecs/features/wasm/wasm.prf +++ b/mkspecs/features/wasm/wasm.prf @@ -29,29 +29,16 @@ exists($$QMAKE_QT_CONFIG) { message("Setting PTHREAD_POOL_SIZE to" $$POOL_SIZE) EMCC_LFLAGS += -s PTHREAD_POOL_SIZE=$$POOL_SIZE - } else { - EMCC_LFLAGS += -s ALLOW_MEMORY_GROWTH=1 } + # Set memory options + EMCC_LFLAGS += -sALLOW_MEMORY_GROWTH isEmpty(QT_WASM_INITIAL_MEMORY) { - # Hardcode wasm memory size. - - qtConfig(thread) { - # Pthreads and ALLOW_MEMORY_GROWTH can cause javascript wasm memory access to - # be slow. Instead, we specify the memory size - # at build time. Further, browsers limit the maximum initial memory size to 1GB. - # https://github.com/WebAssembly/design/issues/1271 - INITIAL_MEMORY = 1GB - } else { - INITIAL_MEMORY = 50MB # emscripten default is 16MB, we need slightly more - } + INITIAL_MEMORY = 50MB # emscripten default is 16MB, we need slightly more } else { - # QT_WASM_INITIAL_MEMORY must be a multiple of 64KB (i.e. 65536) INITIAL_MEMORY = $$QT_WASM_INITIAL_MEMORY - message("Setting INITIAL_MEMORY to" $$INITIAL_MEMORY) } EMCC_LFLAGS += -s INITIAL_MEMORY=$$INITIAL_MEMORY - message("Setting INITIAL_MEMORY to" $$INITIAL_MEMORY) qtConfig(sse2) { QMAKE_CFLAGS += -O2 -msimd128 -msse -msse2 -- cgit v1.2.3