@@ -323,27 +323,6 @@ is_64bit_type(uint8 type)
323323 return false;
324324}
325325
326- static bool
327- is_value_type(uint8 type)
328- {
329- if (/* I32/I64/F32/F64, 0x7C to 0x7F */
330- (type >= VALUE_TYPE_F64 && type <= VALUE_TYPE_I32)
331- #if WASM_ENABLE_GC != 0
332- /* reference types, 0x65 to 0x70 */
333- || wasm_is_type_reftype(type)
334- #elif WASM_ENABLE_REF_TYPES != 0
335- || (type == VALUE_TYPE_FUNCREF || type == VALUE_TYPE_EXTERNREF)
336- #endif
337- #if WASM_ENABLE_SIMD != 0
338- #if (WASM_ENABLE_WAMR_COMPILER != 0) || (WASM_ENABLE_JIT != 0)
339- || type == VALUE_TYPE_V128 /* 0x7B */
340- #endif
341- #endif
342- )
343- return true;
344- return false;
345- }
346-
347326#if WASM_ENABLE_GC != 0
348327static bool
349328is_packed_type(uint8 type)
@@ -355,7 +334,8 @@ is_packed_type(uint8 type)
355334static bool
356335is_byte_a_type(uint8 type)
357336{
358- return (is_value_type(type) || (type == VALUE_TYPE_VOID)) ? true : false;
337+ return (is_valid_value_type(type) || (type == VALUE_TYPE_VOID)) ? true
338+ : false;
359339}
360340
361341#if WASM_ENABLE_SIMD != 0
@@ -1462,7 +1442,7 @@ resolve_value_type(const uint8 **p_buf, const uint8 *buf_end,
14621442 }
14631443 else {
14641444 /* type which can be represented by one byte */
1465- if (!is_value_type (type)
1445+ if (!is_valid_value_type (type)
14661446 && !(allow_packed_type && is_packed_type(type))) {
14671447 set_error_buf(error_buf, error_buf_size, "type mismatch");
14681448 return false;
@@ -1972,7 +1952,7 @@ load_type_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module,
19721952 type->types[param_count + j] = read_uint8(p);
19731953 }
19741954 for (j = 0; j < param_count + result_count; j++) {
1975- if (!is_value_type (type->types[j])) {
1955+ if (!is_valid_value_type (type->types[j])) {
19761956 set_error_buf(error_buf, error_buf_size,
19771957 "unknown value type");
19781958 return false;
@@ -3061,7 +3041,7 @@ load_global_import(const uint8 **p_buf, const uint8 *buf_end,
30613041 CHECK_BUF(p, p_end, 2);
30623042 /* global type */
30633043 declare_type = read_uint8(p);
3064- if (!is_value_type (declare_type)) {
3044+ if (!is_valid_value_type (declare_type)) {
30653045 set_error_buf(error_buf, error_buf_size, "type mismatch");
30663046 return false;
30673047 }
@@ -3773,7 +3753,7 @@ load_function_section(const uint8 *buf, const uint8 *buf_end,
37733753 CHECK_BUF(p_code, buf_code_end, 1);
37743754 /* 0x7F/0x7E/0x7D/0x7C */
37753755 type = read_uint8(p_code);
3776- if (!is_value_type (type)) {
3756+ if (!is_valid_value_type (type)) {
37773757 if (type == VALUE_TYPE_V128)
37783758 set_error_buf(error_buf, error_buf_size,
37793759 "v128 value type requires simd feature");
@@ -4048,7 +4028,7 @@ load_global_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module,
40484028 CHECK_BUF(p, p_end, 2);
40494029 /* global type */
40504030 global->type.val_type = read_uint8(p);
4051- if (!is_value_type (global->type.val_type)) {
4031+ if (!is_valid_value_type (global->type.val_type)) {
40524032 set_error_buf(error_buf, error_buf_size, "type mismatch");
40534033 return false;
40544034 }
@@ -12322,7 +12302,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
1232212302#if WASM_ENABLE_GC == 0
1232312303 CHECK_BUF(p, p_end, 1);
1232412304 type = read_uint8(p);
12325- if (!is_value_type (type)) {
12305+ if (!is_valid_value_type (type)) {
1232612306 set_error_buf(error_buf, error_buf_size,
1232712307 "unknown value type");
1232812308 goto fail;
0 commit comments