dotnet / runtimelab

This repo is for experimentation and exploring new ideas that may or may not make it into the main dotnet/runtime repo.
MIT License
1.36k stars 188 forks source link

[NativeAOT-LLVM] Migrate runtime imports (FCalls) and exports to the managed calling convetion #2587

Closed SingleAccretion closed 1 month ago

SingleAccretion commented 1 month ago

The main motivation for this change is uniformity with upstream and the resulting simplification of the mental model (and some code).

In addition, this has some CQ benefits.

Diffs (unfortunately dominated by LLVM inlining noise):

Summary of Code Size diffs:
(Lower is better)

Total bytes of base: 3018196
Total bytes of diff: 3018644
Total bytes of delta: 448 (0.01% % of base)
Average relative delta: 5.89%
    diff is a regression
    average relative diff is a regression

Top method regressions (percentages):
         127 (1,058.33% of base) : 1078.dasm - System.Threading.PeriodicTimer__Finalize
         173 (596.55% of base) : 1187.dasm - S_P_TypeLoader_Internal_Runtime_TypeLoader_LowLevelStringConverter__LowLevelToStringRawEETypeAddress
         185 (430.23% of base) : 1316.dasm - System.Runtime.CachedInterfaceDispatch__RhpCidResolve
         173 (227.63% of base) : 1314.dasm - System.Runtime.CachedInterfaceDispatch__RhpResolveInterfaceMethod
          22 (122.22% of base) : 1126.dasm - System.Math__Tan
         264 (109.09% of base) : 1277.dasm - System.Reflection.Runtime.BindingFlagSupport.QueryResult`1<System___Canon>__CopyTo
         143 (103.62% of base) : 1284.dasm - System.Collections.Generic.List`1<System___Canon>__AddWithResize
         159 (98.76% of base) : 1160.dasm - System.Reflection.Runtime.TypeInfos.RuntimeHasElementTypeInfo__get_FullName
         334 (80.87% of base) : 1146.dasm - HelloWasm_Program__TryFinallyWithCatch
         174 (75.00% of base) : 1128.dasm - HelloWasm_Program__StartTest
          11 (73.33% of base) : 1001.dasm - RhpReversePInvokeReturn
          24 (72.73% of base) : 1204.dasm - HelloWasm_MyUnsealedClass__ToString
          58 (70.73% of base) : 1205.dasm - HelloWasm_MySealedClass__ToString
         143 (69.76% of base) : 1359.dasm - S_P_Reflection_Execution_Internal_Reflection_Execution_FieldAccessors_ReferenceTypeFieldAccessorForStaticFields__GetFieldBypassCctor
         143 (66.51% of base) : 1357.dasm - S_P_Reflection_Execution_Internal_Reflection_Execution_FieldAccessors_PointerTypeFieldAccessorForStaticFields__GetFieldBypassCctor
         143 (66.51% of base) : 1358.dasm - S_P_Reflection_Execution_Internal_Reflection_Execution_FieldAccessors_ValueTypeFieldAccessorForStaticFields__GetFieldBypassCctor
         160 (56.74% of base) : 1166.dasm - System.Globalization.CultureData__IcuGetLocaleInfo_0
         169 (54.52% of base) : 1138.dasm - HelloWasm_Program__TestUnsignedI8ConvOvf
         169 (54.52% of base) : 1139.dasm - HelloWasm_Program__TestI8ConvOvf
         169 (46.05% of base) : 1141.dasm - HelloWasm_Program__TestUnsignedI1ConvOvf

Top methods only present in diff:
           8 (     ∞ of base) : 1376.dasm - get.tan
          13 (     ∞ of base) : 1374.dasm - SetShadowStackTop(void*)
          74 (     ∞ of base) : 1375.dasm - RhpAssignRefWithShadowStack

Top method improvements (percentages):
        -193 (-80.75% of base) : 1304.dasm - System.Runtime.RuntimeExports__RhNewArray
        -435 (-72.74% of base) : 1305.dasm - System.Runtime.RuntimeExports__RhNewObject
         -24 (-40.00% of base) : 1244.dasm - UInt32__ToString
        -190 (-35.25% of base) : 1303.dasm - System.Runtime.RuntimeExports__RhBox
          -6 (-33.33% of base) : 1147.dasm - HelloWasm_IL_ILHelpers_ILHelpersTest__GetToStringFunctionPointer
          -6 (-33.33% of base) : 1148.dasm - HelloWasm_IL_ILHelpers_ILHelpersTest__GetCloneFunctionPointer
         -41 (-30.37% of base) : 1130.dasm - HelloWasm_Program__TestGenericCallInFinally
         -66 (-29.07% of base) : 1226.dasm - System.Enum__GetHashCode
         -32 (-27.59% of base) : 1236.dasm - HelloWasm_Program__TestTryFinally
         -22 (-24.44% of base) : 1228.dasm - System.Number__Int32ToDecStr
         -12 (-23.08% of base) : 1313.dasm - System.Runtime.GCStress__Initialize
          -4 (-22.22% of base) : 1004.dasm - RhNewString
         -22 (-21.36% of base) : 1237.dasm - Int16__ToString
          -4 (-18.18% of base) : 1373.dasm - __ResolveVirtualFunction_System.ICloneable__Clone
          -6 (-16.67% of base) : 1072.dasm - System.Diagnostics.Tracing.EventSource__Dispose
         -12 (-16.22% of base) : 1318.dasm - HelloWasm_Program___CallMe
        -278 (-16.05% of base) : 1091.dasm - System.TimeZoneInfo__GetIsDaylightSavingsFromUtc
          -6 (-15.79% of base) : 1135.dasm - System.Threading.Interlocked__Exchange_2
          -6 (-15.79% of base) : 1272.dasm - System.Threading.Interlocked__Exchange_1<System___Canon>
          -6 (-15.79% of base) : 1132.dasm - HelloWasm_Program___TestInterlocked_g__InterlockedExchangeObj_174_6

Top methods only present in base:
         -11 (-100.00% of base) : 1002.dasm - RhpGetShadowStackTop
         -13 (-100.00% of base) : 1003.dasm - RhpSetShadowStackTop
        -118 (-100.00% of base) : 1020.dasm - System.Runtime.InternalCalls__RhpNewArray
        -118 (-100.00% of base) : 1019.dasm - System.Runtime.InternalCalls__RhpNewArrayAlign8
        -114 (-100.00% of base) : 1018.dasm - System.Runtime.InternalCalls__RhpNewFast
        -114 (-100.00% of base) : 1017.dasm - System.Runtime.InternalCalls__RhpNewFinalizable
        -114 (-100.00% of base) : 1016.dasm - System.Runtime.InternalCalls__RhpNewFastAlign8
        -114 (-100.00% of base) : 1015.dasm - System.Runtime.InternalCalls__RhpNewFastMisalign
        -114 (-100.00% of base) : 1014.dasm - System.Runtime.InternalCalls__RhpNewFinalizableAlign8

377 total methods with Code Size differences (326 improved, 51 regressed)
SingleAccretion commented 1 month ago

@dotnet/nativeaot-llvm

jkotas commented 1 month ago

Thank you!