Coredistools wasm32#437
Open
AndyAyersMS wants to merge 2 commits into
Open
Conversation
Adds wasm32 as a supported target architecture for the coredistools
disassembler. This is the first step toward enabling SuperPMI asm-diffs
for collections produced by the LLVM/Wasm RyuJIT backend, which today
fall through to a host-arch decode and silently degrade to roughly
bitwise comparison of framed Wasm blobs.
Changes:
- coredistools.h: add Target_Wasm32 to TargetArch enum.
- coredistools.cpp: handle Target_Wasm32/Triple::wasm32 in setTarget()
host-detect and explicit-target switches; set a starter Wasm feature
string in init() covering the proposals the LLVM/Wasm JIT may emit
(simd128, sign-ext, nontrapping-fptoint, mutable-globals,
reference-types, bulk-memory, tail-call, exception-handling,
multivalue). Keep this in sync with the JIT's emitted feature set on
each LLVM bump.
- build-coredistools.{cmd,sh} and build-tblgen.{cmd,sh}: append
WebAssembly to the default LLVMTargetsToBuild. Per-arch restricted
matrix legs (linux-arm, linux-loongarch64, linux-riscv64, win-x86)
are left unchanged - wasm32 diffing is not a use case for those
hosts.
Follow-ups (not in this change):
- Frame-aware iteration: walking the per-funclet ULEB128 length prefix
and the per-body locals declaration before disassembling.
- Wasm-aware OffsetComparator on the SuperPMI side, driven by the
recorded relocation table.
- .wat-style dump output on diff.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The LLVM/Wasm RyuJIT backend writes its code buffer as a sequence of length-prefixed function/funclet bodies (ULEB128 body-length followed by the body bytes, where each body begins with the standard Wasm locals declaration). This shape doesn't fit the existing "flat instruction stream" assumption baked into nearDiff/dumpBlock, so Target_Wasm32 collections currently flow through asm-diffs as opaque bytes (or worse, get fed to the host-arch decoder). Add a Wasm-aware path that understands the framing: - Internal ULEB128 reader (readULEB128) plus parseWasmLocals/ formatWasmLocals helpers for the per-body header. - CorDisasm::dumpWasmFramedBlock walks each body, prints the locals header in (local i32 i32 ...) form, then disassembles the opcode stream using the existing LLVM WebAssembly MCInstPrinter (-> .wat- ish output). - CorAsmDiff::nearDiffWasmFramed walks both buffers in lockstep body by body, requires matching locals headers, and falls back to the OffsetComparator on differing integer immediates. The comparator is passed the opcode-byte offset measured from the start of the framed buffer so SuperPMI's recorded reloc tables can be looked up directly. - dumpDiffWasmFramed prints both sides with baseline/diff labels. New entry points NearDiffCodeBlocksFramed, DumpCodeBlockFramed and DumpDiffBlocksFramed are exported for callers that want to be explicit; the existing NearDiffCodeBlocks / DumpCodeBlock / DumpDiffBlocks entry points auto-route to the framed path when the configured target is Target_Wasm32 (the framing is intrinsic to the target, so this is safe). Bump nuspec version to 1.7.0 to reflect the added API surface. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
Author
|
@dotnet/wasm-contrib PTAL |
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.
Add Wasm32 support to coredistools.