Skip to content

Delete JIT_GetDynamic{GC,NonGC}StaticBase_SingleAppDomain asm helpers - #132670

Merged
EgorBo merged 1 commit into
dotnet:mainfrom
EgorBo:remove-singleappdomain-statics-asm
Aug 25, 2026
Merged

Delete JIT_GetDynamic{GC,NonGC}StaticBase_SingleAppDomain asm helpers#132670
EgorBo merged 1 commit into
dotnet:mainfrom
EgorBo:remove-singleappdomain-statics-asm

Conversation

@EgorBo

@EgorBo EgorBo commented Aug 23, 2026

Copy link
Copy Markdown
Member

Deletes the hand-written JIT_GetDynamic{GC,NonGC}StaticBase_SingleAppDomain helpers on amd64/arm64/loongarch64/riscv64, so CORINFO_HELP_GETDYNAMIC_*STATIC_BASE and CORINFO_HELP_GETPINNED_*STATIC_BASE resolve to the managed StaticsHelpers.GetDynamic{GC,NonGC}StaticBase on every platform.

Why:

  • The managed implementations already exist and are already the live path on x86/arm32 (jitinterface.h fell back to NULL -> binder there). This is not a new correctness model, just one fewer platform-specific override.
  • The asm slow path was strictly worse: it converted DynamicStaticsInfo* back to a MethodTable* and tail-jumped to the non-dynamic managed helper, which re-read the statics pointer and re-tested bit 0. The managed dynamic helper tail-jumps straight to GetNonGCStaticBaseSlow.
  • Fast-path codegen is at parity: the managed helper is 23 bytes at FullOpts (same inline bit-0 check + ret) vs ~30 for the asm.
  • The LoongArch64 and RISC-V versions were buggy: they branched on the whole statics pointer (bnez) instead of bit 0, so an initialized base took the slow managed tail call every time. Deleting removes the bug instead of fixing it in four places.
  • Move static helpers to managed #108167, which introduced the managed helpers, kept the asm as a minimal-diff port rather than for perf. It only retargeted the slow path (jmp JIT_GetDynamicNonGCStaticBase_Portable -> jmp [g_pGetNonGCStaticBase]) and wrote the managed dynamic helpers in the same change; they have been unreachable on these four arches ever since. I found no perf concerns recorded anywhere in that PR - there are no review comments on any asm/cgencpu.h/jitinterface.h file in it, and the non-Dynamic pair was taken fully managed there.
  • NativeAOT already keeps the analogous class-constructor handling managed (nativeaot/System.Private.CoreLib/.../ClassConstructorRunner.cs).

Also drops what became dead: g_pGetGCStaticBase / g_pGetNonGCStaticBase, the OFFSETOF__DynamicStaticsInfo__* asmconstants on all four arches, and the always-NULL JIT_Get*StaticBase shims in jitinterface.h (the *_NOCTOR shims stay - they still resolve to real _Portable implementations).

All platforms now use the managed StaticsHelpers.GetDynamic{GC,NonGC}StaticBase,
as x86/arm32 already did.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 7624d8d2-999a-494e-9f64-f597c3faf97d
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 4 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke
See info in area-owners.md if you want to be subscribed.

@EgorBo
EgorBo marked this pull request as ready for review August 23, 2026 15:55
Copilot AI lite review requested due to automatic review settings August 23, 2026 15:55
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 4 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the platform-specific JIT_GetDynamic{GC,NonGC}StaticBase_SingleAppDomain assembly helper implementations (and associated constants/wiring) so the relevant CORINFO_HELP_GET(DYNAMIC|PINNED)_*STATIC_BASE helpers consistently resolve through the existing managed StaticsHelpers implementations via the binder-based dynamic helper mechanism.

Changes:

  • Remove the SingleAppDomain asm helper implementations for dynamic GC/NonGC static base access on amd64/arm64/loongarch64/riscv64 and drop the corresponding cgencpu.h aliasing.
  • Remove now-dead DynamicStaticsInfo asm offset constants and dead g_pGet{GC,NonGC}StaticBase globals/initialization.
  • Switch the affected DYNAMICJITHELPER(...) entries to NULL function pointers so they bind to the managed METHOD__STATICSHELPERS__* targets uniformly.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/coreclr/vm/riscv64/cgencpu.h Removes SingleAppDomain aliasing for dynamic static base helpers.
src/coreclr/vm/riscv64/asmhelpers.S Deletes RISC-V asm implementations of dynamic static base helpers.
src/coreclr/vm/riscv64/asmconstants.h Drops DynamicStaticsInfo offset constants used only by deleted asm helpers.
src/coreclr/vm/loongarch64/cgencpu.h Removes SingleAppDomain aliasing for dynamic static base helpers.
src/coreclr/vm/loongarch64/asmhelpers.S Deletes LoongArch64 asm implementations of dynamic static base helpers.
src/coreclr/vm/loongarch64/asmconstants.h Drops DynamicStaticsInfo offset constants used only by deleted asm helpers.
src/coreclr/vm/jitinterface.h Removes always-NULL shims/declarations for the deleted helper names.
src/coreclr/vm/CMakeLists.txt Removes amd64 single-appdomain asm source files from build inputs.
src/coreclr/vm/arm64/cgencpu.h Removes SingleAppDomain aliasing for dynamic static base helpers.
src/coreclr/vm/arm64/asmhelpers.S Deletes ARM64 Unix asm implementations of dynamic static base helpers.
src/coreclr/vm/arm64/asmhelpers.asm Deletes ARM64 Windows asm implementations and related imports.
src/coreclr/vm/arm64/asmconstants.h Drops DynamicStaticsInfo offset constants used only by deleted asm helpers.
src/coreclr/vm/appdomain.cpp Removes dead g_pGet{GC,NonGC}StaticBase globals and initialization.
src/coreclr/vm/amd64/jithelpers_singleappdomain.S Deletes amd64 Unix single-appdomain helper file.
src/coreclr/vm/amd64/JitHelpers_SingleAppDomain.asm Deletes amd64 Windows single-appdomain helper file.
src/coreclr/vm/amd64/cgencpu.h Removes SingleAppDomain aliasing for dynamic static base helpers.
src/coreclr/vm/amd64/asmconstants.h Drops DynamicStaticsInfo offset constants used only by deleted asm helpers.
src/coreclr/inc/jithelpers.h Switches affected static/dynamic/pinned helper entries to binder-based managed resolution (NULL pfn).

@davidwrighton davidwrighton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as you've taken cursory look at perf. I approve.

@EgorBo

EgorBo commented Aug 24, 2026

Copy link
Copy Markdown
Member Author

As long as you've taken cursory look at perf. I approve.

I've done many ad-hoc benchmarks with ALC (unloadable) to trigger JIT_GetDynamic*, wasn't able to detect any regressions nor improvements. The only observable change is that sometimes the call to the managed helper is indirect, while previously it was always direct. But that happens to all managed helpers - they're emitted as direct call only when they reach Tier1 by the time whoever needs them is being compiled (a special VM optimization for all managed helpers).

@EgorBo
EgorBo enabled auto-merge (squash) August 25, 2026 15:52
@EgorBo

EgorBo commented Aug 25, 2026

Copy link
Copy Markdown
Member Author

/ba-g "publish build assets" failed

@EgorBo
EgorBo merged commit 7c33e9b into dotnet:main Aug 25, 2026
102 of 105 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants