Skip to content

Commit a486d38

Browse files
committed
Make emscripten_resize_heap compatible with PURE_WASI
Previosly, using PURE_WASI was incompatible with EMSCRIPTEN_MEMORY_GROWTH flag, and was not documented. Now, using EMSCRIPTEN_MEMORY_GROWTH with PURE_WASI is possible. It will not require the host to export emscripten_notify_memory_growth and will grow the memory as expected from EMSCRIPTEN_MEMORY_GROWTH. Fixes #22211 Signed-off-by: inkeliz <inkeliz@inkeliz.com>
1 parent 7c52107 commit a486d38

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

system/lib/standalone/standalone.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ size_t emscripten_get_heap_max() {
152152
}
153153

154154
int emscripten_resize_heap(size_t size) {
155-
#if defined(EMSCRIPTEN_MEMORY_GROWTH) && !defined(EMSCRIPTEN_PURE_WASI)
155+
#if defined(EMSCRIPTEN_MEMORY_GROWTH)
156156
size_t old_size = __builtin_wasm_memory_size(0) * WASM_PAGE_SIZE;
157157
assert(old_size < size);
158158
ssize_t diff = (size - old_size + WASM_PAGE_SIZE - 1) / WASM_PAGE_SIZE;
@@ -161,8 +161,10 @@ int emscripten_resize_heap(size_t size) {
161161
// (uint32_t)-1 even with memory64:
162162
// https://bugs.chromium.org/p/v8/issues/detail?id=13948
163163
if (result != (uint32_t)-1 && result != (size_t)-1) {
164+
#if !defined(EMSCRIPTEN_PURE_WASI)
164165
// Success, update JS (see https://github.com/WebAssembly/WASI/issues/82)
165166
emscripten_notify_memory_growth(0);
167+
#endif
166168
return 1;
167169
}
168170
#endif

0 commit comments

Comments
 (0)