feat: canonical type IDs, P3 component support, 54 WAST fixes (90→36)#220
Merged
feat: canonical type IDs, P3 component support, 54 WAST fixes (90→36)#220
Conversation
…onversion Implement canonical type IDs for structural type equivalence in ref.test, ref.cast, and br_on_cast with concrete types. Add proper any.convert_extern / extern.convert_any semantics using Value::Ref for internalized externs. Support GC instructions (array.new, array.new_fixed, struct.new) in element segment expression evaluation. Fix array.new_elem to use resolved_elem_items. WAST conformance: 90 → 82 failures (65,551/65,633 = 99.875%) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Custom sections must contain at least a valid name per the WebAssembly spec. A custom section with size 0 was incorrectly accepted. Now properly returns 'unexpected end' error. WAST conformance: 82 → 80 failures (65,553/65,633 = 99.878%) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ved items - Validate array field mutability byte in decoder (must be 0 or 1) - Check element segment dropped status in array.init_elem and array.new_elem - Use resolved_elem_items in array.init_elem for pre-evaluated GC values WAST conformance: 80 → 77 failures (65,556/65,633 = 99.883%) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
BrOnNonNull was only preserving 1 value when branching, but multi-value blocks require preserving all result values. Now uses the same values_to_preserve logic as the Br handler. WAST conformance: 77 → 76 failures (65,557/65,633 = 99.884%) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…tity Implement a thread-local side table for preserving original values through the externalize→internalize cycle. Uses high-bit sentinel (0x80000000) in ExternRef.index to distinguish table entries from host-provided externrefs. Host externrefs become opaque anyref (Value::Ref), while round-tripped values recover their original I31Ref/StructRef/ArrayRef identity. WAST conformance: 76 → 73 failures (65,560/65,633 = 99.889%) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…mponents Add deferred resolution for InlineExports that reference source instances not yet instantiated. Resolves after all core instances are created. This is needed for WAC-composed P3 components where the section ordering puts InlineExports before their source instance. Note: P3 CLI still fails at nested component instantiation (issue #211) because from_parsed requires _start for library components. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add from_parsed_library() that instantiates components without requiring _start export. Needed for WAC-composed P3 components where nested library components provide functions but don't have a command entry point. Also passes parent's host_registry to nested components for WASI resolution. P3 CLI progress: gets past _start check, now fails on arg_ref resolution for inter-component imports (text:processor/analyzer, etc.). The arg_refs loop is currently unimplemented — this is the next step for full P3 support. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Enable execution of WAC-composed P3 (Preview 3) components with nested library components. The implementation: - Lenient import linking for nested library components: non-WASI imports that can't be resolved (inter-component interfaces) are stub-resolved so the component can still instantiate - Nested engine discovery: when the parent has no core instances, search nested components for _start or wasi:cli/run entry points - Engine swap: take the nested component's engine as the parent's runtime engine, storing it AFTER the main_handle search - Runtime entry point search: scan all instance handles in the engine to find the correct one exporting the entry point - WASI handler re-setup for P3 components with nested instances Tested with p3_cli.wasm from wasm-component-examples v0.5.0. Note: inter-component function calls (fibonacci, analyze) require full arg_ref resolution which is not yet implemented. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Support descriptor (0x4D) and describes (0x4C) type markers from the WebAssembly custom-descriptors proposal. Each clause can appear at most once per type definition; duplicates are rejected as malformed. WAST conformance: 73 → 72 failures (65,561/65,633 = 99.890%) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fix 4 issues in the validator that allowed invalid types in unreachable code: 1. validate_branch_with_module: check concrete values against branch target types even when unreachable (polymorphic underflow still OK) 2. br_if: properly pop branch values and push label types in unreachable code (br_if defines concrete output types regardless of reachability) 3. select: check concrete operands match even in unreachable code 4. local.tee: model [t] -> [t] stack effect so polymorphic underflow pushes the local's type correctly WAST conformance: 72 → 65 failures (65,568/65,633 = 99.901%) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Import subtyping (12 of 13 fixed): - PreciseTypeInfo for global ref nullability, rec group boundaries, finality - Binary-level global type parser preserving nullable vs non-nullable - Rec-group-aware type matching for function/tag import validation - Finality checking in cross-module type comparison br_on_cast/fail validation (6 fixed): - Nullability check: rt2 nullable + rt1 non-nullable is type mismatch - Branch label type validation for cast result types - Proper fall-through type computation (diff type rt1\rt2) WAST conformance: 65 → 47 failures (65,586/65,633 = 99.928%) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ypes Extend GcTypeInfo::Func to carry param/result types so canonical type IDs distinguish different function signatures. Add GcFieldStorage::Ref/RefNull variants to preserve concrete type indices in struct/array fields. Add call_indirect_type_matches() that uses canonical type IDs with subtype chain walking for proper GC type matching, falling back to structural comparison for pre-GC modules. Update ref_test_value_with_module to prefer canonical IDs when available. WAST conformance: 47 → 36 failures (65,597/65,633 = 99.945%) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Per the spec, table.copy's length operand follows the destination table's index type, not dst64 || src64. This fixes mixed table32/table64 copy validation. WAST conformance: 36 → 35 failures (65,598/65,633 = 99.947%) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…table64 Corrects the table.copy length operand type for mixed table32/table64 copies. Length is i32 unless BOTH tables are table64. WAST conformance: 35 → 34 failures (65,599/65,633 = 99.948%) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ison When comparing struct field types across modules, reference type indices must be relativized to their rec-group positions. Fields containing Ref(idx)/RefNull(idx) now check if the referenced type is inside or outside the rec group and compare accordingly. WAST conformance: 34 → 31 failures (65,602/65,633 = 99.953%) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ents Add InterComponentHandler that chains WASI dispatch with inter-component routing for WAC-composed P3 components. Non-WASI function calls are routed to nested component engines based on interface name → component index mapping. The handler tries multiple export name formats: 1. Plain function name 2. Interface-qualified: "interface@version#function" 3. Async-lift: "[async-lift]interface@version#function" The dispatch reaches the correct nested component but P3 async functions use the async protocol (task.return, subtask.drop) which requires a coroutine runtime not yet implemented. Synchronous P3 functions would work; async ones hit call stack exhaustion from the async-lift wrapper. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add validation that the source table's element type is a subtype of the destination table's element type for table.copy instructions. WAST conformance: 31 → 30 failures (65,603/65,633 = 99.954%) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
🔍 Build Diagnostics ReportSummary
🎯 Impact AnalysisIssues in Files You Modified
Cascading Issues (Your Changes Breaking Other Files)
✅ No Issues DetectedPerfect! Your changes don't introduce any new errors or warnings, and don't break any existing code. 📊 Full diagnostic data available in workflow artifacts 🔧 To reproduce locally: # Install cargo-kiln
cargo install --path cargo-kiln
# Analyze your changes
cargo-kiln build --output json --filter-severity error
cargo-kiln check --output json --filter-severity warning |
Implement the P3 async task protocol builtins that Meld-fused components import from the $root namespace: - [context-get-N] / [context-set-N]: per-instance task-local context slots - [task-return]N: capture async function return values (variadic sigs) - [waitable-set-new]: allocate waitable set handles - [waitable-set-poll]: synchronous no-op (returns 0 in sync mode) - [waitable-set-drop] / [waitable-join] / [task-cancel]: no-ops for sync Builtins are dispatched in both import resolution paths (initial call and Instruction::Call handler) before falling through to WASI/default dispatch. Handles Meld's $N instance suffix stripping for multi-instance components. Also adds unlinked import → host handler fallback so fused modules can resolve WASI imports without explicit import links. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Add P3 async builtin dispatch in the call_indirect import handler, which
is the path used by Meld-fused modules (they use table-based dispatch for
all imports). Also adds host_handler fallback for unlinked WASI imports.
Fused P3 modules execute successfully with --function "0" flag.
All P3 builtins (context-get/set, task-return, waitable-set-*) are
intercepted before WASI dispatch.
Adds automatic entry point detection for fused modules: tries numbered
exports ("0", "1") when _start is not found.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This reverts commit 948d0b0.
Add non-nullable StackType variants (NonNullFuncRef, NonNullAnyRef, etc.) and update heap_type_to_stack_type to respect the nullable flag from br_on_cast instruction encoding. Fixes 4 additional assert_invalid tests where the validator accepted modules with nullable/non-nullable type mismatches. WAST conformance: 34 → 30 failures (65,603/65,633 = 99.954%) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
Major push on WebAssembly spec conformance and P3 component model support.
WAST Conformance: 90 → 36 failures (65,597/65,633 = 99.945%)
Runtime fixes
GcTypeInfo::Funcextended with params/results for function type distinctionGcFieldStorage::Ref/RefNullvariants preserving concrete type indicescall_indirectcanonical type matching with subtype chain walkingany.convert_extern/extern.convert_anyround-trip with thread-local side tablebr_on_non_nullmulti-value branch preservationarray.new_elem/array.init_elemusing resolved_elem_items + dropped checksValidator fixes
Decoder fixes
P3 Component Support
_startrequired)InterComponentHandlerp3_cli.wasm) runs and prints help textLinker fixes
Test plan
🤖 Generated with Claude Code