mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-06-11 07:39:17 +00:00
Merge pull request #3242 from bytecodealliance/main
Merge branch main into dev/memory64
This commit is contained in:
commit
b0f2cca647
4
.github/workflows/nightly_run.yml
vendored
4
.github/workflows/nightly_run.yml
vendored
|
@ -626,7 +626,9 @@ jobs:
|
|||
run: echo "TEST_ON_X86_32=true" >> $GITHUB_ENV
|
||||
|
||||
- name: set additional tsan options
|
||||
run: echo "TSAN_OPTIONS=suppressions=$PWD/tsan_suppressions.txt" >> $GITHUB_ENV
|
||||
run: |
|
||||
echo "TSAN_OPTIONS=suppressions=$PWD/tsan_suppressions.txt" >> $GITHUB_ENV
|
||||
sudo sysctl vm.mmap_rnd_bits=28
|
||||
working-directory: tests/wamr-test-suites
|
||||
|
||||
#only download llvm libraries in jit and aot mode
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
# Set WAMR's build options
|
||||
if("${IDF_TARGET}" STREQUAL "esp32c3")
|
||||
if("${IDF_TARGET}" STREQUAL "esp32c3" OR "${IDF_TARGET}" STREQUAL "esp32c6")
|
||||
set(WAMR_BUILD_TARGET "RISCV32")
|
||||
else()
|
||||
set(WAMR_BUILD_TARGET "XTENSA")
|
||||
|
|
|
@ -2917,6 +2917,17 @@ do_text_relocation(AOTModule *module, AOTRelocationGroup *group,
|
|||
}
|
||||
symbol_addr = module->func_ptrs[func_index];
|
||||
}
|
||||
else if (!strncmp(symbol, "_" AOT_FUNC_INTERNAL_PREFIX,
|
||||
strlen("_" AOT_FUNC_INTERNAL_PREFIX))) {
|
||||
p = symbol + strlen("_" AOT_FUNC_INTERNAL_PREFIX);
|
||||
if (*p == '\0'
|
||||
|| (func_index = (uint32)atoi(p)) > module->func_count) {
|
||||
set_error_buf_v(error_buf, error_buf_size, "invalid symbol %s",
|
||||
symbol);
|
||||
goto check_symbol_fail;
|
||||
}
|
||||
symbol_addr = module->func_ptrs[func_index];
|
||||
}
|
||||
#endif
|
||||
else if (is_text_section(symbol)) {
|
||||
symbol_addr = module->code;
|
||||
|
|
|
@ -189,6 +189,16 @@ wasm_struct_obj_get_field(const WASMStructObjectRef struct_obj,
|
|||
}
|
||||
}
|
||||
|
||||
uint32
|
||||
wasm_struct_obj_get_field_count(const WASMStructObjectRef struct_obj)
|
||||
{
|
||||
WASMRttTypeRef rtt_type =
|
||||
(WASMRttTypeRef)wasm_object_header((WASMObjectRef)struct_obj);
|
||||
WASMStructType *struct_type = (WASMStructType *)rtt_type->defined_type;
|
||||
|
||||
return struct_type->field_count;
|
||||
}
|
||||
|
||||
WASMArrayObjectRef
|
||||
wasm_array_obj_new_internal(void *heap_handle, WASMRttTypeRef rtt_type,
|
||||
uint32 length, WASMValue *init_value)
|
||||
|
|
|
@ -157,6 +157,16 @@ void
|
|||
wasm_struct_obj_get_field(const WASMStructObjectRef struct_obj,
|
||||
uint32 field_idx, bool sign_extend, WASMValue *value);
|
||||
|
||||
/**
|
||||
* Return the field count of the WASM struct object.
|
||||
*
|
||||
* @param struct_obj the WASM struct object
|
||||
*
|
||||
* @return the field count of the WASM struct object
|
||||
*/
|
||||
uint32
|
||||
wasm_struct_obj_get_field_count(const WASMStructObjectRef struct_obj);
|
||||
|
||||
WASMArrayObjectRef
|
||||
wasm_array_obj_new_internal(void *heap_handle, WASMRttTypeRef rtt_type,
|
||||
uint32 length, WASMValue *init_value);
|
||||
|
|
|
@ -3947,7 +3947,12 @@ aot_resolve_object_relocation_group(AOTObjectData *obj_data,
|
|||
* Note: aot_stack_sizes_section_name section only contains
|
||||
* stack_sizes table.
|
||||
*/
|
||||
if (!strcmp(relocation->symbol_name, aot_stack_sizes_name)) {
|
||||
if (!strcmp(relocation->symbol_name, aot_stack_sizes_name)
|
||||
/* in windows 32, the symbol name may start with '_' */
|
||||
|| (strlen(relocation->symbol_name) > 0
|
||||
&& relocation->symbol_name[0] == '_'
|
||||
&& !strcmp(relocation->symbol_name + 1,
|
||||
aot_stack_sizes_name))) {
|
||||
/* discard const */
|
||||
relocation->symbol_name = (char *)aot_stack_sizes_section_name;
|
||||
}
|
||||
|
|
|
@ -437,6 +437,16 @@ WASM_RUNTIME_API_EXTERN void
|
|||
wasm_struct_obj_get_field(const wasm_struct_obj_t obj, uint32_t field_idx,
|
||||
bool sign_extend, wasm_value_t *value);
|
||||
|
||||
/**
|
||||
* Get the field count of the a struct object.
|
||||
*
|
||||
* @param obj the WASM struct object
|
||||
*
|
||||
* @return the field count of the a struct object
|
||||
*/
|
||||
WASM_RUNTIME_API_EXTERN uint32_t
|
||||
wasm_struct_obj_get_field_count(const wasm_struct_obj_t obj);
|
||||
|
||||
/**
|
||||
* Create an array object with the index of defined type, the obj's length is
|
||||
* length, init value is init_value
|
||||
|
|
|
@ -98,17 +98,22 @@ You should only use this method for well tested wasm applications and make sure
|
|||
Linux perf is a powerful tool to analyze the performance of a program, developer can use it to find the hot functions and optimize them. It is one profiler supported by WAMR. In order to use it, you need to add `--perf-profile` while running _iwasm_. By default, it is disabled.
|
||||
|
||||
> [!CAUTION]
|
||||
> For now, only llvm-jit mode supports linux-perf.
|
||||
> For now, only llvm-jit mode and aot mode supports linux-perf.
|
||||
|
||||
Here is a basic example, if there is a Wasm application _foo.wasm_, you'll execute.
|
||||
|
||||
```
|
||||
$ perf record --output=perf.data.raw -- iwasm --perf-profile foo.wasm
|
||||
$ perf record --output=perf.data.raw -- iwasm --enable-linux-perf foo.wasm
|
||||
```
|
||||
|
||||
This will create a _perf.data_ and a _jit-xxx.dump_ under _~/.debug.jit/_ folder. This extra file is WAMR generated at runtime, and it contains the mapping between the JIT code and the original Wasm function names.
|
||||
This will create a _perf.data_ and
|
||||
- a _jit-xxx.dump_ under _~/.debug/jit/_ folder if running llvm-jit mode
|
||||
- or _/tmp/perf-<pid>.map_ if running AOT mode
|
||||
|
||||
The next thing need to do is to merge _jit-xxx.dump_ file into the _perf.data_.
|
||||
|
||||
This file is WAMR generated. It contains information which includes jitted(precompiled) code addresses in memory, names of jitted (precompiled) functions which are named as *aot_func#N* and so on.
|
||||
|
||||
If running with llvm-jit mode, the next thing is to merge _jit-xxx.dump_ file into the _perf.data_.
|
||||
|
||||
```
|
||||
$ perf inject --jit --input=perf.data.raw --output=perf.data
|
||||
|
@ -141,28 +146,28 @@ $ perf report --input=perf.data
|
|||
[Flamegraph](https://www.brendangregg.com/flamegraphs.html) is a powerful tool to visualize stack traces of profiled software so that the most frequent code-paths can be identified quickly and accurately. In order to use it, you need to [capture graphs](https://github.com/brendangregg/FlameGraph#1-capture-stacks) when running `perf record`
|
||||
|
||||
```
|
||||
$ perf record -k mono --call-graph=fp --output=perf.data.raw -- iwasm --perf-profile foo.wasm
|
||||
$ perf record -k mono --call-graph=fp --output=perf.data.raw -- iwasm --enable-linux-perf foo.wasm
|
||||
```
|
||||
|
||||
merge the _jit-xxx.dump_ file into the _perf.data.raw_.
|
||||
If running with llvm-jit mode, merge the _jit-xxx.dump_ file into the _perf.data.raw_.
|
||||
|
||||
```
|
||||
$ perf inject --jit --input=perf.data.raw --output=perf.data
|
||||
```
|
||||
|
||||
generate the stack trace file.
|
||||
Generate the stack trace file.
|
||||
|
||||
```
|
||||
$ perf script > out.perf
|
||||
```
|
||||
|
||||
[fold stacks](https://github.com/brendangregg/FlameGraph#2-fold-stacks).
|
||||
[Fold stacks](https://github.com/brendangregg/FlameGraph#2-fold-stacks).
|
||||
|
||||
```
|
||||
$ ./FlameGraph/stackcollapse-perf.pl out.perf > out.folded
|
||||
```
|
||||
|
||||
[render a flamegraph](https://github.com/brendangregg/FlameGraph#3-flamegraphpl)
|
||||
[Render a flamegraph](https://github.com/brendangregg/FlameGraph#3-flamegraphpl)
|
||||
|
||||
```
|
||||
$ ./FlameGraph/flamegraph.pl out.folded > perf.foo.wasm.svg
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
ESP32_TARGET="esp32"
|
||||
ESP32C3_TARGET="esp32c3"
|
||||
ESP32S3_TARGET="esp32s3"
|
||||
ESP32C6_TARGET="esp32c6"
|
||||
|
||||
usage ()
|
||||
{
|
||||
|
@ -15,6 +16,7 @@ usage ()
|
|||
echo " $0 $ESP32_TARGET"
|
||||
echo " $0 $ESP32C3_TARGET"
|
||||
echo " $0 $ESP32S3_TARGET"
|
||||
echo " $0 $ESP32C6_TARGET"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@ def collect_import_section_content(wasm_objdump_bin: Path, wasm_file: Path) -> d
|
|||
)
|
||||
|
||||
if p.stderr:
|
||||
print("No content in import section")
|
||||
return {}
|
||||
|
||||
import_section = {}
|
||||
|
@ -77,17 +78,19 @@ def collect_import_section_content(wasm_objdump_bin: Path, wasm_file: Path) -> d
|
|||
if not line:
|
||||
continue
|
||||
|
||||
if line.startswith(" - func"):
|
||||
import_section.update("function", import_section.get("function", 0) + 1)
|
||||
if re.search(r"^-\s+func", line):
|
||||
import_section.update(function=import_section.get("function", 0) + 1)
|
||||
else:
|
||||
pass
|
||||
|
||||
assert len(import_section) > 0, "failed to retrive content of import section"
|
||||
return import_section
|
||||
|
||||
|
||||
def collect_name_section_content(wasm_objdump_bin: Path, wasm_file: Path) -> dict:
|
||||
"""
|
||||
execute "wasm_objdump_bin -j name -x wasm_file" and store the output in a list
|
||||
execute "wasm_objdump_bin -j name -x wasm_file" and store the output in a dict
|
||||
{1: xxxx, 2: yyyy, 3: zzzz}
|
||||
"""
|
||||
assert wasm_objdump_bin.exists()
|
||||
assert wasm_file.exists()
|
||||
|
@ -117,7 +120,7 @@ def collect_name_section_content(wasm_objdump_bin: Path, wasm_file: Path) -> dic
|
|||
assert m
|
||||
|
||||
func_index, func_name = m.groups()
|
||||
name_section.update({func_index: func_name})
|
||||
name_section.update({int(func_index): func_name})
|
||||
|
||||
assert name_section
|
||||
return name_section
|
||||
|
@ -162,7 +165,7 @@ def replace_function_name(
|
|||
new_line.append(sym)
|
||||
continue
|
||||
|
||||
func_idx = m.groups()[-1]
|
||||
func_idx = int(m.groups()[-1]) + import_function_count
|
||||
if func_idx in name_section:
|
||||
wasm_func_name = f"[Wasm] {name_section[func_idx]}"
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue
Block a user