Enhance wasm loading with LoadArgs and support module names (#3265)
- Add new API wasm_runtime_load_ex() in wasm_export.h and wasm_module_new_ex in wasm_c_api.h - Put aot_create_perf_map() into a separated file aot_perf_map.c - In perf.map, function names include user specified module name - Enhance the script to help flamegraph generations
This commit is contained in:
32
samples/linux-perf/wasm/fib.c
Normal file
32
samples/linux-perf/wasm/fib.c
Normal file
@ -0,0 +1,32 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int
|
||||
fibonacci(int n)
|
||||
{
|
||||
if (n <= 0)
|
||||
return 0;
|
||||
|
||||
if (n == 1)
|
||||
return 1;
|
||||
|
||||
return fibonacci(n - 1) + fibonacci(n - 2);
|
||||
}
|
||||
|
||||
__attribute__((export_name("run"))) int
|
||||
run(int n)
|
||||
{
|
||||
int result = fibonacci(n);
|
||||
printf("fibonacci(%d)=%d\n", n, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int n = atoi(argv[1]);
|
||||
|
||||
printf("fibonacci(%d)=%d\n", n, fibonacci(n));
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user