f0a8286863
Refactor fast-interpreter SIMD compilation flags ( #4261 )
...
- enable SIMD flag by default unless hardware limitation
- use SIMDE flag to control fast-interpreter behavior
2025-05-14 10:38:30 +08:00
c48dd5ccd7
Don't call os_thread_get_stack_boundary unless we actually use it ( #4264 )
...
Previously, if the user sets their own stack boundary, we still compute
the thread stack boundary (which is expensive), then immediately discard
the result. This change makes the expensive call only if we need it for
sure.
2025-05-09 17:14:33 +08:00
efa8019bdb
Merge dev/simd for fast-interp ( #4131 )
...
* Implement the first few SIMD opcodes for fast interpreter (v128.const, v128.any_true) (#3818 )
Tested on the following code:
```
(module
(import "wasi_snapshot_preview1" "proc_exit" (func $proc_exit (param i32)))
(memory (export "memory") 1)
;; WASI entry point
(func $main (export "_start")
v128.const i8x16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
v128.any_true
if
unreachable
end
v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
v128.any_true
i32.const 0
i32.eq
if
unreachable
end
i32.const 0
call $proc_exit
)
)
```
* implement POP_V128()
This is to simplify the simd implementation for fast interpreter
* Add all SIMD operations into wasm_interp_fast switch
* Add V128 comparison operations
Tested using
```
(module
(import "wasi_snapshot_preview1" "proc_exit" (func $proc_exit (param i32)))
(memory (export "memory") 1)
(func $assert_true (param v128)
local.get 0
v128.any_true
i32.eqz
if
unreachable
end
)
(func $main (export "_start")
;; Test v128.not
v128.const i8x16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
v128.not
v128.const i8x16 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
i8x16.eq
call $assert_true
;; Test v128.and
v128.const i8x16 255 255 255 255 0 0 0 0 255 255 255 255 0 0 0 0
v128.const i8x16 255 255 0 0 255 255 0 0 255 255 0 0 255 255 0 0
v128.and
v128.const i8x16 255 255 0 0 0 0 0 0 255 255 0 0 0 0 0 0
i8x16.eq
call $assert_true
;; Test v128.andnot
v128.const i8x16 255 255 255 255 0 0 0 0 255 255 255 255 0 0 0 0
v128.const i8x16 255 255 0 0 255 255 0 0 255 255 0 0 255 255 0 0
v128.andnot
v128.const i8x16 0 0 255 255 0 0 0 0 0 0 255 255 0 0 0 0
i8x16.eq
call $assert_true
;; Test v128.or
v128.const i8x16 255 255 0 0 0 0 255 255 255 255 0 0 0 0 255 0
v128.const i8x16 0 0 255 255 255 255 0 0 0 0 255 255 255 255 0 0
v128.or
v128.const i8x16 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0
i8x16.eq
call $assert_true
;; Test v128.xor
v128.const i8x16 255 255 0 0 255 255 0 0 255 255 0 0 255 255 0 0
v128.const i8x16 255 255 255 255 0 0 0 0 255 255 255 255 0 0 0 0
v128.xor
v128.const i8x16 0 0 255 255 255 255 0 0 0 0 255 255 255 255 0 0
i8x16.eq
call $assert_true
i32.const 0
call $proc_exit
)
)
```
* Add first NEON SIMD opcode implementations to fast interpreter (#3859 )
Add some implementations of SIMD opcodes using NEON instructions.
Tested using:
```wast
(module
(import "wasi_snapshot_preview1" "proc_exit" (func $proc_exit (param i32)))
(memory (export "memory") 1)
(func $assert_true (param v128)
local.get 0
v128.any_true
i32.eqz
if
unreachable
end
)
(func $main (export "_start")
i32.const 0
i32.const 32
memory.grow
drop
i32.const 0
v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
v128.store
i32.const 0
v128.load
v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
i8x16.eq
call $assert_true
i32.const 16
v128.const i8x16 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
v128.store
i32.const 16
v128.load
v128.const i8x16 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
i8x16.eq
call $assert_true
i32.const 0
v128.load
v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
i8x16.eq
call $assert_true
drop
i32.const 0
i32.const 1
memory.grow
drop
i32.const 0
i64.const 0x7F80FF017E02FE80
i64.store
i32.const 0
v128.load8x8_s
v128.const i16x8 127 -128 -1 1 126 2 -2 -128
i16x8.eq
call $assert_true
i32.const 0
i64.const 0x80FE027E01FF807F
i64.store
i32.const 0
v128.load8x8_u
v128.const i16x8 128 254 2 126 1 255 128 127
i16x8.eq
call $assert_true
i32.const 0
i64.const 0x8000FFFE7FFF0001
i64.store
i32.const 0
v128.load16x4_s
v128.const i32x4 -32768 -2 32767 1
i32x4.eq
call $assert_true
i32.const 0
i64.const 0x8000FFFE7FFF0001
i64.store
i32.const 0
v128.load16x4_u
v128.const i32x4 32768 65534 32767 1
i32x4.eq
call $assert_true
i32.const 0
i64.const 0x8000000000000001
i64.store
i32.const 0
v128.load32x2_s
v128.const i64x2 -2147483648 1
i64x2.eq
call $assert_true
i32.const 0
i64.const 0x8000000000000001
i64.store
i32.const 0
v128.load32x2_u
v128.const i64x2 2147483648 1
i64x2.eq
call $assert_true
call $proc_exit
)
)
```
* Emit imm for lane extract and replace (#3906 )
* Fix replacement value not being correct (#3919 )
* Implement load lanes opcodes for wasm (#3942 )
* Implement final SIMD opcodes: store lane (#4001 )
* Fix load/store (#4054 )
* Correctly use unsigned functions (#4055 )
* implement local and function calls for v128 in the fast interpreter
* Fix splat opcodes, add V128 handling in preserve_referenced_local and reserve_block_ret
* Fix incorrect memory overflow values + SIMD ifdefs
* Fix load/load_splat macros
* correct endif wasm loader
* Update core/iwasm/interpreter/wasm_opcode.h
* Fix spec tests when WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS is 0
* Resolve merge conflicts arising from main -> dev/simd_for_interp and implement fast interpreter const offset loader support for V128
* Enable SIMDe tests on CI
* Document WAMR_BUILD_LIB_SIMDE
---------
Co-authored-by: James Marsh <mrshnja@amazon.co.uk >
Co-authored-by: jammar1 <108334558+jammar1@users.noreply.github.com >
Co-authored-by: Maks Litskevich <makslit@amazon.com >
Co-authored-by: Marcin Kolny <marcin.kolny@gmail.com >
Co-authored-by: Wenyong Huang <wenyong.huang@intel.com >
2025-03-20 14:23:20 +08:00
c6f934434b
Merge pull request #4124 from swankjesse/WAMR_BUILD_GC_HEAP_SIZE_DEFAULT
...
Expose WAMR_BUILD_GC_HEAP_SIZE_DEFAULT as a CMake option
2025-03-12 14:55:27 +08:00
766f378590
Merge pull request #4033 from g0djan/godjan/iterate_callstack
...
Copy callstack API
2025-03-11 10:31:56 +08:00
412631ac13
fix: correct typos and improve comments across multiple files by codespell ( #4116 )
...
Signed-off-by: Huang Qi <huangqi3@xiaomi.com >
2025-03-07 08:21:54 +08:00
d609acf1ee
Move the default heap size initialization
2025-03-04 18:43:30 -05:00
de82d1946f
Address code review feedback
2025-03-03 20:45:59 -05:00
ffcc1579ea
clang format
2025-03-03 13:41:35 +00:00
bc00b3e492
address comments
2025-03-03 13:36:05 +00:00
beb34c3675
Expose WAMR_BUILD_GC_HEAP_SIZE_DEFAULT as a CMake option
...
This is wired through to the GC_HEAP_SIZE_DEFAULT constant.
Also honor this value when configuring the engine with the
wasm_c_api.
2025-03-02 23:32:04 -05:00
fc3077b74d
address comments
2025-02-27 14:32:17 +00:00
a5d8c0b477
define if not defined
2025-02-26 11:11:17 +00:00
857e6b73c8
formatting
2025-02-26 10:57:50 +00:00
188eb1c941
remove unnecessary includes
2025-02-25 17:42:06 +00:00
f1ffbb5b37
cr suggestions
2025-02-24 21:20:07 +00:00
dfcadc6202
prevent data overflow on 32 bit platform for memory.grow
2025-02-24 21:20:07 +00:00
cc3f0a096b
Cleaning up
2025-02-24 17:33:14 +00:00
32338bb7d6
Copy read only API behind a flag instead of using user defined callback
2025-02-24 17:22:05 +00:00
964037c9b5
feat: add support for EXTERNREF value type and enable AOT validator in fuzz tests ( #4083 )
2025-02-17 13:34:18 +08:00
159f5890a6
[gc] Subtyping fix ( #4075 )
2025-02-17 11:55:58 +08:00
e6a47d5cee
In wasm32, fix potential conversion overflow when enlarging 65536 pages ( #4064 )
...
fix enlarge 65536 pages conversion overflow in wasm32
2025-02-06 14:48:53 +08:00
376385c608
Update memory allocation functions to use allocator user data ( #4043 )
2025-02-06 13:15:00 +08:00
b9039f986e
Merge branch 'main' into godjan/iterate_callstack
2025-01-28 13:35:47 +00:00
813831de0e
keep devs notes out of public API
2025-01-27 11:39:53 +00:00
1f4d3dd4d4
clang-format
2025-01-27 11:31:02 +00:00
e3ddbd58f7
Synchronize the GC spec tests to the commit from December 9. 2024. ( #4022 )
...
- Synchronize the GC spec tests to the commit from December 9. 2024.
- Revise the error messages to be consistent with the spec test cases.
- bypass gc spec test on the nuttx platform as a workaround
2025-01-20 09:41:47 +08:00
68e4534822
Iterate callstack API
2025-01-17 16:16:45 +00:00
7f3e0df21c
Handle a new scenario where an item is both exported and imported. ( #3984 )
2024-12-29 15:52:12 +08:00
c32a6ceae1
Refactor SConscript and add file checks in iwasm.c ( #3945 )
2024-12-06 14:54:37 +08:00
838dd81e68
don't return an uninitialized trap if argv_to_results fails ( #3935 )
...
Currently, if argv_to_results fails (e.g. because an unsupported type is
encountered), an non-null trap with an uninitialized message is
returned.
2024-11-28 11:50:44 +08:00
e09613c722
support WASM_FUNCREF return type in argv_to_results ( #3936 )
2024-11-28 11:50:16 +08:00
9d8150efae
Fix WASI Path Mapping Processing ( #3923 )
...
Filesystem paths can be mapped from the host path to a guest path using
the format `<guest-path>::<host-path>`.
Previously `strtok` was used to find the `::` delimiter. Unfortunately
`strtok` processes each delimiter character individually. This meant
that the code was ~equivalent to `strtok(mapping_copy, ":")` which
breaks with Windows-style paths (E.g. `C:\my_path\`).
To fix this `strstr` is used to search for the exact delimiter.
2024-11-24 11:31:55 +08:00
0e4dffc479
Fix a leak in wasm_loader_emit_br_info ( #3900 )
...
Reference Info: 377955855 wamr:wasm_mutator_fuzz_loader: Direct-leak in wasm_loader_emit_br_info
https://issues.oss-fuzz.com/issues/377955855
2024-11-13 15:16:13 +08:00
c7b2683f17
Fix out of bounds issue in is_native_addr_in_shared_heap function ( #3886 )
...
When checking for integer overflow, you may often write tests like p + i < p.
This works fine if p and i are unsigned integers, since any overflow in the
addition will cause the value to simply "wrap around." However, using this
pattern when p is a pointer is problematic because pointer overflow has
undefined behavior according to the C and C++ standards. If the addition
overflows and has an undefined result, the comparison will likewise be
undefined; it may produce an unintended result, or may be deleted entirely
by an optimizing compiler.
2024-10-31 12:44:55 +08:00
a3960c834d
Refine looking up aot function with index ( #3882 )
...
* Refine looking up aot function with index
* refine the code
2024-10-29 10:58:11 +08:00
48eaa2286a
Refine wasm/aot function instance lookup ( #3865 )
...
Sort the module instance's export functions with the function name,
and use binary search to lookup the wasm/aot function.
2024-10-18 15:15:33 +08:00
74d2427fdc
Allow to set native stack boundary to exec_env ( #3862 )
...
Add runtime API wasm_runtime_set_native_stack_boundary.
p.s. https://github.com/bytecodealliance/wasm-micro-runtime/issues/3816
2024-10-18 12:49:57 +08:00
327374cfee
Fix some compile warnings and typos ( #3854 )
...
- Clear some compile warnings
- Fix some typos
- Fix llvm LICENSE link error
- Remove unused aot file and binarydump bin
- Add checks when loading AOT exports
2024-10-15 16:04:58 +08:00
b038f2721b
Merge pull request #3823 from bytecodealliance/dev/shared_heap
...
Implement the shared heap feature for interpreter, aot and llvm jit.
Add below runtime APIs:
```C
wasm_shared_heap_t
wasm_runtime_create_shared_heap(SharedHeapInitArgs *init_args);
bool
wasm_runtime_attach_shared_heap(wasm_module_inst_t module_inst,
wasm_shared_heap_t shared_heap);
void
wasm_runtime_detach_shared_heap(wasm_module_inst_t module_inst);
uint64_t
wasm_runtime_shared_heap_malloc(wasm_module_inst_t module_inst, uint64_t size,
void **p_native_addr);
void
wasm_runtime_shared_heap_free(wasm_module_inst_t module_inst, uint64_t ptr);
```
And allow wasm app to call API shared_heap_malloc and shared_heap_free:
```C
void *shared_heap_malloc(uint32_t size);
void shared_heap_free(void *ptr);
```
2024-10-15 14:26:22 +08:00
36d438051e
Support table64 extension in classic-interp and AOT running modes ( #3811 )
...
Add table64 extension(in Memory64 proposal) support in classic-interp
and AOT running modes, currently still use uint32 to represent table's
initial and maximum size to keep AOT ABI unchanged.
2024-10-11 21:14:56 +08:00
19160f0e1d
Fix issues of destroy_shared_heaps ( #3847 )
...
Set shared_heap_list to NULL with lock, and destroy shared_heap_list_lock.
Signed-off-by: wenlingyun1 <wenlingyun1@xiaomi.com >
2024-10-10 10:56:36 +08:00
9ba36e284c
Implement shared heap for AOT ( #3815 )
2024-09-29 12:50:59 +08:00
e87f7a920d
Fix Windows compile error when uvwasi is enabled ( #3810 )
...
No need to compile win_file.c when uvwasi is enabled.
2024-09-25 16:43:00 +08:00
1fd422ae6e
Merge branch main into dev/shared_heap
2024-09-20 14:34:00 +08:00
4dacef2d60
shared heap: Fix some issues and add basic unit test case ( #3801 )
...
Fix some issues and add basic unit test case for shared heap feature.
Signed-off-by: wenlingyun1 <wenlingyun1@xiaomi.com >
2024-09-20 14:24:38 +08:00
21330990a8
Add no_resolve to LoadArgs and wasm_runtime_resolve_symbols ( #3790 )
...
Add no_resolve to LoadArgs and wasm_runtime_resolve_symbols so one can
delay resolving of symbols.
This is useful for inspecting the module between loading and instantiating.
2024-09-20 08:54:09 +08:00
5e20cf383e
Refactor shared heap feature for interpreter mode ( #3794 )
...
To add test cases and samples.
2024-09-18 14:53:41 +08:00
92852f3719
Implement a first version of shared heap feature ( #3789 )
...
ps. https://github.com/bytecodealliance/wasm-micro-runtime/issues/3546
2024-09-14 10:51:42 +08:00
926f662231
Add memory instance support apis ( #3786 )
...
Now that WAMR supports multiple memory instances, this PR adds some APIs
to access them in a standard way.
This involves moving some existing utility functions out from the
`WASM_ENABLE_MULTI_MODULE` blocks they were nested in, but multi-memory
and multi-module seem independent as far as I can tell so I assume that's okay.
APIs added:
```C
wasm_runtime_lookup_memory
wasm_runtime_get_default_memory
wasm_runtime_get_memory
wasm_memory_get_cur_page_count
wasm_memory_get_max_page_count
wasm_memory_get_bytes_per_page
wasm_memory_get_shared
wasm_memory_get_base_address
wasm_memory_enlarge
```
2024-09-14 10:31:13 +08:00