diff options
author | Morgan Brown <morganbr@users.noreply.github.com> | 2017-12-05 09:45:38 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-05 09:45:38 +0300 |
commit | 3d25db5b1c010346bbc480a20646c80ea413492f (patch) | |
tree | e49e79d7ef6cd6861dd54d6db5262dfce216e695 /src/Native/Runtime/unix | |
parent | c900f3d03df888df2271cc7e207cdc645ae94aa2 (diff) |
Build runtime and libraries for WebAssembly (#4876)
* Fix issues building the runtime, corelib and type loader for WebAssembly
* Fix test infrastructure to allow running with the wasm flavor
Diffstat (limited to 'src/Native/Runtime/unix')
-rw-r--r-- | src/Native/Runtime/unix/PalRedhawkUnix.cpp | 4 | ||||
-rw-r--r-- | src/Native/Runtime/unix/UnixContext.cpp | 39 |
2 files changed, 42 insertions, 1 deletions
diff --git a/src/Native/Runtime/unix/PalRedhawkUnix.cpp b/src/Native/Runtime/unix/PalRedhawkUnix.cpp index af11b38f0..0b91e07a5 100644 --- a/src/Native/Runtime/unix/PalRedhawkUnix.cpp +++ b/src/Native/Runtime/unix/PalRedhawkUnix.cpp @@ -800,6 +800,10 @@ bool QueryCacheSize() } } } + +#elif defined(_WASM_) + // Processor cache size not available on WebAssembly + success = false; #else #error Do not know how to get cache size on this platform #endif // __linux__ diff --git a/src/Native/Runtime/unix/UnixContext.cpp b/src/Native/Runtime/unix/UnixContext.cpp index 0fdbc23ca..549271e30 100644 --- a/src/Native/Runtime/unix/UnixContext.cpp +++ b/src/Native/Runtime/unix/UnixContext.cpp @@ -19,6 +19,34 @@ #include "UnixContext.h" +// WebAssembly has a slightly different version of LibUnwind that doesn't define unw_get_save_loc +#if defined(_WASM_) +enum unw_save_loc_type_t +{ + UNW_SLT_NONE, /* register is not saved ("not an l-value") */ + UNW_SLT_MEMORY, /* register has been saved in memory */ + UNW_SLT_REG /* register has been saved in (another) register */ +}; +typedef enum unw_save_loc_type_t unw_save_loc_type_t; + +struct unw_save_loc_t +{ + unw_save_loc_type_t type; + union + { + unw_word_t addr; /* valid if type==UNW_SLT_MEMORY */ + unw_regnum_t regnum; /* valid if type==UNW_SLT_REG */ + } + u; +}; +typedef struct unw_save_loc_t unw_save_loc_t; + +int unw_get_save_loc(unw_cursor_t*, int, unw_save_loc_t*) +{ + return -1; +} +#endif // _WASM + #ifdef __APPLE__ #define MCREG_Rip(mc) ((mc)->__ss.__rip) @@ -255,6 +283,8 @@ bool GetUnwindProcInfo(PCODE ip, unw_proc_info_t *procInfo) unwContext.data[16] = ip; #elif _ARM_ ((uint32_t*)(unwContext.data))[15] = ip; +#elif _WASM_ + ASSERT(false); #else #error "GetUnwindProcInfo is not supported on this arch yet." #endif @@ -358,6 +388,9 @@ static void GetContextPointer(unw_cursor_t *cursor, unw_context_t *unwContext, i #define GET_CONTEXT_POINTERS \ GET_CONTEXT_POINTER(UNW_X86_EBP, Rbp) \ GET_CONTEXT_POINTER(UNW_X86_EBX, Rbx) +#elif defined (_WASM_) +// No registers +#define GET_CONTEXT_POINTERS #else #error unsupported architecture #endif @@ -454,7 +487,11 @@ void UnwindCursorToRegDisplay(unw_cursor_t *cursor, unw_context_t *unwContext, R #define ASSIGN_TWO_ARGUMENT_REGS // MCREG_X0(nativeContext->uc_mcontext) = arg0Reg; \ // MCREG_X1(nativeContext->uc_mcontext) = arg1Reg; - +#elif defined(_WASM_) + // TODO: determine how unwinding will work on WebAssembly +#define ASSIGN_CONTROL_REGS +#define ASSIGN_INTEGER_REGS +#define ASSIGN_TWO_ARGUMENT_REGS #else #error unsupported architecture #endif |