Are the GROWABLE_HEAP_X methods only needed for pthreads + ALLOW_MEMORY_GROWTH?

39 views
Skip to first unread message

Michael Hagar

unread,
Jul 7, 2023, 8:25:46 PM7/7/23
to emscripten-discuss
Do I need to use the GROWABLE_HEAP_X methods if I am only using ALLOW_MEMORY_GROWTH, but not pthreads?

Sam Clegg

unread,
Jul 7, 2023, 8:41:51 PM7/7/23
to emscripte...@googlegroups.com
Yes, those methods are only used/needed/present when growable memory is combined with threads.

What is more, you should not normally need to use them directly since emscripten should automatically convert all your heap accesses.  This is done using the `growableHeap` in `tools/acorn-optimizer.js`.   Are you running into cases where this is not handled automatically for you?

cheers,
sam

On Fri, Jul 7, 2023 at 5:25 PM 'Michael Hagar' via emscripten-discuss <emscripte...@googlegroups.com> wrote:
Do I need to use the GROWABLE_HEAP_X methods if I am only using ALLOW_MEMORY_GROWTH, but not pthreads?

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/8917e991-3f77-4e9b-99a5-ffc94c750ef3n%40googlegroups.com.

Michael Hagar

unread,
Aug 7, 2023, 10:47:06 AM8/7/23
to emscripten-discuss
Thanks! I haven't tested using the non-GROWABLE methods for heap access, but that's good to know they shouldn't be needed.

Michael Hagar

unread,
Apr 2, 2024, 11:38:11 AMApr 2
to emscripten-discuss
Does the acorn optimizer only run on Emscripten generated JS? In my case, I'm accessing Module.HEAPU8 directly from my own JS (which is not library JS). Based on the documentation here: https://emscripten.org/docs/porting/pthreads.html?highlight=growable#special-considerations

If I am using PThreads and memory growth, I do need to be using the GROWABLE_HEAP_X methods explicitly.

Alon Zakai

unread,
Apr 2, 2024, 12:51:53 PMApr 2
to emscripte...@googlegroups.com
The Acorn optimizer runs on code that is combined with the Emscripten JS output. That is the main JS output, including JS library support, and also --pre/post-js and EM_ASM code, which are combined and then optimized as one (which is good for DCE).

Reply all
Reply to author
Forward
0 new messages