Complete the ChildTyper migration of validator child-type checks

Open
#9,123 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Active
Tech stack
cpp, wasm
Domain
compilers

Research direction

Start with src/wasm/wasm-validator.cpp and src/ir/child-typer.h, then run the coverage diff described in the issue for each remaining validator method. Migrate methods whose child-type cases match, document methods dominated by non-child checks, and extend ChildTyper first when validator cases are missing; run python3 check.py lit and repeat the coverage diffs for each batch.

Written by the indexing model from the issue text.

Description

Problem:

#6613 migrated four methods (visitUnary, visitBinary,
visitRefIsNull, visitRefEq) to a ValidatorTypeChecker subclass of
ChildTyper. Roughly 70 methods with ChildTyper counterparts
remain unmigrated. The issue's stated goal — "Using ChildTyper
would delete code and improve correctness" — is partially
achieved.

Migrated (4):
visitUnary, visitBinary, visitRefIsNull, visitRefEq.

Blocked by sharedness (2), see the sibling issue:
visitI31Get, visitCallRef.

Deliberately skipped, with reasoning:
SIMD family (7 methods). Switch is dominated by immediate
validation (lane index range), memory helpers (validateOffset,
validateAlignment), and result-type computation. At most one
child-type check per method; migration would add a cross-file
dependency without code reduction.
Tuple family (visitTupleExtract, visitTupleMake). Result-type
checks, not child-type checks.
visitRefI31, visitRefAs. Feature-gate switches with one
migratable child-type check apiece.

Not yet examined:
visitCall, visitCallIndirect visitStructGet, visitStructSet, visitStructRMW, visitStructCmpxchg, visitStructWait visitArrayNew, visitArrayNewData, visitArrayNewElem, visitArrayNewFixed, visitArrayGet, visitArraySet, visitArrayLoad, visitArrayStore, visitArrayLen, visitArrayCopy, visitArrayFill, visitArrayInitData, visitArrayInitElem, visitArrayRMW, visitArrayCmpxchg visitStringNew, visitStringMeasure, visitStringEncode, visitStringConcat, visitStringEq, visitStringTest, visitStringWTF16Get, visitStringSliceWTF visitContNew, visitContBind, visitSuspend, visitResume, visitResumeThrow, visitStackSwitch visitTryTable, visitThrow, visitThrowRef visitBrOn, visitRefTest, visitRefCast, visitRefGetDesc visitDrop, visitReturn, visitMemoryGrow visitTableGet, visitTableSet, visitTableGrow, visitTableFill, visitTableCopy, visitTableInit visitMemoryInit, visitMemoryCopy, visitMemoryFill visitAtomicRMW, visitAtomicCmpxchg, visitAtomicWait, visitAtomicNotify
and others.

Proposed approach: For each remaining method, run the same
coverage diff that #6613 used:

git show HEAD:src/wasm/wasm-validator.cpp \
  | awk '/^void FunctionValidator::visitM(/{p=1} p{print} p && /^}/{exit}' \
  | grep -oE 'case [A-Za-z0-9_]+:' | sort -u > /tmp/val.txt
sed -n '/void visitM(/,/^  }/p' src/ir/child-typer.h \
  | grep -oE 'case [A-Za-z0-9_]+:' | sort -u > /tmp/ct.txt
diff /tmp/val.txt /tmp/ct.txt

If the diff is empty, migrate. If the method's switch is dominated
by non-child checks, skip and document. If the diff is non-empty
in the validator direction, ChildTyper is missing opcodes and
must be extended first.

Verification per batch: python3 check.py lit, plus the coverage
diff for each migrated method.

Follow-up: Batch 2 of this work is the array and struct accessor
families, which are structurally similar and likely share a
common migration pattern.

Refs #6613.

Dominant language
WebAssembly
Stars
8.6k
Forks
885
Avg merge
1d 20h
Merged PRs (30d)
64

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from WebAssembly/binaryen

All issues in WebAssembly/binaryen

Similar issues

More Compilers issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.