Skip to content

[Strings] Adopt new instruction binary encoding#5714

Merged
kripken merged 3 commits into
WebAssembly:mainfrom
vouillon:stringref
May 12, 2023
Merged

[Strings] Adopt new instruction binary encoding#5714
kripken merged 3 commits into
WebAssembly:mainfrom
vouillon:stringref

Conversation

@vouillon

Copy link
Copy Markdown
Contributor

See WebAssembly/stringref#46.
This format is already adopted by V8: https://chromium-review.googlesource.com/c/v8/v8/+/3892695.
The text format is left unchanged (see #5607 for a discussion on the subject).

I have also added support for string.encode_lossy_utf8 and string.encode_lossy_utf8 array (by allowing the replace policy for Binaryen's string.encode_wtf8 instruction).

@kripken

kripken commented May 11, 2023

Copy link
Copy Markdown
Member

Thanks for the PR!

You say V8 already implemented this change - is it backwards compatible? AFAIK our state before this PR works in V8, and the linked V8 CL is quite old, so I'm surprised things have been working so far for people using Binaryen+V8...

@vouillon

Copy link
Copy Markdown
Contributor Author

No, this changes is not backwards compatible. I investigated this because string.new_wtf8_array replace was not working.
Maybe they are using string.new_wtf8 wtf8 which happens to be interpreted by V8 as instruction string.new_utf8 followed by a nop (opcode 0x01)?

@kripken

kripken commented May 12, 2023

Copy link
Copy Markdown
Member

Interesting... maybe it happens to work out that way.

@kripken kripken left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks right to me. I'm not 100% sure we understand why the same binaries seem to work before and after this change (that is, with v8 and binaryen using incompatible versions) but it seems like this should only help. And if we see breakage after it lands we can back it out and investigate further.

@kripken kripken merged commit 71a1512 into WebAssembly:main May 12, 2023
radekdoulik pushed a commit to dotnet/binaryen that referenced this pull request Jul 12, 2024
See WebAssembly/stringref#46.

This format is already adopted by V8: https://chromium-review.googlesource.com/c/v8/v8/+/3892695.
The text format is left unchanged (see WebAssembly#5607 for a discussion on the subject).

I have also added support for string.encode_lossy_utf8 and
string.encode_lossy_utf8 array (by allowing the replace policy for
Binaryen's string.encode_wtf8 instruction).
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