Skip to content

Instantly share code, notes, and snippets.

@mattwarren
Last active October 14, 2017 00:57
Show Gist options
  • Save mattwarren/bdb14bf0a87f6b24d338 to your computer and use it in GitHub Desktop.
Save mattwarren/bdb14bf0a87f6b24d338 to your computer and use it in GitHub Desktop.
How String ctor method calls are mapped in the CLR
String ctor - String(char *value);
---------------------------------------------------------------------------
Definition - https://github.com/dotnet/coreclr/blob/master/src/mscorlib/src/System/String.cs#L1323
Lookup pt1 - https://github.com/dotnet/coreclr/blob/master/src/vm/ecalllist.h#L215
Lookup pt2 - https://github.com/dotnet/coreclr/blob/master/src/vm/ecall.cpp#L42
Lookup pt3 - https://github.com/dotnet/coreclr/blob/master/src/vm/ecall.cpp#L34
Mapping - https://github.com/dotnet/coreclr/blob/master/src/vm/mscorlib.h#L1510
CtorCharArray impl - https://github.com/dotnet/coreclr/blob/master/src/mscorlib/src/System/String.cs#L1533-L1547
String ctor - String(sbyte *value, int startIndex, int length, Encoding enc)
----------------------------------------------------------------------------
Definition - https://github.com/dotnet/coreclr/blob/master/src/mscorlib/src/System/String.cs#L1337
Lookup - https://github.com/dotnet/coreclr/blob/master/src/vm/ecalllist.h#L223
StringInitSBytPtrPartialEx - https://github.com/dotnet/coreclr/blob/master/src/classlibnative/bcltype/stringnative.cpp#L64-L91
CreatString impl - https://github.com/dotnet/coreclr/blob/master/src/mscorlib/src/System/String.cs#L1340-L1366
String ctor - String(sbyte *value)
----------------------------------
Definition - https://github.com/dotnet/coreclr/blob/master/src/mscorlib/src/System/String.cs#L1331
Lookup -https://github.com/dotnet/coreclr/blob/master/src/vm/ecalllist.h#L220
COMString::StringInitCharPtr - https://github.com/dotnet/coreclr/blob/master/src/classlibnative/bcltype/stringnative.cpp#L99-L110
StringObject::StringInitCharHelper - https://github.com/dotnet/coreclr/blob/master/src/vm/object.cpp#L2086-L2130
Call to AllocateString https://github.com/dotnet/coreclr/blob/master/src/vm/object.cpp#L2121
AllocateString - https://github.com/dotnet/coreclr/blob/master/src/vm/gchelpers.cpp#L773-L789
JIT Wiring up GenAllocString - https://github.com/dotnet/coreclr/blob/master/src/vm/i386/jitinterfacex86.cpp#L1573
JIT Emitting GenAllocString - https://github.com/dotnet/coreclr/blob/master/src/vm/i386/jitinterfacex86.cpp#L1206-L1305
JIT EmitCore - https://github.com/dotnet/coreclr/blob/master/src/vm/i386/jitinterfacex86.cpp#L575-L717