Skip to content

Suggestion: Make a list of JIT optimization supported by RyuJIT #9005

@damageboy

Description

@damageboy

From time to time, I learn of "new" (in the sense of not known to me) optimization that RyuJIT or the LegacyJIT can take.

From a recent example, I learned, for instance, that:

For BCL ValueType primitives byte, sbyte, ushort, short, uint, int, ulong, long, IntPtr, UIntPtr, Guid cast via object to the type and use .Equals directly them directly; then rely on the Jit to elide the boxing - meaning the mostly completely inline (e.g. Guid doesn't; though isn't a virtual call)

Or in other words, that in this type of code-construct:

           if (typeof(TKey) == typeof(byte))
            {
                return (byte)(object)key0 == (byte)(object)key1;
            }

The JIT can omit the boxing all together.

As someone attempting to write correct yet readable code, this sort of information, of what the JIT can and can't do, is not available to the best of my knowledge.

Is there a way the a definitive list could be made that describes exactly which optimizations the JIT can make and under what circumstances?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions