Random improvements to samples/native-stack-overflow (#3353)

This commit is contained in:
YAMAMOTO Takashi
2024-04-25 12:22:08 +09:00
committed by GitHub
parent 9d6d3466ff
commit a36c7d5aa9
7 changed files with 124 additions and 28 deletions

View File

@ -17,7 +17,7 @@ cb(int x)
}
int
consume_stack_cb(int x)
consume_stack_cb(int x) __attribute__((disable_tail_calls))
{
/*
* intentions:
@ -39,16 +39,36 @@ 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;
ret = host_consume_stack_and_call_indirect(cb, 321, native_stack);
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
/*
* ------ os_thread_get_stack_boundary
* ^
* |
* | "native_stack" bytes of stack left by
* | host_consume_stack_and_call_indirect
* |
* | ^
* | |
* | | consume_stack_cb (interpreter or aot)
* v |
* ^
* |
* | host_consume_stack_and_call_indirect
* |
*
*
*/
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;
}