diff --git a/docs/design/datacontracts/GCInfo.md b/docs/design/datacontracts/GCInfo.md index 7ba3cfbc90ab9d..a136cffdac2dbc 100644 --- a/docs/design/datacontracts/GCInfo.md +++ b/docs/design/datacontracts/GCInfo.md @@ -665,6 +665,9 @@ For encodings without interruptible ranges (`HAS_INTERRUPTIBLE_RANGES` is false, **Slot filtering**: Before reporting any slot, the algorithm checks: - **Scratch registers**: Only reported for the active/leaf frame (`ActiveStackFrame` flag). + Valid Wasm GC info never contains register slots, so the WebAssembly platform + decoder's scratch-register predicate always returns false and asserts in debug + builds if called, mirroring the native unsupported-platform fallback. - **Scratch stack slots**: Only reported for the active/leaf frame (slots in the outgoing/scratch area). - **FP-based-only mode** (`ReportFPBasedSlotsOnly`): Only frame-register-relative stack slots are reported; all register slots and non-frame-relative stack slots are skipped. diff --git a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/GCInfo/PlatformTraits/WasmGCInfoTraits.cs b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/GCInfo/PlatformTraits/WasmGCInfoTraits.cs index 60fa8fe8f3894b..6097373872693b 100644 --- a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/GCInfo/PlatformTraits/WasmGCInfoTraits.cs +++ b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/GCInfo/PlatformTraits/WasmGCInfoTraits.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Diagnostics; + namespace Microsoft.Diagnostics.DataContractReader.Contracts.GCInfoHelpers; // Mirrors Wasm32GcInfoEncoding in src/coreclr/inc/gcinfotypes.h. @@ -37,5 +39,13 @@ internal sealed class WasmGCInfoTraits : IGCInfoTraits public static int NUM_INTERRUPTIBLE_RANGES_ENCBASE => 1; public static bool HAS_FIXED_STACK_PARAMETER_SCRATCH_AREA => false; public static bool HAS_INTERRUPTIBLE_RANGES => false; - public static bool IsScratchRegister(uint regNum) => false; + + // Valid Wasm GC info has no register slots; RyuJIT never emits one. Mirror the + // native fallback (gcinfodecoder.cpp PORTABILITY_ASSERT): flag the unexpected + // call in debug builds and otherwise return false, like other unimplemented platforms. + public static bool IsScratchRegister(uint regNum) + { + Debug.Fail("Wasm GC info must not contain register slots."); + return false; + } }