Add/reorganize locks for thread synchronization (#1995)
Attempt to fix data races when using threads. - Protect access (from multiple threads) to exception and memory - Fix shared memory lock usage
This commit is contained in:
@ -19,6 +19,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define EXCEPTION_BUF_LEN 128
|
||||
|
||||
typedef struct WASMModuleInstance WASMModuleInstance;
|
||||
typedef struct WASMFunctionInstance WASMFunctionInstance;
|
||||
typedef struct WASMMemoryInstance WASMMemoryInstance;
|
||||
@ -282,7 +284,7 @@ struct WASMModuleInstance {
|
||||
DefPointer(WASMExportTabInstance *, export_tables);
|
||||
|
||||
/* The exception buffer of wasm interpreter for current thread. */
|
||||
char cur_exception[128];
|
||||
char cur_exception[EXCEPTION_BUF_LEN];
|
||||
|
||||
/* The WASM module or AOT module, for AOTModuleInstance,
|
||||
it denotes `AOTModule *` */
|
||||
@ -444,6 +446,15 @@ wasm_set_exception_with_id(WASMModuleInstance *module_inst, uint32 id);
|
||||
const char *
|
||||
wasm_get_exception(WASMModuleInstance *module);
|
||||
|
||||
/**
|
||||
* @brief Copy exception in buffer passed as parameter. Thread-safe version of
|
||||
* `wasm_get_exception()`
|
||||
* @note Buffer size must be no smaller than EXCEPTION_BUF_LEN
|
||||
* @return true if exception found
|
||||
*/
|
||||
bool
|
||||
wasm_copy_exception(WASMModuleInstance *module_inst, char *exception_buf);
|
||||
|
||||
uint32
|
||||
wasm_module_malloc(WASMModuleInstance *module_inst, uint32 size,
|
||||
void **p_native_addr);
|
||||
|
||||
Reference in New Issue
Block a user