Skip to content

Add wabt::Const::set_funcref(uintptr_t) overload #2610

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

Closed
wants to merge 1 commit into from

Conversation

sjamesr
Copy link
Contributor

@sjamesr sjamesr commented May 27, 2025

This allows wabt::Const funcrefs to be created from bits read from other sources, e.g. a WASM engine under test.

@@ -154,6 +154,7 @@ struct Const {
set_expected_nan(0, nan);
}
void set_funcref() { From<uintptr_t>(Type::FuncRef, 0); }
void set_funcref(uintptr_t x) { From<uintptr_t>(Type::FuncRef, x); }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the <uintptr_t> needed here? I see the its not present on the line below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yea, not required, removed.

This allows wabt::Const funcrefs to be created from bits read from
other sources, e.g. a WASM engine under test.
@sbc100
Copy link
Member

sbc100 commented May 27, 2025

LGTM, although I'm a little hesitant to make changes like this without a test case. Can you explain a little bit more about why you need it? What exactly are you trying to do? What is a "wasm engine under test" in this context?

@sjamesr
Copy link
Contributor Author

sjamesr commented May 28, 2025

We discussed this change offline, and I think we can close this pull request.

We're using wabt internal APIs to parse WAST files and implement the commands in those WAST files. For example, we implement assert_returns by converting the values returned by a WASM engine into wabt values and then compare them. This approach does not work for FuncRefs, because wabt's API doesn't allow construction of funcrefs except with zero bits.

@sjamesr sjamesr closed this May 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants