Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge branch main into dev/exce_handling #3750

Merged
merged 198 commits into from
Aug 22, 2024
Merged

Merge branch main into dev/exce_handling #3750

merged 198 commits into from
Aug 22, 2024

Conversation

wenyongh
Copy link
Contributor

No description provided.

bnason-nf and others added 30 commits April 30, 2024 08:57
…3378)

The current length type of aot_memmove/aot_memset is size_t, and on
a 64 bit host it is uint64, while what the aot code passes to it is uint32,
this might lead to unexpected behavior.

ps. #3376.
#3382)

Note: wamrc chooses different methods to call native functions
with and without signatures.
Export API:
```C
   wasm_func_type_get_param_count
   wasm_func_type_get_param_valkind
   wasm_func_type_get_result_count
   wasm_func_type_get_result_valkind
```
And change wasm_import_type/wasm_export_type to wasm_import_t/wasm_export_t.
Fix some of the spelling issues found by CSpell.
Add aot binary analysis tool aot-analyzer, samples:

```bash
# parse example.aot, and print basic information about AoT file
$ ./aot-analyzer -i example.aot

# parse example.aot, and print the size of text section of the AoT file
$ ./aot-analyzer -t example.aot

# compare these two files, and show the difference in function size between them
$ ./aot-analyzer -c example.aot example.wasm
```

