mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-07-15 16:58:34 +00:00
samples/native-stack-overflow: add another test
This commit is contained in:
parent
74d9659e22
commit
2fb5c35159
|
@ -1,16 +1,18 @@
|
|||
#!/bin/bash
|
||||
|
||||
NAME=${1:-test1}
|
||||
|
||||
echo "====== Interpreter"
|
||||
out/native-stack-overflow out/wasm-apps/testapp.wasm
|
||||
out/native-stack-overflow out/wasm-apps/testapp.wasm ${NAME}
|
||||
|
||||
echo
|
||||
echo "====== Interpreter WAMR_DISABLE_HW_BOUND_CHECK=1"
|
||||
out/native-stack-overflow.WAMR_DISABLE_HW_BOUND_CHECK out/wasm-apps/testapp.wasm
|
||||
out/native-stack-overflow.WAMR_DISABLE_HW_BOUND_CHECK out/wasm-apps/testapp.wasm ${NAME}
|
||||
|
||||
echo
|
||||
echo "====== AOT"
|
||||
out/native-stack-overflow out/wasm-apps/testapp.wasm.aot
|
||||
out/native-stack-overflow out/wasm-apps/testapp.wasm.aot ${NAME}
|
||||
|
||||
echo
|
||||
echo "====== AOT WAMR_DISABLE_HW_BOUND_CHECK=1"
|
||||
out/native-stack-overflow.WAMR_DISABLE_HW_BOUND_CHECK out/wasm-apps/testapp.wasm.aot.bounds-checks
|
||||
out/native-stack-overflow.WAMR_DISABLE_HW_BOUND_CHECK out/wasm-apps/testapp.wasm.aot.bounds-checks ${NAME}
|
||||
|
|
|
@ -40,10 +40,11 @@ main(int argc, char **argv)
|
|||
char *buffer;
|
||||
char error_buf[128];
|
||||
|
||||
if (argc != 2) {
|
||||
if (argc != 3) {
|
||||
return 2;
|
||||
}
|
||||
char *module_path = argv[1];
|
||||
const char *module_path = argv[1];
|
||||
const char *funcname = argv[2];
|
||||
|
||||
wasm_module_t module = NULL;
|
||||
uint32 buf_size;
|
||||
|
@ -124,7 +125,6 @@ main(int argc, char **argv)
|
|||
goto fail2;
|
||||
}
|
||||
|
||||
const char *funcname = "test";
|
||||
wasm_function_inst_t func =
|
||||
wasm_runtime_lookup_function(module_inst, funcname);
|
||||
if (!func) {
|
||||
|
|
|
@ -54,7 +54,7 @@ host_consume_stack_and_call_indirect(wasm_exec_env_t exec_env, uint32_t funcidx,
|
|||
return call_indirect(exec_env, funcidx, x);
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
__attribute__((noinline)) static uint32_t
|
||||
consume_stack1(wasm_exec_env_t exec_env, void *base, uint32_t stack)
|
||||
{
|
||||
void *fp = __builtin_frame_address(0);
|
||||
|
|
|
@ -39,14 +39,9 @@ host_consume_stack_cb(int x)
|
|||
return host_consume_stack(x);
|
||||
}
|
||||
|
||||
__attribute__((export_name("test"))) uint32_t
|
||||
test(uint32_t native_stack, uint32_t recurse_count)
|
||||
__attribute__((export_name("test1"))) uint32_t
|
||||
test1(uint32_t native_stack, uint32_t recurse_count)
|
||||
{
|
||||
uint32_t ret;
|
||||
#if 0 /* notyet */
|
||||
ret = host_consume_stack_and_call_indirect(cb, 321, native_stack);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* ------ os_thread_get_stack_boundary
|
||||
* ^
|
||||
|
@ -65,11 +60,15 @@ test(uint32_t native_stack, uint32_t recurse_count)
|
|||
*
|
||||
*
|
||||
*/
|
||||
ret = host_consume_stack_and_call_indirect(consume_stack_cb, recurse_count,
|
||||
native_stack);
|
||||
#if 0 /* notyet */
|
||||
ret = host_consume_stack_and_call_indirect(host_consume_stack_cb, 1000000,
|
||||
native_stack);
|
||||
#endif
|
||||
uint32_t ret = host_consume_stack_and_call_indirect(
|
||||
consume_stack_cb, recurse_count, native_stack);
|
||||
return 42;
|
||||
}
|
||||
|
||||
__attribute__((export_name("test2"))) uint32_t
|
||||
test2(uint32_t native_stack, uint32_t recurse_count)
|
||||
{
|
||||
uint32_t ret = host_consume_stack_and_call_indirect(host_consume_stack_cb,
|
||||
6000, native_stack);
|
||||
return 42;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user