Commit Graph

1005 Commits

Author SHA1 Message Date
Marcin Kolny
72b34eaf30
Fix AOT shift operations for indirect constants (#2627)
When doing more investigations related to this PR:
  https://github.com/bytecodealliance/wasm-micro-runtime/pull/2619
We found that in some scenarios the constant might not be directly
available to the LLVM IR builder, e.g.:
```
  (func $const_ret (result i32)
    i32.const -5
  )
  (func $foo
    (i32.shr_u (i32.const -1) (call $const_ret))
    (i32.const 31)
  )
```
In that case, the right parameter to `i32.shr_u` is not constant, therefore
the `SHIFT_COUNT_MASK` isn't applied. However, when the optimization
is enabled (`--opt-level` is 2 or 3), the optimization passes resolve the
call into constant, and that constant is poisoned, causing the compiler to
resolve the whole function to an exception.
2023-10-11 11:22:34 +08:00
liang.he
e73993709e
Use another default pipeline when opt-level is 0 (#2624)
According to the description of `buildPerModuleDefaultPipeline()` and
`buildLTOPreLinkDefaultPipeline()`, it is not allowed to call them with `O0` level.
Use `buildO0DefaultPipeline` instead when the opt-level is 0.
2023-10-10 10:52:37 +08:00
Wenyong Huang
e222955f31 Merge branch main into dev/wasi-libc-windows 2023-10-09 09:24:00 +08:00
TianlongLiang
059fbfc252
Fix potential issue in aot compiler when translating block opcodes (#2622)
The LLVM zext IR may be inserted after the terminator of a basic block
when popping the arguments of a wasm block. Change to insert the
zext IR before the terminator of the basic block to resolve the issue.

Reported in #2620.
2023-10-08 09:17:54 +08:00
Wenyong Huang
7c22bde8dc
CI: Enable testing AOT multi-module feature (#2621)
And refine some code pieces.
2023-10-08 08:36:49 +08:00
Marcin Kolny
b115b7baac
Fix compilation of shift opcodes on x86_64 and i386 architectures (#2619)
This change fixes the case where the right parameter of shift
operator is negative, specifically, when both parameters of
shift opcode are constants.
2023-10-07 19:55:14 +08:00
Enrico Loparco
3668093053
Enable AOT usage on M1 mac (#2618) 2023-10-07 16:05:10 +08:00
Gavin Hayes
d8ee771e28
Add Cosmopolitan Libc Platform (#2598)
This PR adds the Cosmopolitan Libc platform enabling compatibility with multiple
x86_64 operating systems with the same binary. The platform is similar to the
Linux platform, but for now only x86_64 with interpreter modes are supported.

The only major change to the core is `posix.c/convert_errno()` was rewritten to use
a switch statement. With Cosmopolitan errno values depend on the currently
running operating system, and so they are non-constant and cannot be used in array
designators. However, the `cosmocc` compiler allows non-constant case labels in
switch statements, enabling the new version.

And updated wamr-test-suites script to add `-j <platform>` option. The spec tests
can be ran via `CC=cosmocc ./test_wamr.sh -j cosmopolitan -t classic-interp`
or `CC=cosmocc ./test_wamr.sh -j cosmopolitan -t fast-interp`.
2023-10-04 21:55:37 +08:00
zoraaver
8987432f36
libc-wasi: Conditionally support SYNC flags (#2581)
To make it clearer to users when synchronization behaviour is not
supported, return ENOTSUP when O_RSYNC, O_DSYNC or O_SYNC are
respectively not defined. Linux also doesn't support O_RSYNC despite the
O_RSYNC flag being defined.
2023-10-04 21:02:25 +08:00
Maks Litskevich
28ebd57400
Refactor stress tests to make them runnable in reactor mode (#2614) 2023-10-04 08:10:10 +08:00
funera1
64baf54d88
Fix label index out-of-range references in op_br_table_cache (#2615)
Fixed a bug in the processing of the br_table_cache opcode that caused out-of-range
references when the label index was greater than the length of the label.
2023-10-03 10:33:00 +08:00
Zhen Kong
1a88104160
Remove module instance from hashmap in wasi_nn_destroy (#2613)
When destroying wasi-nn context, module instance should be also
removed from hashmap to avoid memory leak.
2023-10-03 08:33:11 +08:00
YAMAMOTO Takashi
e1ea15d94e
aot_resolve_stack_sizes: Disable the size check for now (#2608)
cf.
https://github.com/bytecodealliance/wasm-micro-runtime/issues/2555#issuecomment-1738530877
https://github.com/llvm/llvm-project/issues/67765
2023-09-29 15:30:52 +08:00
Enrico Loparco
00539620e9
Improve stack trace dump and fix coding guideline CI (#2599)
Avoid the stack traces getting mixed up together when multi-threading is enabled
by using exception_lock/unlock in dumping the call stacks.

And remove duplicated call stack dump in wasm_application.c.

Also update coding guideline CI to fix the clang-format-12 not found issue.
2023-09-29 10:52:54 +08:00
liang.he
3c17a36ccb
Patch implementations of vfbinop(min,max,pmin,pax) (#2584)
According to the specification,
- fNxM_pmin/max returns v1 or v2 based on flt(v1,v2) result
- fNxM_min/max returns +/-NaN, +/-Inf, v1 or v2 based on more than
  flt(v1,v2) result

Fixes issue #2561.
2023-09-28 09:32:01 +08:00
liang.he
cd0cec5beb
Check ValueKind before extracting a constant int value (#2595)
Only when the value kind is LLVMConstantIntValueKind and the value
is not undef and not poison can we extract the value of a constant int.

Fixes #2557 and #2559.
2023-09-28 09:15:56 +08:00
dongsheng28849455
79b27c1934
Support muti-module for AOT mode (#2482)
Support muti-module for AOT mode, currently only implement the
multi-module's function import feature for AOT, the memory/table/
global import are not implemented yet.

And update wamr-test-suites scripts, multi-module sample and some
CIs accordingly.
2023-09-28 08:56:11 +08:00
Wenyong Huang
fff0e2ad1c
Fix nightly run sanitizer error in Fast JIT (#2601)
Suppress a sanitizer integer overflow error in signed integer add operation
in Fast JIT.
2023-09-27 15:41:48 +08:00
Wenyong Huang
a50a438461
Ignore handling SIG_DFL/SIG_IGN for previous sig action (#2589) 2023-09-26 19:59:48 +08:00
Wenyong Huang
ade73f6142
Fix compilation error on Android platform (#2594)
The CI might use clang-17 to build iwasm for Android platform and it may
report compilation error:
https://github.com/bytecodealliance/wasm-micro-runtime/actions/runs/6308980430/job/17128073777

/home/runner/work/wasm-micro-runtime/wasm-micro-runtime/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/blocking_op.c:45:19: error: call to undeclared function 'preadv'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    ssize_t ret = preadv(fd, iov, iovcnt, offset);
                  ^

Explicitly declare preadv and pwritev in android platform header file to resolve it.
2023-09-26 16:13:12 +08:00
Wenyong Huang
6382162711
Fix loader push_pop_frame_ref_offset (#2590)
`wasm_loader_push_pop_frame_offset` may pop n operands by using
`loader_ctx->stack_cell_num` to check whether the operand can be
popped or not. While `loader_ctx->stack_cell_num` is updated in the
later `wasm_loader_push_pop_frame_ref`, the check may fail if the stack
is in polymorphic state and lead to `ctx->frame_offset` underflow.

Fix issue #2577 and #2586.
2023-09-26 10:17:54 +08:00
zoraaver
913a1414ad
Add support for closing/renumbering preopen fds (#2578)
There doesn't appear to be a clear reason not to support this behavior.
It seems it was disallowed previously as a precaution. See
67e2e57b02
for more context.
2023-09-26 09:31:32 +08:00
Alfred E. Neumayer
99b47fd334
Support AOT compiler with LLVM 17 (#2567)
Adapt API usage to new interfaces where applicable, including LLVM function
usage, obsoleted llvm::Optional type and removal of unavailable headers.

Know issues:
- AOT static PGO isn't enabled
- LLVM JIT may run failed due to llvm_orc_registerEHFrameSectionWrapper
  isn't linked into iwasm
2023-09-25 19:00:46 +08:00
zoraaver
f474f3d668
Return __WASI_EINVAL from fd_prestat_dir_name (#2580)
Return a WASI error code (rather than a host POSIX one). In addition,
there is no need to return an error in the case that the provided buffer
is too large.
2023-09-25 18:40:12 +08:00
TianlongLiang
71e07a7fa4
Fix potential unaligned store issue when extra return value is v128 (#2583)
Unaligned store v128 value to the AOT function argument of the pointer for
the extra return value may cause segmentation fault.

Fix the issue reported in #2556.
2023-09-23 09:06:35 +08:00
zoraaver
06527f724e
Remove provision of unnecessary fd rights (#2579)
The WASI docs allow for fewer rights to be applied to an fd than requested but
not more. This behavior is also asserted in the rust WASI tests, so it's necessary
for those to pass as well.
2023-09-22 09:11:25 +08:00
YAMAMOTO Takashi
6fca48d8e6
Fix inverted WASM_DISABLE_WAKEUP_BLOCKING_OP checks (#2571) 2023-09-21 11:56:21 +08:00
YAMAMOTO Takashi
444b159963
Implement async termination of blocking thread (#2516)
Send a signal whose handler is no-op to a blocking thread to wake up
the blocking syscall with either EINTR equivalent or partial success.

Unlike the approach taken in the `dev/interrupt_block_insn` branch (that is,
signal + longjmp similarly to `OS_ENABLE_HW_BOUND_CHECK`), this PR
does not use longjmp because:
* longjmp from signal handler doesn't work on nuttx
  refer to https://github.com/apache/nuttx/issues/10326
* the singal+longjmp approach may be too difficult for average programmers
  who might implement host functions to deal with

See also https://github.com/bytecodealliance/wasm-micro-runtime/issues/1910
2023-09-20 18:11:52 +08:00
Enrico Loparco
132378f30b
Allow using custom signal handler from non-main thread (#2551)
Remove thread local attribute of prev_sig_act_SIGSEGV/SIGBUS to allow using
custom signal handler from non-main thread since in a thread spawned by
embedder, embedder may be unable to call wasm_runtime_init_thread_env to
initialize them.

And fix the handling of prev_sig_act when its sa_handler is SIG_DFL, SIG_IGN,
or a user customized handler.
2023-09-15 18:55:16 +08:00
Enrico Loparco
83db970953
Add user to enlarge memory error callback (#2546) 2023-09-13 18:03:49 +08:00
YAMAMOTO Takashi
a6fda9b7ab
Add an API to terminate instance (#2538)
Add API wasm_runtime_terminate to terminate a module instance
by setting "terminated by user" exception to the module instance.

And update the product-mini of posix platforms.

Note: this doesn't work for some situations like blocking system calls.
2023-09-13 17:09:31 +08:00
YAMAMOTO Takashi
f128150d43
fd_object_release: Preserve errno (#2535)
Preserve errno because this function is often used like
the following. The caller wants to report the error from the main
operation (`lseek` in this example), not from fd_object_release.

```
    off_t ret = lseek(fd_number(fo), offset, nwhence);
    fd_object_release(fo);
    if (ret < 0)
        return convert_errno(errno);
```
2023-09-08 12:26:32 +08:00
YAMAMOTO Takashi
534a8cf9f4
Handle a return from wasi _start function correctly (#2529)
This fixes a few test cases in wasi-threads testsuite like wasi_threads_return_main_block.
And also move the special handling for "wasi proc exit" to a more appropriate place.
2023-09-08 11:49:04 +08:00
YAMAMOTO Takashi
6c846acc59
Implement module instance context APIs (#2436)
Introduce module instance context APIs which can set one or more contexts created
by the embedder for a wasm module instance:
```C
    wasm_runtime_create_context_key
    wasm_runtime_destroy_context_key
    wasm_runtime_set_context
    wasm_runtime_set_context_spread
    wasm_runtime_get_context
```

And make libc-wasi use it and set wasi context as the first context bound to the wasm
module instance.

Also add samples.

Refer to https://github.com/bytecodealliance/wasm-micro-runtime/issues/2460.
2023-09-07 14:54:11 +08:00
Cengizhan Pasaoglu
af2f3c8759
Fix typo for IP address buffer (#2532) 2023-09-07 14:29:52 +08:00
YAMAMOTO Takashi
151dfae49c
Unifdef -U WASMTIME_SSP_STATIC_CURFDS (#2533)
The macro WASMTIME_SSP_STATIC_CURFDS isn't used in the source code,
remove the related macro control code.
2023-09-06 15:25:58 +08:00
Marcin Kolny
4798b69f36
Add ARM aeabi symbol for clearing memory content in a specific range (#2531) 2023-09-06 13:17:16 +08:00
Enrico Loparco
709127d631
Add callback to handle memory.grow failures (#2522)
When embedding WAMR, this PR allows to register a callback that is
invoked when memory.grow fails.

In case of memory allocation failures, some languages allow to handle
the error (e.g. by checking the return code of malloc/calloc in C), some
others (e.g. Rust) just panic.
2023-09-05 16:41:52 +08:00
YAMAMOTO Takashi
48b71a05fb
libc-wasi: Remove unused code (#2528) 2023-09-04 19:14:56 +08:00
YAMAMOTO Takashi
9e3904337e
Revert "Return error when exception was raised after main thread finishes" (#2524)
This reverts commit 71d43f3ca1.
2023-09-04 18:01:09 +08:00
YAMAMOTO Takashi
2e78230e06
set_exception_visitor: Remove the special case for wasi proc exit (#2525)
While wasi proc exit is not a real trap, what the runtime does on it is mostly same as
real traps. That is, kill the siblings threads and represent the exit/trap as the result of
the "process" to the user api. There seems no reason to distinguish it from real traps
here.

Note that:
- The target thread either doesn't care the specific exception type or ignore wasi
  proc exit by themselves. (clear_wasi_proc_exit_exception)
- clear_wasi_proc_exit_exception only clears local exception.
2023-09-04 16:52:19 +08:00
Marcin Kolny
8c2dc1d011
Add unit tests for the tid allocator (#2519)
Add simple infrastructure to add more unit tests in the future. At the moment tests
are only executed on Linux, but can be extended to other platforms if needed.

Use https://github.com/google/googletest/ as a framework.
2023-09-04 13:21:10 +08:00
YAMAMOTO Takashi
1ff41ebdc2
Implement os_usleep for posix (#2517) 2023-09-01 12:10:54 +08:00
YAMAMOTO Takashi
382d52fc05
Stop abusing shared memory lock to protect exception (#2509)
Use a separate global lock instead.

Fixes: https://github.com/bytecodealliance/wasm-micro-runtime/issues/2407
2023-08-31 20:39:08 +08:00
Marcin Kolny
53d7027de0
Implement strict validation of thread IDs according to the specification (#2521) 2023-08-31 20:23:54 +08:00
Maks Litskevich
411b903cee
Add mutex stress test (#2472)
As a part of stress-testing we want to ensure that mutex implementation is working
correctly and protecting shared resource to be allocated from other threads when
mutex is locked.

This test covers the most common situations that happen when some program uses
mutexes like locks from various threads, locks from the same thread etc.
2023-08-30 19:01:44 +08:00
Jämes Ménétrey
ff151fb7ba
sgx-ra: Disable the building of samples (#2507) 2023-08-28 09:42:16 +08:00
Wenyong Huang
b7a9da1620 Merge branch main into dev/wasi-libc-windows 2023-08-23 17:05:19 +08:00
Wenyong Huang
858d1dd69c
Fix duplicate vector init in wasm_module_validate (#2498) 2023-08-23 12:35:46 +08:00
Huang Qi
051dfbbb9e
Fix a typo in is_win_platform (#2490) 2023-08-22 11:50:11 +08:00
Marcin Kolny
7f996a4559
Update version number and release notes (#2378)
Update the version number to 1.2.3 and update the release notes.
2023-08-22 08:55:36 +08:00
liang.he
f0632edc37
Clone the input binary during wasm_module_validate (#2483) 2023-08-21 19:43:28 +08:00
Wenyong Huang
a2f76cf93c
Fix typo in aot_emit_aot_file.c (#2478) 2023-08-18 13:57:23 +08:00
Wenyong Huang
2cb701f7f3
Fix windows AOT hw bound check (#2475)
When AOT out of bound linear memory access or stack overflow occurs, the call stack of
AOT functions cannot be unwound currently, so from the exception handler, runtime
cannot jump back into the place that calls the AOT function.
We temporarily skip the current instruction and let AOT code continue to run and return
to caller as soon as possible. And use the zydis library the decode the current instruction
to get its size.

And remove using RtlAddFunctionTable to register the AOT functions since it doesn't work
currently.
2023-08-18 10:16:03 +08:00
Wenyong Huang
6716c23dd1
wamrc: Fix windows relocation to aot_func_internal#n (#2474)
AOT relocation to aot_func_internal#n is generated by wamrc --bounds-checks=1.
Resolve the issue by applying the relocation in the compilation stage by wamrc and
don't generate these relocations in the AOT file.

Fixes #2471.
2023-08-18 09:56:00 +08:00
Xu Jun
7baaed2fb8
Fix opcode overwrite issue in fast interp (#2476) 2023-08-17 19:49:35 +08:00
Marcin Kolny
3534980c9e
Fix spec tests on windows, enable spec tests for windows in CI (#2473) 2023-08-17 19:23:27 +08:00
Wenyong Huang
e2f8721ec9
Fix issues reported by Coverity and clear windows warnings (#2467) 2023-08-17 10:54:02 +08:00
Maks Litskevich
4ce675aacd
Add another wamr test (#2411)
Follows up #2364 where we discussed that we might want to have a test
which has really short thread function and creates many threads.
2023-08-17 10:31:05 +08:00
TianlongLiang
c820643b2b
wamrc: More friendly to print help info (#2451)
Allow wamrc to print help info like below:
```bash
wamrc --target=help
wamrc --target-abi=help
wamrc --target=<target> --cpu=help
wamrc --target=<target> --cpu=help --cpu-features=+help
```
2023-08-16 11:28:45 +08:00
YAMAMOTO Takashi
0f18051e66
aot: Disable musttail for mips (#2457)
Fixes https://github.com/bytecodealliance/wasm-micro-runtime/issues/2412
2023-08-15 11:15:45 +08:00
Maks Litskevich
a9bd6af0ac
Build wasi-libc from source in WAMR CI (#2465)
We need to apply some bug fixes that were merged to wasi-libc because wasi-sdk-20
is about half a year old.

It is a temporary solution and the code will be removed when wasi-sdk 21 is released.
2023-08-15 10:36:10 +08:00
Jämes Ménétrey
365cdfeb71
Upgrade SGX-RA integration for 0.1.2 and Ubuntu 20.04 (#2454) 2023-08-15 10:12:43 +08:00
tonibofarull
b45d014112
wasi-nn: Improve TPU support (#2447)
1. Allow TPU and GPU support at the same time.
2. Add Dockerfile to run example with [Coral USB](https://coral.ai/products/accelerator/).
2023-08-14 20:03:56 +08:00
Wenyong Huang
923e8d6471
Fix windows link error and clear windows warnings (#2463)
- Fix windows wamrc link error: aot_generate_tempfile_name undefined.
- Clear windows compile warnings.
- And rename folder `samples/bh_atomic` and `samples/mem_allocator` to
  `samples/bh-atomic` and `samples/mem-allocator`.
2023-08-14 19:04:49 +08:00
YAMAMOTO Takashi
e360b7a919
wasm_instantiate: Fix a potential integer overflow issue (#2459)
Fixes: https://github.com/bytecodealliance/wasm-micro-runtime/issues/2450
2023-08-14 17:27:14 +08:00
tonibofarull
8d1cf46f02
Implement wasm_externref_objdel and wasm_externref_set_cleanup (#2455)
## Context

Some native libraries may want to explicitly delete an externref object without
waiting for the module instance to be deleted.
In addition, it may want to add a cleanup function.

## Proposed Changes

Implement:
* `wasm_externref_objdel` to explicitly delete an externeref'd object. 
* `wasm_externref_set_cleanup` to set a cleanup function that is called when
  the externref'd object is deleted.
2023-08-14 16:45:30 +08:00
YAMAMOTO Takashi
5c6613b2b1
Correct --heap-size option in messages (#2458) 2023-08-14 15:12:59 +08:00
tonibofarull
0b0af1b3df
wasi-nn: Support uint8 quantized networks (#2433)
Support (non-full) uint8 quantized networks.
Inputs and outputs are still required to be `float`. The (de)quantization is done internally by wasi-nn.

Example generated from `quantized_model.py`:
![Screenshot from 2023-08-07 17-57-05](https://github.com/bytecodealliance/wasm-micro-runtime/assets/80318361/91f12ff6-870c-427a-b1dc-e307f7d1f5ee)

Visualization with [netron](https://netron.app/).
2023-08-11 07:55:40 +08:00
Wenyong Huang
8b5bb0009d
wasm_export.h: Fix struct wasm_val_t (#2435)
Struct wasm_val_t should be same in wasm_export.h and wasm_c_api.h.

And fix some invalid calls to aot function in LLVM JIT mode.
2023-08-09 09:43:20 +08:00
Marcin Kolny
ea763009b7
Enable running spec tests on Windows (#2423)
Update wamr-test-suites scripts to enable running spec tests on Windows.
We don't enable those tests in CI yet as not all of them are passing.
2023-08-09 09:40:59 +08:00
YAMAMOTO Takashi
51714c41c0
Introduce WASMModuleInstanceExtraCommon (#2429)
Move the common parts of WASMModuleInstanceExtra and
AOTModuleInstanceExtra into the new structure.
2023-08-08 09:35:29 +08:00
Cengizhan Pasaoglu
81fbfbfcc0
Remove unnecessary and extra zero length check in mem functions' macro (#2428)
In macro bh_memcpy_s, bh_memcy_wa and bh_memmove_s, no need to do extra check
for length is zero or not because it was already done inside of the functions called.
2023-08-08 08:52:25 +08:00
Wenyong Huang
a07d8160f9
Merge pull request #2426 from bytecodealliance/main
Merge branch main into dev/wasi-libc-windows
2023-08-06 08:50:21 +08:00
dongsheng28849455
ebd9466d57
Add some relocation symbols for xtensa target (#2422) 2023-08-06 08:08:11 +08:00
YAMAMOTO Takashi
91592429f4
Fix memory sharing (#2415)
- Inherit shared memory from the parent instance, instead of
  trying to look it up by the underlying module. The old method
  works correctly only when every cluster uses different module.
- Use reference count in WASMMemoryInstance/AOTMemoryInstance
  to mark whether the memory is shared or not
- Retire WASMSharedMemNode
- For atomic opcode implementations in the interpreters, use
  a global lock for now
- Update the internal API users
  (wasi-threads, lib-pthread, wasm_runtime_spawn_thread)

Fixes https://github.com/bytecodealliance/wasm-micro-runtime/issues/1962
2023-08-04 10:18:13 +08:00
YAMAMOTO Takashi
28125ec538
Move wasm_runtime_destroy_wasi and wasi_nn_destroy calls together (#2418)
And remove obsolete comment.
2023-08-03 08:46:56 +08:00
Wenyong Huang
cb6d85069e
Fix lib-pthread issues (#2410)
- Avoid destroying module instance repeatedly in pthread_exit_wrapper and
  wasm_thread_cluster_exit.
- Wait enough time in pthread_join_wrapper for target thread to exit and
  destroy its resources.
2023-08-01 18:11:58 +08:00
Maks Litskevich
b88f2c06c6
Add initial stress test (#2364)
We need to make a test that runs longer than the tests we had before to check
some problems that might happen after running for some time (e.g. memory
corruption or something else).
2023-08-01 17:38:37 +08:00
Huang Qi
4b1f027690
Re-organize intrinsics in aot_reloc_riscv.c to fix some FPU issues (#2414) 2023-08-01 17:28:57 +08:00
YAMAMOTO Takashi
8518197053
Remove a few unused functions (#2409)
They have been unused since commit 5fc48e3584
2023-07-31 19:14:44 +08:00
Cengizhan Pasaoglu
84ecf15322
Update libuv version to v1.46.0 (#2405) 2023-07-31 18:32:20 +08:00
Wenyong Huang
edea32b629
Fix result arity check on select_t opcode (#2406)
Typed select must have exactly one result. Reported in issue #2402.
2023-07-31 18:20:11 +08:00
YAMAMOTO Takashi
b1fa27e91d
bh_atomic.h: Add BH_ATOMIC_32_FETCH_ADD/BH_ATOMIC_32_FETCH_SUB (#2408) 2023-07-31 17:56:15 +08:00
Marcin Kolny
151600fef2
Fix wasi-sockets tests (#2389)
Tests were failing because the right permissions were not provided to iwasm.
Also, test failures didn't trigger build failure due to typo - also fixed in this change.

In addition to that, this PR fixes a few issues with the test itself:
* the `server_init_complete` was not reset early enough causing the client to occasionally
  assume the server started even though it didn't yet
* set `SO_REUSEADDR` on the server socket so the port can be reused shortly after
  closing the previous socket
* defined receive-send-receive sequence from server to make sure server is alive at the
  time of sending message
2023-07-30 19:34:09 +08:00
YAMAMOTO Takashi
6d6cea1a73
Fix non-builtin BH_ATOMIC_32_FETCH_OR and BH_ATOMIC_32_FETCH_AND (#2400) 2023-07-30 19:23:30 +08:00
Huang Qi
10b18d85cd
Fix ExpandMemoryOpPass doesn't work properly (#2399)
The old method may not work for some cases. This PR iterates over all instructions
in the function, looking for memcpy, memmove and memset instructions, putting
them into a set, and finally expands them into a loop one by one.

And move this LLVM Pass after building the pipe line of pass builder to ensure that
the memcpy/memmove/memset instrinsics are generated before applying the pass.
2023-07-29 10:28:09 +08:00
YAMAMOTO Takashi
7db4815e83
bh_atomic.h: Add comments (#2398) 2023-07-28 20:36:35 +08:00
Wenyong Huang
59b2099b68
Fix some check issues on table operations (#2392)
Fix some check issues on table.init, table.fill and table.copy, and unify the check method
for all running modes.
Fix issue #2390 and #2096.
2023-07-27 21:53:48 +08:00
YAMAMOTO Takashi
228417ab8c
Move generic parts of wasm_suspend_flags.h to bh_atomic.h (#2393) 2023-07-27 21:37:23 +08:00
dongheng
ada7e3fe88
ESP-IDF platform supports to load AOT to PSRAM and run it (#2385) 2023-07-27 10:17:21 +08:00
Marcin Kolny
5463ea4a20
Temporarily disable code that does not compile on windows (#2386)
And return ENOSYS. We do that so we can at least compile the code on CI.
We'll be gradually enabling more and more functions.

Also, enabled `proc_raise()` for windows.
2023-07-25 10:35:05 +08:00
Wenyong Huang
24c6c6977b
Fix llvm jit failed to lookup aot_stack_sizes symbol issue (#2384)
LVM JIT failed to lookup symbol "aot_stack_sizes" as it is an internal symbol,
change to lookup "aot_stack_sizes_alias" instead.

Reported in #2372.
2023-07-24 15:15:48 +08:00
Marcin Kolny
fe4ee37122
Add more fixes for wasi libc on windows (#2380)
* disable translations of errno codes that aren't defined on Windows
* undef `min()` macro if it is defined to not conflict with the `min()` function we define
* implement `shed_yield` wasi call
* disable some of the features in the config for windows by default
2023-07-24 15:14:52 +08:00
Marcin Kolny
a9d008f942
Use _fullpath function on windows to get absolute path of a directory (#2377)
There is no standard `realpath` function in the C/C++ standard libraries for Windows,
use `_fullpath` function instead to get absolute path of a directory.
2023-07-22 08:46:10 +08:00
Marcin Kolny
0f4edf9735
Implement suspend flags as atomic variable (#2361)
We have observed a significant performance degradation after merging
https://github.com/bytecodealliance/wasm-micro-runtime/pull/1991
Instead of protecting suspend flags with a mutex, we implement the flags
as atomic variable and only use mutex when atomics are not available
on a given platform.
2023-07-21 08:27:09 +08:00
dongsheng28849455
fbe072c0d3
Bring up WAMR on esp32-s3 device (#2348)
esp32-s3's instruction memory and data memory can be accessed through mutual mirroring way,
so we define a new feature named as WASM_MEM_DUAL_BUS_MIRROR.
2023-07-21 07:54:13 +08:00
Cengizhan Pasaoglu
57abdfdb5c
Fix typo (dwarf) in the codebase (#2367)
In the codebase, the struct and functions were written without "f" for dwarf.
2023-07-19 17:58:52 +08:00
Xu Jun
fbcf8c2c60
Fix some static scan issues (#2362) 2023-07-18 16:06:21 +08:00
Marcin Kolny
662e38e9b0
[Partial] Build wasi-libc for Windows (#2338)
Build wasi-libc library on Windows since libuv may be not supported. This PR is a first step
to make it working, but there's still a number of changes to get it fully working.
2023-07-13 21:02:29 +08:00