Signed-off-by: ganjing <[email protected]>
…om section name (#3398)

``` shell
$ python3 append_aot_to_wasm.py --wasm waf.wasm --aot waf.aot -o waf.aot.wasm
$ /opt/wabt-1.0.34/bin/wasm-objdump -h waf.aot.wasm | grep wamr-aot
  Custom start=0x007520c7 end=0x00e021a0 (size=0x006b00d9) "wamr-aot"

$ python3 append_aot_to_wasm.py --wasm waf.wasm --aot waf.aot --ver-str 2.0.0 -o waf.aot.wasm
$ /opt/wabt-1.0.34/bin/wasm-objdump -h waf.aot.wasm | grep wamr-aot
  Custom start=0x007520c7 end=0x00e021a4 (size=0x006b00dd) "wamr-aot-2.0.0"
```
In classic interpreter, fast interpreter and fast-jit running modes, set the local
variables' default value to NULL_REF (0xFFFFFFFF) rather than 0 if they are type
of externref or funcref.

The issue was reported in #3390 and #3391.
If there is no else branch, make a virtual else opcode for easier integrity
check and to copy the correct results to the block return address for
fast-interp mode: change if block from `if ... end` to `if ... else end`.

Reported in issue #3386, #3387, #3388.
Support getting global type from `wasm_runtime_get_import_type` and
`wasm_runtime_get_export_type`, and add two APIs:

```C
wasm_valkind_t
wasm_global_type_get_valkind(const wasm_global_type_t global_type);

bool
wasm_global_type_get_mutable(const wasm_global_type_t global_type);
```
This should match the path inside of .devcontainer/Dockerfile.
Use `WASMFuncType` to represent tag_type in `WASMTagImport` and
`WASMTag` so that the type definition is consistent no matter to GC is
enabled or not.

This PR fixes #3409.
Note: this breaks AOT ABI for xtensa again because of a revert of an ABI-breaking change.
Add WASM_V128 in wasm_valkind_enum and handle the the type accordingly
in wasm_c_api.c and wasm_runtime_common.c, and fix a typo in V128 union.
Some macros are not related to WAMR and have been moved to wamr-app-framework,
we remove them in WAMR.

ps.
#3393 (comment)
bytecodealliance/wamr-app-framework#9
wasm-c-api wasm.h had changed WASM_ANYREF to WASM_EXTERNREF,
we had better change it in WAMR also:
https://github.com/WebAssembly/wasm-c-api/blob/2ce1367c9d1271c83fb63bef26d896a2f290cd23/include/wasm.h#L185
Change to WAMR_CONFIGURABLE_BOUNDS_CHECKS, and fix CodeQL compilation errors
which were introduced by PR #3406.

ps.
#3393 (comment)
https://github.com/bytecodealliance/wasm-micro-runtime/actions/runs/9055318553/job/24876266629
When copying two cells from src offsets to dst offsets in RECOVER_BR_INFO,
the offsets may be overlapped and the src data may be overwritten, use
GET_I64_FROM_ADDR and then SET_I64_FROM_ADDR instead to resolve it.

And handling VALUE_TYPE_FUNCREF/VALUE_TYPE_EXTERNREF for opcode
local.set and local.tee when reference types feature is enabled.

This PR fixes issue #3401 and #3402.
yamt and others added 29 commits August 7, 2024 13:43
Revert commit 6d8d60d:
"Set linux iwasm default visibility to hidden also"

Address comments for pull request #3655.
…#3693)

Some host environment may also create an signal alternate stack and access
it after the wasm runtime exits, the runtime should backup the stack info and
restore it before thread exits.

The issue was found in golang:
```
signal 23 received on thread with on signal stack
fatal error: non-Go code disabled signaltstack
```
Add all possible generated tmp files to the list, those not actually generated
will be simply ignored in the deletion process.
…r access modes (#3694)

When determining the file descriptor rights in the function fd_determine_type_rights(),
we assign fixed and unchangeable rights to STDIN, STDOUT and STDERR.

ps.
#3686
…3702)

Fix:
```
wamr/core/iwasm/libraries/libc-builtin/libc_builtin_wrapper.c:20:1:
  warning: type of 'wasm_runtime_module_realloc' does not match original declaration [-Wlto-type-mismatch]
wamr/core/iwasm/common/wasm_runtime_common.c:3033:1:
  note: return value type mismatch
wamr/core/iwasm/common/wasm_runtime_common.c:3033:1:
  note: type 'uint64' should match type 'uint32'
wamr/core/iwasm/common/wasm_runtime_common.c:3033:1:
  note: 'wasm_runtime_module_realloc' was previously declared here
wamr/core/iwasm/common/wasm_runtime_common.c:3033:1:
  note: code may be misoptimized unless '-fno-strict-aliasing' is used
```
…ween loader and mini loader (#3701)

There's probably a number of other places where the bh_leb_read could be used (e.g. aot loader)
but I'm making the change as small as possible. Further refactoring can be done later.
As reported in #3500, when debug interpreter is enabled, the classic interpreter
performs a lock operation to read `exec_env->current_status->signal_flag` and
do further handling before fetching next opcode, which makes the interpreter
run slower.

This PR atomic loads the `exec_env->current_status->signal_flag` without mutex
lock when 32-bit atomic load is supported, and only adding lock for further
handling when the signal_flag is WAMR_SIG_SINGSTEP, which improves the
performance.
Compilation warnings were reported on mac:
```
core/shared/mem-alloc/ems/ems_gc.c:454:22: warning: passing arguments to 'wasm_runtime_gc_prepare' without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
    gct_vm_gc_prepare(NULL);
                     ^
core/shared/mem-alloc/ems/ems_gc.c:466:23: warning: passing arguments to 'wasm_runtime_gc_finalize' without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
    gct_vm_gc_finished(NULL);
                      ^
2 warnings generated.
```
And fix a typo in ATTRIBUTIONS.md.
These symbols had been removed from NuttX in 2022, so it's time to
remove references to them.
Any use of a table index that isn't exactly a null byte (`0x00`) means that
the module makes use of the reference types proposal. This is important
to track because `aot_compiler.c` will blindly assume that all table indices
are a single byte long otherwise.

This fixes a crash in WAMR for modules that contain multi-byte encodings
of table indices in `call_indirect` but make no other use of reference types
features.
…3721)

If the value of a float constant is an NaN, the aot compiler creates an alloca,
stores the converted i32 const into it and then loads f32 from it again, which
may introduce a relocation in the AOT file and is not allowed for XIP mode.
The table index in the call_indirect/return_call_indirect opcode should be
one byte 0x00 when ref-types/GC isn't enabled, and should be treated as
leb u32 when ref-types/GC is enabled.

And make aot compiler bail out if ref-types/GC is disabled by command line
argument while ref-types instructions are used.
For JIT, we naturally use mach-o on macOS, where the section name
we currently use is not valid and ends up with the errors like:

```
LLVM ERROR: Global variable '__orc_lcl.aot_stack_sizes.0' has an invalid section specifier '.aot_stack_sizes': mach-o section specifier requires a segment and section separated by a comma.
```

Because the dedicated section is not necessary for JIT,
this commit simply stops using it.

Fixes: #3730
When AOT isn't enabled and the input is a wasm file, wasm_runtime_load doesn't
report error. Same when interpreter isn't enabled and the input is AOT file.

This PR makes wasm_runtime_load report error "magic header not detected" for
such situations.
Implement multi-memory for classic-interpreter. Support core spec (and bulk memory) opcodes now,
and will support atomic opcodes, and add multi-memory export APIs in the future. 

PS: Multi-memory spec test patched a lot for linking test to adapt for multi-module implementation.
Enable merged os_mmap for aot data sections first, and try enabling merged
os_mmap for them and aot text except on platform nuttx and esp-idf.

This fixes the issue that aarch64 AOT module fails to load on android:
#2274

And also refine os_mmap related code.
@wenyongh wenyongh merged commit a2be00f into dev/exce_handling Aug 22, 2024
4109 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.