Repository navigation
[NO MERGE] JIT: Experiment with non-null this for Wasm R2R - #134677
Draft
adamperlin wants to merge 2 commits into
Draft
adamperlin wants to merge 2 commits into
adamperlin wants to merge 2 commits into
Conversation
Co-authored-by: Copilot App <[email protected]>
|
Azure Pipelines: Successfully started running 5 pipeline(s). 11 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
this for Wasm R2Rthis for Wasm R2R
Exclude value classes explicitly and interface methods that may run on boxed structs. Co-authored-by: Copilot App <[email protected]>
5 of 16 tasks
This branch has not been deployed
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
thisis non-null during ReadyToRun compilationTYP_REFreceiver and explicitly exclude declaring types markedCORINFO_FLG_VALUECLASSorCORINFO_FLG_INTERFACEOrdinary struct
thisarguments are byrefs and already fail theTYP_REFguard. The explicit value-class exclusion documents the intended boundary. Interface methods are also excluded because default interface implementations can execute on struct receivers, including boxed structs; excluding only value-class declaring types would not cover that case.This is an experimental upper-bound measurement, not a proposed production contract. Arbitrary IL can invoke an instance method with a null receiver using
call, so enabling this option is intentionally unsound unless the runtime/toolchain provides an additional guarantee or checked-entry mechanism.Results
Current class-only experiment
Wasm SuperPMI with the separately built unmodified base JIT and updated treatment JIT measured 9,750,029 → 9,429,057 bytes: -320,972 (-3.29%) across 28,729 mutually replayable CoreLib contexts. There were 7,601 size improvements and no size regressions. The treatment requested JIT/EE data absent from the baseline-collected MCH in 256 of 28,985 contexts, while the base had no missing contexts. This is a common-context result, not a complete-corpus total.
A focused six-method Crossgen2 probe showed the class receiver's
this is nullcomparison shrinking from 34 to 23 bytes. The default interface implementation retained its comparison at 34 bytes, including when the interface is implemented by a struct. Struct field-access codegen, struct object-argument checks, and static object-argument checks were identical with the option enabled and disabled. These are codegen checks, not execution tests.Historical measurements before excluding interface methods
The following untrimmed browser-Wasm Release
System.Private.CoreLibR2R measurements were collected with the earlier reference-receiver experiment. They have not been rerun for the current class-only guard:Both historical builds compiled the same 52,503 managed methods. 12,619 methods became smaller and none became larger.
SafeFileHandle.get_IsInvalidshrank from 124 to 42 bytes. Static and value-type instance controls were byte-identical.The earlier Wasm SuperPMI comparison measured 9,750,029 → 9,427,949 bytes across the same 28,729 common contexts: -322,080 (-3.30%), with 7,620 size improvements and no regressions.
Validation
Current guard:
.\build.cmd clr.wasmjit -c Release— passed, zero warnings/errors.--parallelism:1 --targetarch:wasm --targetos:browser --obj-format:wasm --target-allows-runtime-code-generation:false -O --codegenopt:JitDisasm=*— passed; Python assertions checked all six method bodies and the expected null-comparison/code-size changes.python src\coreclr\scripts\superpmi.py asmdiffs -target_os browser -target_arch wasm --altjit -mch_files <published-CoreLib-MCH> -product_location artifacts\bin\coreclr\windows.x64.Release -base_jit_path <unmodified-base-JIT> -diff_jit_path artifacts\bin\coreclr\windows.x64.Release\clrjit_universal_wasm_x64.dll -diff_jit_option JitWasmAssumeNonNullThis=1 --summary_as_json -tag class-only -log_level info— completed; 256 treatment missing-data contexts, as noted above.jit-format.exe -r <worktree> -o windows -a x64 -b Release --untidy valuenum.cpp jitconfigvalues.h— passed clang-format check for both modified files; clang-tidy was not run.git diff --check— passed.Historical validation:
build.cmd -os browser -c Release -subset clr+libs— passed before the receiver restriction.No Wasm execution tests or runtime throughput benchmarks were run for this update.
Resolves #134674
Note
This pull request description was created with GitHub Copilot.