mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-02-06 06:55:07 +00:00
Correct Exception Handling tag type when GC is enabled (#3413)
Use `WASMFuncType` to represent tag_type in `WASMTagImport` and `WASMTag` so that the type definition is consistent no matter to GC is enabled or not. This PR fixes https://github.com/bytecodealliance/wasm-micro-runtime/issues/3409.
This commit is contained in:
parent
22eef3d88d
commit
c6d42db598
|
@ -574,7 +574,7 @@ typedef struct WASMTagImport {
|
|||
char *field_name;
|
||||
uint8 attribute; /* the type of the tag (numerical) */
|
||||
uint32 type; /* the type of the catch function (numerical)*/
|
||||
WASMType *tag_type;
|
||||
WASMFuncType *tag_type;
|
||||
void *tag_ptr_linked;
|
||||
|
||||
#if WASM_ENABLE_MULTI_MODULE != 0
|
||||
|
@ -706,7 +706,7 @@ struct WASMFunction {
|
|||
struct WASMTag {
|
||||
uint8 attribute; /* the attribute property of the tag (expected to be 0) */
|
||||
uint32 type; /* the type of the tag (expected valid inden in type table) */
|
||||
WASMType *tag_type;
|
||||
WASMFuncType *tag_type;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1612,7 +1612,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
|||
/* landing pad for the rethrow ? */
|
||||
find_a_catch_handler:
|
||||
{
|
||||
WASMType *tag_type = NULL;
|
||||
WASMFuncType *tag_type = NULL;
|
||||
uint32 cell_num_to_copy = 0;
|
||||
if (IS_INVALID_TAGINDEX(exception_tag_index)) {
|
||||
/*
|
||||
|
|
|
@ -2919,7 +2919,8 @@ load_tag_import(const uint8 **p_buf, const uint8 *buf_end,
|
|||
goto fail;
|
||||
}
|
||||
|
||||
WASMType *declare_tag_type = parent_module->types[declare_type_index];
|
||||
WASMFuncType *declare_tag_type =
|
||||
(WASMFuncType *)parent_module->types[declare_type_index];
|
||||
|
||||
/* check, that the type of the declared tag returns void */
|
||||
if (declare_tag_type->result_count != 0) {
|
||||
|
@ -4806,7 +4807,7 @@ load_tag_section(const uint8 *buf, const uint8 *buf_end, const uint8 *buf_code,
|
|||
|
||||
/* get return type (must be 0) */
|
||||
/* check, that the type of the referred tag returns void */
|
||||
WASMType *func_type = (WASMType *)module->types[tag_type];
|
||||
WASMFuncType *func_type = (WASMFuncType *)module->types[tag_type];
|
||||
if (func_type->result_count != 0) {
|
||||
set_error_buf(error_buf, error_buf_size,
|
||||
"non-empty tag result type");
|
||||
|
@ -11122,7 +11123,7 @@ re_scan:
|
|||
|
||||
/* the tag_type is stored in either the WASMTag (section tags)
|
||||
* or WASMTagImport (import tag) */
|
||||
WASMType *tag_type = NULL;
|
||||
WASMFuncType *tag_type = NULL;
|
||||
if (tag_index < module->import_tag_count) {
|
||||
tag_type = module->import_tags[tag_index].u.tag.tag_type;
|
||||
}
|
||||
|
@ -11145,11 +11146,36 @@ re_scan:
|
|||
/* Check stack values match return types by comparing tag param
|
||||
* types with stack cells */
|
||||
uint8 *frame_ref = loader_ctx->frame_ref;
|
||||
#if WASM_ENABLE_GC != 0
|
||||
WASMRefTypeMap *frame_reftype_map =
|
||||
loader_ctx->frame_reftype_map;
|
||||
uint32 frame_reftype_map_num = loader_ctx->reftype_map_num;
|
||||
param_reftype_maps = tag_type->ref_type_maps;
|
||||
/* For tag_type function, it shouldn't have result_count = 0 */
|
||||
param_reftype_map_count = tag_type->ref_type_map_count;
|
||||
param_count = (int32)tag_type->param_count;
|
||||
#endif
|
||||
|
||||
for (int tti = (int32)tag_type->param_count - 1; tti >= 0;
|
||||
tti--) {
|
||||
#if WASM_ENABLE_GC != 0
|
||||
local_type = tag_type->types[tti];
|
||||
local_idx = tti;
|
||||
/* Get the wasm_ref_type if the local_type is multibyte
|
||||
* type */
|
||||
GET_LOCAL_REFTYPE();
|
||||
#endif
|
||||
|
||||
if (!check_stack_top_values(
|
||||
loader_ctx, frame_ref, available_stack_cell,
|
||||
tag_type->types[tti], error_buf, error_buf_size)) {
|
||||
#if WASM_ENABLE_GC != 0
|
||||
frame_reftype_map, frame_reftype_map_num,
|
||||
#endif
|
||||
tag_type->types[tti],
|
||||
#if WASM_ENABLE_GC != 0
|
||||
&wasm_ref_type,
|
||||
#endif
|
||||
error_buf, error_buf_size)) {
|
||||
snprintf(error_buf, error_buf_size,
|
||||
"type mismatch: instruction requires [%s] but "
|
||||
"stack has [%s]",
|
||||
|
@ -11232,7 +11258,7 @@ re_scan:
|
|||
|
||||
/* the tag_type is stored in either the WASMTag (section tags)
|
||||
* or WASMTagImport (import tag) */
|
||||
WASMType *func_type = NULL;
|
||||
WASMFuncType *func_type = NULL;
|
||||
if (tag_index < module->import_tag_count) {
|
||||
func_type = module->import_tags[tag_index].u.tag.tag_type;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user