test(cpp): cover map runtime roundtrips - #1667
Open
yordis wants to merge 2 commits into
Open
Conversation
ResultLower moved the payload into a block-scoped local, so when lowering a result argument into an import, the payload's heap data (e.g. map entries or strings) was freed at the end of the ok/err block, before the import call consumed the flat buffer. Binding by rvalue reference keeps the data owned by the operand, which outlives the call, matching how VariantLower already binds case payloads. The export direction is unaffected: it transfers ownership into the flat buffer with leak() and frees in cabi_post, and leaking through the reference behaves the same. Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
Restores the C++ map runtime coverage deferred in bytecodealliance#1590 and adds the import direction, which never existed. The runner exercises the span-based borrowed-map lowering plus owned maps inside records, variants, results, and tuples. The C++ harness now links a core module with --skip-wit-component and componentizes with the workspace's wit-component, mirroring the C harness. This keeps the wasi-sdk's bundled wasm-component-ld out of the WIT processing path, which predates the component-model map encoding and was the reason bytecodealliance#1590 dropped its runtime test. Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
yordis
force-pushed
the
yordis/test-maps-runtime-cpp
branch
from
July 27, 2026 16:33
67bc3d6 to
a0b1c5e
Compare
yordis
marked this pull request as ready for review
July 27, 2026 23:54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ResultLowermoved the payload into a block-scoped local, freeing its heap data before the lowered import call consumed the flat buffer. Payloads are now bound by rvalue reference, matching howVariantLowerbinds case payloads. This affected any heap-carryingresultpassed as an argument into an import, not just maps; no existing C++ fixture covered that path.How the toolchain blocker is avoided
#1590 dropped its runtime test because the
wasm-component-ldbundled with wasi-sdk doesn't understand the component-modelmapencoding. The C++ test harness now links a core module with-Wl,--skip-wit-componentand componentizes with the workspace'swit-component, mirroring what the C harness already does for every C test. The wasi-sdk linker never parses the map metadata, so no external toolchain update is needed.Testing
With wasi-sdk 30 and wasmtime 46.0.1 (the CI versions):
tests/runtimewith--languages rust,c,cpp: 269 component builds, 236 runtime tests, all passing, including the full 3x3 map runner/test matrix.tests/codegenwith--languages cpp: 101 tests passing, validating theResultLowerchange across the codegen fixtures.