diff --git a/code/mps.c b/code/mps.c index 41c8d076af..b809189f4e 100644 --- a/code/mps.c +++ b/code/mps.c @@ -255,6 +255,19 @@ #include "spw3i6.c" /* Windows on x86-64 stack probe */ #include "mpsiw3.c" /* Windows interface layer extras */ +/* Emscripten */ + +#elif defined(MPS_PF_EMJ3LL) || defined(MPS_PF_EMJ6LL) + +#include "lockan.c" /* generic locks */ +#include "than.c" /* generic threads manager */ +#include "vman.c" /* malloc-based pseudo memory mapping */ +#include "protan.c" /* generic memory protection */ +#include "prmcan.c" /* generic operating system mutator context */ +#include "prmcanan.c" /* generic architecture mutator context */ +#include "span.c" /* generic stack probe */ + + #else #error "Unknown platform -- can't determine platform specific parts." diff --git a/code/mpstd.h b/code/mpstd.h index 7df1c2a12f..394fae61bc 100644 --- a/code/mpstd.h +++ b/code/mpstd.h @@ -392,6 +392,38 @@ #define MPS_PF_ALIGN 8 +#elif defined(__EMSCRIPTEN__) && defined(__wasm32__) +#if defined(CONFIG_PF_STRING) && ! defined(CONFIG_PF_EMJ3LL) +#error "specified CONFIG_PF_... inconsistent with detected emj3ll" +#endif +#define MPS_PF_EMJ3LL +#define MPS_PF_STRING "emj3ll" +#define MPS_OS_EM +#define MPS_ARCH_J3 +#define MPS_BUILD_LL +#define MPS_T_WORD unsigned long +#define MPS_T_ULONGEST unsigned long +#define MPS_WORD_WIDTH 32 +#define MPS_WORD_SHIFT 5 +#define MPS_PF_ALIGN 4 + + +#elif defined(__EMSCRIPTEN__) && defined(__wasm64__) +#if defined(CONFIG_PF_STRING) && ! defined(CONFIG_PF_EMJ6LL) +#error "specified CONFIG_PF_... inconsistent with detected emj6ll" +#endif +#define MPS_PF_EMJ6LL +#define MPS_PF_STRING "emj6ll" +#define MPS_OS_EM +#define MPS_ARCH_J6 +#define MPS_BUILD_LL +#define MPS_T_WORD unsigned long +#define MPS_T_ULONGEST unsigned long +#define MPS_WORD_WIDTH 64 +#define MPS_WORD_SHIFT 6 +#define MPS_PF_ALIGN 8 + + #else #error "The MPS Kit does not have a configuration for this platform out of the box; see manual/build.txt" #endif diff --git a/manual/source/topic/platform.rst b/manual/source/topic/platform.rst index 3e3671d49a..d12d5313f9 100644 --- a/manual/source/topic/platform.rst +++ b/manual/source/topic/platform.rst @@ -17,6 +17,7 @@ six-character code breaks down into three pairs of characters: ====== ================ ==================== ``OS`` Operating system Constant ====== ================ ==================== +``em`` Emscripten :c:macro:`MPS_OS_EM` ``fr`` FreeBSD :c:macro:`MPS_OS_FR` ``li`` Linux :c:macro:`MPS_OS_LI` ``w3`` Windows :c:macro:`MPS_OS_W3` @@ -31,6 +32,8 @@ The second pair of characters names the processor architecture: ``a6`` ARM64 :c:macro:`MPS_ARCH_A6` ``i3`` Intel/AMD IA-32 :c:macro:`MPS_ARCH_I3` ``i6`` Intel/AMD x86-64 :c:macro:`MPS_ARCH_I6` +``j3`` WebAssembly (32 bit) :c:macro:`MPS_ARCH_WA` +``j6`` WebAssembly (64 bit) :c:macro:`MPS_ARCH_WA` ====== ====================== ====================== The third pair of characters names the compiler toolchain: @@ -92,6 +95,20 @@ Platform interface The MPS is not supported on IA-64 (Itanium). +.. c:macro:: MPS_ARCH_J3 + + A :term:`C` preprocessor macro that indicates, if defined, that + the target processor architecture of the compilation is 32-bit + WebAssembly. + + +.. c:macro:: MPS_ARCH_J6 + + A :term:`C` preprocessor macro that indicates, if defined, that + the target processor architecture of the compilation is 64-bit + WebAssembly. + + .. c:macro:: MPS_BUILD_GC A :term:`C` preprocessor macro that indicates, if defined, that @@ -113,6 +130,12 @@ Platform interface Studio. +.. c:macro:: MPS_OS_EM + + A :term:`C` preprocessor macro that indicates, if defined, that + the MPS was compiled for Emscripten. + + .. c:macro:: MPS_OS_FR A :term:`C` preprocessor macro that indicates, if defined, that @@ -143,6 +166,20 @@ Platform interface the :term:`natural alignment` of the :term:`platform`. +.. c:macro:: MPS_PF_EMJ3LL + + A :term:`C` preprocessor macro that indicates, if defined, that + the :term:`platform` consists of the Emscripten operating environment, + the 32-bit WebAssembly target architecture, and the Clang/LLVM compiler. + + +.. c:macro:: MPS_PF_EMJ6LL + + A :term:`C` preprocessor macro that indicates, if defined, that + the :term:`platform` consists of the Emscripten operating environment, + the 64-bit WebAssembly target architecture, and the Clang/LLVM compiler. + + .. c:macro:: MPS_PF_FRI3GC A :term:`C` preprocessor macro that indicates, if defined, that @@ -381,6 +418,8 @@ the Memory Pool System, with their current status. ========== ======================= Platform Status ========== ======================= +``emj3ll`` In development +``emj6ll`` In development ``fri3gc`` Supported ``fri3ll`` Supported ``fri4gc`` Corrected to ``fri3gc``