Skip to content

Consider adding a cache of well known tokens to the JIT #50426

@tannergooding

Description

@tannergooding

Today, the JIT uses a set of heuristics to determine whether or not a method is profitable to inline. However, due to tokens being unique per module and due to the cost associated with resolving tokens the JIT (when inlining) can't easily see when certain code patterns will result in constants or otherwise dead code elimination. This can hinder the ability for the JIT to correctly inline methods with things like Isa.IsSupported, if (typeof(T) == typeof(...)) checks, or even string.Length.

As such, I propose we create a cache (effectively a Dictionary<TokenId, MethodInfo> or similar, per module) of well known methods (i.e. certain NamedIntrinsics) so the inliner can correctly determine if the inlining is profitable.

This table could be built up during Tier 0 and would be available during Tier 1 so that the inliner can correctly see when a call is constant and do the appropriate dead code elimination and size adjustments.

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions