YAMAMOTO Takashi and GitHub
456e2f6919
aot compiler: Fix a type mismatch in compile_op_float_min_max ( #3423 )
...
Fixes https://github.com/bytecodealliance/wasm-micro-runtime/issues/3422
2024-05-14 10:06:48 +08:00
YAMAMOTO Takashi and GitHub
8f098a5905
aot: Make precheck functions use short-call for xtensa ( #3418 )
...
Note: this breaks AOT ABI for xtensa again because of a revert of an ABI-breaking change.
2024-05-13 16:55:00 +08:00
YAMAMOTO Takashi and GitHub
46f83cf486
core/iwasm/compilation: Remove stale function prototypes ( #3408 )
2024-05-09 16:55:32 +08:00
YAMAMOTO Takashi and GitHub
3e5361f76d
samples/native-stack-overflow: Examine native functions with signature ( #3382 )
...
Note: wamrc chooses different methods to call native functions
with and without signatures.
2024-05-03 09:16:35 +08:00
YAMAMOTO Takashi and GitHub
163f29e51b
Add some more comments on WASM_STACK_GUARD_SIZE ( #3380 )
2024-05-01 15:15:17 +08:00
YAMAMOTO Takashi and GitHub
120b9659dd
A few native stack detection fixes for macOS/arm64 ( #3368 )
2024-04-26 19:37:55 +08:00
YAMAMOTO Takashi and GitHub
410ee580ae
Add wasm_runtime_detect_native_stack_overflow_size ( #3355 )
...
- Add a few API (https://github.com/bytecodealliance/wasm-micro-runtime/issues/3325 )
```c
wasm_runtime_detect_native_stack_overflow_size
wasm_runtime_detect_native_stack_overflow
```
- Adapt the runtime to use them
- Adapt samples/native-stack-overflow to use them
- Add a few missing overflow checks in the interpreters
- Build and run the sample on the CI
2024-04-26 16:00:58 +08:00
YAMAMOTO Takashi and GitHub
1b5ff93656
CI: Use macos-13 instead of macos-latest ( #3366 )
...
Our workflows assume macos-latest is intel, but now it's arm64.
Use macos-13, which is documented to be intel, instead.
reference:
https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners
2024-04-26 14:38:49 +08:00
YAMAMOTO Takashi and GitHub
a36c7d5aa9
Random improvements to samples/native-stack-overflow ( #3353 )
2024-04-25 11:22:08 +08:00
YAMAMOTO Takashi and GitHub
9d6d3466ff
Fix a few native stack address calculations ( #3351 )
2024-04-24 16:39:38 +08:00
YAMAMOTO Takashi and GitHub
09a5be411f
Reduce WASM_STACK_GUARD_SIZE a bit for posix-like platforms ( #3350 )
...
I found a few mistakes in my research on the stack consumption.
Update the comment and tweak WASM_STACK_GUARD_SIZE accordingly.
2024-04-24 16:18:58 +08:00
YAMAMOTO Takashi and GitHub
98ad36e35a
core/config.h: Bump the default WASM_STACK_GUARD_SIZE ( #3344 )
...
The old value (1KB) doesn't seem sufficient for many cases.
I suspect that the new value is still not sufficient for some cases.
But it's far safer than the old value.
Consider if the classic interpreter loop (2600 bytes) calls
host snprintf. (2000 bytes)
Fixes: https://github.com/bytecodealliance/wasm-micro-runtime/issues/3314
2024-04-23 16:51:47 +08:00
YAMAMOTO Takashi and GitHub
7bdea3c2ae
Add some more comments on WASM_STACK_GUARD_SIZE ( #3341 )
2024-04-22 15:00:09 +08:00
YAMAMOTO Takashi and GitHub
d6e8d224ce
Add native-stack-overflow sample ( #3321 )
...
This is a test code to examine native stack overflow detection logic.
The current output on my environment (macOS amd64):
```shell
====== Interpreter
stack size | fail? | leak? | exception
---------------------------------------------------------------------------
0 - 14704 | failed | leaked | Exception: native stack overflow
14704 - 17904 | failed | ok | Exception: native stack overflow
17904 - 24576 | ok | ok |
====== AOT
stack size | fail? | leak? | exception
---------------------------------------------------------------------------
0 - 18176 | failed | leaked | Exception: native stack overflow
18176 - 24576 | ok | ok |
====== AOT WAMR_DISABLE_HW_BOUND_CHECK=1
stack size | fail? | leak? | exception
---------------------------------------------------------------------------
0 - 1968 | failed | ok | Exception: native stack overflow
1968 - 24576 | ok | ok |
```
This is a preparation to work on relevant issues, including:
https://github.com/bytecodealliance/wasm-micro-runtime/issues/3325
https://github.com/bytecodealliance/wasm-micro-runtime/issues/3320
https://github.com/bytecodealliance/wasm-micro-runtime/issues/3314
https://github.com/bytecodealliance/wasm-micro-runtime/issues/3297
2024-04-19 15:49:09 +08:00
YAMAMOTO Takashi and GitHub
f6481cedec
Add a comment on WASM_STACK_GUARD_SIZE ( #3332 )
2024-04-19 10:19:59 +08:00
YAMAMOTO Takashi and GitHub
53f0941ffa
Revert "lldb_function_to_function_dbi: A hack to avoid crashing on C++ methods ( #3190 )" ( #3281 )
...
This reverts commit 0e8d949440 .
Because it doesn't make much sense anymore after we disabled debug info
processing on C++ functions in:
"aot debug: process lldb_function_to_function_dbi only for C".
2024-04-06 15:00:48 +08:00
YAMAMOTO Takashi and GitHub
b4cab84e5f
aot debug: Process lldb_function_to_function_dbi only for C ( #3278 )
...
This is a workaroud for:
https://github.com/bytecodealliance/wasm-micro-runtime/issues/3187
https://github.com/bytecodealliance/wasm-micro-runtime/issues/3163
2024-04-03 18:03:31 +08:00
YAMAMOTO Takashi and GitHub
dae09c0e03
aot debug: Fix a NULL dereference ( #3274 )
...
It happens on eg. a C function taking a structure argument.
2024-04-03 17:10:46 +08:00
YAMAMOTO Takashi and GitHub
4806e4e298
LLVM 19: Switch to debug records ( #3272 )
...
References:
https://llvm.org/docs/RemoveDIsDebugInfo.html
https://github.com/llvm/llvm-project/pull/86529
2024-04-02 16:00:43 +08:00
YAMAMOTO Takashi and GitHub
6b0b5de1c5
aot debug: Fix a few NULL dereferences on errors ( #3273 )
2024-04-02 14:30:08 +08:00
YAMAMOTO Takashi and GitHub
0e8d949440
lldb_function_to_function_dbi: A hack to avoid crashing on C++ methods ( #3190 )
...
Also, print the function name on argument mismatch.
2024-03-04 17:08:11 +08:00
YAMAMOTO Takashi and GitHub
503c9694c8
lldb_function_to_function_dbi: Fix a null dereference ( #3189 )
...
C++ allows unnamed arguments.
In the debug info, they are represented as DW_TAG_formal_parameter
w/o DW_AT_name.
variable.GetName() here returns NULL for them.
cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/3187
2024-02-29 14:03:49 +08:00
YAMAMOTO Takashi and GitHub
b0c54c8a86
Fix a ubsan complaint "applying zero offset to null pointer" ( #3160 )
...
Set a type's `result_ref_type_maps` only when `ref_type_map_count > 0`.
2024-02-17 10:11:10 +08:00
YAMAMOTO Takashi and GitHub
5931aaacbe
aot compiler: Place precheck wrapper before the corresponding wrapped function ( #3141 )
...
This increases the chance to use "short" calls.
Assumptions:
- LLVM preserves the order of functions in a module
- The wrapper function are smaller than the wrapped functions
- The target CPU has "short" PC-relative variation of call/jmp instructions
and they are preferrable over the "long" ones.
A motivation:
- To avoid some relocations for XIP, I want to use xtensa PC-relative
call instructions, which can only reach ~512KB.
2024-02-06 15:05:32 +08:00
YAMAMOTO Takashi and GitHub
6e547baf46
aot_compile_op_call: Stop setting calling convention explicitly ( #3140 )
...
The current logic doesn't work for some cases.
cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/3138
It's unclear why we are setting the calling convention explicitly here
at all. In many cases, the default just seems working.
2024-02-06 13:14:25 +08:00
YAMAMOTO Takashi and GitHub
529fa9dd17
EH: Fix broken stack usage calculation ( #3121 )
...
Fixes: https://github.com/bytecodealliance/wasm-micro-runtime/issues/3108
2024-02-03 12:21:15 +08:00
YAMAMOTO Takashi and GitHub
edc3643909
EH: Fix validation of delegate opcode ( #3107 )
...
cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/1884#issuecomment-1914000294
2024-02-01 12:32:06 +08:00
YAMAMOTO Takashi and GitHub
3111a86cb3
EH: Fix delegate parsing in wasm_loader_find_block_addr ( #3106 )
2024-02-01 07:46:49 +08:00
YAMAMOTO Takashi and GitHub
10e87d2966
EH: Don't call word_copy with zero size ( #3105 )
2024-01-31 21:54:19 +08:00
YAMAMOTO Takashi and GitHub
43c4a5c434
exception handling: Fix build error ( #3104 )
2024-01-31 20:24:34 +08:00
YAMAMOTO Takashi and GitHub
7e65f9a244
aot: Fix LLVMSetTailCallKind check ( #3099 )
2024-01-30 20:50:33 +08:00
YAMAMOTO Takashi and GitHub
9afbeab1c8
wasi: Apply wasm_runtime_begin_blocking_op to poll as well ( #3080 )
...
While we used a different approach for poll_oneoff [1],
the implementation works only when the poll list includes
an absolute clock event. That is, if we have a thread which is
polling on descriptors without a timeout, we fail to terminate
the thread.
This commit fixes it by applying wasm_runtime_begin_blocking_op
to poll as well.
[1] https://github.com/bytecodealliance/wasm-micro-runtime/pull/1951
2024-01-25 16:29:34 +08:00
YAMAMOTO Takashi and GitHub
f56154ed80
thread-mgr: Fix locking problems around aux stack allocation ( #3073 )
...
Fixes: https://github.com/bytecodealliance/wasm-micro-runtime/issues/3069
2024-01-24 09:46:53 +08:00
YAMAMOTO Takashi and GitHub
ab97d543e0
wasm_cluster_destroy_spawned_exec_env: Avoid "invalid exec env" trap ( #3068 )
...
Possible alternatives:
* Make wasm_cluster_destroy_spawned_exec_env take two exec_env.
One for wasm execution and another to specify the target to destroy.
* Make execute functions to switch exec_env as briefly discussed in
https://github.com/bytecodealliance/wasm-micro-runtime/pull/2047
2024-01-23 15:20:01 +08:00
YAMAMOTO Takashi and GitHub
b44aa654b8
aot_reloc_x86_64.c: Suggest to try --size-level=0 as well ( #3067 )
...
cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/3035
2024-01-23 13:00:19 +08:00
YAMAMOTO Takashi and GitHub
4bafa40052
nuttx: If STACK_GUARD_SIZE is not set, leave it to config.h ( #2927 )
...
cf. https://github.com/apache/nuttx-apps/pull/2241
2024-01-23 11:52:25 +08:00
YAMAMOTO Takashi and GitHub
bc35602004
Fix aot large model (--size-level=0) with LLVM 18 ( #3057 )
...
The recent versions LLVM uses ".ltext" section for X86 large model.
cf. https://github.com/llvm/llvm-project/commit/d8a04398f9492f043ffd8fbaf2458778f7d0fcd5
This fixes https://github.com/bytecodealliance/wasm-micro-runtime/issues/3034
2024-01-19 19:43:41 +08:00
YAMAMOTO Takashi and GitHub
17b0111577
wasm_runtime_begin_blocking_op: A comment about usage expectation ( #3056 )
2024-01-19 18:31:21 +08:00
YAMAMOTO Takashi and GitHub
8b37048823
Do not inherit WASM_SUSPEND_FLAG_BLOCKING from the parent thread ( #3051 )
...
It seems that some users want to wrap rather large chunk of code
with wasm_runtime_begin_blocking_op/wasm_runtime_end_blocking_op.
If the wrapped code happens to have a call to
e.g. wasm_runtime_spawn_exec_env, WASM_SUSPEND_FLAG_BLOCKING is
inherited to the child exec_env and it may cause unexpected behaviors.
2024-01-19 09:55:01 +08:00
YAMAMOTO Takashi and GitHub
fde98331ff
examples/terminate: Use wasm_runtime_spawn_exec_env as well ( #3049 )
2024-01-18 20:44:09 +08:00
YAMAMOTO Takashi and GitHub
b97370e3a8
samples/terminate: Add a sample to demonstrate wasm_runtime_terminate ( #3043 )
...
This is basically a modified copy of the "shared-module" example.
2024-01-18 15:01:03 +08:00
YAMAMOTO Takashi and GitHub
d13a54f860
Revert "Enable MAP_32BIT for macOS ( #2992 )" ( #3032 )
...
Revert "Do not use pagezero size option if osx version >= 13 (#3025 )"
and "Enable MAP_32BIT for macOS (#2992 )".
Discussion: https://github.com/bytecodealliance/wasm-micro-runtime/issues/3009
2024-01-18 09:22:09 +08:00
YAMAMOTO Takashi and GitHub
685d55d2e7
nuttx: Use larger alignment for os_mmap and comment why ( #3017 )
...
Other platforms with malloc-based os_mmap might need similar changes
too, depending on their target cpu arch.
2024-01-16 09:17:58 +08:00
YAMAMOTO Takashi and GitHub
837b9904f5
aot debug: Try to use a bit more appropriate file names ( #3000 )
...
When the original wasm contains multiple compilation units, the current
logic uses the first one for everything. This commit tries to use a bit more
appropriate ones.
2024-01-15 15:02:12 +08:00
YAMAMOTO Takashi and GitHub
08442458b1
aot debug: Update DW_AT_producer ( #3001 )
...
Currently we are using "ant compiler", which is a bit historical.
This commit changes it to use "WAMR AoT compiler" instead.
2024-01-12 13:43:18 +08:00
YAMAMOTO Takashi and GitHub
6fa6d6d9a5
Enable MAP_32BIT for macOS ( #2992 )
...
On macOS, by default, the first 4GB is occupied by the pagezero.
While it can be controlled with link time options, as we are
an library, we usually don't have a control on how to link an
executable.
2024-01-10 16:19:06 +08:00
YAMAMOTO Takashi and GitHub
49ac1e0636
doc/build_wasm_app.md: Add a note about aot abi compatibility ( #2993 )
2024-01-10 12:10:40 +08:00
YAMAMOTO Takashi and GitHub
722381fcf2
aot compiler: Some updates for LLVM 18 ( #2981 )
...
Note: This commit includes copy-and-paste from LLVM and thus adds
the LLVM copyright notice.
cf. https://github.com/llvm/llvm-project/commit/0a1aa6cda2758b0926a95f87d39ffefb1cb90200
cf. https://github.com/llvm/llvm-project/commit/a1e9777b760fbd4428073fd7b0fc8bea15bd2183
cf. https://github.com/llvm/llvm-project/commit/56c72c7f339cd6ff780a0d6aa1a0ac8bfc1487aa
2024-01-08 10:15:31 +08:00
YAMAMOTO Takashi and GitHub
5edd85d055
doc: Separate source_debugging.md into two files ( #2932 )
...
The original file was confusing as it contains both of
interpreter and aot debugging information intermixed.
2023-12-27 15:51:51 +08:00
YAMAMOTO Takashi and GitHub
8318333304
nuttx: Add CONFIG_INTERPRETERS_WAMR_DEBUG_AOT ( #2929 )
...
At least it's sometimes useful for nuttx sim.
eg. (modified a bit to avoid github autolinks)
```
spacetanuki% lldb ./nuttx
(lldb) target create "./nuttx"
Current executable set to '/Users/yamamoto/git/nuttx/nuttx/nuttx' (x86_64).
(lldb) settings set plugin.jit-loader.gdb.enable on
(lldb) b foo
Breakpoint 1: no locations (pending).
WARNING: Unable to resolve breakpoint to any actual locations.
(lldb) r
Process 37011 launched: '/Users/yamamoto/git/nuttx/nuttx/nuttx' (x86_64)
NuttShell (NSH) NuttX-10.4.0
nsh> mount -t hostfs -o fs=/tmp/wasm /mnt
nsh> iwasm /mnt/test.aot
1 location added to breakpoint 1
Process 37011 stopped
* thread #_1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #_0: 0x0000000105800673 JIT(0x1058002d4)`foo(exenv=0x0000000101284280) at test.c:5
2
3 __attribute__((noinline))
4 void foo()
-> 5 {
6 printf("hello from %s\n", __func__);
7 }
8
Target 0: (nuttx) stopped.
(lldb) bt
* thread #_1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
* frame #_0: 0x0000000105800673 JIT(0x1058002d4)`foo(exenv=0x0000000101284280) at test.c:5
frame #_1: 0x000000010580077a JIT(0x1058002d4)`bar(exenv=0x0000000101284280) at test.c:12:2
frame #_2: 0x000000010580086a JIT(0x1058002d4)`baz(exenv=0x0000000101284280) at test.c:19:2
frame #_3: 0x0000000105800972 JIT(0x1058002d4)`__main_argc_argv(exenv=<unavailable>, argc=<unavailable>, argv=<unavailable>) at test.c:26:3
frame #_4: 0x00000001058061aa JIT(0x1058002d4)`aot_func#14 + 278
...
```
2023-12-26 16:56:34 +08:00
YAMAMOTO Takashi and GitHub
18529253d8
interpreter: Simplify memory.grow a bit ( #2899 )
2023-12-12 20:24:51 +08:00
YAMAMOTO Takashi and GitHub
1dbae404b4
samples/spawn-thread: Tweak to expose a bug ( #2888 )
...
this would expose the deadlock bug, which has been fixed by
https://github.com/bytecodealliance/wasm-micro-runtime/pull/2882
2023-12-08 18:35:40 +08:00
YAMAMOTO Takashi and GitHub
9c3581c179
samples/spawn-thread: Disable libc and pthread ( #2883 )
...
because this sample doesn't really require them.
2023-12-08 18:12:37 +08:00
YAMAMOTO Takashi and GitHub
73914caa9b
core/iwasm/interpreter/wasm_loader.c: remove an extra validation ( #2845 )
...
* Empty names are spec-wise valid.
* As we ignore unknown custom sections anyway, it's safe to
accept empty names here.
* Currently, the problem is not exposed on our CI because
the wabt version used there is a bit old.
2023-12-01 18:29:15 +08:00
YAMAMOTO Takashi and GitHub
fbd9a760e7
test_wamr.sh: Don't bother to build shared library ( #2844 )
...
This script only uses the iwasm command.
2023-12-01 18:12:55 +08:00
YAMAMOTO Takashi and GitHub
562a5dd1b6
Fix data/elem drop ( #2747 )
...
Currently, `data.drop` instruction is implemented by directly modifying the
underlying module. It breaks use cases where you have multiple instances
sharing a single loaded module. `elem.drop` has the same problem too.
This PR fixes the issue by keeping track of which data/elem segments have
been dropped by using bitmaps for each module instances separately, and
add a sample to demonstrate the issue and make the CI run it.
Also add a missing check of dropped elements to the fast-jit `table.init`.
Fixes: https://github.com/bytecodealliance/wasm-micro-runtime/issues/2735
Fixes: https://github.com/bytecodealliance/wasm-micro-runtime/issues/2772
2023-11-18 08:50:16 +08:00
YAMAMOTO Takashi and GitHub
2d0d4a0be9
Remove unused JitBitmap ( #2775 )
...
Fixes: https://github.com/bytecodealliance/wasm-micro-runtime/issues/2754
2023-11-16 18:48:06 +08:00
YAMAMOTO Takashi and GitHub
24c4d256b3
Grab cluster->lock when modifying exec_env->module_inst ( #2685 )
...
Fixes: https://github.com/bytecodealliance/wasm-micro-runtime/issues/2680
And when switching back to the original module_inst, propagate exception if any.
cf. https://github.com/bytecodealliance/wasm-micro-runtime/issues/2512
2023-11-09 18:56:02 +08:00
YAMAMOTO Takashi and GitHub
9a5c777aff
Revert "Strip static and shared libraries of iwasm to reduce the binary size ( #2431 )" ( #2669 )
...
This reverts commit 7e3a29d5e4 :
* it doesn't work for macOS. ("unrecognized option: --strip-all")
* it doesn't work for ubuntu.
https://github.com/bytecodealliance/wasm-micro-runtime/issues/2665
2023-10-25 20:46:49 +08:00
YAMAMOTO Takashi and GitHub
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
YAMAMOTO Takashi and GitHub
ac6435884f
doc/memory_tune.md: "remove malloc" hack is not relevant to wasi-threads ( #2603 )
2023-09-28 09:27:33 +08:00
YAMAMOTO Takashi and GitHub
b622622096
samples/inst-context-threads: Add a brief explanation ( #2592 )
2023-09-26 10:00:33 +08:00
YAMAMOTO Takashi and GitHub
94f276eab0
test_wamr.sh: Bump wasi-testsuite version ( #2568 )
...
On posix-like platforms, the rest of wasi-threads tests
should pass after the recent changes including the following PRs:
#2516 , #2524 , #2529 , #2571 , #2576 and #2582 .
2023-09-26 09:20:13 +08:00
YAMAMOTO Takashi and GitHub
363f08975b
Fix a few issues in "run_wasi_tests.sh: provide stdin by ourselves" ( #2582 )
...
Apply "provide stdin by ourselves" to the aot case and check the correct exit code.
2023-09-23 10:28:18 +08:00
YAMAMOTO Takashi and GitHub
0677288f22
run_wasi_tests.sh: Provide stdin by ourselves ( #2576 )
...
This improves test consistency between typical local environments and
github runners.
This is necessary for some of latest wasi-threads tests.
cf. https://github.com/yamt/toywasm/commit/570e6706312cbdccb9d5268347186b441a24444b
2023-09-22 08:57:48 +08:00
YAMAMOTO Takashi and GitHub
cf97ee081f
test_wamr.sh: Print a bit more meaningful message ( #2574 )
2023-09-21 18:39:12 +08:00
YAMAMOTO Takashi and GitHub
c7a7db21b7
export_native_api.md: Add a note about thread termination ( #2572 )
2023-09-21 13:32:08 +08:00
YAMAMOTO Takashi and GitHub
6fca48d8e6
Fix inverted WASM_DISABLE_WAKEUP_BLOCKING_OP checks ( #2571 )
2023-09-21 11:56:21 +08:00
YAMAMOTO Takashi and GitHub
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
YAMAMOTO Takashi and GitHub
9c34fc3514
Fix build with ancient GCC (4.8) ( #2553 )
...
Fixes: https://github.com/bytecodealliance/wasm-micro-runtime/issues/2552
2023-09-15 16:24:12 +08:00
YAMAMOTO Takashi and GitHub
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 and GitHub
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 and GitHub
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 and GitHub
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
YAMAMOTO Takashi and GitHub
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
YAMAMOTO Takashi and GitHub
48b71a05fb
libc-wasi: Remove unused code ( #2528 )
2023-09-04 19:14:56 +08:00
YAMAMOTO Takashi and GitHub
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 and GitHub
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
YAMAMOTO Takashi and GitHub
1ff41ebdc2
Implement os_usleep for posix ( #2517 )
2023-09-01 12:10:54 +08:00
YAMAMOTO Takashi and GitHub
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
YAMAMOTO Takashi and GitHub
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
YAMAMOTO Takashi and GitHub
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
YAMAMOTO Takashi and GitHub
5c6613b2b1
Correct --heap-size option in messages ( #2458 )
2023-08-14 15:12:59 +08:00
YAMAMOTO Takashi and GitHub
5780effc07
iwasm: Fix native lib cleanup after error occurs ( #2443 )
...
- If something failed after calling init_native_lib, call deinit_native_lib to clean up.
- Restructure the relevant code for better maintainability.
2023-08-14 14:05:59 +08:00
YAMAMOTO Takashi and GitHub
a550f4d9f7
iwasm: call native lib init/deinit if exists ( #2439 )
2023-08-10 09:26:52 +08:00
YAMAMOTO Takashi and GitHub
51714c41c0
Introduce WASMModuleInstanceExtraCommon ( #2429 )
...
Move the common parts of WASMModuleInstanceExtra and
AOTModuleInstanceExtra into the new structure.
2023-08-08 09:35:29 +08:00
YAMAMOTO Takashi and GitHub
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 and GitHub
bdd99137a4
embed_wamr.md: Improvements about threads ( #2420 )
...
- Some more clarifications
- Mention wasi-threads
- Fix a confusing indentation
2023-08-04 09:28:30 +08:00
YAMAMOTO Takashi and GitHub
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
YAMAMOTO Takashi and GitHub
8518197053
Remove a few unused functions ( #2409 )
...
They have been unused since commit 5fc48e3584
2023-07-31 19:14:44 +08:00
YAMAMOTO Takashi and GitHub
b1fa27e91d
bh_atomic.h: Add BH_ATOMIC_32_FETCH_ADD/BH_ATOMIC_32_FETCH_SUB ( #2408 )
2023-07-31 17:56:15 +08:00
YAMAMOTO Takashi and GitHub
6d6cea1a73
Fix non-builtin BH_ATOMIC_32_FETCH_OR and BH_ATOMIC_32_FETCH_AND ( #2400 )
2023-07-30 19:23:30 +08:00
YAMAMOTO Takashi and GitHub
7db4815e83
bh_atomic.h: Add comments ( #2398 )
2023-07-28 20:36:35 +08:00
YAMAMOTO Takashi and GitHub
228417ab8c
Move generic parts of wasm_suspend_flags.h to bh_atomic.h ( #2393 )
2023-07-27 21:37:23 +08:00
YAMAMOTO Takashi and GitHub
7448a994ed
iwasm: Disable app heap by default if wasi is enabled ( #2346 )
...
It's rare to require app heap with wasi and sometimes harmful in some cases:
https://github.com/bytecodealliance/wasm-micro-runtime/issues/2275
2023-07-07 16:09:15 +08:00
YAMAMOTO Takashi and GitHub
a300b627d5
nuttx: Add a kconfig for wasi-threads ( #2343 )
...
nuttx apps counterpart: https://github.com/apache/nuttx-apps/pull/1823
2023-07-07 15:12:00 +08:00
YAMAMOTO Takashi and GitHub
228a3bed53
Fix unused warnings on disable_bounds_checks ( #2347 )
2023-07-06 15:31:22 +08:00
YAMAMOTO Takashi and GitHub
3bbf59ad45
wamrc: Warn on text relocations for XIP ( #2340 )
2023-07-05 10:49:45 +08:00
YAMAMOTO Takashi and GitHub
1f89e446d9
Avoid switch lowering to lookup tables for XIP ( #2339 )
...
Because it involves relocations for the table. (.Lswitch.table.XXX)
Discussions: https://github.com/bytecodealliance/wasm-micro-runtime/issues/2316
2023-07-04 16:48:32 +08:00
YAMAMOTO Takashi and GitHub
c39eb46b6f
Add a few more assertions on structures to which aot abi is sensitive ( #2326 )
2023-06-30 10:22:46 +08:00