Add the tail-call feature support for classic-interp (#401)
* Add the tail-call feature support for classic-interp Signed-off-by: Xiaokang Qin <xiaokang.qxk@antgroup.com> * add CI for tail call and custom name section * add CI for tail call and custom name section * update CI for mac Co-authored-by: Xu Jun <693788454@qq.com>
This commit is contained in:
@ -2235,10 +2235,16 @@ wasm_loader_find_block_addr(BlockAddr *block_addr_cache,
|
||||
break;
|
||||
|
||||
case WASM_OP_CALL:
|
||||
#if WASM_ENABLE_TAIL_CALL != 0
|
||||
case WASM_OP_RETURN_CALL:
|
||||
#endif
|
||||
skip_leb_uint32(p, p_end); /* funcidx */
|
||||
break;
|
||||
|
||||
case WASM_OP_CALL_INDIRECT:
|
||||
#if WASM_ENABLE_TAIL_CALL != 0
|
||||
case WASM_OP_RETURN_CALL_INDIRECT:
|
||||
#endif
|
||||
skip_leb_uint32(p, p_end); /* typeidx */
|
||||
CHECK_BUF(p, p_end, 1);
|
||||
u8 = read_uint8(p); /* 0x00 */
|
||||
@ -4612,6 +4618,9 @@ handle_op_block_and_loop:
|
||||
}
|
||||
|
||||
case WASM_OP_CALL:
|
||||
#if WASM_ENABLE_TAIL_CALL != 0
|
||||
case WASM_OP_RETURN_CALL:
|
||||
#endif
|
||||
{
|
||||
WASMType *func_type;
|
||||
uint32 func_idx;
|
||||
@ -4641,22 +4650,37 @@ handle_op_block_and_loop:
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < func_type->result_count; i++) {
|
||||
PUSH_TYPE(func_type->types[func_type->param_count + i]);
|
||||
#if WASM_ENABLE_FAST_INTERP != 0
|
||||
/* Here we emit each return value's dynamic_offset. But in fact
|
||||
* these offsets are continuous, so interpreter only need to get
|
||||
* the first return value's offset.
|
||||
*/
|
||||
PUSH_OFFSET_TYPE(func_type->types[func_type->param_count + i]);
|
||||
#if WASM_ENABLE_TAIL_CALL != 0
|
||||
if (opcode == WASM_OP_CALL) {
|
||||
#endif
|
||||
for (i = 0; i < func_type->result_count; i++) {
|
||||
PUSH_TYPE(func_type->types[func_type->param_count + i]);
|
||||
#if WASM_ENABLE_FAST_INTERP != 0
|
||||
/* Here we emit each return value's dynamic_offset. But in fact
|
||||
* these offsets are continuous, so interpreter only need to get
|
||||
* the first return value's offset.
|
||||
*/
|
||||
PUSH_OFFSET_TYPE(func_type->types[func_type->param_count + i]);
|
||||
#endif
|
||||
}
|
||||
#if WASM_ENABLE_TAIL_CALL != 0
|
||||
}
|
||||
|
||||
else {
|
||||
bh_assert(func_type->result_count == func->func_type->result_count);
|
||||
for (i = 0; i < func_type->result_count; i++) {
|
||||
bh_assert(func_type->types[func_type->param_count + i] ==
|
||||
func->func_type->types[func->func_type->param_count + i]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
func->has_op_func_call = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case WASM_OP_CALL_INDIRECT:
|
||||
#if WASM_ENABLE_TAIL_CALL != 0
|
||||
case WASM_OP_RETURN_CALL_INDIRECT:
|
||||
#endif
|
||||
{
|
||||
int32 idx;
|
||||
WASMType *func_type;
|
||||
@ -4690,12 +4714,25 @@ handle_op_block_and_loop:
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < func_type->result_count; i++) {
|
||||
PUSH_TYPE(func_type->types[func_type->param_count + i]);
|
||||
#if WASM_ENABLE_FAST_INTERP != 0
|
||||
PUSH_OFFSET_TYPE(func_type->types[func_type->param_count + i]);
|
||||
#if WASM_ENABLE_TAIL_CALL != 0
|
||||
if (opcode == WASM_OP_CALL) {
|
||||
#endif
|
||||
for (i = 0; i < func_type->result_count; i++) {
|
||||
PUSH_TYPE(func_type->types[func_type->param_count + i]);
|
||||
#if WASM_ENABLE_FAST_INTERP != 0
|
||||
PUSH_OFFSET_TYPE(func_type->types[func_type->param_count + i]);
|
||||
#endif
|
||||
}
|
||||
#if WASM_ENABLE_TAIL_CALL != 0
|
||||
}
|
||||
else {
|
||||
bh_assert(func_type->result_count == func->func_type->result_count);
|
||||
for (i = 0; i < func_type->result_count; i++) {
|
||||
bh_assert(func_type->types[func_type->param_count + i] ==
|
||||
func->func_type->types[func->func_type->param_count + i]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
func->has_op_func_call = true;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user