Commit Graph

1749 Commits

Author SHA1 Message Date
Enrico Loparco
170ae35131
test_wamr.sh: Allow using test script on different platforms (#3098)
The `^^` for uppercase is not widely supported, e.g. not working on some MacOS M1.
2024-01-30 11:02:40 +08:00
Wenyong Huang
7f8e2133ec
Fix windows build error and compilation warnings (#3095)
Fix wamrc build error reported on Windows:
```bash
CMake Error at CMakeLists.txt:84 (message):
  Unsupported CMAKE_HOST_SYSTEM_PROCESSOR AMD64
```
And clear several compilation warnings.
2024-01-29 18:57:57 +08:00
Huang Qi
b98f150f82
CI: Update version of checkout to suppress warnings (#3093) 2024-01-27 07:55:49 +08:00
tkernelcn
83c3ef0f46
freertos: Thread exit more common (#3094)
In native side,  even not call `os_thread_exit` at end of thread code,
can also exit correctly.
2024-01-26 18:38:55 +08:00
liang.he
99bbad8cdb
perf profiling: Adjust the calculation of execution time (#3089) 2024-01-26 18:06:21 +08:00
Huang Qi
9fb5fcc709
Add comments to suppress warning from clang-tidy (#3088)
Suppress style warnings for macro definition, name of these macros is
inconsistent with others (upper case).
2024-01-26 17:02:24 +08:00
Huang Qi
ad46290770
Update outdated reference link in multi_module.md (#3092) 2024-01-26 16:55:27 +08:00
Wenyong Huang
313ce8cb61
Fix memory/table segment checks in memory.init/table.init (#3081)
According to the wasm core spec, the checks for the table segments in
`table.init` opcode are similar to the checks for `memory.init` opcode:
- The size of a passive segment is shrunk to zero after `data.drop`
  (or `elem.drop`) opcode is executed, and the segment can be used to do
  `memory.init` (or `table.init`) again
- The `memory.init` only traps when `s+n > len(data.data)` or `d+n > len(mem.data)`
  and `table.init` only traps when `s+n > len(elem.elem)` or `d+n > len(tab.elem)`
- The active segment can also be used to do `memory.init` (or `table.init`),
  while it behaves like a dropped passive segment

https://github.com/WebAssembly/bulk-memory-operations/blob/master/proposals/bulk-memory-operations/Overview.md
```
Segments can also be shrunk to size zero by using the following new instructions:
- data.drop: discard the data in an data segment
- elem.drop: discard the data in an element segment

An active segment is equivalent to a passive segment, but with an implicit
memory.init followed by a data.drop (or table.init followed by a elem.drop)
that is prepended to the module's start function.
```
ps.
https://webassembly.github.io/spec/core/bikeshed/#-hrefsyntax-instr-memorymathsfmemoryinitx%E2%91%A0
https://webassembly.github.io/spec/core/bikeshed/#-hrefsyntax-instr-tablemathsftableinitxy%E2%91%A0
https://github.com/bytecodealliance/wasm-micro-runtime/issues/3020
2024-01-26 09:45:59 +08:00
Huang Qi
6daaf6d27a
Fix inconsistent code style in aot_loader.c (#3082) 2024-01-25 17:19:14 +08:00
YAMAMOTO Takashi
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
Gavin Hayes
bf9fb2e680
cosmopolitan: Update compiler and update platform_internal.h (#3079)
This fixes the cosmopolitan platform.
- Switch `build_cosmocc.sh` and platform documentation to
  explicitly use the x86_64 cosmocc compiler as multi-arch
  cosmocc won't work here. Older version `cosmocc` just did
  a x86_64 build.
- Add missing items from `platform_internal.h` to fix build.
2024-01-24 16:04:48 +08:00
Bruce Mitchener
d815bbc3db
README.md: Fix typo tunning to tuning (#3078) 2024-01-24 15:35:45 +08:00
Bruce Mitchener
61fe78c9ff
Fix download link for wasi-sdk (#3077)
The wasi-sdk repo moved from CraneStation to the WebAssembly org
on GitHub.
2024-01-24 13:42:45 +08:00
Enrico Loparco
3fcd79867d
Forward log and log level to custom bh_log callback (#3070)
Follow-up on #2907. The log level is needed in the host embedder to
better integrate with the embedder's logger.

Allow the developer to customize his bh_log callback with
`cmake -DWAMR_BH_LOG=<log_callback>`,
and update sample/basic to show the usage.
2024-01-24 13:05:07 +08:00
Marcin Kolny
1505e61704
Remove a lot of "unused parameter" warnings (#3075)
They might shadow some of the real issues, so better to keep the number
of warnings as low as possible.
2024-01-24 11:21:13 +08:00
YAMAMOTO Takashi
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
Wenyong Huang
0eb788d711
build_wamr.md: Update the document (#3074)
Add description for `WAMR_BUILD_LINUX_PERF`, `WAMR_BUILD_QUICK_AOT_ENTRY`
and `WAMR_BUILD_MODULE_INST_CONTEXT`.
And add some reference links.
2024-01-24 09:45:57 +08:00
Wenyong Huang
9f64340529
Fix some issues reported by CodeQL (#3064)
Refer to https://github.com/bytecodealliance/wasm-micro-runtime/pull/2812
and https://github.com/bytecodealliance/wasm-micro-runtime/security/code-scanning?query=pr%3A2812+is%3Aopen
2024-01-23 21:38:30 +08:00
YAMAMOTO Takashi
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
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
Wenyong Huang
c8b59588a7
Enhance setting write gs base with cmake variable (#3066)
In linux x86-64, developer can use cmake variable to configure whether
to enable writing linear memory base address to x86 GS register or not:
- `cmake -DWAMR_DISABLE_WRITE_GS_BASE=1`: disabled it
- `cmake -DWAMR_DISABLE_WRITE_GS_BASE=0`: enabled it
- `cmake` without `-DWAMR_DISABLE_WRITE_GS_BASE=1/0`:
        auto-detected by the compiler
2024-01-23 12:21:20 +08:00
Wenyong Huang
7f035d4206
perf_tune.md: Add refine the calling processes between host and wasm (#3065) 2024-01-23 12:20:28 +08:00
YAMAMOTO Takashi
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
Marcin Kolny
627debcefb
Add flag to control Winsocket initialization (#3060)
When WAMR is embedded to other application, the lifecycle of the socket
might conflict with other usecases. E.g. if WAMR is deinitialized before any
other use of sockets, the application goes into the invalid state. The new
flag allows host application to take control over the socket initialization.
2024-01-22 07:33:26 +08:00
Xu Jun
1977ad23ef
fast-interp: Fix dynamic offset error issue in else branch (#3058)
Reported in https://github.com/bytecodealliance/wasm-micro-runtime/issues/3026.
2024-01-19 19:58:12 +08:00
YAMAMOTO Takashi
bc35602004
Fix aot large model (--size-level=0) with LLVM 18 (#3057)
The recent versions LLVM uses ".ltext" section for X86 large model.

cf. d8a04398f9

This fixes https://github.com/bytecodealliance/wasm-micro-runtime/issues/3034
2024-01-19 19:43:41 +08:00
Wenyong Huang
ec6d9cb6be
Check arguments before calling bh_hash_map_find (#3055)
Check whether the arguments are NULL before calling bh_hash_map_find,
or lots of "HashMap find elem failed: map or key is NULL" warnings may
be dumped. Reported in #3053.
2024-01-19 19:29:21 +08:00
YAMAMOTO Takashi
17b0111577
wasm_runtime_begin_blocking_op: A comment about usage expectation (#3056) 2024-01-19 18:31:21 +08:00
Wenyong Huang
a7545df5d0
classic-interp: Handle SIMD opcode when JIT is enabled (#3046)
Though SIMD isn't supported by interpreter, when JIT is enabled,
developer may run `iwasm --interp <wasm_file>` to trigger the SIMD
opcode in interpreter, which isn't handled before this PR.
2024-01-19 12:31:18 +08:00
Huang Qi
54ef0e4de7
Bump NuttX version to 12.4.x in CI (#3047) 2024-01-19 11:24:48 +08:00
YAMAMOTO Takashi
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
Wenyong Huang
9bcf6b4dd3
Enable quick aot entry when hw bound check is disabled (#3044)
- Enable quick aot entry when hw bound check is disabled
- Remove unnecessary ret_type argument in the quick aot entries
- Declare detailed prototype of aot function to call in each quick aot entry
2024-01-19 08:55:35 +08:00
YAMAMOTO Takashi
fde98331ff
examples/terminate: Use wasm_runtime_spawn_exec_env as well (#3049) 2024-01-18 20:44:09 +08:00
YAMAMOTO Takashi
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
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
tkernelcn
a9807058a6
Set CONFIG_HAS_CAP_ENTER to support posix file api for freertos (#3041)
Since there is no so rich api in freertos like embedded system, simply set
CONFIG_HAS_CAP_ENTER to 1 to support posix file api for freertos.
Test file api in wasm app pass.
2024-01-17 21:20:35 +08:00
Huang Qi
64e82ca102
Disable WASM_ENABLE_SHARED_MEMORY_MMAP by default (#3042)
Fix compilation warning.
2024-01-17 19:29:31 +08:00
Huang Qi
dcaaed0160
nuttx: Add option to enable quick aot entry (#3040) 2024-01-17 16:26:53 +08:00
Wenyong Huang
6fb376cbe3
Disable quick aot entry for interp and fast-jit (#3039)
Quick aot/jit entry is only for aot and llvm jit now, no need to enable it
for interpreter and fast-jit when aot and llvm jit are disabled.
2024-01-17 16:17:08 +08:00
Xavier Del Campo
ade97ac3e1
wamr-compiler: Fix non-x86{_64} host builds (#3037)
The build system assumed sizeof (void *) == 8 as a host system
running on a x86_64 architecture, x86 otherwise. However, this
assumption is invalid for most other architectures out there, such as
aarch64 or armv7l.

This PR refers to the CMAKE_HOST_SYSTEM_PROCESSOR variable
which, according to the documentation, typically refers to the output
from "uname -m" for Unix-like systems.
2024-01-17 15:56:04 +08:00
liang.he
5c8b8a17a6
Enhancements on wasm function execution time statistic (#2985)
Enhance the statistic of wasm function execution time, or the performance
profiling feature:
- Add os_time_thread_cputime_us() to get the cputime of a thread,
  and use it to calculate the execution time of a wasm function
- Support the statistic of the children execution time of a function,
  and dump it in wasm_runtime_dump_perf_profiling
- Expose two APIs:
  wasm_runtime_sum_wasm_exec_time
  wasm_runtime_get_wasm_func_exec_time

And rename os_time_get_boot_microsecond to os_time_get_boot_us.
2024-01-17 09:51:54 +08:00
Enrico Loparco
25ccc9f2d5
Avoid unused thread_id warning and recompile multi-module sample (#3033)
- Unused variable warning (when building in release mode):
```bash
wasm-micro-runtime/samples/wasi-threads/wasm-apps/no_pthread.c:44:9:
warning: variable 'thread_id' set but not used [-Wunused-but-set-variable]
    int thread_id;
```
- When using the multi-module example and changing the files in `wasm-apps`,
  they don't get recompiled when the sample is rebuilt. Adding `BUILD_ALWAYS`
  as it's done in other samples.
2024-01-17 08:06:02 +08:00
Maks Litskevich
7b6d0a5d45
Don't redefine D_INO if already defined (#3036) 2024-01-16 22:28:06 +08:00
Marcin Kolny
ffa131b5ac
Allow using mmap for shared memory if hw bound check is disabled (#3029)
For shared memory, the max memory size must be defined in advanced. Re-allocation
for growing memory can't be used as it might change the base address, therefore when
OS_ENABLE_HW_BOUND_CHECK is enabled the memory is mmaped, and if the flag is
disabled, the memory is allocated. This change introduces a flag that allows users to use
mmap for reserving memory address space even if the OS_ENABLE_HW_BOUND_CHECK
is disabled.
2024-01-16 22:15:55 +08:00
Wenyong Huang
b3aaf2abc0
Check passive mode in fast-jit table.init (#3031)
Reported in https://github.com/bytecodealliance/wasm-micro-runtime/issues/3021.
2024-01-16 21:55:10 +08:00
Enrico Loparco
bb053e3a2d
Do not use pagezero size option if osx version >= 13 (#3025)
Reported in https://github.com/bytecodealliance/wasm-micro-runtime/issues/3009.
2024-01-16 12:14:43 +08:00
Wenyong Huang
705bf807b2
Remove deprecated tests in language-bindings python (#3018)
After PR #2922, the caller of wasm-c-api wasm_func_call should ensure
the params and results are correctly created, runtime doesn't check
their format again.
2024-01-16 10:15:56 +08:00
Enrico Loparco
c9fd44e8b8
Build samples in debug mode (#3019)
Follow-up on #3008. Compiling samples in Debug mode allows us to
take advantage of asserts and would have prevented the fix in #3008.
2024-01-16 09:36:05 +08:00
YAMAMOTO Takashi
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
Huang Qi
915adc433d
Rename rwlock_init to avoid conflict (#3016)
This symbol is too simple to cause conflict with others, such as the RW
spinlock in Linux kernel and NuttX, so rename it to avoid the conflict.
2024-01-16 08:53:18 +08:00