Repository navigation
[JIT] [wasm]: Compare TYP_REF references directly with null using i32.eqz - #134666
Conversation
…a more size efficient instruction sequence
|
Azure Pipelines: Successfully started running 6 pipeline(s). 10 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
A critical null-check correctness issue remains for TYP_REF address-mode expressions.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Updates WebAssembly JIT null checks to use i32.eqz for direct object references while preserving offset-aware checks for byrefs and integers.
Changes:
- Propagates operand types through null-check emission.
- Updates Wasm null-check callers and declarations.
- Retains ordered comparisons for non-reference addresses.
Review findings include a critical correctness issue for TYP_REF address-mode expressions and a request for code-size/performance evidence.
| File | Description |
|---|---|
src/coreclr/jit/hwintrinsiccodegenwasm.cpp |
Supplies address types for intrinsic null checks. |
src/coreclr/jit/codegenwasm.cpp |
Implements typed null-check emission and updates callers. |
src/coreclr/jit/codegen.h |
Updates the null-check helper declaration. |
…o handle possible offset in TYP_REF address
|
LGTM, but I'm not an expert in the JIT codebase enough to signoff on this. |
|
Also, I'm a bit surprised we can't do it in some cases where the read has an offset. If we can prove the use of the address+offset load is something like i32.load offset=X, we probably could also use the eqz form of this. |
|
@EgorBo can you take a look at this one? |
This should actually work today with this change. In a case like |
…GT_LEA to handle possible offset in TYP_REF address" This reverts commit 8006a3c.

Resolves #134463; For Object References (TYP_REF) with no added offset we can perform a null check by comparing directly with zero and use
i32.eqzfor that purpose. We must keep the longer ordered comparison ofi32.const 1023; i32.le_ufor null-checks on byref/int typed references and any address with an offset/index.SuperPMI Metrics (System.Private.CoreLib)
Code size: −70,101 bytes (−0.75%)
PerfScore in Diffs: −2.00%
10,079 size improvements, 0 regressions
10,022 PerfScore improvements, 0 regressions