Merge branch main into dev/wasi_threads

This commit is contained in:
Wenyong Huang
2023-02-17 08:46:12 +08:00
163 changed files with 7153 additions and 1857 deletions

View File

@ -277,7 +277,6 @@ static void
handle_cmd_unload_module(uint64 *args, uint32 argc)
{
EnclaveModule *enclave_module = *(EnclaveModule **)args++;
uint32 i;
bh_assert(argc == 1);

View File

@ -32,12 +32,28 @@ print_help()
#if WASM_ENABLE_LOG != 0
printf(" -v=n Set log verbose level (0 to 5, default is 2) larger\n"
" level with more log\n");
#endif
#if WASM_ENABLE_INTERP != 0
printf(" --interp Run the wasm app with interpreter mode\n");
#endif
#if WASM_ENABLE_FAST_JIT != 0
printf(" --fast-jit Run the wasm app with fast jit mode\n");
#endif
#if WASM_ENABLE_JIT != 0
printf(" --llvm-jit Run the wasm app with llvm jit mode\n");
#endif
#if WASM_ENABLE_JIT != 0 && WASM_ENABLE_FAST_JIT != 0 && WASM_ENABLE_LAZY_JIT != 0
printf(" --multi-tier-jit Run the wasm app with multi-tier jit mode\n");
#endif
printf(" --stack-size=n Set maximum stack size in bytes, default is 64 KB\n");
printf(" --heap-size=n Set maximum heap size in bytes, default is 16 KB\n");
#if WASM_ENABLE_FAST_JIT != 0
printf(" --jit-codecache-size=n Set fast jit maximum code cache size in bytes,\n");
printf(" default is %u KB\n", FAST_JIT_DEFAULT_CODE_CACHE_SIZE / 1024);
#endif
#if WASM_ENABLE_JIT != 0
printf(" --llvm-jit-size-level=n Set LLVM JIT size level, default is 3\n");
printf(" --llvm-jit-opt-level=n Set LLVM JIT optimization level, default is 3\n");
#endif
printf(" --repl Start a very simple REPL (read-eval-print-loop) mode\n"
" that runs commands in the form of \"FUNC ARG...\"\n");
@ -347,9 +363,14 @@ main(int argc, char *argv[])
uint32 stack_size = 64 * 1024, heap_size = 16 * 1024;
#if WASM_ENABLE_FAST_JIT != 0
uint32 jit_code_cache_size = FAST_JIT_DEFAULT_CODE_CACHE_SIZE;
#endif
#if WASM_ENABLE_JIT != 0
uint32 llvm_jit_size_level = 3;
uint32 llvm_jit_opt_level = 3;
#endif
wasm_module_t wasm_module = NULL;
wasm_module_inst_t wasm_module_inst = NULL;
RunningMode running_mode = 0;
RuntimeInitArgs init_args;
char error_buf[128] = { 0 };
#if WASM_ENABLE_LOG != 0
@ -387,6 +408,27 @@ main(int argc, char *argv[])
}
func_name = argv[0];
}
#if WASM_ENABLE_INTERP != 0
else if (!strcmp(argv[0], "--interp")) {
running_mode = Mode_Interp;
}
#endif
#if WASM_ENABLE_FAST_JIT != 0
else if (!strcmp(argv[0], "--fast-jit")) {
running_mode = Mode_Fast_JIT;
}
#endif
#if WASM_ENABLE_JIT != 0
else if (!strcmp(argv[0], "--llvm-jit")) {
running_mode = Mode_LLVM_JIT;
}
#endif
#if WASM_ENABLE_JIT != 0 && WASM_ENABLE_FAST_JIT != 0 \
&& WASM_ENABLE_LAZY_JIT != 0
else if (!strcmp(argv[0], "--multi-tier-jit")) {
running_mode = Mode_Multi_Tier_JIT;
}
#endif
#if WASM_ENABLE_LOG != 0
else if (!strncmp(argv[0], "-v=", 3)) {
log_verbose_level = atoi(argv[0] + 3);
@ -414,6 +456,38 @@ main(int argc, char *argv[])
jit_code_cache_size = atoi(argv[0] + 21);
}
#endif
#if WASM_ENABLE_JIT != 0
else if (!strncmp(argv[0], "--llvm-jit-size-level=", 22)) {
if (argv[0][22] == '\0')
return print_help();
llvm_jit_size_level = atoi(argv[0] + 22);
if (llvm_jit_size_level < 1) {
printf("LLVM JIT size level shouldn't be smaller than 1, "
"setting it to 1\n");
llvm_jit_size_level = 1;
}
else if (llvm_jit_size_level > 3) {
printf("LLVM JIT size level shouldn't be greater than 3, "
"setting it to 3\n");
llvm_jit_size_level = 3;
}
}
else if (!strncmp(argv[0], "--llvm-jit-opt-level=", 21)) {
if (argv[0][21] == '\0')
return print_help();
llvm_jit_opt_level = atoi(argv[0] + 21);
if (llvm_jit_opt_level < 1) {
printf("LLVM JIT opt level shouldn't be smaller than 1, "
"setting it to 1\n");
llvm_jit_opt_level = 1;
}
else if (llvm_jit_opt_level > 3) {
printf("LLVM JIT opt level shouldn't be greater than 3, "
"setting it to 3\n");
llvm_jit_opt_level = 3;
}
}
#endif
#if WASM_ENABLE_LIBC_WASI != 0
else if (!strncmp(argv[0], "--dir=", 6)) {
if (argv[0][6] == '\0')
@ -539,6 +613,7 @@ main(int argc, char *argv[])
memset(&init_args, 0, sizeof(RuntimeInitArgs));
init_args.running_mode = running_mode;
#if WASM_ENABLE_GLOBAL_HEAP_POOL != 0
init_args.mem_alloc_type = Alloc_With_Pool;
init_args.mem_alloc_option.pool.heap_buf = global_heap_buf;
@ -554,6 +629,11 @@ main(int argc, char *argv[])
init_args.fast_jit_code_cache_size = jit_code_cache_size;
#endif
#if WASM_ENABLE_JIT != 0
init_args.llvm_jit_size_level = llvm_jit_size_level;
init_args.llvm_jit_opt_level = llvm_jit_opt_level;
#endif
#if WASM_ENABLE_DEBUG_INTERP != 0
init_args.instance_port = instance_port;
if (ip_addr)

View File

@ -26,9 +26,25 @@ print_help()
#if WASM_ENABLE_LOG != 0
printf(" -v=n Set log verbose level (0 to 5, default is 2) larger\n"
" level with more log\n");
#endif
#if WASM_ENABLE_INTERP != 0
printf(" --interp Run the wasm app with interpreter mode\n");
#endif
#if WASM_ENABLE_FAST_JIT != 0
printf(" --fast-jit Run the wasm app with fast jit mode\n");
#endif
#if WASM_ENABLE_JIT != 0
printf(" --llvm-jit Run the wasm app with llvm jit mode\n");
#endif
#if WASM_ENABLE_JIT != 0 && WASM_ENABLE_FAST_JIT != 0 && WASM_ENABLE_LAZY_JIT != 0
printf(" --multi-tier-jit Run the wasm app with multi-tier jit mode\n");
#endif
printf(" --stack-size=n Set maximum stack size in bytes, default is 64 KB\n");
printf(" --heap-size=n Set maximum heap size in bytes, default is 16 KB\n");
#if WASM_ENABLE_JIT != 0
printf(" --llvm-jit-size-level=n Set LLVM JIT size level, default is 3\n");
printf(" --llvm-jit-opt-level=n Set LLVM JIT optimization level, default is 3\n");
#endif
printf(" --repl Start a very simple REPL (read-eval-print-loop) mode\n"
" that runs commands in the form of `FUNC ARG...`\n");
#if WASM_ENABLE_LIBC_WASI != 0
@ -228,8 +244,13 @@ main(int argc, char *argv[])
uint8 *wasm_file_buf = NULL;
uint32 wasm_file_size;
uint32 stack_size = 64 * 1024, heap_size = 16 * 1024;
#if WASM_ENABLE_JIT != 0
uint32 llvm_jit_size_level = 3;
uint32 llvm_jit_opt_level = 3;
#endif
wasm_module_t wasm_module = NULL;
wasm_module_inst_t wasm_module_inst = NULL;
RunningMode running_mode = 0;
RuntimeInitArgs init_args;
char error_buf[128] = { 0 };
#if WASM_ENABLE_LOG != 0
@ -257,6 +278,26 @@ main(int argc, char *argv[])
}
func_name = argv[0];
}
#if WASM_ENABLE_INTERP != 0
else if (!strcmp(argv[0], "--interp")) {
running_mode = Mode_Interp;
}
#endif
#if WASM_ENABLE_FAST_JIT != 0
else if (!strcmp(argv[0], "--fast-jit")) {
running_mode = Mode_Fast_JIT;
}
#endif
#if WASM_ENABLE_JIT != 0
else if (!strcmp(argv[0], "--llvm-jit")) {
running_mode = Mode_LLVM_JIT;
}
#endif
#if WASM_ENABLE_JIT != 0 && WASM_ENABLE_FAST_JIT != 0
else if (!strcmp(argv[0], "--multi-tier-jit")) {
running_mode = Mode_Multi_Tier_JIT;
}
#endif
#if WASM_ENABLE_LOG != 0
else if (!strncmp(argv[0], "-v=", 3)) {
log_verbose_level = atoi(argv[0] + 3);
@ -277,6 +318,38 @@ main(int argc, char *argv[])
return print_help();
heap_size = atoi(argv[0] + 12);
}
#if WASM_ENABLE_JIT != 0
else if (!strncmp(argv[0], "--llvm-jit-size-level=", 22)) {
if (argv[0][22] == '\0')
return print_help();
llvm_jit_size_level = atoi(argv[0] + 22);
if (llvm_jit_size_level < 1) {
printf("LLVM JIT size level shouldn't be smaller than 1, "
"setting it to 1\n");
llvm_jit_size_level = 1;
}
else if (llvm_jit_size_level > 3) {
printf("LLVM JIT size level shouldn't be greater than 3, "
"setting it to 3\n");
llvm_jit_size_level = 3;
}
}
else if (!strncmp(argv[0], "--llvm-jit-opt-level=", 21)) {
if (argv[0][21] == '\0')
return print_help();
llvm_jit_opt_level = atoi(argv[0] + 21);
if (llvm_jit_opt_level < 1) {
printf("LLVM JIT opt level shouldn't be smaller than 1, "
"setting it to 1\n");
llvm_jit_opt_level = 1;
}
else if (llvm_jit_opt_level > 3) {
printf("LLVM JIT opt level shouldn't be greater than 3, "
"setting it to 3\n");
llvm_jit_opt_level = 3;
}
}
#endif
#if WASM_ENABLE_LIBC_WASI != 0
else if (!strncmp(argv[0], "--dir=", 6)) {
if (argv[0][6] == '\0')
@ -357,6 +430,7 @@ main(int argc, char *argv[])
memset(&init_args, 0, sizeof(RuntimeInitArgs));
init_args.running_mode = running_mode;
#if WASM_ENABLE_GLOBAL_HEAP_POOL != 0
init_args.mem_alloc_type = Alloc_With_Pool;
init_args.mem_alloc_option.pool.heap_buf = global_heap_buf;
@ -368,6 +442,11 @@ main(int argc, char *argv[])
init_args.mem_alloc_option.allocator.free_func = free;
#endif
#if WASM_ENABLE_JIT != 0
init_args.llvm_jit_size_level = llvm_jit_size_level;
init_args.llvm_jit_opt_level = llvm_jit_opt_level;
#endif
#if WASM_ENABLE_DEBUG_INTERP != 0
init_args.instance_port = instance_port;
if (ip_addr)