Skip to content

Support all garbage collector tests - #2622

Open
zherczeg wants to merge 3 commits into
WebAssembly:mainfrom
zherczeg:gc_tests
Open

zherczeg wants to merge 3 commits into
WebAssembly:mainfrom
zherczeg:gc_tests

Conversation

@zherczeg

Copy link
Copy Markdown
Collaborator

This patch adds support for all tests in testsuite/proposals/gc. Two tests are still missing.

@zherczeg
zherczeg force-pushed the gc_tests branch 3 times, most recently from e973c0b to 2426298 Compare June 30, 2025 11:39
@zherczeg

Copy link
Copy Markdown
Collaborator Author

It looks like garbage collection tests are finally working. It took me 4 months, but the initial version of garbage collection support is completed. I think I understand the concept of references in WebAssembly, and know why it works that way. The code probably needs a lot of changes.

@zherczeg
zherczeg force-pushed the gc_tests branch 3 times, most recently from 645b133 to 1917fb3 Compare July 9, 2025 10:20
matetokodi added a commit to matetokodi/walrus that referenced this pull request Jul 15, 2025
matetokodi added a commit to matetokodi/walrus that referenced this pull request Jul 16, 2025
from: https://github.com/zherczeg/wabt/tree/gc_tests (1917fb3)
WebAssembly/wabt#2622

Signed-off-by: Máté Tokodi mate.tokodi@szteszoftver.hu
matetokodi added a commit to matetokodi/walrus that referenced this pull request Jul 18, 2025
from: https://github.com/zherczeg/wabt/tree/gc_tests (1917fb3)
WebAssembly/wabt#2622

Signed-off-by: Máté Tokodi mate.tokodi@szteszoftver.hu
matetokodi added a commit to matetokodi/walrus that referenced this pull request Jul 22, 2025
from: https://github.com/zherczeg/wabt/tree/gc_tests (1917fb3)
WebAssembly/wabt#2622

Signed-off-by: Máté Tokodi mate.tokodi@szteszoftver.hu
matetokodi added a commit to matetokodi/walrus that referenced this pull request Jul 22, 2025
from: https://github.com/zherczeg/wabt/tree/gc_tests (1917fb3)
WebAssembly/wabt#2622

Signed-off-by: Máté Tokodi mate.tokodi@szteszoftver.hu
ksh8281 pushed a commit to Samsung/walrus that referenced this pull request Jul 31, 2025
from: https://github.com/zherczeg/wabt/tree/gc_tests (1917fb3)
WebAssembly/wabt#2622

Signed-off-by: Máté Tokodi mate.tokodi@szteszoftver.hu
bfredl added a commit to bfredl/forklift that referenced this pull request Nov 11, 2025
note: this requires a version of wabt which doesn't exist yet, see
WebAssembly/wabt#2622
@zherczeg
zherczeg force-pushed the gc_tests branch 2 times, most recently from 46dac3d to 692da15 Compare February 4, 2026 10:08
@kevmoo

kevmoo commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

So exciting to see this moving along!

@zherczeg

zherczeg commented Mar 5, 2026

Copy link
Copy Markdown
Collaborator Author

Thank you! I try to update this patchset reguraly. The longer term aim is full wasm 3.0 support, but I also do some work on WebAssembly Components. Do you need this code for something?

@kevmoo

kevmoo commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

I work with the dart2wasm team. We have our own wasm2wat impl for our output. I'd be awesome if we could use the default tools.

@kevmoo

kevmoo commented Mar 7, 2026

Copy link
Copy Markdown
Contributor

If you want a sample file: https://bouncing.web.app/main.dart.wasm

@zherczeg
zherczeg force-pushed the gc_tests branch 2 times, most recently from 743218b to 595a459 Compare March 13, 2026 06:17
@zherczeg
zherczeg force-pushed the gc_tests branch 2 times, most recently from 9e1178d to afe6c80 Compare March 27, 2026 06:28
@zherczeg
zherczeg force-pushed the gc_tests branch 2 times, most recently from 29627a7 to 4247008 Compare May 7, 2026 11:17
@kevmoo

kevmoo commented May 7, 2026

Copy link
Copy Markdown
Contributor

Sweet!

@zherczeg

zherczeg commented May 8, 2026

Copy link
Copy Markdown
Collaborator Author

I am updating these patches but I don't know when they land. The first one in the set has a birthday soon!

@zherczeg

Copy link
Copy Markdown
Collaborator Author

I have some good news. Due to the recent improvements of wabt, with this patchset the webassembly 3.0 spec tests can be run with wabt.

@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.

Hi! While I'm not normally a wabt reviewer, I do know a bit about WasmGC, and I think it would be great for the community to get this patchset landed, so I took a bit of a look now.

Comment thread src/interp/istream.cc
case Opcode::I32X4RelaxedTruncF64X2UZero:
case Opcode::RefEq:
// 0 immediates, 1 operand.
instr.kind = InstrKind::Imm_0_Op_1;

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.

Doesn't RefEq takes two operands, the two references to compare for equality?

Do we not have a test for RefEq? (If we do, how did it pass?)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Nice catch! Probably just pure luck, since only the number of immediates matter (the values are on the stack, they don't need to be read from the byte stream). There are 3 PR-s for the patchset, I will fix this in the relevant one.

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.

Oh, is the order of the 3 PRs listed somewhere?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

#2607 #2618 and this one. They built on the top of each other. The first contains the first patch, the second one the first two patches, and this one is all three patches.

Comment thread src/binary-reader.cc
*out_value = Type(is_nullable ? Type::RefNull : Type::Ref,
static_cast<Index>(heap_type));
}
return Result::Ok;

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.

I was expecting to see a check that the type index is in bounds (less than the number of types) - should that not be here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

No. Webassenbly has rules for malformed and invalid forms. Malformed data should cause a fail during parsing. However, an invalid webassembly should be accepted, and validation should reject it later. Hence an invalid webassembly file could be read and written back without issues.

This patch supports parsing the new GC types
- Abstract types
- Recursive types
- Composite types

The patch also improves type comparison.

This branch has not been deployed

No deployments
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.

3 participants