Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove pointer relocs from GC statics #78794

Merged
merged 1 commit into from
Nov 24, 2022

Conversation

MichalStrehovsky
Copy link
Member

For every type with a GC static base (i.e. something with static fields that contain references to the GC heap) we are generating a small data structure that has up to two pointers in it:

  • The first pointer points to a fake MethodTable that is used to allocate the static base on the GC heap (and assists in reporting GC pointers within that data).
  • The second pointer potentially points to data that was generated when interpreting the .cctor and gets memcopied to the GC static base at startup

These pointers can be relative pointers, so I'm doing that. Saves about 2 kB on a hello world on Windows. The savings will be closer to 0.5% on Linux due to getting rid of the full pointers (each costs extra 24 bytes on Linux).

Cc @dotnet/ilc-contrib

@ghost
Copy link

ghost commented Nov 24, 2022

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

Issue Details

For every type with a GC static base (i.e. something with static fields that contain references to the GC heap) we are generating a small data structure that has up to two pointers in it:

  • The first pointer points to a fake MethodTable that is used to allocate the static base on the GC heap (and assists in reporting GC pointers within that data).
  • The second pointer potentially points to data that was generated when interpreting the .cctor and gets memcopied to the GC static base at startup

These pointers can be relative pointers, so I'm doing that. Saves about 2 kB on a hello world on Windows. The savings will be closer to 0.5% on Linux due to getting rid of the full pointers (each costs extra 24 bytes on Linux).

Cc @dotnet/ilc-contrib

Author: MichalStrehovsky
Assignees: MichalStrehovsky
Labels:

area-NativeAOT-coreclr

Milestone: -

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

Nice!

@MichalStrehovsky MichalStrehovsky merged commit 8606a91 into dotnet:main Nov 24, 2022
@MichalStrehovsky MichalStrehovsky deleted the gcstaticptr branch November 24, 2022 06:35
@ghost ghost locked as resolved and limited conversation to collaborators Dec 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants