Skip to content

RyuJIT should treat sealed virtual methods as normal ones and inline them where appropriate #4328

@omariom

Description

@omariom

Currently JIT treats sealed methods as virtual.
I use VS 2015 RC.

[MethodImpl(MethodImplOptions.NoInlining)]
private int TestSealedMethodInlining(Derived obj)
{
    return obj.GetValue(3);
}

class Base
{
    public virtual int GetValue(int value)
    {
        return 0x33;
    }
}

class Derived : Base
{
    public sealed override int GetValue(int value)
    {
        return value;
    }
}

TestSealedMethodInlining in machine code:

 sub         rsp,28h  
 mov         qword ptr [rsp+38h],rdx  
 mov         rcx,rdx  
 mov         edx,3  
 mov         rax,qword ptr [rsp+38h]  
 mov         rax,qword ptr [rax]  
 mov         rax,qword ptr [rax+40h]  
 call        qword ptr [rax+20h]  
 nop  
 add         rsp,28h  
 ret  

What I would expect:

  mov   rdx, qword ptr [rdx]
  mov   rax, 3 
  ret

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions