Deep Dive: .NET InternalCall Mechanics

Deep Dive: .NET InternalCall Mechanics

.NET Internals: InternalCall Visualizer

CoreCLR
C# / Managed
// In System.Private.CoreLib.dll
namespace System {
  public class Object {

    [MethodImpl(MethodImplOptions.InternalCall)]
    public extern int GetHashCode();
  }
}
JIT Compiler
Resolving Method Token 0x060002
Flag Action Target
IsIL Compile MSIL Native Code Block
IsInternalCall Lookup ECall Table ObjectNative::GetHashCode
IsPInvoke Load Library kernel32.dll
MANAGED
GC Mode: Cooperative
UNMANAGED (C++)
GC Mode: Preemptive
C++ / CoreCLR
// src/vm/object.cpp
FCIMPL1(INT32, ObjectNative::GetHashCode, Object* obj)
{
  // Access raw object header in heap
  if (obj == NULL) return 0;
  DWORD idx = obj->GetHeader()->GetSyncBlockIndex();
  return (INT32)idx;
}
FCIMPLEND
104928
Loading...

Comments

Popular posts from this blog

Master Asp.Net Core Middleware concepts.

ASP.net Interview P1

Book Store Project