Skip to content

Add TagType support for WebAssembly exception-handling proposal#197

Open
bacek wants to merge 3 commits intoWebAssembly:mainfrom
bacek:bacek/tag
Open

Add TagType support for WebAssembly exception-handling proposal#197
bacek wants to merge 3 commits intoWebAssembly:mainfrom
bacek:bacek/tag

Conversation

@bacek
Copy link
Contributor

@bacek bacek commented Mar 12, 2026

  • Add WASM_EXTERN_TAG to wasm_externkind_enum
  • Add WASM_DECLARE_TYPE(tagtype) with constructor and functype accessor
  • Add cast functions: wasm_tagtype_as_externtype* and wasm_externtype_as_tagtype*
  • Add TAG to ExternKind enum in C++ API
  • Add TagType class extending ExternType with make(own<FuncType>&&) and functype() accessor
  • Add tag() accessors on ExternType

Tags are described by an associated function type whose parameters are
the exception payload types (per the WebAssembly exception-handling proposal).

- Add `WASM_EXTERN_TAG` to `wasm_externkind_enum`
- Add `WASM_DECLARE_TYPE(tagtype)` with constructor and functype accessor
- Add cast functions: `wasm_tagtype_as_externtype*` and `wasm_externtype_as_tagtype*`
- Add `TAG` to `ExternKind` enum in C++ API
- Add `TagType` class extending `ExternType` with `make(own<FuncType>&&)` and `functype()` accessor
- Add `tag()` accessors on `ExternType`

Tags are described by an associated function type whose parameters are
the exception payload types (per the WebAssembly exception-handling proposal).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@rossberg
Copy link
Member

Thanks, this is great! But it seems to need a couple of adjustments to the V8 wrapper as well, in order to unbreak CI - mostly adding a bunch of straightforward new switch cases for tag types (see the CI failures).

bacek and others added 2 commits March 18, 2026 05:05
Add TagTypeImpl and implement TagType::make/copy/destroy/functype.
Add ExternType::tag() accessors. Handle ExternKind::TAG in all four
switch statements that previously caused -Werror,-Wswitch failures:
- ExternType::copy()
- ExternType::destroy()
- Extern::type()
- Instance exports construction

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@bacek
Copy link
Contributor Author

bacek commented Mar 17, 2026

Thanks, this is great! But it seems to need a couple of adjustments to the V8 wrapper as well, in order to unbreak CI - mostly adding a bunch of straightforward new switch cases for tag types (see the CI failures).

Updated. I didn't actually implement Tag in v8 wrapper. Can try to do it in a separate PR.

@bacek
Copy link
Contributor Author

bacek commented Mar 17, 2026

https://github.com/WebAssembly/wasm-c-api/actions/runs/23210241938/job/67461420459?pr=197#step:6:211

mkdir -p out/example
clang++ -c -std=c++17 -DWASM_API_DEBUG   -DV8_COMPRESS_POINTERS -DV8_ENABLE_SANDBOX -Wall -Werror -ggdb -O -fsanitize=address -I. -Iv8/v8/include -I./include example/finalize.cc -o out/example/finalize-cc.o
clang++ -std=c++17 -DWASM_API_DEBUG   -DV8_COMPRESS_POINTERS -DV8_ENABLE_SANDBOX -Wall -Werror -ggdb -O -fsanitize=address -fsanitize-memory-track-origins -fsanitize-memory-use-after-dtor out/example/finalize-cc.o -o out/example/finalize-cc \
	out/./wasm-bin.o out/./wasm-v8.o \
	 \
	v8/v8/out.gn/x64.release/obj/libv8_monolith.a \
	 \
	-ldl -pthread
../spec/interpreter/wasm   -d example/finalize.wat -o example/finalize.wasm
make: ../spec/interpreter/wasm: No such file or directory

Is it just timed out building v8? All checks are passing locally for me.

@rossberg
Copy link
Member

Good question, I triggered a rerun.

@bacek
Copy link
Contributor Author

bacek commented Mar 18, 2026

Good question, I triggered a rerun.

Yep. It helped.

@bacek
Copy link
Contributor Author

bacek commented Mar 18, 2026

Good question, I triggered a rerun.

Tests passed. Can it be merged?

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