ruby-changes:71621
From: Peter <ko1@a...>
Date: Mon, 4 Apr 2022 22:27:35 +0900 (JST)
Subject: [ruby-changes:71621] ea9c09a92c (master): Disable mmap on WASM
https://git.ruby-lang.org/ruby.git/commit/?id=ea9c09a92c From ea9c09a92c770e9e3cb0f5ceafd42c8407836f7e Mon Sep 17 00:00:00 2001 From: Peter Zhu <peter@p...> Date: Fri, 1 Apr 2022 13:31:19 -0400 Subject: Disable mmap on WASM WASM does not have proper support for mmap. --- gc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gc.c b/gc.c index 9caa67accc..5ce440670c 100644 --- a/gc.c +++ b/gc.c @@ -882,7 +882,12 @@ enum { https://github.com/ruby/ruby/blob/trunk/gc.c#L882 #endif #ifdef HAVE_MMAP -# if HAVE_CONST_PAGE_SIZE +/* wasmtime does not have proper support for mmap. + * See https://github.com/bytecodealliance/wasmtime/blob/main/docs/WASI-rationale.md#why-no-mmap-and-friends + */ +# if defined(__wasm__) +static const bool HEAP_PAGE_ALLOC_USE_MMAP = false; +# elif HAVE_CONST_PAGE_SIZE /* If we have the HEAP_PAGE and it is a constant, then we can directly use it. */ static const bool HEAP_PAGE_ALLOC_USE_MMAP = (PAGE_SIZE <= HEAP_PAGE_SIZE); # elif defined(PAGE_MAX_SIZE) && (PAGE_MAX_SIZE <= HEAP_PAGE_SIZE) @@ -3632,7 +3637,7 @@ Init_heap(void) https://github.com/ruby/ruby/blob/trunk/gc.c#L3637 { rb_objspace_t *objspace = &rb_objspace; -#if defined(HAVE_MMAP) && !HAVE_CONST_PAGE_SIZE && !defined(PAGE_MAX_SIZE) +#if defined(HAVE_MMAP) && !defined(__wasm__) && !HAVE_CONST_PAGE_SIZE && !defined(PAGE_MAX_SIZE) /* Need to determine if we can use mmap at runtime. */ # ifdef PAGE_SIZE /* If the PAGE_SIZE macro can be used. */ -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/