-
Notifications
You must be signed in to change notification settings - Fork 736
wasm_c_api.c: improve unimplemented cases #1355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wasm_c_api.c: improve unimplemented cases #1355
Conversation
core/iwasm/common/wasm_c_api.c
Outdated
| } | ||
| case IMPORT_KIND_MEMORY: | ||
| case IMPORT_KIND_TABLE: | ||
| ASSERT_NOT_IMPLEMENTED(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This leads to compilation warning in debug mode: warning: this statement may fall through
How about changing to:
case IMPORT_KIND_MEMORY:
case IMPORT_KIND_TABLE:
ASSERT_NOT_IMPLEMENTED();
goto handle_default;
handle_default:
default:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's unfortunate that clang doesn't recognize the traditional /* FALLTHROUGH */.
how do you think about introducing something like #defile BH_FALLTHROUGH __attribute__((fallthrough))?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had better not, it might be not friendly to some compilers.
We have the similar case in:
https://github.com/bytecodealliance/wasm-micro-runtime/blob/main/core/iwasm/compilation/aot_emit_numberic.c#L455-L458
The modification such as that should be OK.
Or how about handling default together with case IMPORT_KIND_MEMORY/IMPORT_KIND_TABLE:
case IMPORT_KIND_MEMORY:
case IMPORT_KIND_TABLE:
default:
ASSERT_NOT_IMPLEMENTED();
LOG_WARNING("%s meets unsupported kind: %d", __FUNCTION__,
import_rt->kind);
goto failed;There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had better not, it might be not friendly to some compilers. We have the similar case in: https://github.com/bytecodealliance/wasm-micro-runtime/blob/main/core/iwasm/compilation/aot_emit_numberic.c#L455-L458 The modification such as that should be OK.
ok
Or how about handling default together with
case IMPORT_KIND_MEMORY/IMPORT_KIND_TABLE:case IMPORT_KIND_MEMORY: case IMPORT_KIND_TABLE: default: ASSERT_NOT_IMPLEMENTED(); LOG_WARNING("%s meets unsupported kind: %d", __FUNCTION__, import_rt->kind); goto failed;
i think it makes the most sense this particular case. done.
core/iwasm/common/wasm_c_api.c
Outdated
| break; | ||
| case WASM_EXTERN_MEMORY: | ||
| case WASM_EXTERN_TABLE: | ||
| ASSERT_NOT_IMPLEMENTED(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
ASSERT_NOT_IMPLEMENTED is bh_assert, which might be no-op. in that case, it's better to fall back to the "default" case, which reports an error properly.
5c065f3 to
60bd4b5
Compare
ASSERT_NOT_IMPLEMENTED is bh_assert, which might be no-op. in that case, it's better to fall back to the "default" case, which reports an error properly.
ASSERT_NOT_IMPLEMENTED is bh_assert, which might be no-op. in that case, it's better to fall back to the "default" case, which reports an error properly.
ASSERT_NOT_IMPLEMENTED is bh_assert, which might be no-op.
in that case, it's better to fall back to the "default" case,
which reports an error properly.