From baf99e8d76a3afffa6d4a9ab275bd0db51751345 Mon Sep 17 00:00:00 2001 From: kerams Date: Wed, 24 Jun 2026 00:39:29 +0200 Subject: [PATCH 01/16] Add language feature and baselines tests --- src/Compiler/FSComp.txt | 1 + src/Compiler/Facilities/LanguageFeatures.fs | 3 + src/Compiler/Facilities/LanguageFeatures.fsi | 1 + src/Compiler/xlf/FSComp.txt.cs.xlf | 5 + src/Compiler/xlf/FSComp.txt.de.xlf | 5 + src/Compiler/xlf/FSComp.txt.es.xlf | 5 + src/Compiler/xlf/FSComp.txt.fr.xlf | 5 + src/Compiler/xlf/FSComp.txt.it.xlf | 5 + src/Compiler/xlf/FSComp.txt.ja.xlf | 5 + src/Compiler/xlf/FSComp.txt.ko.xlf | 5 + src/Compiler/xlf/FSComp.txt.pl.xlf | 5 + src/Compiler/xlf/FSComp.txt.pt-BR.xlf | 5 + src/Compiler/xlf/FSComp.txt.ru.xlf | 5 + src/Compiler/xlf/FSComp.txt.tr.xlf | 5 + src/Compiler/xlf/FSComp.txt.zh-Hans.xlf | 5 + src/Compiler/xlf/FSComp.txt.zh-Hant.xlf | 5 + .../DelegateGenericInstanceMethod.fs | 13 + ...rnalSignatureOn.OptimizeOff.Preview.il.bsl | 179 +++++++ ...RealInternalSignatureOn.OptimizeOff.il.bsl | 179 +++++++ ...ernalSignatureOn.OptimizeOn.Preview.il.bsl | 139 ++++++ ....RealInternalSignatureOn.OptimizeOn.il.bsl | 139 ++++++ .../DelegateGenericStaticMethod.fs | 16 + ...rnalSignatureOn.OptimizeOff.Preview.il.bsl | 171 +++++++ ...RealInternalSignatureOn.OptimizeOff.il.bsl | 171 +++++++ ...ernalSignatureOn.OptimizeOn.Preview.il.bsl | 156 ++++++ ....RealInternalSignatureOn.OptimizeOn.il.bsl | 156 ++++++ .../DirectDelegates/DelegateInstanceMethod.fs | 21 + ...rnalSignatureOn.OptimizeOff.Preview.il.bsl | 295 ++++++++++++ ...RealInternalSignatureOn.OptimizeOff.il.bsl | 295 ++++++++++++ ...ernalSignatureOn.OptimizeOn.Preview.il.bsl | 223 +++++++++ ....RealInternalSignatureOn.OptimizeOn.il.bsl | 223 +++++++++ .../DirectDelegates/DelegateKnownFunction.fs | 21 + ...rnalSignatureOn.OptimizeOff.Preview.il.bsl | 209 ++++++++ ...RealInternalSignatureOn.OptimizeOff.il.bsl | 209 ++++++++ ...ernalSignatureOn.OptimizeOn.Preview.il.bsl | 187 ++++++++ ....RealInternalSignatureOn.OptimizeOn.il.bsl | 187 ++++++++ .../DirectDelegates/DelegateNegativeCases.fs | 14 + ...rnalSignatureOn.OptimizeOff.Preview.il.bsl | 203 ++++++++ ...RealInternalSignatureOn.OptimizeOff.il.bsl | 203 ++++++++ ...ernalSignatureOn.OptimizeOn.Preview.il.bsl | 182 +++++++ ....RealInternalSignatureOn.OptimizeOn.il.bsl | 182 +++++++ .../DirectDelegates/DelegateNonInlinable.fs | 56 +++ ...rnalSignatureOn.OptimizeOff.Preview.il.bsl | 447 ++++++++++++++++++ ...RealInternalSignatureOn.OptimizeOff.il.bsl | 447 ++++++++++++++++++ ...ernalSignatureOn.OptimizeOn.Preview.il.bsl | 445 +++++++++++++++++ ....RealInternalSignatureOn.OptimizeOn.il.bsl | 445 +++++++++++++++++ .../DelegatePartialApplication.fs | 27 ++ ...rnalSignatureOn.OptimizeOff.Preview.il.bsl | 270 +++++++++++ ...RealInternalSignatureOn.OptimizeOff.il.bsl | 270 +++++++++++ ...ernalSignatureOn.OptimizeOn.Preview.il.bsl | 195 ++++++++ ....RealInternalSignatureOn.OptimizeOn.il.bsl | 195 ++++++++ .../DirectDelegates/DelegateStaticMethod.fs | 21 + ...rnalSignatureOn.OptimizeOff.Preview.il.bsl | 215 +++++++++ ...RealInternalSignatureOn.OptimizeOff.il.bsl | 215 +++++++++ ...ernalSignatureOn.OptimizeOn.Preview.il.bsl | 193 ++++++++ ....RealInternalSignatureOn.OptimizeOn.il.bsl | 193 ++++++++ .../DirectDelegates/DelegateUnitArg.fs | 11 + ...rnalSignatureOn.OptimizeOff.Preview.il.bsl | 114 +++++ ...RealInternalSignatureOn.OptimizeOff.il.bsl | 114 +++++ ...ernalSignatureOn.OptimizeOn.Preview.il.bsl | 110 +++++ ....RealInternalSignatureOn.OptimizeOn.il.bsl | 110 +++++ .../DirectDelegates/DirectDelegates.fs | 120 +++++ .../FSharp.Compiler.ComponentTests.fsproj | 1 + .../Language/CodeQuotationTests.fs | 36 ++ 64 files changed, 8293 insertions(+) create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOn.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOff.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOn.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOff.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOn.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOff.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOn.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index d29b5d3dde7..54132f2b406 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -1822,3 +1822,4 @@ featurePreprocessorElif,"#elif preprocessor directive" 3889,tastNamespaceAndTypeWithSameNameInAssembly,"The namespace '%s' clashes with the type '%s'." featureExceptionFieldSerializationSupport,"emit GetObjectData and field-restoring deserialization constructor for exception types" featureErrorOnMissingSignatureAttribute,"error (rather than warning) when an enforced compiler-semantic attribute is present in the .fs but missing from the .fsi" +featureDirectDelegateConstruction,"construct delegates that point directly at the target method, avoiding an intermediate closure" diff --git a/src/Compiler/Facilities/LanguageFeatures.fs b/src/Compiler/Facilities/LanguageFeatures.fs index da4ef690311..04f0e89dcfc 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fs +++ b/src/Compiler/Facilities/LanguageFeatures.fs @@ -110,6 +110,7 @@ type LanguageFeature = | PreprocessorElif | ExceptionFieldSerializationSupport | ErrorOnMissingSignatureAttribute + | DirectDelegateConstruction /// LanguageVersion management type LanguageVersion(versionText, ?disabledFeaturesArray: LanguageFeature array) = @@ -263,6 +264,7 @@ type LanguageVersion(versionText, ?disabledFeaturesArray: LanguageFeature array) LanguageFeature.MethodOverloadsCache, previewVersion // Performance optimization for overload resolution LanguageFeature.ImplicitDIMCoverage, languageVersion110 LanguageFeature.ErrorOnMissingSignatureAttribute, previewVersion // Opt-in: turn FS3888 from warning into error + LanguageFeature.DirectDelegateConstruction, previewVersion ] static let defaultLanguageVersion = LanguageVersion("default") @@ -459,6 +461,7 @@ type LanguageVersion(versionText, ?disabledFeaturesArray: LanguageFeature array) | LanguageFeature.PreprocessorElif -> FSComp.SR.featurePreprocessorElif () | LanguageFeature.ExceptionFieldSerializationSupport -> FSComp.SR.featureExceptionFieldSerializationSupport () | LanguageFeature.ErrorOnMissingSignatureAttribute -> FSComp.SR.featureErrorOnMissingSignatureAttribute () + | LanguageFeature.DirectDelegateConstruction -> FSComp.SR.featureDirectDelegateConstruction () /// Get a version string associated with the given feature. static member GetFeatureVersionString feature = diff --git a/src/Compiler/Facilities/LanguageFeatures.fsi b/src/Compiler/Facilities/LanguageFeatures.fsi index 5ba352191af..51c41a951c9 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fsi +++ b/src/Compiler/Facilities/LanguageFeatures.fsi @@ -101,6 +101,7 @@ type LanguageFeature = | PreprocessorElif | ExceptionFieldSerializationSupport | ErrorOnMissingSignatureAttribute + | DirectDelegateConstruction /// LanguageVersion management type LanguageVersion = diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index 3ea52c5b169..7ed8ac66b89 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -362,6 +362,11 @@ Deprecate places where 'seq' can be omitted + + construct delegates that point directly at the target method, avoiding an intermediate closure + construct delegates that point directly at the target method, avoiding an intermediate closure + + discard pattern in use binding vzor discard ve vazbě použití diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index f9fc62909ef..d6313dda61c 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -362,6 +362,11 @@ Deprecate places where 'seq' can be omitted + + construct delegates that point directly at the target method, avoiding an intermediate closure + construct delegates that point directly at the target method, avoiding an intermediate closure + + discard pattern in use binding Das Verwerfen des verwendeten Musters ist verbindlich. diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index eca7c688eed..10d4c46c8a6 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -362,6 +362,11 @@ Deprecate places where 'seq' can be omitted + + construct delegates that point directly at the target method, avoiding an intermediate closure + construct delegates that point directly at the target method, avoiding an intermediate closure + + discard pattern in use binding descartar enlace de patrón en uso diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 0922cee5acd..2687a44b909 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -362,6 +362,11 @@ Deprecate places where 'seq' can be omitted + + construct delegates that point directly at the target method, avoiding an intermediate closure + construct delegates that point directly at the target method, avoiding an intermediate closure + + discard pattern in use binding annuler le modèle dans la liaison d’utilisation diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index d39f0a33a85..7f955c5add6 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -362,6 +362,11 @@ Deprecate places where 'seq' can be omitted + + construct delegates that point directly at the target method, avoiding an intermediate closure + construct delegates that point directly at the target method, avoiding an intermediate closure + + discard pattern in use binding rimuovi criterio nell'utilizzo dell'associazione diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index 6f4969e8148..f65cdf8b0cf 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -362,6 +362,11 @@ Deprecate places where 'seq' can be omitted + + construct delegates that point directly at the target method, avoiding an intermediate closure + construct delegates that point directly at the target method, avoiding an intermediate closure + + discard pattern in use binding 使用バインドでパターンを破棄する diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index fb488a6c240..fe21f373d13 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -362,6 +362,11 @@ Deprecate places where 'seq' can be omitted + + construct delegates that point directly at the target method, avoiding an intermediate closure + construct delegates that point directly at the target method, avoiding an intermediate closure + + discard pattern in use binding 사용 중인 패턴 바인딩 무시 diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index 2720c59fc22..47b24cf0213 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -362,6 +362,11 @@ Deprecate places where 'seq' can be omitted + + construct delegates that point directly at the target method, avoiding an intermediate closure + construct delegates that point directly at the target method, avoiding an intermediate closure + + discard pattern in use binding odrzuć wzorzec w powiązaniu użycia diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 8fc5566545f..ef601ecc0a6 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -362,6 +362,11 @@ Deprecate places where 'seq' can be omitted + + construct delegates that point directly at the target method, avoiding an intermediate closure + construct delegates that point directly at the target method, avoiding an intermediate closure + + discard pattern in use binding descartar o padrão em uso de associação diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 16eb9766b81..59779a48068 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -362,6 +362,11 @@ Deprecate places where 'seq' can be omitted + + construct delegates that point directly at the target method, avoiding an intermediate closure + construct delegates that point directly at the target method, avoiding an intermediate closure + + discard pattern in use binding шаблон отмены в привязке использования diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index da5fd475a81..6a8ba91016c 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -362,6 +362,11 @@ Deprecate places where 'seq' can be omitted + + construct delegates that point directly at the target method, avoiding an intermediate closure + construct delegates that point directly at the target method, avoiding an intermediate closure + + discard pattern in use binding kullanım bağlamasında deseni at diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index c43aa519603..16ab595ccfa 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -362,6 +362,11 @@ Deprecate places where 'seq' can be omitted + + construct delegates that point directly at the target method, avoiding an intermediate closure + construct delegates that point directly at the target method, avoiding an intermediate closure + + discard pattern in use binding 放弃使用绑定模式 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index d287b294184..960719ebb8b 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -362,6 +362,11 @@ Deprecate places where 'seq' can be omitted + + construct delegates that point directly at the target method, avoiding an intermediate closure + construct delegates that point directly at the target method, avoiding an intermediate closure + + discard pattern in use binding 捨棄使用繫結中的模式 diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs new file mode 100644 index 00000000000..6f3e738f6fa --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs @@ -0,0 +1,13 @@ +module DelegateGenericInstanceMethod + +open System + +type C() = + member _.IMc<'T> (x: 'T) (y: 'T) : unit = () + member _.IMt<'T> (x: 'T, y: 'T) : unit = () + +// 13. eta-expanded, generic instance method, curried application +let case13_etaCurried (o: C) = Action(fun a b -> o.IMc a b) + +// 14. eta-expanded, generic instance method, tupled application +let case14_etaTupled (o: C) = Action(fun a b -> o.IMt(a, b)) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl new file mode 100644 index 00000000000..b9299772df1 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl @@ -0,0 +1,179 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public specialname rtspecialname instance void .ctor() cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ret + } + + .method public hidebysig instance void IMc(!!T x, !!T y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public hidebysig instance void IMt(!!T x, !!T y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case13_etaCurried@10 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/case13_etaCurried@10::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/case13_etaCurried@10::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance void assembly/C::IMc(!!0, + !!0) + IL_000d: nop + IL_000e: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case14_etaTupled@13 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/case14_etaTupled@13::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/case14_etaTupled@13::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance void assembly/C::IMt(!!0, + !!0) + IL_000d: nop + IL_000e: ret + } + + } + + .method public static class [runtime]System.Action`2 case13_etaCurried(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/case13_etaCurried@10::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case13_etaCurried@10::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Action`2 case14_etaTupled(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/case14_etaTupled@13::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case14_etaTupled@13::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl new file mode 100644 index 00000000000..b9299772df1 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl @@ -0,0 +1,179 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public specialname rtspecialname instance void .ctor() cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ret + } + + .method public hidebysig instance void IMc(!!T x, !!T y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public hidebysig instance void IMt(!!T x, !!T y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case13_etaCurried@10 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/case13_etaCurried@10::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/case13_etaCurried@10::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance void assembly/C::IMc(!!0, + !!0) + IL_000d: nop + IL_000e: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case14_etaTupled@13 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/case14_etaTupled@13::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/case14_etaTupled@13::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance void assembly/C::IMt(!!0, + !!0) + IL_000d: nop + IL_000e: ret + } + + } + + .method public static class [runtime]System.Action`2 case13_etaCurried(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/case13_etaCurried@10::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case13_etaCurried@10::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Action`2 case14_etaTupled(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/case14_etaTupled@13::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case14_etaTupled@13::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl new file mode 100644 index 00000000000..6836a936968 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl @@ -0,0 +1,139 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public specialname rtspecialname instance void .ctor() cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ret + } + + .method public hidebysig instance void IMc(!!T x, !!T y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public hidebysig instance void IMt(!!T x, !!T y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case13_etaCurried@10 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case14_etaTupled@13 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .method public static class [runtime]System.Action`2 case13_etaCurried(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case13_etaCurried@10::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case14_etaTupled(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case14_etaTupled@13::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl new file mode 100644 index 00000000000..6836a936968 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -0,0 +1,139 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public specialname rtspecialname instance void .ctor() cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ret + } + + .method public hidebysig instance void IMc(!!T x, !!T y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public hidebysig instance void IMt(!!T x, !!T y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case13_etaCurried@10 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case14_etaTupled@13 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .method public static class [runtime]System.Action`2 case13_etaCurried(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case13_etaCurried@10::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case14_etaTupled(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case14_etaTupled@13::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs new file mode 100644 index 00000000000..b48e9130735 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs @@ -0,0 +1,16 @@ +module DelegateGenericStaticMethod + +open System + +type G<'U> = + static member SMc<'T> (x: 'T) (y: 'T) : unit = () + static member SMt<'T> (x: 'T, y: 'T) : unit = () + +// 7. non-eta-expanded generic static method (generic type + generic method) +let case7_nonEta () = Action(G.SMc) + +// 8. eta-expanded, curried application +let case8_etaCurried () = Action(fun a b -> G.SMc a b) + +// 9. eta-expanded, tupled application +let case9_etaTupled () = Action(fun a b -> G.SMt(a, b)) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl new file mode 100644 index 00000000000..23269e8fd6b --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl @@ -0,0 +1,171 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public G`1 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public static void SMc(!!T x, + !!T y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static void SMt(!!T x, + !!T y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case7_nonEta@10 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void class assembly/G`1::SMc(!!0, + !!0) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case8_etaCurried@13 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void class assembly/G`1::SMc(!!0, + !!0) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case9_etaTupled@16 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void class assembly/G`1::SMt(!!0, + !!0) + IL_0007: nop + IL_0008: ret + } + + } + + .method public static class [runtime]System.Action`2 case7_nonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case7_nonEta@10::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case8_etaCurried() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case8_etaCurried@13::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case9_etaTupled() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case9_etaTupled@16::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl new file mode 100644 index 00000000000..91c5b9cd522 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl @@ -0,0 +1,171 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public G`1 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public static void SMc(!!T x, + !!T y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static void SMt(!!T x, + !!T y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case7_nonEta@10 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void class assembly/G`1::SMc(!!0, + !!0) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case8_etaCurried@13 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void class assembly/G`1::SMc(!!0, + !!0) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case9_etaTupled@16 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void class assembly/G`1::SMt(!!0, + !!0) + IL_0007: nop + IL_0008: ret + } + + } + + .method public static class [runtime]System.Action`2 case7_nonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case7_nonEta@10::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case8_etaCurried() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case8_etaCurried@13::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case9_etaTupled() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case9_etaTupled@16::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl new file mode 100644 index 00000000000..e6bb3aa83fc --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl @@ -0,0 +1,156 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public G`1 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public static void SMc(!!T x, + !!T y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static void SMt(!!T x, + !!T y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case7_nonEta@10 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case8_etaCurried@13 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case9_etaTupled@16 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .method public static class [runtime]System.Action`2 case7_nonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case7_nonEta@10::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case8_etaCurried() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case8_etaCurried@13::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case9_etaTupled() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case9_etaTupled@16::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl new file mode 100644 index 00000000000..e6bb3aa83fc --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -0,0 +1,156 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public G`1 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public static void SMc(!!T x, + !!T y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static void SMt(!!T x, + !!T y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case7_nonEta@10 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case8_etaCurried@13 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case9_etaTupled@16 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .method public static class [runtime]System.Action`2 case7_nonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case7_nonEta@10::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case8_etaCurried() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case8_etaCurried@13::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case9_etaTupled() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case9_etaTupled@16::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs new file mode 100644 index 00000000000..1701b1c35e6 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs @@ -0,0 +1,21 @@ +module DelegateInstanceMethod + +open System + +type C(k: int) = + member _.AddC (x: int) (y: int) : unit = ignore k + member _.AddT (x: int, y: int) : unit = ignore k + abstract V : int -> int -> unit + default _.V (x: int) (y: int) : unit = ignore k + +// 10. non-eta-expanded instance method target +let case10_nonEta (o: C) = Action(o.AddC) + +// 11. eta-expanded, curried application +let case11_etaCurried (o: C) = Action(fun a b -> o.AddC a b) + +// 12. eta-expanded, tupled application +let case12_etaTupled (o: C) = Action(fun a b -> o.AddT(a, b)) + +// virtual instance method: a direct delegate must use ldvirtftn (with dup) to preserve dispatch +let caseVirtual (o: C) = Action(o.V) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl new file mode 100644 index 00000000000..b908fa4c200 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl @@ -0,0 +1,295 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .field assembly int32 k + .method public specialname rtspecialname instance void .ctor(int32 k) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ldarg.0 + IL_0009: ldarg.1 + IL_000a: stfld int32 assembly/C::k + IL_000f: ret + } + + .method public hidebysig instance void AddC(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 3 + .locals init (int32 V_0) + IL_0000: ldarg.0 + IL_0001: ldfld int32 assembly/C::k + IL_0006: stloc.0 + IL_0007: ret + } + + .method public hidebysig instance void AddT(int32 x, int32 y) cil managed + { + + .maxstack 3 + .locals init (int32 V_0) + IL_0000: ldarg.0 + IL_0001: ldfld int32 assembly/C::k + IL_0006: stloc.0 + IL_0007: ret + } + + .method public hidebysig virtual instance void V(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 3 + .locals init (int32 V_0) + IL_0000: ldarg.0 + IL_0001: ldfld int32 assembly/C::k + IL_0006: stloc.0 + IL_0007: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case10_nonEta@12 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/case10_nonEta@12::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/case10_nonEta@12::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance void assembly/C::AddC(int32, + int32) + IL_000d: nop + IL_000e: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case11_etaCurried@15 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/case11_etaCurried@15::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/case11_etaCurried@15::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance void assembly/C::AddC(int32, + int32) + IL_000d: nop + IL_000e: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case12_etaTupled@18 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/case12_etaTupled@18::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/case12_etaTupled@18::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance void assembly/C::AddT(int32, + int32) + IL_000d: nop + IL_000e: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname caseVirtual@21 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/caseVirtual@21::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/caseVirtual@21::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: tail. + IL_000a: callvirt instance void assembly/C::V(int32, + int32) + IL_000f: ret + } + + } + + .method public static class [runtime]System.Action`2 case10_nonEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/case10_nonEta@12::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case10_nonEta@12::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Action`2 case11_etaCurried(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/case11_etaCurried@15::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case11_etaCurried@15::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Action`2 case12_etaTupled(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/case12_etaTupled@18::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case12_etaTupled@18::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Action`2 caseVirtual(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/caseVirtual@21::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/caseVirtual@21::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl new file mode 100644 index 00000000000..b908fa4c200 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl @@ -0,0 +1,295 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .field assembly int32 k + .method public specialname rtspecialname instance void .ctor(int32 k) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ldarg.0 + IL_0009: ldarg.1 + IL_000a: stfld int32 assembly/C::k + IL_000f: ret + } + + .method public hidebysig instance void AddC(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 3 + .locals init (int32 V_0) + IL_0000: ldarg.0 + IL_0001: ldfld int32 assembly/C::k + IL_0006: stloc.0 + IL_0007: ret + } + + .method public hidebysig instance void AddT(int32 x, int32 y) cil managed + { + + .maxstack 3 + .locals init (int32 V_0) + IL_0000: ldarg.0 + IL_0001: ldfld int32 assembly/C::k + IL_0006: stloc.0 + IL_0007: ret + } + + .method public hidebysig virtual instance void V(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 3 + .locals init (int32 V_0) + IL_0000: ldarg.0 + IL_0001: ldfld int32 assembly/C::k + IL_0006: stloc.0 + IL_0007: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case10_nonEta@12 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/case10_nonEta@12::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/case10_nonEta@12::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance void assembly/C::AddC(int32, + int32) + IL_000d: nop + IL_000e: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case11_etaCurried@15 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/case11_etaCurried@15::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/case11_etaCurried@15::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance void assembly/C::AddC(int32, + int32) + IL_000d: nop + IL_000e: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case12_etaTupled@18 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/case12_etaTupled@18::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/case12_etaTupled@18::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance void assembly/C::AddT(int32, + int32) + IL_000d: nop + IL_000e: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname caseVirtual@21 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/caseVirtual@21::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/caseVirtual@21::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: tail. + IL_000a: callvirt instance void assembly/C::V(int32, + int32) + IL_000f: ret + } + + } + + .method public static class [runtime]System.Action`2 case10_nonEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/case10_nonEta@12::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case10_nonEta@12::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Action`2 case11_etaCurried(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/case11_etaCurried@15::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case11_etaCurried@15::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Action`2 case12_etaTupled(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/case12_etaTupled@18::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case12_etaTupled@18::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Action`2 caseVirtual(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/caseVirtual@21::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/caseVirtual@21::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl new file mode 100644 index 00000000000..44b0b4cbbd5 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl @@ -0,0 +1,223 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .field assembly int32 k + .method public specialname rtspecialname instance void .ctor(int32 k) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ldarg.0 + IL_0009: ldarg.1 + IL_000a: stfld int32 assembly/C::k + IL_000f: ret + } + + .method public hidebysig instance void AddC(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public hidebysig instance void AddT(int32 x, int32 y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + .method public hidebysig virtual instance void V(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case10_nonEta@12 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 delegateArg0, + int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case11_etaCurried@15 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case12_etaTupled@18 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname caseVirtual@21 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/caseVirtual@21::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/caseVirtual@21::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: tail. + IL_000a: callvirt instance void assembly/C::V(int32, + int32) + IL_000f: ret + } + + } + + .method public static class [runtime]System.Action`2 case10_nonEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case10_nonEta@12::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case11_etaCurried(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case11_etaCurried@15::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case12_etaTupled(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case12_etaTupled@18::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 caseVirtual(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/caseVirtual@21::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/caseVirtual@21::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl new file mode 100644 index 00000000000..44b0b4cbbd5 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -0,0 +1,223 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .field assembly int32 k + .method public specialname rtspecialname instance void .ctor(int32 k) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ldarg.0 + IL_0009: ldarg.1 + IL_000a: stfld int32 assembly/C::k + IL_000f: ret + } + + .method public hidebysig instance void AddC(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public hidebysig instance void AddT(int32 x, int32 y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + .method public hidebysig virtual instance void V(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case10_nonEta@12 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 delegateArg0, + int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case11_etaCurried@15 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case12_etaTupled@18 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname caseVirtual@21 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/caseVirtual@21::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/caseVirtual@21::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: tail. + IL_000a: callvirt instance void assembly/C::V(int32, + int32) + IL_000f: ret + } + + } + + .method public static class [runtime]System.Action`2 case10_nonEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case10_nonEta@12::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case11_etaCurried(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case11_etaCurried@15::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case12_etaTupled(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case12_etaTupled@18::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 caseVirtual(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/caseVirtual@21::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/caseVirtual@21::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs new file mode 100644 index 00000000000..e89b00afc72 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs @@ -0,0 +1,21 @@ +module DelegateKnownFunction + +open System + +// known F# functions compiled as methods +let handlerCurried (x: int) (y: int) : unit = () +let handlerTupled (x: int, y: int) : unit = () +let handler3 (x: int) (y: int) (z: int) : unit = () + +// 1. non-eta-expanded known target +let case1_nonEta () = Action(handlerCurried) + +// 2. eta-expanded known target (curried application) +let case2_etaCurried () = Action(fun a b -> handlerCurried a b) + +// 3. eta-expanded known target, tupled application, same compiled representation +let case3_etaTupled () = Action(fun a b -> handlerTupled (a, b)) + +// 15. non-eta-expanded known target via partial application +// (currently a closure with "delegateArg0"-style names; proposal: use elided arg names y, z) +let case15_partial () = Action(handler3 1) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl new file mode 100644 index 00000000000..9c87cb38678 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl @@ -0,0 +1,209 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case1_nonEta@11 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void assembly::handlerCurried(int32, + int32) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case2_etaCurried@14 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void assembly::handlerCurried(int32, + int32) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case3_etaTupled@17 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void assembly::handlerTupled(int32, + int32) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case15_partial@21 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 delegateArg0, + int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.1 + IL_0001: ldarg.0 + IL_0002: ldarg.1 + IL_0003: call void assembly::handler3(int32, + int32, + int32) + IL_0008: nop + IL_0009: ret + } + + } + + .method public static void handlerCurried(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static void handlerTupled(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + .method public static void handler3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action`2 case1_nonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case1_nonEta@11::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case2_etaCurried() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case2_etaCurried@14::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case3_etaTupled() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case3_etaTupled@17::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case15_partial() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case15_partial@21::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.il.bsl new file mode 100644 index 00000000000..9c87cb38678 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.il.bsl @@ -0,0 +1,209 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case1_nonEta@11 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void assembly::handlerCurried(int32, + int32) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case2_etaCurried@14 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void assembly::handlerCurried(int32, + int32) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case3_etaTupled@17 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void assembly::handlerTupled(int32, + int32) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case15_partial@21 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 delegateArg0, + int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.1 + IL_0001: ldarg.0 + IL_0002: ldarg.1 + IL_0003: call void assembly::handler3(int32, + int32, + int32) + IL_0008: nop + IL_0009: ret + } + + } + + .method public static void handlerCurried(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static void handlerTupled(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + .method public static void handler3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action`2 case1_nonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case1_nonEta@11::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case2_etaCurried() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case2_etaCurried@14::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case3_etaTupled() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case3_etaTupled@17::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case15_partial() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case15_partial@21::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl new file mode 100644 index 00000000000..548f0ecb854 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl @@ -0,0 +1,187 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case1_nonEta@11 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case2_etaCurried@14 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case3_etaTupled@17 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case15_partial@21 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 delegateArg0, + int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .method public static void handlerCurried(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static void handlerTupled(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + .method public static void handler3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action`2 case1_nonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case1_nonEta@11::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case2_etaCurried() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case2_etaCurried@14::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case3_etaTupled() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case3_etaTupled@17::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case15_partial() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case15_partial@21::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOn.il.bsl new file mode 100644 index 00000000000..548f0ecb854 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -0,0 +1,187 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case1_nonEta@11 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case2_etaCurried@14 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case3_etaTupled@17 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case15_partial@21 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 delegateArg0, + int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .method public static void handlerCurried(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static void handlerTupled(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + .method public static void handler3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action`2 case1_nonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case1_nonEta@11::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case2_etaCurried() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case2_etaCurried@14::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case3_etaTupled() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case3_etaTupled@17::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case15_partial() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case15_partial@21::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs new file mode 100644 index 00000000000..8f177b36053 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs @@ -0,0 +1,14 @@ +module DelegateNegativeCases + +open System + +// first-class function value: there is no target method to point at, so a closure must remain +let firstClass (handler: int -> int -> unit) = Action(handler) + +// lambda body is not a single direct forwarding call to a known target (the argument is computed, +// not the delegate parameters forwarded as-is): a closure must remain +let private sink (x: int) : unit = () +let notDirect (k: int) = Action(fun a b -> sink (a + b + k)) + +// arguments reordered: not a transparent forwarding, so a closure must remain +let reordered (handler: int -> int -> unit) = Action(fun a b -> handler b a) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl new file mode 100644 index 00000000000..32cd386fabb --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl @@ -0,0 +1,203 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto autochar serializable sealed nested assembly beforefieldinit specialname firstClass@6 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler' + .method public specialname rtspecialname instance void .ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/firstClass@6::'handler' + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/firstClass@6::'handler' + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: call !!0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::InvokeFast(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>, + !0, + !1) + IL_000d: pop + IL_000e: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname notDirect@11 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public int32 k + .method public specialname rtspecialname instance void .ctor(int32 k) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld int32 assembly/notDirect@11::k + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: add + IL_0003: ldarg.0 + IL_0004: ldfld int32 assembly/notDirect@11::k + IL_0009: add + IL_000a: call void assembly::sink(int32) + IL_000f: nop + IL_0010: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname reordered@14 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler' + .method public specialname rtspecialname instance void .ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/reordered@14::'handler' + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/reordered@14::'handler' + IL_0006: ldarg.2 + IL_0007: ldarg.1 + IL_0008: call !!0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::InvokeFast(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>, + !0, + !1) + IL_000d: pop + IL_000e: ret + } + + } + + .method public static class [runtime]System.Action`2 firstClass(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/firstClass@6::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>) + IL_0006: ldftn instance void assembly/firstClass@6::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + + .method private static void sink(int32 x) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action`2 notDirect(int32 k) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/notDirect@11::.ctor(int32) + IL_0006: ldftn instance void assembly/notDirect@11::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Action`2 reordered(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/reordered@14::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>) + IL_0006: ldftn instance void assembly/reordered@14::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOff.il.bsl new file mode 100644 index 00000000000..32cd386fabb --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOff.il.bsl @@ -0,0 +1,203 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto autochar serializable sealed nested assembly beforefieldinit specialname firstClass@6 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler' + .method public specialname rtspecialname instance void .ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/firstClass@6::'handler' + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/firstClass@6::'handler' + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: call !!0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::InvokeFast(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>, + !0, + !1) + IL_000d: pop + IL_000e: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname notDirect@11 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public int32 k + .method public specialname rtspecialname instance void .ctor(int32 k) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld int32 assembly/notDirect@11::k + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: add + IL_0003: ldarg.0 + IL_0004: ldfld int32 assembly/notDirect@11::k + IL_0009: add + IL_000a: call void assembly::sink(int32) + IL_000f: nop + IL_0010: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname reordered@14 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler' + .method public specialname rtspecialname instance void .ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/reordered@14::'handler' + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/reordered@14::'handler' + IL_0006: ldarg.2 + IL_0007: ldarg.1 + IL_0008: call !!0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::InvokeFast(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>, + !0, + !1) + IL_000d: pop + IL_000e: ret + } + + } + + .method public static class [runtime]System.Action`2 firstClass(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/firstClass@6::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>) + IL_0006: ldftn instance void assembly/firstClass@6::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + + .method private static void sink(int32 x) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action`2 notDirect(int32 k) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/notDirect@11::.ctor(int32) + IL_0006: ldftn instance void assembly/notDirect@11::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Action`2 reordered(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/reordered@14::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>) + IL_0006: ldftn instance void assembly/reordered@14::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl new file mode 100644 index 00000000000..39878c4a64b --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl @@ -0,0 +1,182 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto autochar serializable sealed nested assembly beforefieldinit specialname firstClass@6 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler' + .method public specialname rtspecialname instance void .ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/firstClass@6::'handler' + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/firstClass@6::'handler' + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: call !!0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::InvokeFast(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>, + !0, + !1) + IL_000d: pop + IL_000e: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname notDirect@11 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname reordered@14 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler' + .method public specialname rtspecialname instance void .ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/reordered@14::'handler' + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/reordered@14::'handler' + IL_0006: ldarg.2 + IL_0007: ldarg.1 + IL_0008: call !!0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::InvokeFast(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>, + !0, + !1) + IL_000d: pop + IL_000e: ret + } + + } + + .method public static class [runtime]System.Action`2 firstClass(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/firstClass@6::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>) + IL_0006: ldftn instance void assembly/firstClass@6::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + + .method private static void sink(int32 x) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action`2 notDirect(int32 k) cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/notDirect@11::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 reordered(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/reordered@14::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>) + IL_0006: ldftn instance void assembly/reordered@14::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOn.il.bsl new file mode 100644 index 00000000000..39878c4a64b --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -0,0 +1,182 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto autochar serializable sealed nested assembly beforefieldinit specialname firstClass@6 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler' + .method public specialname rtspecialname instance void .ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/firstClass@6::'handler' + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/firstClass@6::'handler' + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: call !!0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::InvokeFast(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>, + !0, + !1) + IL_000d: pop + IL_000e: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname notDirect@11 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname reordered@14 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler' + .method public specialname rtspecialname instance void .ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/reordered@14::'handler' + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/reordered@14::'handler' + IL_0006: ldarg.2 + IL_0007: ldarg.1 + IL_0008: call !!0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::InvokeFast(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>, + !0, + !1) + IL_000d: pop + IL_000e: ret + } + + } + + .method public static class [runtime]System.Action`2 firstClass(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/firstClass@6::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>) + IL_0006: ldftn instance void assembly/firstClass@6::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + + .method private static void sink(int32 x) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action`2 notDirect(int32 k) cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/notDirect@11::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 reordered(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/reordered@14::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>) + IL_0006: ldftn instance void assembly/reordered@14::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs new file mode 100644 index 00000000000..fb8979eee4f --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs @@ -0,0 +1,56 @@ +module DelegateNonInlinable + +open System + +// Section D, bullet 1: the optimizer inlines small function bodies before IlxGen runs. If a delegate +// target is inlined away in release/Optimize+ builds, the forwarding call no longer survives and the +// direct-delegate recognizer has nothing to fire on. To prove the release path is actually exercised we +// need targets the optimizer will NOT inline. [] forces ValInline.Never, so the +// forwarding call is guaranteed to reach IlxGen regardless of how small the body is (see +// ComputeInlineFlag in CheckExpressions.fs). Bodies are arithmetic only (TFM-stable, no BCL calls) and +// Func<_,_,_> is used so the result is observable. + +[] +let accCurried (x: int) (y: int) : int = x + y + +[] +let accTupled (x: int, y: int) : int = x + y + +// non-inlinable known target, non-eta-expanded +let niNonEta () = Func(accCurried) + +// non-inlinable known target, eta-expanded, curried application +let niEtaCurried () = Func(fun a b -> accCurried a b) + +// non-inlinable known target, eta-expanded, tupled application +let niEtaTupled () = Func(fun a b -> accTupled (a, b)) + +type S = + [] + static member AccS (x: int) (y: int) : int = x + y + +// non-inlinable static target, non-eta-expanded +let niStaticNonEta () = Func(S.AccS) + +// non-inlinable static target, eta-expanded +let niStaticEta () = Func(fun a b -> S.AccS a b) + +type C(k: int) = + [] + member _.AccC (x: int) (y: int) : int = x + y + k + +// non-inlinable instance target, non-eta-expanded +let niInstanceNonEta (o: C) = Func(o.AccC) + +// non-inlinable instance target, eta-expanded +let niInstanceEta (o: C) = Func(fun a b -> o.AccC a b) + +// Section D, bullet 1 (the contrast case): a trivial, inlinable target kept on purpose to document and +// guard the inline-vs-direct interaction. In release the optimizer may inline the body before the +// recognizer runs; the recognizer must therefore act in the optimizer (before the head call is inlined) +// for this to still become a direct delegate. +let trivial (x: int) (y: int) : int = x + y + +let niTrivialNonEta () = Func(trivial) + +let niTrivialEta () = Func(fun a b -> trivial a b) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl new file mode 100644 index 00000000000..3d35edadfa8 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl @@ -0,0 +1,447 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public S + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public static int32 AccS(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + } + + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .field assembly int32 k + .method public specialname rtspecialname instance void .ctor(int32 k) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ldarg.0 + IL_0009: ldarg.1 + IL_000a: stfld int32 assembly/C::k + IL_000f: ret + } + + .method public hidebysig instance int32 AccC(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: add + IL_0003: ldarg.0 + IL_0004: ldfld int32 assembly/C::k + IL_0009: add + IL_000a: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niNonEta@20 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::accCurried(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaCurried@23 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::accCurried(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaTupled@26 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::accTupled(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticNonEta@33 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly/S::AccS(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticEta@36 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly/S::AccS(int32, + int32) + IL_0007: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceNonEta@43 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/niInstanceNonEta@43::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/niInstanceNonEta@43::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance int32 assembly/C::AccC(int32, + int32) + IL_000d: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceEta@46 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/niInstanceEta@46::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/niInstanceEta@46::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance int32 assembly/C::AccC(int32, + int32) + IL_000d: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@54 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::trivial(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@56 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::trivial(int32, + int32) + IL_0007: ret + } + + } + + .method public static int32 accCurried(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + .method public static int32 accTupled(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + .method public static class [runtime]System.Func`3 niNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niNonEta@20::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niEtaCurried() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niEtaCurried@23::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niEtaTupled() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niEtaTupled@26::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niStaticNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niStaticNonEta@33::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niStaticEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niStaticEta@36::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niInstanceNonEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/niInstanceNonEta@43::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niInstanceNonEta@43::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Func`3 niInstanceEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/niInstanceEta@46::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niInstanceEta@46::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + + .method public static int32 trivial(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + .method public static class [runtime]System.Func`3 niTrivialNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niTrivialNonEta@54::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niTrivialEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niTrivialEta@56::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.il.bsl new file mode 100644 index 00000000000..78ddf50dac2 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.il.bsl @@ -0,0 +1,447 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public S + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public static int32 AccS(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + } + + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .field assembly int32 k + .method public specialname rtspecialname instance void .ctor(int32 k) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ldarg.0 + IL_0009: ldarg.1 + IL_000a: stfld int32 assembly/C::k + IL_000f: ret + } + + .method public hidebysig instance int32 AccC(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: add + IL_0003: ldarg.0 + IL_0004: ldfld int32 assembly/C::k + IL_0009: add + IL_000a: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niNonEta@20 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::accCurried(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaCurried@23 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::accCurried(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaTupled@26 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::accTupled(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticNonEta@33 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly/S::AccS(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticEta@36 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly/S::AccS(int32, + int32) + IL_0007: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceNonEta@43 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/niInstanceNonEta@43::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/niInstanceNonEta@43::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance int32 assembly/C::AccC(int32, + int32) + IL_000d: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceEta@46 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/niInstanceEta@46::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/niInstanceEta@46::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance int32 assembly/C::AccC(int32, + int32) + IL_000d: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@54 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::trivial(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@56 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::trivial(int32, + int32) + IL_0007: ret + } + + } + + .method public static int32 accCurried(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + .method public static int32 accTupled(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + .method public static class [runtime]System.Func`3 niNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niNonEta@20::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niEtaCurried() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niEtaCurried@23::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niEtaTupled() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niEtaTupled@26::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niStaticNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niStaticNonEta@33::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niStaticEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niStaticEta@36::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niInstanceNonEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/niInstanceNonEta@43::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niInstanceNonEta@43::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Func`3 niInstanceEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/niInstanceEta@46::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niInstanceEta@46::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + + .method public static int32 trivial(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + .method public static class [runtime]System.Func`3 niTrivialNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niTrivialNonEta@54::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niTrivialEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niTrivialEta@56::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl new file mode 100644 index 00000000000..dd5dc76e043 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl @@ -0,0 +1,445 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public S + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public static int32 AccS(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + } + + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .field assembly int32 k + .method public specialname rtspecialname instance void .ctor(int32 k) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ldarg.0 + IL_0009: ldarg.1 + IL_000a: stfld int32 assembly/C::k + IL_000f: ret + } + + .method public hidebysig instance int32 AccC(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: add + IL_0003: ldarg.0 + IL_0004: ldfld int32 assembly/C::k + IL_0009: add + IL_000a: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niNonEta@20 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::accCurried(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaCurried@23 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::accCurried(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaTupled@26 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::accTupled(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticNonEta@33 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly/S::AccS(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticEta@36 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly/S::AccS(int32, + int32) + IL_0007: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceNonEta@43 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/niInstanceNonEta@43::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/niInstanceNonEta@43::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance int32 assembly/C::AccC(int32, + int32) + IL_000d: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceEta@46 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/niInstanceEta@46::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/niInstanceEta@46::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance int32 assembly/C::AccC(int32, + int32) + IL_000d: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@54 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@56 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + } + + .method public static int32 accCurried(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + .method public static int32 accTupled(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + .method public static class [runtime]System.Func`3 niNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niNonEta@20::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niEtaCurried() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niEtaCurried@23::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niEtaTupled() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niEtaTupled@26::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niStaticNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niStaticNonEta@33::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niStaticEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niStaticEta@36::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niInstanceNonEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/niInstanceNonEta@43::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niInstanceNonEta@43::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Func`3 niInstanceEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/niInstanceEta@46::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niInstanceEta@46::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + + .method public static int32 trivial(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + .method public static class [runtime]System.Func`3 niTrivialNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niTrivialNonEta@54::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niTrivialEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niTrivialEta@56::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.il.bsl new file mode 100644 index 00000000000..7fa0f5a0c7d --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -0,0 +1,445 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public S + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public static int32 AccS(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + } + + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .field assembly int32 k + .method public specialname rtspecialname instance void .ctor(int32 k) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ldarg.0 + IL_0009: ldarg.1 + IL_000a: stfld int32 assembly/C::k + IL_000f: ret + } + + .method public hidebysig instance int32 AccC(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: add + IL_0003: ldarg.0 + IL_0004: ldfld int32 assembly/C::k + IL_0009: add + IL_000a: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niNonEta@20 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::accCurried(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaCurried@23 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::accCurried(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaTupled@26 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::accTupled(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticNonEta@33 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly/S::AccS(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticEta@36 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly/S::AccS(int32, + int32) + IL_0007: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceNonEta@43 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/niInstanceNonEta@43::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/niInstanceNonEta@43::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance int32 assembly/C::AccC(int32, + int32) + IL_000d: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceEta@46 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/niInstanceEta@46::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/niInstanceEta@46::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance int32 assembly/C::AccC(int32, + int32) + IL_000d: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@54 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@56 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + } + + .method public static int32 accCurried(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + .method public static int32 accTupled(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + .method public static class [runtime]System.Func`3 niNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niNonEta@20::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niEtaCurried() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niEtaCurried@23::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niEtaTupled() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niEtaTupled@26::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niStaticNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niStaticNonEta@33::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niStaticEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niStaticEta@36::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niInstanceNonEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/niInstanceNonEta@43::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niInstanceNonEta@43::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Func`3 niInstanceEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/niInstanceEta@46::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niInstanceEta@46::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + + .method public static int32 trivial(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + .method public static class [runtime]System.Func`3 niTrivialNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niTrivialNonEta@54::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niTrivialEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/niTrivialEta@56::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs new file mode 100644 index 00000000000..8b12ee25545 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs @@ -0,0 +1,27 @@ +module DelegatePartialApplication + +open System + +// Section D, bullet 2: cases 15/16 (in DelegateKnownFunction.fs / DelegateStaticMethod.fs) capture a +// constant first argument, so their closure can stay static (the constant is re-materialised in Invoke +// with no instance field). Capturing a runtime VALUE instead forces the closure to carry an instance +// field, which exercises a distinct emit path. None of these can ever become a direct delegate (the +// target has more parameters than the delegate's Invoke), so a closure must remain regardless of +// langversion; the only proposed change here is friendlier elided argument names. + +let handler3 (x: int) (y: int) (z: int) : unit = () + +type C = + static member Add3 (x: int) (y: int) (z: int) : unit = () + +type I(k: int) = + member _.Add3 (x: int) (y: int) (z: int) : unit = ignore k + +// variable-capture partial application of a known function (instance-field capture of n) +let papKnownVar (n: int) = Action(handler3 n) + +// variable-capture partial application of a static method +let papStaticVar (n: int) = Action(C.Add3 n) + +// variable-capture partial application of an instance method (captures both the receiver and n) +let papInstanceVar (o: I) (n: int) = Action(o.Add3 n) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl new file mode 100644 index 00000000000..1b719dd6d94 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl @@ -0,0 +1,270 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public static void Add3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + } + + .class auto ansi serializable nested public I + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .field assembly int32 k + .method public specialname rtspecialname instance void .ctor(int32 k) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ldarg.0 + IL_0009: ldarg.1 + IL_000a: stfld int32 assembly/I::k + IL_000f: ret + } + + .method public hidebysig instance void + Add3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 3 + .locals init (int32 V_0) + IL_0000: ldarg.0 + IL_0001: ldfld int32 assembly/I::k + IL_0006: stloc.0 + IL_0007: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname papKnownVar@21 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public int32 n + .method public specialname rtspecialname instance void .ctor(int32 n) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld int32 assembly/papKnownVar@21::n + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 assembly/papKnownVar@21::n + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: call void assembly::handler3(int32, + int32, + int32) + IL_000d: nop + IL_000e: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname papStaticVar@24 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public int32 n + .method public specialname rtspecialname instance void .ctor(int32 n) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld int32 assembly/papStaticVar@24::n + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 assembly/papStaticVar@24::n + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: call void assembly/C::Add3(int32, + int32, + int32) + IL_000d: nop + IL_000e: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname papInstanceVar@27 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/I o + .field public int32 n + .method public specialname rtspecialname instance void .ctor(class assembly/I o, int32 n) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/I assembly/papInstanceVar@27::o + IL_0007: ldarg.0 + IL_0008: ldarg.2 + IL_0009: stfld int32 assembly/papInstanceVar@27::n + IL_000e: ldarg.0 + IL_000f: call instance void [runtime]System.Object::.ctor() + IL_0014: ret + } + + .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/I assembly/papInstanceVar@27::o + IL_0006: ldarg.0 + IL_0007: ldfld int32 assembly/papInstanceVar@27::n + IL_000c: ldarg.1 + IL_000d: ldarg.2 + IL_000e: callvirt instance void assembly/I::Add3(int32, + int32, + int32) + IL_0013: nop + IL_0014: ret + } + + } + + .method public static void handler3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action`2 papKnownVar(int32 n) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/papKnownVar@21::.ctor(int32) + IL_0006: ldftn instance void assembly/papKnownVar@21::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Action`2 papStaticVar(int32 n) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/papStaticVar@24::.ctor(int32) + IL_0006: ldftn instance void assembly/papStaticVar@24::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Action`2 papInstanceVar(class assembly/I o, int32 n) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: newobj instance void assembly/papInstanceVar@27::.ctor(class assembly/I, + int32) + IL_0007: ldftn instance void assembly/papInstanceVar@27::Invoke(int32, + int32) + IL_000d: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0012: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOff.il.bsl new file mode 100644 index 00000000000..fc1e7bc6303 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOff.il.bsl @@ -0,0 +1,270 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public static void Add3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + } + + .class auto ansi serializable nested public I + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .field assembly int32 k + .method public specialname rtspecialname instance void .ctor(int32 k) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ldarg.0 + IL_0009: ldarg.1 + IL_000a: stfld int32 assembly/I::k + IL_000f: ret + } + + .method public hidebysig instance void + Add3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 3 + .locals init (int32 V_0) + IL_0000: ldarg.0 + IL_0001: ldfld int32 assembly/I::k + IL_0006: stloc.0 + IL_0007: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname papKnownVar@21 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public int32 n + .method public specialname rtspecialname instance void .ctor(int32 n) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld int32 assembly/papKnownVar@21::n + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 assembly/papKnownVar@21::n + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: call void assembly::handler3(int32, + int32, + int32) + IL_000d: nop + IL_000e: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname papStaticVar@24 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public int32 n + .method public specialname rtspecialname instance void .ctor(int32 n) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld int32 assembly/papStaticVar@24::n + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 assembly/papStaticVar@24::n + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: call void assembly/C::Add3(int32, + int32, + int32) + IL_000d: nop + IL_000e: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname papInstanceVar@27 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/I o + .field public int32 n + .method public specialname rtspecialname instance void .ctor(class assembly/I o, int32 n) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/I assembly/papInstanceVar@27::o + IL_0007: ldarg.0 + IL_0008: ldarg.2 + IL_0009: stfld int32 assembly/papInstanceVar@27::n + IL_000e: ldarg.0 + IL_000f: call instance void [runtime]System.Object::.ctor() + IL_0014: ret + } + + .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/I assembly/papInstanceVar@27::o + IL_0006: ldarg.0 + IL_0007: ldfld int32 assembly/papInstanceVar@27::n + IL_000c: ldarg.1 + IL_000d: ldarg.2 + IL_000e: callvirt instance void assembly/I::Add3(int32, + int32, + int32) + IL_0013: nop + IL_0014: ret + } + + } + + .method public static void handler3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action`2 papKnownVar(int32 n) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/papKnownVar@21::.ctor(int32) + IL_0006: ldftn instance void assembly/papKnownVar@21::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Action`2 papStaticVar(int32 n) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/papStaticVar@24::.ctor(int32) + IL_0006: ldftn instance void assembly/papStaticVar@24::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Action`2 papInstanceVar(class assembly/I o, int32 n) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: newobj instance void assembly/papInstanceVar@27::.ctor(class assembly/I, + int32) + IL_0007: ldftn instance void assembly/papInstanceVar@27::Invoke(int32, + int32) + IL_000d: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_0012: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl new file mode 100644 index 00000000000..f9efcbd168b --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl @@ -0,0 +1,195 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public static void Add3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + } + + .class auto ansi serializable nested public I + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .field assembly int32 k + .method public specialname rtspecialname instance void .ctor(int32 k) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ldarg.0 + IL_0009: ldarg.1 + IL_000a: stfld int32 assembly/I::k + IL_000f: ret + } + + .method public hidebysig instance void + Add3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papKnownVar@21 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 delegateArg0, + int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papStaticVar@24 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 delegateArg0, + int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papInstanceVar@27 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 delegateArg0, + int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .method public static void handler3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action`2 papKnownVar(int32 n) cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/papKnownVar@21::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 papStaticVar(int32 n) cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/papStaticVar@24::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 papInstanceVar(class assembly/I o, int32 n) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/papInstanceVar@27::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOn.il.bsl new file mode 100644 index 00000000000..afb6d8c3f64 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -0,0 +1,195 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public static void Add3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + } + + .class auto ansi serializable nested public I + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .field assembly int32 k + .method public specialname rtspecialname instance void .ctor(int32 k) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ldarg.0 + IL_0009: ldarg.1 + IL_000a: stfld int32 assembly/I::k + IL_000f: ret + } + + .method public hidebysig instance void + Add3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papKnownVar@21 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 delegateArg0, + int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papStaticVar@24 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 delegateArg0, + int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papInstanceVar@27 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 delegateArg0, + int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .method public static void handler3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action`2 papKnownVar(int32 n) cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/papKnownVar@21::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 papStaticVar(int32 n) cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/papStaticVar@24::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 papInstanceVar(class assembly/I o, int32 n) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/papInstanceVar@27::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs new file mode 100644 index 00000000000..5f3ec7b724e --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs @@ -0,0 +1,21 @@ +module DelegateStaticMethod + +open System + +type C = + static member AddC (x: int) (y: int) : unit = () + static member AddT (x: int, y: int) : unit = () + static member Add3 (x: int) (y: int) (z: int) : unit = () + +// 4. non-eta-expanded static method target +// (a tupled member is seen as a single tuple-arg value and will not coerce non-eta; use the curried member) +let case4_nonEta () = Action(C.AddC) + +// 5. eta-expanded, curried application +let case5_etaCurried () = Action(fun a b -> C.AddC a b) + +// 6. eta-expanded, tupled application +let case6_etaTupled () = Action(fun a b -> C.AddT(a, b)) + +// 16. non-eta-expanded static method via partial application +let case16_partial () = Action(C.Add3 1) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl new file mode 100644 index 00000000000..15590de3edc --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl @@ -0,0 +1,215 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public static void AddC(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static void AddT(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + .method public static void Add3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case4_nonEta@12 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void assembly/C::AddC(int32, + int32) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case5_etaCurried@15 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void assembly/C::AddC(int32, + int32) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case6_etaTupled@18 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void assembly/C::AddT(int32, + int32) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case16_partial@21 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 delegateArg0, + int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.1 + IL_0001: ldarg.0 + IL_0002: ldarg.1 + IL_0003: call void assembly/C::Add3(int32, + int32, + int32) + IL_0008: nop + IL_0009: ret + } + + } + + .method public static class [runtime]System.Action`2 case4_nonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case4_nonEta@12::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case5_etaCurried() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case5_etaCurried@15::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case6_etaTupled() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case6_etaTupled@18::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case16_partial() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case16_partial@21::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl new file mode 100644 index 00000000000..15590de3edc --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl @@ -0,0 +1,215 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public static void AddC(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static void AddT(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + .method public static void Add3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case4_nonEta@12 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void assembly/C::AddC(int32, + int32) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case5_etaCurried@15 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void assembly/C::AddC(int32, + int32) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case6_etaTupled@18 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void assembly/C::AddT(int32, + int32) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case16_partial@21 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 delegateArg0, + int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.1 + IL_0001: ldarg.0 + IL_0002: ldarg.1 + IL_0003: call void assembly/C::Add3(int32, + int32, + int32) + IL_0008: nop + IL_0009: ret + } + + } + + .method public static class [runtime]System.Action`2 case4_nonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case4_nonEta@12::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case5_etaCurried() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case5_etaCurried@15::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case6_etaTupled() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case6_etaTupled@18::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case16_partial() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case16_partial@21::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl new file mode 100644 index 00000000000..eadfc7c3f13 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl @@ -0,0 +1,193 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public static void AddC(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static void AddT(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + .method public static void Add3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case4_nonEta@12 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case5_etaCurried@15 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case6_etaTupled@18 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case16_partial@21 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 delegateArg0, + int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .method public static class [runtime]System.Action`2 case4_nonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case4_nonEta@12::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case5_etaCurried() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case5_etaCurried@15::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case6_etaTupled() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case6_etaTupled@18::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case16_partial() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case16_partial@21::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl new file mode 100644 index 00000000000..eadfc7c3f13 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -0,0 +1,193 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public static void AddC(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static void AddT(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + .method public static void Add3(int32 x, + int32 y, + int32 z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case4_nonEta@12 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case5_etaCurried@15 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case6_etaTupled@18 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case16_partial@21 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 delegateArg0, + int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .method public static class [runtime]System.Action`2 case4_nonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case4_nonEta@12::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case5_etaCurried() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case5_etaCurried@15::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case6_etaTupled() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case6_etaTupled@18::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 case16_partial() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/case16_partial@21::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs new file mode 100644 index 00000000000..7b27fb8611b --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs @@ -0,0 +1,11 @@ +module DelegateUnitArg + +open System + +let handler () : unit = () + +// unit-argument delegate, non-eta-expanded known target +let caseUnitNonEta () = Action(handler) + +// unit-argument delegate, eta-expanded +let caseUnitEta () = Action(fun () -> handler ()) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl new file mode 100644 index 00000000000..b91d58c4597 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl @@ -0,0 +1,114 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitNonEta@8 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke() cil managed + { + + .maxstack 8 + IL_0000: call void assembly::'handler'() + IL_0005: nop + IL_0006: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitEta@11 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke() cil managed + { + + .maxstack 8 + IL_0000: call void assembly::'handler'() + IL_0005: nop + IL_0006: ret + } + + } + + .method public static void 'handler'() cil managed + { + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action caseUnitNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/caseUnitNonEta@8::Invoke() + IL_0007: newobj instance void [runtime]System.Action::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action caseUnitEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/caseUnitEta@11::Invoke() + IL_0007: newobj instance void [runtime]System.Action::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOff.il.bsl new file mode 100644 index 00000000000..b91d58c4597 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOff.il.bsl @@ -0,0 +1,114 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitNonEta@8 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke() cil managed + { + + .maxstack 8 + IL_0000: call void assembly::'handler'() + IL_0005: nop + IL_0006: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitEta@11 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke() cil managed + { + + .maxstack 8 + IL_0000: call void assembly::'handler'() + IL_0005: nop + IL_0006: ret + } + + } + + .method public static void 'handler'() cil managed + { + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action caseUnitNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/caseUnitNonEta@8::Invoke() + IL_0007: newobj instance void [runtime]System.Action::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action caseUnitEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/caseUnitEta@11::Invoke() + IL_0007: newobj instance void [runtime]System.Action::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl new file mode 100644 index 00000000000..3684e4e4a6b --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl @@ -0,0 +1,110 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitNonEta@8 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke() cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitEta@11 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke() cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .method public static void 'handler'() cil managed + { + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action caseUnitNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/caseUnitNonEta@8::Invoke() + IL_0007: newobj instance void [runtime]System.Action::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action caseUnitEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/caseUnitEta@11::Invoke() + IL_0007: newobj instance void [runtime]System.Action::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOn.il.bsl new file mode 100644 index 00000000000..3684e4e4a6b --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -0,0 +1,110 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitNonEta@8 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke() cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitEta@11 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke() cil managed + { + + .maxstack 8 + IL_0000: ret + } + + } + + .method public static void 'handler'() cil managed + { + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action caseUnitNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/caseUnitNonEta@8::Invoke() + IL_0007: newobj instance void [runtime]System.Action::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action caseUnitEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/caseUnitEta@11::Invoke() + IL_0007: newobj instance void [runtime]System.Action::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs new file mode 100644 index 00000000000..ccf7d8d41a0 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs @@ -0,0 +1,120 @@ +namespace EmittedIL.RealInternalSignature + +open System.IO +open Xunit +open FSharp.Test +open FSharp.Test.Compiler + +module DirectDelegates = + + let private coreOptions compilation = + compilation + |> withOptions [ "--test:EmitFeeFeeAs100001" ] + |> asExe + |> withEmbeddedPdb + |> withEmbedAllSource + |> ignoreWarnings + + // Default langversion: direct delegates must NOT be emitted (a closure is still generated). + // Baselines: ..il.bsl -- these should remain unchanged when the feature lands. + let verifyCompilation compilation = + compilation + |> coreOptions + |> compile + |> verifyILBaseline + + // Redirect the IL baseline to a distinct *.Preview.il.bsl path so the preview variant can reuse the + // very same input .fs file (no input duplication / drift) without clobbering the default baseline. + let private withPreviewBaseline (cUnit: CompilationUnit) : CompilationUnit = + match cUnit with + | FS src -> + let baseline = + src.Baseline + |> Option.map (fun bsl -> + let path = bsl.ILBaseline.BslSource.Replace(".il.bsl", ".Preview.il.bsl") + let content = if File.Exists path then Some(File.ReadAllText path) else None + { bsl with ILBaseline = { bsl.ILBaseline with BslSource = path; Content = content } }) + FS { src with Baseline = baseline } + | other -> other + + // Preview langversion: direct delegates ARE emitted once the feature lands. + // Baselines: ..Preview.il.bsl -- these are the ones that will change. + let verifyPreviewCompilation compilation = + compilation + |> coreOptions + |> withLangVersionPreview + |> withPreviewBaseline + |> compile + |> verifyILBaseline + + [] + let ``DelegateKnownFunction_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + + [] + let ``DelegateKnownFunction_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + + [] + let ``DelegateStaticMethod_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + + [] + let ``DelegateStaticMethod_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + + [] + let ``DelegateGenericStaticMethod_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + + [] + let ``DelegateGenericStaticMethod_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + + [] + let ``DelegateInstanceMethod_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + + [] + let ``DelegateInstanceMethod_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + + [] + let ``DelegateGenericInstanceMethod_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + + [] + let ``DelegateGenericInstanceMethod_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + + [] + let ``DelegateUnitArg_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + + [] + let ``DelegateUnitArg_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + + [] + let ``DelegateNegativeCases_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + + [] + let ``DelegateNegativeCases_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + + [] + let ``DelegateNonInlinable_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + + [] + let ``DelegateNonInlinable_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + + [] + let ``DelegatePartialApplication_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + + [] + let ``DelegatePartialApplication_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj index 5f8dbb26c5b..ab0d33585d1 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj +++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj @@ -260,6 +260,7 @@ + diff --git a/tests/FSharp.Compiler.ComponentTests/Language/CodeQuotationTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/CodeQuotationTests.fs index 29556381221..7085bd7a3a7 100644 --- a/tests/FSharp.Compiler.ComponentTests/Language/CodeQuotationTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/CodeQuotationTests.fs @@ -40,6 +40,42 @@ let z : unit = |> compileAndRun |> shouldSucceed + [] + let ``Delegate construction quotations are unaffected by the direct delegate optimization`` () = + Fsx """ +open System +open FSharp.Quotations.Patterns + +let handlerCurried (x: int) (y: int) : unit = () + +type C(k: int) = + member _.AddC (x: int) (y: int) : unit = ignore k + +let check (label: string) (target: string) (expr: Quotations.Expr) = + match expr with + | NewDelegate(dty, _, _) when dty = typeof> -> () + | e -> failwithf "%s: expected NewDelegate of Action, got %A" label e + if not ((string expr).Contains target) then + failwithf "%s: expected the quotation to reference target '%s', got %A" label target expr + +let o = C(1) + +// non-eta-expanded known function +check "nonEta" "handlerCurried" <@ Action(handlerCurried) @> +// eta-expanded known function +check "etaCurried" "handlerCurried" <@ Action(fun a b -> handlerCurried a b) @> +// non-eta-expanded instance method +check "instanceNonEta" "AddC" <@ Action(o.AddC) @> +// eta-expanded instance method +check "instanceEta" "AddC" <@ Action(fun a b -> o.AddC a b) @> + +printfn "ok" + """ + |> asExe + |> withLangVersionPreview + |> compileAndRun + |> shouldSucceed + [] let ``Quotation on decimal literal compiles and runs`` () = FSharp """ From 87cff9abf7f1c9624265401e0856d1763e7f60cc Mon Sep 17 00:00:00 2001 From: kerams Date: Wed, 24 Jun 2026 20:16:58 +0200 Subject: [PATCH 02/16] Implementation --- src/Compiler/CodeGen/IlxGen.fs | 362 ++++++++++++++---- .../TypedTree/TypedTreeOps.ExprOps.fs | 65 ++++ .../TypedTree/TypedTreeOps.ExprOps.fsi | 26 ++ .../DelegateExtensionMethod.fs | 18 + ...rnalSignatureOn.OptimizeOff.Preview.il.bsl | 139 +++++++ ...RealInternalSignatureOn.OptimizeOff.il.bsl | 139 +++++++ ...ernalSignatureOn.OptimizeOn.Preview.il.bsl | 139 +++++++ ....RealInternalSignatureOn.OptimizeOn.il.bsl | 139 +++++++ ...rnalSignatureOn.OptimizeOff.Preview.il.bsl | 23 +- .../DirectDelegates/DelegateILMethod.fs | 16 + ...rnalSignatureOn.OptimizeOff.Preview.il.bsl | 127 ++++++ ...RealInternalSignatureOn.OptimizeOff.il.bsl | 127 ++++++ ...ernalSignatureOn.OptimizeOn.Preview.il.bsl | 78 ++++ ....RealInternalSignatureOn.OptimizeOn.il.bsl | 127 ++++++ ...rnalSignatureOn.OptimizeOff.Preview.il.bsl | 85 +--- ...ernalSignatureOn.OptimizeOn.Preview.il.bsl | 43 +-- ...rnalSignatureOn.OptimizeOff.Preview.il.bsl | 23 +- .../DirectDelegates/DelegateNonInlinable.fs | 9 + ...rnalSignatureOn.OptimizeOff.Preview.il.bsl | 149 ++++--- ...RealInternalSignatureOn.OptimizeOff.il.bsl | 136 ++++++- ...ernalSignatureOn.OptimizeOn.Preview.il.bsl | 202 +++------- ....RealInternalSignatureOn.OptimizeOn.il.bsl | 128 ++++++- ...rnalSignatureOn.OptimizeOff.Preview.il.bsl | 23 +- .../DirectDelegates/DelegateStructTarget.fs | 15 + ...rnalSignatureOn.OptimizeOff.Preview.il.bsl | 317 +++++++++++++++ ...RealInternalSignatureOn.OptimizeOff.il.bsl | 317 +++++++++++++++ ...ernalSignatureOn.OptimizeOn.Preview.il.bsl | 284 ++++++++++++++ ....RealInternalSignatureOn.OptimizeOn.il.bsl | 284 ++++++++++++++ .../DirectDelegates/DelegateUnitReturn.fs | 23 ++ ...rnalSignatureOn.OptimizeOff.Preview.il.bsl | 160 ++++++++ ...RealInternalSignatureOn.OptimizeOff.il.bsl | 194 ++++++++++ ...ernalSignatureOn.OptimizeOn.Preview.il.bsl | 126 ++++++ ....RealInternalSignatureOn.OptimizeOn.il.bsl | 194 ++++++++++ .../DirectDelegates/DirectDelegates.fs | 183 +++++++++ 34 files changed, 3891 insertions(+), 529 deletions(-) create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOff.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOn.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOff.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOn.il.bsl diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index c63398b4267..8f6b8c92711 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -7462,108 +7462,302 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, let ilDelegeeParams, ilDelegeeRet = GenActualSlotsig m cenv envForDelegeeUnderTypars slotsig methTyparsOfOverridingMethod tmvs - let envForDelegeeMeth = - AddStorageForLocalVals g (List.mapi (fun i v -> (v, Arg(i + numthis))) tmvs) envForDelegeeUnderTypars + // Direct delegate construction: when the delegate body is a saturated, transparent forwarding call to a + // known static method, module-level function, or instance method, point the delegate straight at that + // method instead of generating an intermediate closure class. For a static target the receiver is null + // (ldnull; ldftn target); for an instance target the receiver is evaluated and the function pointer is + // bound with ldftn, or dup; ldvirtftn for a virtual target so dispatch is preserved. A strict + // IL-signature check makes the rewrite provably equivalent to the closure form; anything that does not + // match exactly falls back to the closure path below. Gated by LanguageFeature.DirectDelegateConstruction. + let directDelegateTarget = + if not (g.langVersion.SupportsFeature LanguageFeature.DirectDelegateConstruction) then + None + elif + not cenv.options.localOptimizationsEnabled + && tmvs |> List.exists (fun (v: Val) -> not v.IsCompilerGenerated) + then + // Eta-expanded delegate in an unoptimized build: the Invoke parameters are the user's own lambda + // variables, so keep the closure to preserve their names for debugging. Non-eta delegates (whose + // parameters are synthesized by BuildNewDelegateExpr) are always made direct; eta-expanded ones + // are made direct only in optimized builds, where debuggability is not a concern and the + // forwarding call survives to here. + None + else + match body with + | DirectDelegateForwardingCall g tmvs (target, leadingArgs) -> + // For an instance method the single leading argument is the receiver; a static method or + // module function must have no leading arguments (otherwise it is a partial application). + let receiverShapeOk takesInstanceArg = + if takesInstanceArg then + match leadingArgs with + | [ _ ] -> true + | _ -> false + else + List.isEmpty leadingArgs + + // The receiver is hoisted to the delegate-construction site, so a direct delegate is only sound + // when it can be evaluated there exactly once and as the Target: + // - A closure built from an explicit eta-lambda (e.g. `fun a -> recv.M a`) re-evaluates the + // receiver on every Invoke; evaluating it once instead is observable unless it is + // side-effect free (a non-mutable value, a constant, a pure field read). + // - It must not reference the delegate's own Invoke parameters, which only exist inside the + // delegee method. + // Checked lazily (and after the cheaper structural bails) so disqualified delegates skip the + // receiver traversal; ExprHasEffect short-circuits before the freeInExpr allocation. + let receiverNotBindable () = + match leadingArgs with + | [ recv ] -> + Optimizer.ExprHasEffect g recv + || (let recvFreeLocals = (freeInExpr CollectLocals recv).FreeLocals + tmvs |> List.exists (fun tv -> Zset.contains tv recvFreeLocals)) + | _ -> false - let ilMethodBody = - CodeGenMethodForExpr - cenv - cgbuf.mgbuf - ([], - delegeeMethName, - envForDelegeeMeth, - 1, - None, - body, - (if slotSigHasVoidReturnTy slotsig then - discardAndReturnVoid - else - Return)) + // The type checker has already verified that the delegate is built from a compatible function + // shape, and the structural match above forwards the Invoke parameters verbatim, so the + // target's signature is compatible with the delegate's Invoke by construction. We just confirm + // the compiled shape lines up: + // - for a non-generic target, identical parameter and return types (cheap and exact); + // - for a generic target, matching parameter count (the formal signature is written in terms + // of type variables, so an exact type comparison here is not meaningful; arity rejects + // unit-elision / param-array / tupled-arity mismatches). + // For an instance method the receiver is implicit and does not appear in FormalArgTypes. + let signatureMatches (ilEnclArgTys: ILType list) (ilMethArgTys: ILType list) (targetMspec: ILMethodSpec) = + if List.isEmpty ilEnclArgTys && List.isEmpty ilMethArgTys then + typesOfILParams ilDelegeeParams = targetMspec.FormalArgTypes + && ilDelegeeRet.Type = targetMspec.FormalReturnType + else + targetMspec.FormalArgTypes.Length = ilDelegeeParams.Length - let delegeeInvokeMeth = - (if useStaticClosure then - mkILNonGenericStaticMethod - else - mkILNonGenericInstanceMethod) ( - delegeeMethName, - ILMemberAccess.Assembly, - ilDelegeeParams, - ilDelegeeRet, - MethodBody.IL(InterruptibleLazy.FromValue ilMethodBody) - ) + let receiverInfo virtualCall = + match leadingArgs with + | [ recv ] -> Some(recv, virtualCall) + | _ -> None - let delegeeCtorMeth = - mkILSimpleStorageCtor (Some g.ilg.typ_Object.TypeSpec, ilDelegeeTyInner, [], [], ILMemberAccess.Assembly, None, eenvouter.imports) + match target with + | DirectDelegateForwardingTarget.FSharpVal(vref, valUseFlags, tyargs) -> + match StorageForValRef m vref eenvouter with + | Method(valReprInfo, vrefM, mspec, _, _, ctps, _, _, _, _, _, _) -> + let _, witnessInfos, _, _, _ = + GetValReprTypeInCompiledForm g valReprInfo ctps.Length vrefM.Type m - let ilCtorBody = delegeeCtorMeth.MethodBody + let hasWitnesses = ComputeGenerateWitnesses g eenvouter && not witnessInfos.IsEmpty - let ilCloLambdas = Lambdas_return ilCtxtDelTy + let _, virtualCall, newobj, isSuperInit, isSelfInit, takesInstanceArg, _, _ = + GetMemberCallInfo g (vrefM, valUseFlags) - let cloTypeDefs = - (if useStaticClosure then - GenStaticDelegateClosureTypeDefs - else - GenClosureTypeDefs) - cenv - (ilDelegeeTypeRef, - ilDelegeeGenericParams, - [], - ilCloAllFreeVars, - ilCloLambdas, - ilCtorBody, - [ delegeeInvokeMeth ], - [], - g.ilg.typ_Object, - [], - None) + let isBaseCall = valUseFlags.IsVSlotDirectCall - for cloTypeDef in cloTypeDefs do - cgbuf.mgbuf.AddTypeDef(ilDelegeeTypeRef, cloTypeDef, false, false, None) + if + hasWitnesses + || newobj + || isSuperInit + || isSelfInit + || isBaseCall + || not (receiverShapeOk takesInstanceArg) + || receiverNotBindable () + then + None + else + let ilTyArgs = GenTypeArgs cenv m eenvouter.tyenv tyargs - CountClosure() + let numEnclILTypeArgs = + if vrefM.MemberInfo.IsSome && not vrefM.IsExtensionMember then + List.length (vrefM.MemberApparentEntity.Typars |> DropErasedTypars) + else + 0 - // Push the constructor for the delegee - let ctxtGenericArgsForDelegee = GenGenericArgs m eenvouter.tyenv cloFreeTyvars + if ilTyArgs.Length < numEnclILTypeArgs then + None + else + let ilEnclArgTys, ilMethArgTys = List.splitAt numEnclILTypeArgs ilTyArgs + let boxity = mspec.DeclaringType.Boxity + let targetMspec = mkILMethSpec (mspec.MethodRef, boxity, ilEnclArgTys, ilMethArgTys) + + if takesInstanceArg <> targetMspec.MethodRef.CallingConv.IsInstance then + None + elif takesInstanceArg && boxity = AsValue then + // value-type receivers not handled + None + elif signatureMatches ilEnclArgTys ilMethArgTys targetMspec then + Some(targetMspec, receiverInfo virtualCall) + else + None + | _ -> None + + | DirectDelegateForwardingTarget.ILMethod(isVirtual, isStruct, isCtor, valUseFlag, ilMethRef, enclTypeInst, methInst) -> + // A direct IL call (e.g. a BCL method). Everything needed to build the method spec is on + // the node, so there is no storage/witness resolution; we still bail on the shapes that + // have no closed direct-delegate form. + let isBaseCall = valUseFlag.IsVSlotDirectCall + + let isConstrainedCall = valUseFlag.IsPossibleConstrainedCall + + let takesInstanceArg = ilMethRef.CallingConv.IsInstance + let boxity = if isStruct then AsValue else AsObject + + if + isCtor + || isBaseCall + || isConstrainedCall + || not (receiverShapeOk takesInstanceArg) + || (takesInstanceArg && boxity = AsValue) + || receiverNotBindable () + then + None + else + let ilEnclArgTys = GenTypeArgs cenv m eenvouter.tyenv enclTypeInst + let ilMethArgTys = GenTypeArgs cenv m eenvouter.tyenv methInst + let targetMspec = mkILMethSpec (ilMethRef, boxity, ilEnclArgTys, ilMethArgTys) + + // Unlike the F# case we cannot compare parameter/return IL types here: the target's + // types come from imported metadata, whose assembly scope refs differ from the + // compiler-generated delegee types (e.g. `System.Int32, System.Runtime` vs the bare + // primary-assembly form), so structural equality reports false negatives for the very + // primitives that always match. The forwarding match already pins the arity, and the + // type checker has verified the call is well-typed, so element compatibility holds by + // construction; an arity check is the sound guard (matching the generic case). + if targetMspec.FormalArgTypes.Length = ilDelegeeParams.Length then + Some(targetMspec, receiverInfo isVirtual) + else + None + | _ -> None - if useStaticClosure then - GenUnit cenv eenvouter m cgbuf - else - let ilxCloSpec = - IlxClosureSpec.Create(IlxClosureRef(ilDelegeeTypeRef, ilCloLambdas, ilCloAllFreeVars), ctxtGenericArgsForDelegee, false) + match directDelegateTarget with + | Some(targetMspec, receiverInfo) -> + match receiverInfo with + | None -> + // Static target: the delegate carries a null receiver. + GenUnit cenv eenvouter m cgbuf + CG.EmitInstr cgbuf (pop 0) (Push [ g.ilg.typ_IntPtr ]) (I_ldftn targetMspec) + | Some(receiverExpr, isVirtual) -> + // Instance target: evaluate the receiver as the delegate's target object. + GenExpr cenv cgbuf eenvouter receiverExpr Continue + + if isVirtual then + // dup the receiver and bind the function pointer to its runtime type's override. + CG.EmitInstr cgbuf (pop 0) (Push [ targetMspec.DeclaringType ]) AI_dup + CG.EmitInstr cgbuf (pop 1) (Push [ g.ilg.typ_IntPtr ]) (I_ldvirtftn targetMspec) + else + CG.EmitInstr cgbuf (pop 0) (Push [ g.ilg.typ_IntPtr ]) (I_ldftn targetMspec) - GenWitnessArgsFromWitnessInfos cenv cgbuf eenvouter m cloWitnessInfos + // newobj Delegate::.ctor(object, native int) + let ilDelegeeCtorMethOuter = + mkCtorMethSpecForDelegate g.ilg (ilCtxtDelTy, useUIntPtrForDelegateCtor) - for fv in cloFreeVars do - GenGetFreeVarForClosure cenv cgbuf eenvouter m fv + CG.EmitInstr cgbuf (pop 2) (Push [ ilCtxtDelTy ]) (I_newobj(ilDelegeeCtorMethOuter, None)) + GenSequel cenv eenvouter.cloc cgbuf sequel - CG.EmitInstr - cgbuf - (pop ilCloAllFreeVars.Length) - (Push [ EraseClosures.mkTyOfLambdas cenv.ilxPubCloEnv ilCloLambdas ]) - (I_newobj(ilxCloSpec.Constructor, None)) + | None -> + let envForDelegeeMeth = + AddStorageForLocalVals g (List.mapi (fun i v -> (v, Arg(i + numthis))) tmvs) envForDelegeeUnderTypars - // Push the function pointer to the Invoke method of the delegee - let ilDelegeeTyOuter = mkILBoxedTy ilDelegeeTypeRef ctxtGenericArgsForDelegee + let ilMethodBody = + CodeGenMethodForExpr + cenv + cgbuf.mgbuf + ([], + delegeeMethName, + envForDelegeeMeth, + 1, + None, + body, + (if slotSigHasVoidReturnTy slotsig then + discardAndReturnVoid + else + Return)) + + let delegeeInvokeMeth = + (if useStaticClosure then + mkILNonGenericStaticMethod + else + mkILNonGenericInstanceMethod) ( + delegeeMethName, + ILMemberAccess.Assembly, + ilDelegeeParams, + ilDelegeeRet, + MethodBody.IL(InterruptibleLazy.FromValue ilMethodBody) + ) - let ilDelegeeInvokeMethOuter = - (if useStaticClosure then - mkILNonGenericStaticMethSpecInTy - else - mkILNonGenericInstanceMethSpecInTy) ( - ilDelegeeTyOuter, - "Invoke", - typesOfILParams ilDelegeeParams, - ilDelegeeRet.Type - ) + let delegeeCtorMeth = + mkILSimpleStorageCtor ( + Some g.ilg.typ_Object.TypeSpec, + ilDelegeeTyInner, + [], + [], + ILMemberAccess.Assembly, + None, + eenvouter.imports + ) - CG.EmitInstr cgbuf (pop 0) (Push [ g.ilg.typ_IntPtr ]) (I_ldftn ilDelegeeInvokeMethOuter) + let ilCtorBody = delegeeCtorMeth.MethodBody - // Instantiate the delegate - let ilDelegeeCtorMethOuter = - mkCtorMethSpecForDelegate g.ilg (ilCtxtDelTy, useUIntPtrForDelegateCtor) + let ilCloLambdas = Lambdas_return ilCtxtDelTy - CG.EmitInstr cgbuf (pop 2) (Push [ ilCtxtDelTy ]) (I_newobj(ilDelegeeCtorMethOuter, None)) - GenSequel cenv eenvouter.cloc cgbuf sequel + let cloTypeDefs = + (if useStaticClosure then + GenStaticDelegateClosureTypeDefs + else + GenClosureTypeDefs) + cenv + (ilDelegeeTypeRef, + ilDelegeeGenericParams, + [], + ilCloAllFreeVars, + ilCloLambdas, + ilCtorBody, + [ delegeeInvokeMeth ], + [], + g.ilg.typ_Object, + [], + None) + + for cloTypeDef in cloTypeDefs do + cgbuf.mgbuf.AddTypeDef(ilDelegeeTypeRef, cloTypeDef, false, false, None) + + CountClosure() + + // Push the constructor for the delegee + let ctxtGenericArgsForDelegee = GenGenericArgs m eenvouter.tyenv cloFreeTyvars + + if useStaticClosure then + GenUnit cenv eenvouter m cgbuf + else + let ilxCloSpec = + IlxClosureSpec.Create(IlxClosureRef(ilDelegeeTypeRef, ilCloLambdas, ilCloAllFreeVars), ctxtGenericArgsForDelegee, false) + + GenWitnessArgsFromWitnessInfos cenv cgbuf eenvouter m cloWitnessInfos + + for fv in cloFreeVars do + GenGetFreeVarForClosure cenv cgbuf eenvouter m fv + + CG.EmitInstr + cgbuf + (pop ilCloAllFreeVars.Length) + (Push [ EraseClosures.mkTyOfLambdas cenv.ilxPubCloEnv ilCloLambdas ]) + (I_newobj(ilxCloSpec.Constructor, None)) + + // Push the function pointer to the Invoke method of the delegee + let ilDelegeeTyOuter = mkILBoxedTy ilDelegeeTypeRef ctxtGenericArgsForDelegee + + let ilDelegeeInvokeMethOuter = + (if useStaticClosure then + mkILNonGenericStaticMethSpecInTy + else + mkILNonGenericInstanceMethSpecInTy) ( + ilDelegeeTyOuter, + "Invoke", + typesOfILParams ilDelegeeParams, + ilDelegeeRet.Type + ) + + CG.EmitInstr cgbuf (pop 0) (Push [ g.ilg.typ_IntPtr ]) (I_ldftn ilDelegeeInvokeMethOuter) + + // Instantiate the delegate + let ilDelegeeCtorMethOuter = + mkCtorMethSpecForDelegate g.ilg (ilCtxtDelTy, useUIntPtrForDelegateCtor) + + CG.EmitInstr cgbuf (pop 2) (Push [ ilCtxtDelTy ]) (I_newobj(ilDelegeeCtorMethOuter, None)) + GenSequel cenv eenvouter.cloc cgbuf sequel /// Used to search FSharp.Core implementations of "^T : ^T" and decide whether the conditional activates and ExprIsTraitCall expr = diff --git a/src/Compiler/TypedTree/TypedTreeOps.ExprOps.fs b/src/Compiler/TypedTree/TypedTreeOps.ExprOps.fs index bdebaf40ff5..54c28c13c18 100644 --- a/src/Compiler/TypedTree/TypedTreeOps.ExprOps.fs +++ b/src/Compiler/TypedTree/TypedTreeOps.ExprOps.fs @@ -33,6 +33,24 @@ open FSharp.Compiler.TypedTreeBasics open FSharp.Compiler.TypeProviders #endif +/// The target of a direct-delegate forwarding call recognized by (|DirectDelegateForwardingCall|_|). +[] +type internal DirectDelegateForwardingTarget = + /// A known F# value: a module-level function or a member. Carries the value reference, its use flags + /// and the call's type arguments; the consumer resolves storage to a method spec. + | FSharpVal of vref: ValRef * valUseFlags: ValUseFlag * tyargs: TypeInst + /// A direct IL method call (e.g. a BCL method), compiled as TOp.ILCall. Carries everything needed to + /// build the method spec directly: virtual/struct/ctor flags, use flags, the IL method reference and + /// the enclosing-type and method type instantiations. + | ILMethod of + isVirtual: bool * + isStruct: bool * + isCtor: bool * + valUseFlags: ValUseFlag * + ilMethRef: ILMethodRef * + enclTypeInst: TypeInst * + methInst: TypeInst + [] module internal AddressOps = @@ -1815,6 +1833,53 @@ module internal ExprTransforms = ) | _ -> ValueNone + /// Recognizes the body of a delegate's Invoke method when it is a saturated, transparent forwarding + /// call `target leading... p0 p1 ...` to a known method, whose trailing arguments are exactly the + /// delegate's Invoke parameters in order. This is the shape that lets a delegate point directly at + /// `target` instead of an intermediate closure. Any leading arguments (e.g. an instance method's + /// receiver) are returned to the consumer, which decides whether a direct delegate can actually be + /// emitted (matching IL signature, receiver shape, no witnesses, etc.). + [] + let (|DirectDelegateForwardingCall|_|) g (invokeParams: Val list) expr = + // The trailing arguments of the call must be exactly the delegate's Invoke parameters, forwarded + // verbatim and in order. The remaining leading arguments (e.g. an instance receiver) are returned + // for the consumer to handle. + let matchForwarding (args: Expr list) = + let numLeading = args.Length - invokeParams.Length + + if numLeading >= 0 then + let leadingArgs, forwardedArgs = List.splitAt numLeading args + + if + List.forall2 + (fun (a: Expr) (tv: Val) -> + match stripDebugPoints a with + | Expr.Val(avref, _, _) -> valRefEq g avref (mkLocalValRef tv) + | _ -> false) + forwardedArgs + invokeParams + then + ValueSome leadingArgs + else + ValueNone + else + ValueNone + + match stripDebugPoints expr with + | Expr.App(Expr.Val(vref, valUseFlags, _), _, tyargs, args, _) -> + match matchForwarding args with + | ValueSome leadingArgs -> ValueSome(DirectDelegateForwardingTarget.FSharpVal(vref, valUseFlags, tyargs), leadingArgs) + | ValueNone -> ValueNone + | Expr.Op(TOp.ILCall(isVirtual, _, isStruct, isCtor, valUseFlag, _, _, ilMethRef, enclTypeInst, methInst, _), _, args, _) -> + match matchForwarding args with + | ValueSome leadingArgs -> + ValueSome( + DirectDelegateForwardingTarget.ILMethod(isVirtual, isStruct, isCtor, valUseFlag, ilMethRef, enclTypeInst, methInst), + leadingArgs + ) + | ValueNone -> ValueNone + | _ -> ValueNone + [] let (|DelegateInvokeExpr|_|) g expr = match expr with diff --git a/src/Compiler/TypedTree/TypedTreeOps.ExprOps.fsi b/src/Compiler/TypedTree/TypedTreeOps.ExprOps.fsi index ad90c5c818c..afb4874f70d 100644 --- a/src/Compiler/TypedTree/TypedTreeOps.ExprOps.fsi +++ b/src/Compiler/TypedTree/TypedTreeOps.ExprOps.fsi @@ -12,6 +12,24 @@ open FSharp.Compiler.TypedTree open FSharp.Compiler.TypedTreeBasics open FSharp.Compiler.Syntax +/// The target of a direct-delegate forwarding call recognized by (|DirectDelegateForwardingCall|_|). +[] +type internal DirectDelegateForwardingTarget = + /// A known F# value: a module-level function or a member. Carries the value reference, its use flags + /// and the call's type arguments; the consumer resolves storage to a method spec. + | FSharpVal of vref: ValRef * valUseFlags: ValUseFlag * tyargs: TypeInst + /// A direct IL method call (e.g. a BCL method), compiled as TOp.ILCall. Carries everything needed to + /// build the method spec directly: virtual/struct/ctor flags, use flags, the IL method reference and + /// the enclosing-type and method type instantiations. + | ILMethod of + isVirtual: bool * + isStruct: bool * + isCtor: bool * + valUseFlags: ValUseFlag * + ilMethRef: ILMethodRef * + enclTypeInst: TypeInst * + methInst: TypeInst + [] module internal AddressOps = @@ -544,6 +562,14 @@ module internal ExprTransforms = [] val (|NewDelegateExpr|_|): TcGlobals -> Expr -> (Unique * Val list * Expr * range * (Expr -> Expr)) voption + /// Recognizes the body of a delegate's Invoke method when it is a saturated, transparent forwarding + /// call to a known method (an F# value or a direct IL call) whose trailing arguments are exactly the + /// delegate's Invoke parameters in order. Returns the resolved target and any leading (non-forwarded) + /// argument expressions, e.g. an instance method's receiver. + [] + val (|DirectDelegateForwardingCall|_|): + TcGlobals -> Val list -> Expr -> (DirectDelegateForwardingTarget * Expr list) voption + [] val (|DelegateInvokeExpr|_|): TcGlobals -> Expr -> (Expr * TType * TypeInst * Expr * Expr * range) voption diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs new file mode 100644 index 00000000000..7eba16766c9 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs @@ -0,0 +1,18 @@ +module DelegateExtensionMethod + +open System +open System.Runtime.CompilerServices + +type Holder() = + class + end + +[] +type HolderExtensions = + [] + static member Combine (h: Holder, x: int, y: int) : int = x + y + +// An extension member compiles to a static method whose first parameter is the receiver, so using it as a +// delegate target binds that receiver as a leading argument - a partial application, which has no closed +// direct-delegate form. A closure must remain regardless of langversion. +let extensionEta (h: Holder) = Func(fun a b -> h.Combine(a, b)) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl new file mode 100644 index 00000000000..0b7acdc3542 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl @@ -0,0 +1,139 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public Holder + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public specialname rtspecialname instance void .ctor() cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ret + } + + } + + .class auto ansi serializable nested public HolderExtensions + extends [runtime]System.Object + { + .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public static int32 Combine(class assembly/Holder h, + int32 x, + int32 y) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: add + IL_0003: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname extensionEta@18 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/Holder h + .method public specialname rtspecialname instance void .ctor(class assembly/Holder h) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/Holder assembly/extensionEta@18::h + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/Holder assembly/extensionEta@18::h + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: call int32 assembly/HolderExtensions::Combine(class assembly/Holder, + int32, + int32) + IL_000d: ret + } + + } + + .method public static class [runtime]System.Func`3 extensionEta(class assembly/Holder h) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/extensionEta@18::.ctor(class assembly/Holder) + IL_0006: ldftn instance int32 assembly/extensionEta@18::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl new file mode 100644 index 00000000000..7347dab3c0d --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl @@ -0,0 +1,139 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public Holder + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public specialname rtspecialname instance void .ctor() cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ret + } + + } + + .class auto ansi serializable nested public HolderExtensions + extends [runtime]System.Object + { + .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public static int32 Combine(class assembly/Holder h, + int32 x, + int32 y) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: add + IL_0003: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname extensionEta@18 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/Holder h + .method public specialname rtspecialname instance void .ctor(class assembly/Holder h) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/Holder assembly/extensionEta@18::h + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/Holder assembly/extensionEta@18::h + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: call int32 assembly/HolderExtensions::Combine(class assembly/Holder, + int32, + int32) + IL_000d: ret + } + + } + + .method public static class [runtime]System.Func`3 extensionEta(class assembly/Holder h) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/extensionEta@18::.ctor(class assembly/Holder) + IL_0006: ldftn instance int32 assembly/extensionEta@18::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl new file mode 100644 index 00000000000..0b7acdc3542 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl @@ -0,0 +1,139 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public Holder + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public specialname rtspecialname instance void .ctor() cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ret + } + + } + + .class auto ansi serializable nested public HolderExtensions + extends [runtime]System.Object + { + .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public static int32 Combine(class assembly/Holder h, + int32 x, + int32 y) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: add + IL_0003: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname extensionEta@18 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/Holder h + .method public specialname rtspecialname instance void .ctor(class assembly/Holder h) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/Holder assembly/extensionEta@18::h + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/Holder assembly/extensionEta@18::h + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: call int32 assembly/HolderExtensions::Combine(class assembly/Holder, + int32, + int32) + IL_000d: ret + } + + } + + .method public static class [runtime]System.Func`3 extensionEta(class assembly/Holder h) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/extensionEta@18::.ctor(class assembly/Holder) + IL_0006: ldftn instance int32 assembly/extensionEta@18::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl new file mode 100644 index 00000000000..7347dab3c0d --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -0,0 +1,139 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public Holder + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public specialname rtspecialname instance void .ctor() cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ret + } + + } + + .class auto ansi serializable nested public HolderExtensions + extends [runtime]System.Object + { + .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public static int32 Combine(class assembly/Holder h, + int32 x, + int32 y) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: add + IL_0003: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname extensionEta@18 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/Holder h + .method public specialname rtspecialname instance void .ctor(class assembly/Holder h) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/Holder assembly/extensionEta@18::h + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/Holder assembly/extensionEta@18::h + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: call int32 assembly/HolderExtensions::Combine(class assembly/Holder, + int32, + int32) + IL_000d: ret + } + + } + + .method public static class [runtime]System.Func`3 extensionEta(class assembly/Holder h) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/extensionEta@18::.ctor(class assembly/Holder) + IL_0006: ldftn instance int32 assembly/extensionEta@18::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl index 23269e8fd6b..bc63a786879 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl @@ -56,25 +56,6 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case7_nonEta@10 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static void Invoke(int32 x, - int32 y) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call void class assembly/G`1::SMc(!!0, - !!0) - IL_0007: nop - IL_0008: ret - } - - } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case8_etaCurried@13 extends [runtime]System.Object { @@ -118,8 +99,8 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case7_nonEta@10::Invoke(int32, - int32) + IL_0001: ldftn void class assembly/G`1::SMc(!!0, + !!0) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs new file mode 100644 index 00000000000..db933f2f73e --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs @@ -0,0 +1,16 @@ +module DelegateILMethod + +open System +open System.Text + +// IL (BCL) method targets are compiled as TOp.ILCall rather than an F# value application. They are made +// direct only when the eta-expanded forwarding call survives to codegen, i.e. in optimized builds; in +// unoptimized builds the eta form keeps a closure (matching the F# eta policy). See DelegateNonInlinable +// for the F#-value equivalent. + +// Static IL method (System.Math.Max), eta-expanded. +let ilStaticEta () = Func(fun a b -> Math.Max(a, b)) + +// Instance IL method (StringBuilder.Append(string)) on a reference type, eta-expanded. The receiver is a +// parameter, evaluated at the construction site and carried as the delegate's Target. +let ilInstanceEta (sb: StringBuilder) = Func(fun s -> sb.Append(s)) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl new file mode 100644 index 00000000000..718255efb91 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl @@ -0,0 +1,127 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname ilStaticEta@12 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 [runtime]System.Math::Max(int32, + int32) + IL_0007: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname ilInstanceEta@16 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class [runtime]System.Text.StringBuilder sb + .method public specialname rtspecialname instance void .ctor(class [runtime]System.Text.StringBuilder sb) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class [runtime]System.Text.StringBuilder assembly/ilInstanceEta@16::sb + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance class [runtime]System.Text.StringBuilder Invoke(string s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class [runtime]System.Text.StringBuilder assembly/ilInstanceEta@16::sb + IL_0006: ldarg.1 + IL_0007: callvirt instance class [runtime]System.Text.StringBuilder [runtime]System.Text.StringBuilder::Append(string) + IL_000c: ret + } + + } + + .method public static class [runtime]System.Func`3 ilStaticEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/ilStaticEta@12::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`2 ilInstanceEta(class [runtime]System.Text.StringBuilder sb) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/ilInstanceEta@16::.ctor(class [runtime]System.Text.StringBuilder) + IL_0006: ldftn instance class [runtime]System.Text.StringBuilder assembly/ilInstanceEta@16::Invoke(string) + IL_000c: newobj instance void class [runtime]System.Func`2::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl new file mode 100644 index 00000000000..718255efb91 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl @@ -0,0 +1,127 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname ilStaticEta@12 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 [runtime]System.Math::Max(int32, + int32) + IL_0007: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname ilInstanceEta@16 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class [runtime]System.Text.StringBuilder sb + .method public specialname rtspecialname instance void .ctor(class [runtime]System.Text.StringBuilder sb) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class [runtime]System.Text.StringBuilder assembly/ilInstanceEta@16::sb + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance class [runtime]System.Text.StringBuilder Invoke(string s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class [runtime]System.Text.StringBuilder assembly/ilInstanceEta@16::sb + IL_0006: ldarg.1 + IL_0007: callvirt instance class [runtime]System.Text.StringBuilder [runtime]System.Text.StringBuilder::Append(string) + IL_000c: ret + } + + } + + .method public static class [runtime]System.Func`3 ilStaticEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/ilStaticEta@12::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`2 ilInstanceEta(class [runtime]System.Text.StringBuilder sb) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/ilInstanceEta@16::.ctor(class [runtime]System.Text.StringBuilder) + IL_0006: ldftn instance class [runtime]System.Text.StringBuilder assembly/ilInstanceEta@16::Invoke(string) + IL_000c: newobj instance void class [runtime]System.Func`2::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl new file mode 100644 index 00000000000..ef4e95130a2 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl @@ -0,0 +1,78 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .method public static class [runtime]System.Func`3 ilStaticEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 [runtime]System.Math::Max(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`2 ilInstanceEta(class [runtime]System.Text.StringBuilder sb) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldftn instance class [runtime]System.Text.StringBuilder [runtime]System.Text.StringBuilder::Append(string) + IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl new file mode 100644 index 00000000000..718255efb91 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -0,0 +1,127 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname ilStaticEta@12 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 [runtime]System.Math::Max(int32, + int32) + IL_0007: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname ilInstanceEta@16 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class [runtime]System.Text.StringBuilder sb + .method public specialname rtspecialname instance void .ctor(class [runtime]System.Text.StringBuilder sb) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class [runtime]System.Text.StringBuilder assembly/ilInstanceEta@16::sb + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance class [runtime]System.Text.StringBuilder Invoke(string s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class [runtime]System.Text.StringBuilder assembly/ilInstanceEta@16::sb + IL_0006: ldarg.1 + IL_0007: callvirt instance class [runtime]System.Text.StringBuilder [runtime]System.Text.StringBuilder::Append(string) + IL_000c: ret + } + + } + + .method public static class [runtime]System.Func`3 ilStaticEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/ilStaticEta@12::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`2 ilInstanceEta(class [runtime]System.Text.StringBuilder sb) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/ilInstanceEta@16::.ctor(class [runtime]System.Text.StringBuilder) + IL_0006: ldftn instance class [runtime]System.Text.StringBuilder assembly/ilInstanceEta@16::Invoke(string) + IL_000c: newobj instance void class [runtime]System.Func`2::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl index b908fa4c200..4e57d30669e 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl @@ -89,39 +89,6 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname case10_nonEta@12 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .field public class assembly/C o - .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/case10_nonEta@12::o - IL_0007: ldarg.0 - IL_0008: call instance void [runtime]System.Object::.ctor() - IL_000d: ret - } - - .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/case10_nonEta@12::o - IL_0006: ldarg.1 - IL_0007: ldarg.2 - IL_0008: callvirt instance void assembly/C::AddC(int32, - int32) - IL_000d: nop - IL_000e: ret - } - - } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname case11_etaCurried@15 extends [runtime]System.Object { @@ -188,50 +155,16 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname caseVirtual@21 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .field public class assembly/C o - .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/caseVirtual@21::o - IL_0007: ldarg.0 - IL_0008: call instance void [runtime]System.Object::.ctor() - IL_000d: ret - } - - .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/caseVirtual@21::o - IL_0006: ldarg.1 - IL_0007: ldarg.2 - IL_0008: tail. - IL_000a: callvirt instance void assembly/C::V(int32, - int32) - IL_000f: ret - } - - } - .method public static class [runtime]System.Action`2 case10_nonEta(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/case10_nonEta@12::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/case10_nonEta@12::Invoke(int32, - int32) - IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + IL_0001: ldftn instance void assembly/C::AddC(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) - IL_0011: ret + IL_000c: ret } .method public static class [runtime]System.Action`2 case11_etaCurried(class assembly/C o) cil managed @@ -265,12 +198,12 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/caseVirtual@21::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/caseVirtual@21::Invoke(int32, - int32) - IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + IL_0001: dup + IL_0002: ldvirtftn instance void assembly/C::V(int32, + int32) + IL_0008: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) - IL_0011: ret + IL_000d: ret } } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl index 44b0b4cbbd5..0297f76438f 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl @@ -119,39 +119,6 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname caseVirtual@21 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .field public class assembly/C o - .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/caseVirtual@21::o - IL_0007: ldarg.0 - IL_0008: call instance void [runtime]System.Object::.ctor() - IL_000d: ret - } - - .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/caseVirtual@21::o - IL_0006: ldarg.1 - IL_0007: ldarg.2 - IL_0008: tail. - IL_000a: callvirt instance void assembly/C::V(int32, - int32) - IL_000f: ret - } - - } - .method public static class [runtime]System.Action`2 case10_nonEta(class assembly/C o) cil managed { @@ -193,12 +160,12 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/caseVirtual@21::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/caseVirtual@21::Invoke(int32, - int32) - IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, + IL_0001: dup + IL_0002: ldvirtftn instance void assembly/C::V(int32, + int32) + IL_0008: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) - IL_0011: ret + IL_000d: ret } } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl index 9c87cb38678..977948fe928 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl @@ -33,25 +33,6 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case1_nonEta@11 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static void Invoke(int32 x, - int32 y) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call void assembly::handlerCurried(int32, - int32) - IL_0007: nop - IL_0008: ret - } - - } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case2_etaCurried@14 extends [runtime]System.Object { @@ -144,8 +125,8 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case1_nonEta@11::Invoke(int32, - int32) + IL_0001: ldftn void assembly::handlerCurried(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs index fb8979eee4f..1cf2e00e70f 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs @@ -39,12 +39,21 @@ type C(k: int) = [] member _.AccC (x: int) (y: int) : int = x + y + k + [] + member _.GPick<'T> (x: 'T) (y: 'T) : 'T = x + // non-inlinable instance target, non-eta-expanded let niInstanceNonEta (o: C) = Func(o.AccC) // non-inlinable instance target, eta-expanded let niInstanceEta (o: C) = Func(fun a b -> o.AccC a b) +// non-inlinable generic instance target, non-eta-expanded +let niGenericInstanceNonEta (o: C) = Func(o.GPick) + +// non-inlinable generic instance target, eta-expanded +let niGenericInstanceEta (o: C) = Func(fun a b -> o.GPick a b) + // Section D, bullet 1 (the contrast case): a trivial, inlinable target kept on purpose to document and // guard the inline-vs-direct interaction. In release the optimizer may inline the body before the // recognizer runs; the recognizer must therefore act in the optimizer (before the head call is inlined) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl index 3d35edadfa8..b31ec227850 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl @@ -86,22 +86,14 @@ IL_000a: ret } - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niNonEta@20 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 x, - int32 y) cil managed + .method public hidebysig instance !!T GPick(!!T x, !!T y) cil managed { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call int32 assembly::accCurried(int32, - int32) - IL_0007: ret + IL_0000: ldarg.1 + IL_0001: ret } } @@ -142,24 +134,6 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticNonEta@33 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 x, - int32 y) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call int32 assembly/S::AccS(int32, - int32) - IL_0007: ret - } - - } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticEta@36 extends [runtime]System.Object { @@ -178,7 +152,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceNonEta@43 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceEta@49 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -189,28 +163,29 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niInstanceNonEta@43::o + IL_0002: stfld class assembly/C assembly/niInstanceEta@49::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret } - .method assembly hidebysig instance int32 Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niInstanceNonEta@43::o + IL_0001: ldfld class assembly/C assembly/niInstanceEta@49::o IL_0006: ldarg.1 IL_0007: ldarg.2 - IL_0008: callvirt instance int32 assembly/C::AccC(int32, + IL_0008: tail. + IL_000a: callvirt instance int32 assembly/C::AccC(int32, int32) - IL_000d: ret + IL_000f: ret } } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceEta@46 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niGenericInstanceEta@55 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -221,7 +196,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niInstanceEta@46::o + IL_0002: stfld class assembly/C assembly/niGenericInstanceEta@55::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -232,35 +207,17 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niInstanceEta@46::o + IL_0001: ldfld class assembly/C assembly/niGenericInstanceEta@55::o IL_0006: ldarg.1 IL_0007: ldarg.2 - IL_0008: callvirt instance int32 assembly/C::AccC(int32, - int32) + IL_0008: callvirt instance !!0 assembly/C::GPick(!!0, + !!0) IL_000d: ret } } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@54 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 x, - int32 y) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call int32 assembly::trivial(int32, - int32) - IL_0007: ret - } - - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@56 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@65 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -308,10 +265,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niNonEta@20::Invoke(int32, - int32) + IL_0001: ldftn int32 assembly::accCurried(int32, + int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -323,7 +280,7 @@ IL_0001: ldftn int32 assembly/niEtaCurried@23::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -335,7 +292,7 @@ IL_0001: ldftn int32 assembly/niEtaTupled@26::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -344,10 +301,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niStaticNonEta@33::Invoke(int32, - int32) + IL_0001: ldftn int32 assembly/S::AccS(int32, + int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -359,7 +316,7 @@ IL_0001: ldftn int32 assembly/niStaticEta@36::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -368,12 +325,11 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niInstanceNonEta@43::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niInstanceNonEta@43::Invoke(int32, - int32) - IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_0011: ret + IL_0001: ldftn instance int32 assembly/C::AccC(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret } .method public static class [runtime]System.Func`3 niInstanceEta(class assembly/C o) cil managed @@ -381,11 +337,36 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niInstanceEta@46::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niInstanceEta@46::Invoke(int32, + IL_0001: newobj instance void assembly/niInstanceEta@49::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niInstanceEta@49::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Func`3 niGenericInstanceNonEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldftn instance !!0 assembly/C::GPick(!!0, + !!0) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niGenericInstanceEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/niGenericInstanceEta@55::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niGenericInstanceEta@55::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) IL_0011: ret } @@ -406,10 +387,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialNonEta@54::Invoke(int32, - int32) + IL_0001: ldftn int32 assembly::trivial(int32, + int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -418,10 +399,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialEta@56::Invoke(int32, + IL_0001: ldftn int32 assembly/niTrivialEta@65::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.il.bsl index 78ddf50dac2..075811968d9 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.il.bsl @@ -86,6 +86,16 @@ IL_000a: ret } + .method public hidebysig instance !!T GPick(!!T x, !!T y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ret + } + } .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niNonEta@20 @@ -178,7 +188,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceNonEta@43 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceNonEta@46 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -189,7 +199,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niInstanceNonEta@43::o + IL_0002: stfld class assembly/C assembly/niInstanceNonEta@46::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -200,17 +210,18 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niInstanceNonEta@43::o + IL_0001: ldfld class assembly/C assembly/niInstanceNonEta@46::o IL_0006: ldarg.1 IL_0007: ldarg.2 - IL_0008: callvirt instance int32 assembly/C::AccC(int32, + IL_0008: tail. + IL_000a: callvirt instance int32 assembly/C::AccC(int32, int32) - IL_000d: ret + IL_000f: ret } } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceEta@46 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceEta@49 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -221,7 +232,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niInstanceEta@46::o + IL_0002: stfld class assembly/C assembly/niInstanceEta@49::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -232,17 +243,82 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niInstanceEta@46::o + IL_0001: ldfld class assembly/C assembly/niInstanceEta@49::o IL_0006: ldarg.1 IL_0007: ldarg.2 - IL_0008: callvirt instance int32 assembly/C::AccC(int32, + IL_0008: tail. + IL_000a: callvirt instance int32 assembly/C::AccC(int32, int32) + IL_000f: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niGenericInstanceNonEta@52 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/niGenericInstanceNonEta@52::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/niGenericInstanceNonEta@52::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance !!0 assembly/C::GPick(!!0, + !!0) + IL_000d: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niGenericInstanceEta@55 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/niGenericInstanceEta@55::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/niGenericInstanceEta@55::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance !!0 assembly/C::GPick(!!0, + !!0) IL_000d: ret } } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@54 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@63 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -260,7 +336,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@56 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@65 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -368,8 +444,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niInstanceNonEta@43::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niInstanceNonEta@43::Invoke(int32, + IL_0001: newobj instance void assembly/niInstanceNonEta@46::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niInstanceNonEta@46::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) @@ -381,14 +457,40 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niInstanceEta@46::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niInstanceEta@46::Invoke(int32, + IL_0001: newobj instance void assembly/niInstanceEta@49::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niInstanceEta@49::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) IL_0011: ret } + .method public static class [runtime]System.Func`3 niGenericInstanceNonEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/niGenericInstanceNonEta@52::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niGenericInstanceNonEta@52::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Func`3 niGenericInstanceEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/niGenericInstanceEta@55::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niGenericInstanceEta@55::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + .method public static int32 trivial(int32 x, int32 y) cil managed { @@ -406,7 +508,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialNonEta@54::Invoke(int32, + IL_0001: ldftn int32 assembly/niTrivialNonEta@63::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) @@ -418,7 +520,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialEta@56::Invoke(int32, + IL_0001: ldftn int32 assembly/niTrivialEta@65::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl index dd5dc76e043..769f5764703 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl @@ -86,40 +86,14 @@ IL_000a: ret } - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niNonEta@20 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 x, - int32 y) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call int32 assembly::accCurried(int32, - int32) - IL_0007: ret - } - - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaCurried@23 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 a, - int32 b) cil managed + .method public hidebysig instance !!T GPick(!!T x, !!T y) cil managed { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call int32 assembly::accCurried(int32, - int32) - IL_0007: ret + IL_0000: ldarg.1 + IL_0001: ret } } @@ -142,107 +116,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticNonEta@33 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 x, - int32 y) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call int32 assembly/S::AccS(int32, - int32) - IL_0007: ret - } - - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticEta@36 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 a, - int32 b) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call int32 assembly/S::AccS(int32, - int32) - IL_0007: ret - } - - } - - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceNonEta@43 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .field public class assembly/C o - .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niInstanceNonEta@43::o - IL_0007: ldarg.0 - IL_0008: call instance void [runtime]System.Object::.ctor() - IL_000d: ret - } - - .method assembly hidebysig instance int32 Invoke(int32 delegateArg0, int32 delegateArg1) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niInstanceNonEta@43::o - IL_0006: ldarg.1 - IL_0007: ldarg.2 - IL_0008: callvirt instance int32 assembly/C::AccC(int32, - int32) - IL_000d: ret - } - - } - - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceEta@46 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .field public class assembly/C o - .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niInstanceEta@46::o - IL_0007: ldarg.0 - IL_0008: call instance void [runtime]System.Object::.ctor() - IL_000d: ret - } - - .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niInstanceEta@46::o - IL_0006: ldarg.1 - IL_0007: ldarg.2 - IL_0008: callvirt instance int32 assembly/C::AccC(int32, - int32) - IL_000d: ret - } - - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@54 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@63 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -259,7 +133,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@56 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@65 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -306,8 +180,8 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niNonEta@20::Invoke(int32, - int32) + IL_0001: ldftn int32 assembly::accCurried(int32, + int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) IL_000c: ret @@ -318,8 +192,8 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niEtaCurried@23::Invoke(int32, - int32) + IL_0001: ldftn int32 assembly::accCurried(int32, + int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) IL_000c: ret @@ -342,8 +216,8 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niStaticNonEta@33::Invoke(int32, - int32) + IL_0001: ldftn int32 assembly/S::AccS(int32, + int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) IL_000c: ret @@ -354,8 +228,8 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niStaticEta@36::Invoke(int32, - int32) + IL_0001: ldftn int32 assembly/S::AccS(int32, + int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) IL_000c: ret @@ -366,12 +240,11 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niInstanceNonEta@43::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niInstanceNonEta@43::Invoke(int32, - int32) - IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + IL_0001: ldftn instance int32 assembly/C::AccC(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) - IL_0011: ret + IL_000c: ret } .method public static class [runtime]System.Func`3 niInstanceEta(class assembly/C o) cil managed @@ -379,12 +252,35 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niInstanceEta@46::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niInstanceEta@46::Invoke(int32, - int32) - IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + IL_0001: ldftn instance int32 assembly/C::AccC(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) - IL_0011: ret + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niGenericInstanceNonEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldftn instance !!0 assembly/C::GPick(!!0, + !!0) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`3 niGenericInstanceEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldftn instance !!0 assembly/C::GPick(!!0, + !!0) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret } .method public static int32 trivial(int32 x, @@ -404,7 +300,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialNonEta@54::Invoke(int32, + IL_0001: ldftn int32 assembly/niTrivialNonEta@63::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) @@ -416,7 +312,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialEta@56::Invoke(int32, + IL_0001: ldftn int32 assembly/niTrivialEta@65::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.il.bsl index 7fa0f5a0c7d..a10586e3a2e 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -86,6 +86,16 @@ IL_000a: ret } + .method public hidebysig instance !!T GPick(!!T x, !!T y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ret + } + } .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niNonEta@20 @@ -178,7 +188,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceNonEta@43 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceNonEta@46 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -189,7 +199,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niInstanceNonEta@43::o + IL_0002: stfld class assembly/C assembly/niInstanceNonEta@46::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -200,7 +210,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niInstanceNonEta@43::o + IL_0001: ldfld class assembly/C assembly/niInstanceNonEta@46::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance int32 assembly/C::AccC(int32, @@ -210,7 +220,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceEta@46 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceEta@49 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -221,7 +231,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niInstanceEta@46::o + IL_0002: stfld class assembly/C assembly/niInstanceEta@49::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -232,7 +242,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niInstanceEta@46::o + IL_0001: ldfld class assembly/C assembly/niInstanceEta@49::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance int32 assembly/C::AccC(int32, @@ -242,7 +252,71 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@54 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niGenericInstanceNonEta@52 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/niGenericInstanceNonEta@52::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/niGenericInstanceNonEta@52::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance !!0 assembly/C::GPick(!!0, + !!0) + IL_000d: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niGenericInstanceEta@55 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C o + .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/niGenericInstanceEta@55::o + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/niGenericInstanceEta@55::o + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance !!0 assembly/C::GPick(!!0, + !!0) + IL_000d: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@63 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -259,7 +333,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@56 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@65 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -366,8 +440,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niInstanceNonEta@43::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niInstanceNonEta@43::Invoke(int32, + IL_0001: newobj instance void assembly/niInstanceNonEta@46::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niInstanceNonEta@46::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) @@ -379,14 +453,40 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niInstanceEta@46::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niInstanceEta@46::Invoke(int32, + IL_0001: newobj instance void assembly/niInstanceEta@49::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niInstanceEta@49::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) IL_0011: ret } + .method public static class [runtime]System.Func`3 niGenericInstanceNonEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/niGenericInstanceNonEta@52::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niGenericInstanceNonEta@52::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Func`3 niGenericInstanceEta(class assembly/C o) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/niGenericInstanceEta@55::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niGenericInstanceEta@55::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + .method public static int32 trivial(int32 x, int32 y) cil managed { @@ -404,7 +504,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialNonEta@54::Invoke(int32, + IL_0001: ldftn int32 assembly/niTrivialNonEta@63::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) @@ -416,7 +516,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialEta@56::Invoke(int32, + IL_0001: ldftn int32 assembly/niTrivialEta@65::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl index 15590de3edc..d9c7305029d 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl @@ -67,25 +67,6 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case4_nonEta@12 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static void Invoke(int32 x, - int32 y) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call void assembly/C::AddC(int32, - int32) - IL_0007: nop - IL_0008: ret - } - - } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case5_etaCurried@15 extends [runtime]System.Object { @@ -150,8 +131,8 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case4_nonEta@12::Invoke(int32, - int32) + IL_0001: ldftn void assembly/C::AddC(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs new file mode 100644 index 00000000000..b7f55d44097 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs @@ -0,0 +1,15 @@ +module DelegateStructTarget + +open System + +[] +type S = + [] + member _.Add (x: int) (y: int) : int = x + y + +// The target is an instance method on a value type. A delegate's Target is an object, so a direct delegate +// would have to box the receiver; until that is implemented a closure is kept. (See DelegateInstanceMethod +// for the reference-type case, which is emitted directly.) +let structInstanceNonEta (s: S) = Func(s.Add) + +let structInstanceEta (s: S) = Func(fun a b -> s.Add a b) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl new file mode 100644 index 00000000000..8055c451a93 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl @@ -0,0 +1,317 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class sequential ansi serializable sealed nested public S + extends [runtime]System.ValueType + implements class [runtime]System.IEquatable`1, + [runtime]System.Collections.IStructuralEquatable, + class [runtime]System.IComparable`1, + [runtime]System.IComparable, + [runtime]System.Collections.IStructuralComparable + { + .pack 0 + .size 1 + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.StructAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public hidebysig virtual final instance int32 CompareTo(valuetype assembly/S obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 3 + .locals init (valuetype assembly/S& V_0) + IL_0000: ldarga.s obj + IL_0002: stloc.0 + IL_0003: ldc.i4.0 + IL_0004: ret + } + + .method public hidebysig virtual final instance int32 CompareTo(object obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: unbox.any assembly/S + IL_0007: call instance int32 assembly/S::CompareTo(valuetype assembly/S) + IL_000c: ret + } + + .method public hidebysig virtual final instance int32 CompareTo(object obj, class [runtime]System.Collections.IComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 3 + .locals init (valuetype assembly/S V_0, + valuetype assembly/S& V_1) + IL_0000: ldarg.1 + IL_0001: unbox.any assembly/S + IL_0006: stloc.0 + IL_0007: ldloca.s V_0 + IL_0009: stloc.1 + IL_000a: ldc.i4.0 + IL_000b: ret + } + + .method public hidebysig virtual final instance int32 GetHashCode(class [runtime]System.Collections.IEqualityComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: ret + } + + .method public hidebysig virtual final instance int32 GetHashCode() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call class [runtime]System.Collections.IEqualityComparer [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::get_GenericEqualityComparer() + IL_0006: call instance int32 assembly/S::GetHashCode(class [runtime]System.Collections.IEqualityComparer) + IL_000b: ret + } + + .method public hidebysig instance bool Equals(valuetype assembly/S obj, class [runtime]System.Collections.IEqualityComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 3 + .locals init (valuetype assembly/S& V_0) + IL_0000: ldarga.s obj + IL_0002: stloc.0 + IL_0003: ldc.i4.1 + IL_0004: ret + } + + .method public hidebysig virtual final instance bool Equals(object obj, class [runtime]System.Collections.IEqualityComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 5 + .locals init (object V_0, + valuetype assembly/S V_1) + IL_0000: ldarg.1 + IL_0001: stloc.0 + IL_0002: ldloc.0 + IL_0003: isinst assembly/S + IL_0008: ldnull + IL_0009: cgt.un + IL_000b: brfalse.s IL_001d + + IL_000d: ldarg.1 + IL_000e: unbox.any assembly/S + IL_0013: stloc.1 + IL_0014: ldarg.0 + IL_0015: ldloc.1 + IL_0016: ldarg.2 + IL_0017: call instance bool assembly/S::Equals(valuetype assembly/S, + class [runtime]System.Collections.IEqualityComparer) + IL_001c: ret + + IL_001d: ldc.i4.0 + IL_001e: ret + } + + .method public hidebysig instance int32 Add(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: add + IL_0003: ret + } + + .method public hidebysig virtual final instance bool Equals(valuetype assembly/S obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 3 + .locals init (valuetype assembly/S& V_0) + IL_0000: ldarga.s obj + IL_0002: stloc.0 + IL_0003: ldc.i4.1 + IL_0004: ret + } + + .method public hidebysig virtual final instance bool Equals(object obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 4 + .locals init (object V_0, + valuetype assembly/S V_1) + IL_0000: ldarg.1 + IL_0001: stloc.0 + IL_0002: ldloc.0 + IL_0003: isinst assembly/S + IL_0008: ldnull + IL_0009: cgt.un + IL_000b: brfalse.s IL_001c + + IL_000d: ldarg.1 + IL_000e: unbox.any assembly/S + IL_0013: stloc.1 + IL_0014: ldarg.0 + IL_0015: ldloc.1 + IL_0016: call instance bool assembly/S::Equals(valuetype assembly/S) + IL_001b: ret + + IL_001c: ldc.i4.0 + IL_001d: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceNonEta@13 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public valuetype assembly/S s + .method public specialname rtspecialname instance void .ctor(valuetype assembly/S s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld valuetype assembly/S assembly/structInstanceNonEta@13::s + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 7 + .locals init (valuetype assembly/S V_0) + IL_0000: ldarg.0 + IL_0001: ldfld valuetype assembly/S assembly/structInstanceNonEta@13::s + IL_0006: stloc.0 + IL_0007: ldloca.s V_0 + IL_0009: ldarg.1 + IL_000a: ldarg.2 + IL_000b: call instance int32 assembly/S::Add(int32, + int32) + IL_0010: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceEta@15 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public valuetype assembly/S s + .method public specialname rtspecialname instance void .ctor(valuetype assembly/S s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld valuetype assembly/S assembly/structInstanceEta@15::s + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed + { + + .maxstack 7 + .locals init (valuetype assembly/S V_0) + IL_0000: ldarg.0 + IL_0001: ldfld valuetype assembly/S assembly/structInstanceEta@15::s + IL_0006: stloc.0 + IL_0007: ldloca.s V_0 + IL_0009: ldarg.1 + IL_000a: ldarg.2 + IL_000b: call instance int32 assembly/S::Add(int32, + int32) + IL_0010: ret + } + + } + + .method public static class [runtime]System.Func`3 structInstanceNonEta(valuetype assembly/S s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/structInstanceNonEta@13::.ctor(valuetype assembly/S) + IL_0006: ldftn instance int32 assembly/structInstanceNonEta@13::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Func`3 structInstanceEta(valuetype assembly/S s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/structInstanceEta@15::.ctor(valuetype assembly/S) + IL_0006: ldftn instance int32 assembly/structInstanceEta@15::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOff.il.bsl new file mode 100644 index 00000000000..3c01648fc8d --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOff.il.bsl @@ -0,0 +1,317 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class sequential ansi serializable sealed nested public S + extends [runtime]System.ValueType + implements class [runtime]System.IEquatable`1, + [runtime]System.Collections.IStructuralEquatable, + class [runtime]System.IComparable`1, + [runtime]System.IComparable, + [runtime]System.Collections.IStructuralComparable + { + .pack 0 + .size 1 + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.StructAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public hidebysig virtual final instance int32 CompareTo(valuetype assembly/S obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 3 + .locals init (valuetype assembly/S& V_0) + IL_0000: ldarga.s obj + IL_0002: stloc.0 + IL_0003: ldc.i4.0 + IL_0004: ret + } + + .method public hidebysig virtual final instance int32 CompareTo(object obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: unbox.any assembly/S + IL_0007: call instance int32 assembly/S::CompareTo(valuetype assembly/S) + IL_000c: ret + } + + .method public hidebysig virtual final instance int32 CompareTo(object obj, class [runtime]System.Collections.IComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 3 + .locals init (valuetype assembly/S V_0, + valuetype assembly/S& V_1) + IL_0000: ldarg.1 + IL_0001: unbox.any assembly/S + IL_0006: stloc.0 + IL_0007: ldloca.s V_0 + IL_0009: stloc.1 + IL_000a: ldc.i4.0 + IL_000b: ret + } + + .method public hidebysig virtual final instance int32 GetHashCode(class [runtime]System.Collections.IEqualityComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: ret + } + + .method public hidebysig virtual final instance int32 GetHashCode() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call class [runtime]System.Collections.IEqualityComparer [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::get_GenericEqualityComparer() + IL_0006: call instance int32 assembly/S::GetHashCode(class [runtime]System.Collections.IEqualityComparer) + IL_000b: ret + } + + .method public hidebysig instance bool Equals(valuetype assembly/S obj, class [runtime]System.Collections.IEqualityComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 3 + .locals init (valuetype assembly/S& V_0) + IL_0000: ldarga.s obj + IL_0002: stloc.0 + IL_0003: ldc.i4.1 + IL_0004: ret + } + + .method public hidebysig virtual final instance bool Equals(object obj, class [runtime]System.Collections.IEqualityComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 5 + .locals init (object V_0, + valuetype assembly/S V_1) + IL_0000: ldarg.1 + IL_0001: stloc.0 + IL_0002: ldloc.0 + IL_0003: isinst assembly/S + IL_0008: ldnull + IL_0009: cgt.un + IL_000b: brfalse.s IL_001d + + IL_000d: ldarg.1 + IL_000e: unbox.any assembly/S + IL_0013: stloc.1 + IL_0014: ldarg.0 + IL_0015: ldloc.1 + IL_0016: ldarg.2 + IL_0017: call instance bool assembly/S::Equals(valuetype assembly/S, + class [runtime]System.Collections.IEqualityComparer) + IL_001c: ret + + IL_001d: ldc.i4.0 + IL_001e: ret + } + + .method public hidebysig instance int32 Add(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: add + IL_0003: ret + } + + .method public hidebysig virtual final instance bool Equals(valuetype assembly/S obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 3 + .locals init (valuetype assembly/S& V_0) + IL_0000: ldarga.s obj + IL_0002: stloc.0 + IL_0003: ldc.i4.1 + IL_0004: ret + } + + .method public hidebysig virtual final instance bool Equals(object obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 4 + .locals init (object V_0, + valuetype assembly/S V_1) + IL_0000: ldarg.1 + IL_0001: stloc.0 + IL_0002: ldloc.0 + IL_0003: isinst assembly/S + IL_0008: ldnull + IL_0009: cgt.un + IL_000b: brfalse.s IL_001c + + IL_000d: ldarg.1 + IL_000e: unbox.any assembly/S + IL_0013: stloc.1 + IL_0014: ldarg.0 + IL_0015: ldloc.1 + IL_0016: call instance bool assembly/S::Equals(valuetype assembly/S) + IL_001b: ret + + IL_001c: ldc.i4.0 + IL_001d: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceNonEta@13 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public valuetype assembly/S s + .method public specialname rtspecialname instance void .ctor(valuetype assembly/S s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld valuetype assembly/S assembly/structInstanceNonEta@13::s + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 7 + .locals init (valuetype assembly/S V_0) + IL_0000: ldarg.0 + IL_0001: ldfld valuetype assembly/S assembly/structInstanceNonEta@13::s + IL_0006: stloc.0 + IL_0007: ldloca.s V_0 + IL_0009: ldarg.1 + IL_000a: ldarg.2 + IL_000b: call instance int32 assembly/S::Add(int32, + int32) + IL_0010: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceEta@15 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public valuetype assembly/S s + .method public specialname rtspecialname instance void .ctor(valuetype assembly/S s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld valuetype assembly/S assembly/structInstanceEta@15::s + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed + { + + .maxstack 7 + .locals init (valuetype assembly/S V_0) + IL_0000: ldarg.0 + IL_0001: ldfld valuetype assembly/S assembly/structInstanceEta@15::s + IL_0006: stloc.0 + IL_0007: ldloca.s V_0 + IL_0009: ldarg.1 + IL_000a: ldarg.2 + IL_000b: call instance int32 assembly/S::Add(int32, + int32) + IL_0010: ret + } + + } + + .method public static class [runtime]System.Func`3 structInstanceNonEta(valuetype assembly/S s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/structInstanceNonEta@13::.ctor(valuetype assembly/S) + IL_0006: ldftn instance int32 assembly/structInstanceNonEta@13::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Func`3 structInstanceEta(valuetype assembly/S s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/structInstanceEta@15::.ctor(valuetype assembly/S) + IL_0006: ldftn instance int32 assembly/structInstanceEta@15::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl new file mode 100644 index 00000000000..1cbf8a76d65 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl @@ -0,0 +1,284 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class sequential ansi serializable sealed nested public S + extends [runtime]System.ValueType + implements class [runtime]System.IEquatable`1, + [runtime]System.Collections.IStructuralEquatable, + class [runtime]System.IComparable`1, + [runtime]System.IComparable, + [runtime]System.Collections.IStructuralComparable + { + .pack 0 + .size 1 + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.StructAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public hidebysig virtual final instance int32 CompareTo(valuetype assembly/S obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: ret + } + + .method public hidebysig virtual final instance int32 CompareTo(object obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 3 + .locals init (valuetype assembly/S V_0) + IL_0000: ldarg.1 + IL_0001: unbox.any assembly/S + IL_0006: stloc.0 + IL_0007: ldc.i4.0 + IL_0008: ret + } + + .method public hidebysig virtual final instance int32 CompareTo(object obj, class [runtime]System.Collections.IComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 3 + .locals init (valuetype assembly/S V_0) + IL_0000: ldarg.1 + IL_0001: unbox.any assembly/S + IL_0006: stloc.0 + IL_0007: ldc.i4.0 + IL_0008: ret + } + + .method public hidebysig virtual final instance int32 GetHashCode(class [runtime]System.Collections.IEqualityComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: ret + } + + .method public hidebysig virtual final instance int32 GetHashCode() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call class [runtime]System.Collections.IEqualityComparer [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::get_GenericEqualityComparer() + IL_0006: call instance int32 assembly/S::GetHashCode(class [runtime]System.Collections.IEqualityComparer) + IL_000b: ret + } + + .method public hidebysig instance bool Equals(valuetype assembly/S obj, class [runtime]System.Collections.IEqualityComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.1 + IL_0001: ret + } + + .method public hidebysig virtual final instance bool Equals(object obj, class [runtime]System.Collections.IEqualityComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 3 + .locals init (valuetype assembly/S V_0) + IL_0000: ldarg.1 + IL_0001: isinst assembly/S + IL_0006: brfalse.s IL_0011 + + IL_0008: ldarg.1 + IL_0009: unbox.any assembly/S + IL_000e: stloc.0 + IL_000f: ldc.i4.1 + IL_0010: ret + + IL_0011: ldc.i4.0 + IL_0012: ret + } + + .method public hidebysig instance int32 Add(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: add + IL_0003: ret + } + + .method public hidebysig virtual final instance bool Equals(valuetype assembly/S obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.1 + IL_0001: ret + } + + .method public hidebysig virtual final instance bool Equals(object obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 3 + .locals init (valuetype assembly/S V_0) + IL_0000: ldarg.1 + IL_0001: isinst assembly/S + IL_0006: brfalse.s IL_0011 + + IL_0008: ldarg.1 + IL_0009: unbox.any assembly/S + IL_000e: stloc.0 + IL_000f: ldc.i4.1 + IL_0010: ret + + IL_0011: ldc.i4.0 + IL_0012: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceNonEta@13 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public valuetype assembly/S s + .method public specialname rtspecialname instance void .ctor(valuetype assembly/S s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld valuetype assembly/S assembly/structInstanceNonEta@13::s + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldflda valuetype assembly/S assembly/structInstanceNonEta@13::s + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: call instance int32 assembly/S::Add(int32, + int32) + IL_000d: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceEta@15 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public valuetype assembly/S s + .method public specialname rtspecialname instance void .ctor(valuetype assembly/S s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld valuetype assembly/S assembly/structInstanceEta@15::s + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldflda valuetype assembly/S assembly/structInstanceEta@15::s + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: call instance int32 assembly/S::Add(int32, + int32) + IL_000d: ret + } + + } + + .method public static class [runtime]System.Func`3 structInstanceNonEta(valuetype assembly/S s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/structInstanceNonEta@13::.ctor(valuetype assembly/S) + IL_0006: ldftn instance int32 assembly/structInstanceNonEta@13::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Func`3 structInstanceEta(valuetype assembly/S s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/structInstanceEta@15::.ctor(valuetype assembly/S) + IL_0006: ldftn instance int32 assembly/structInstanceEta@15::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOn.il.bsl new file mode 100644 index 00000000000..ae22fd38d8a --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -0,0 +1,284 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class sequential ansi serializable sealed nested public S + extends [runtime]System.ValueType + implements class [runtime]System.IEquatable`1, + [runtime]System.Collections.IStructuralEquatable, + class [runtime]System.IComparable`1, + [runtime]System.IComparable, + [runtime]System.Collections.IStructuralComparable + { + .pack 0 + .size 1 + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.StructAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public hidebysig virtual final instance int32 CompareTo(valuetype assembly/S obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: ret + } + + .method public hidebysig virtual final instance int32 CompareTo(object obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 3 + .locals init (valuetype assembly/S V_0) + IL_0000: ldarg.1 + IL_0001: unbox.any assembly/S + IL_0006: stloc.0 + IL_0007: ldc.i4.0 + IL_0008: ret + } + + .method public hidebysig virtual final instance int32 CompareTo(object obj, class [runtime]System.Collections.IComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 3 + .locals init (valuetype assembly/S V_0) + IL_0000: ldarg.1 + IL_0001: unbox.any assembly/S + IL_0006: stloc.0 + IL_0007: ldc.i4.0 + IL_0008: ret + } + + .method public hidebysig virtual final instance int32 GetHashCode(class [runtime]System.Collections.IEqualityComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: ret + } + + .method public hidebysig virtual final instance int32 GetHashCode() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call class [runtime]System.Collections.IEqualityComparer [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives::get_GenericEqualityComparer() + IL_0006: call instance int32 assembly/S::GetHashCode(class [runtime]System.Collections.IEqualityComparer) + IL_000b: ret + } + + .method public hidebysig instance bool Equals(valuetype assembly/S obj, class [runtime]System.Collections.IEqualityComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.1 + IL_0001: ret + } + + .method public hidebysig virtual final instance bool Equals(object obj, class [runtime]System.Collections.IEqualityComparer comp) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 3 + .locals init (valuetype assembly/S V_0) + IL_0000: ldarg.1 + IL_0001: isinst assembly/S + IL_0006: brfalse.s IL_0011 + + IL_0008: ldarg.1 + IL_0009: unbox.any assembly/S + IL_000e: stloc.0 + IL_000f: ldc.i4.1 + IL_0010: ret + + IL_0011: ldc.i4.0 + IL_0012: ret + } + + .method public hidebysig instance int32 Add(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: add + IL_0003: ret + } + + .method public hidebysig virtual final instance bool Equals(valuetype assembly/S obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.1 + IL_0001: ret + } + + .method public hidebysig virtual final instance bool Equals(object obj) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 3 + .locals init (valuetype assembly/S V_0) + IL_0000: ldarg.1 + IL_0001: isinst assembly/S + IL_0006: brfalse.s IL_0011 + + IL_0008: ldarg.1 + IL_0009: unbox.any assembly/S + IL_000e: stloc.0 + IL_000f: ldc.i4.1 + IL_0010: ret + + IL_0011: ldc.i4.0 + IL_0012: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceNonEta@13 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public valuetype assembly/S s + .method public specialname rtspecialname instance void .ctor(valuetype assembly/S s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld valuetype assembly/S assembly/structInstanceNonEta@13::s + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldflda valuetype assembly/S assembly/structInstanceNonEta@13::s + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: call instance int32 assembly/S::Add(int32, + int32) + IL_000d: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceEta@15 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public valuetype assembly/S s + .method public specialname rtspecialname instance void .ctor(valuetype assembly/S s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld valuetype assembly/S assembly/structInstanceEta@15::s + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldflda valuetype assembly/S assembly/structInstanceEta@15::s + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: call instance int32 assembly/S::Add(int32, + int32) + IL_000d: ret + } + + } + + .method public static class [runtime]System.Func`3 structInstanceNonEta(valuetype assembly/S s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/structInstanceNonEta@13::.ctor(valuetype assembly/S) + IL_0006: ldftn instance int32 assembly/structInstanceNonEta@13::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Func`3 structInstanceEta(valuetype assembly/S s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/structInstanceEta@15::.ctor(valuetype assembly/S) + IL_0006: ldftn instance int32 assembly/structInstanceEta@15::Invoke(int32, + int32) + IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_0011: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs new file mode 100644 index 00000000000..7e2b1c5e31a --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs @@ -0,0 +1,23 @@ +module DelegateUnitReturn + +open System + +// Target returns unit, compiled to void; delegate (Action) returns void. +[] +let returnsUnit (x: int) (y: int) : unit = () + +let voidNonEta () = Action(returnsUnit) + +let voidEta () = Action(fun a b -> returnsUnit a b) + +type C = + // Generic method returning its own type variable; instantiated to unit below. The compiled method + // returns the type variable (System.Unit once instantiated), not void - a distinct case from the + // void-returning member above. + [] + static member Echo<'T>(x: 'T) : 'T = x + +// Generic return type variable instantiated to unit; the delegate likewise returns unit. +let unitGenericReturnNonEta () = Func(C.Echo) + +let unitGenericReturnEta () = Func(fun (x: unit) -> C.Echo x) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl new file mode 100644 index 00000000000..1ac412d919c --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl @@ -0,0 +1,160 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public static !!T Echo(!!T x) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidEta@11 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void assembly::returnsUnit(int32, + int32) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnEta@23 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static class [FSharp.Core]Microsoft.FSharp.Core.Unit Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit x) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call !!0 assembly/C::Echo(!!0) + IL_0006: ret + } + + } + + .method public static void returnsUnit(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action`2 voidNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly::returnsUnit(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 voidEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/voidEta@11::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`2 unitGenericReturnNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn !!0 assembly/C::Echo(!!0) + IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`2 unitGenericReturnEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnEta@23::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) + IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOff.il.bsl new file mode 100644 index 00000000000..2169ff70e6f --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOff.il.bsl @@ -0,0 +1,194 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public static !!T Echo(!!T x) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidNonEta@9 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void assembly::returnsUnit(int32, + int32) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidEta@11 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void assembly::returnsUnit(int32, + int32) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnNonEta@21 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static class [FSharp.Core]Microsoft.FSharp.Core.Unit Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit x) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call !!0 assembly/C::Echo(!!0) + IL_0006: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnEta@23 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static class [FSharp.Core]Microsoft.FSharp.Core.Unit Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit x) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call !!0 assembly/C::Echo(!!0) + IL_0006: ret + } + + } + + .method public static void returnsUnit(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action`2 voidNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/voidNonEta@9::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 voidEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/voidEta@11::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`2 unitGenericReturnNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnNonEta@21::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) + IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`2 unitGenericReturnEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnEta@23::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) + IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl new file mode 100644 index 00000000000..02e82fd6e93 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl @@ -0,0 +1,126 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public static !!T Echo(!!T x) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + } + + .method public static void returnsUnit(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action`2 voidNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly::returnsUnit(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 voidEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly::returnsUnit(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`2 unitGenericReturnNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn !!0 assembly/C::Echo(!!0) + IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`2 unitGenericReturnEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn !!0 assembly/C::Echo(!!0) + IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOn.il.bsl new file mode 100644 index 00000000000..2169ff70e6f --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -0,0 +1,194 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public static !!T Echo(!!T x) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidNonEta@9 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void assembly::returnsUnit(int32, + int32) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidEta@11 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call void assembly::returnsUnit(int32, + int32) + IL_0007: nop + IL_0008: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnNonEta@21 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static class [FSharp.Core]Microsoft.FSharp.Core.Unit Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit x) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call !!0 assembly/C::Echo(!!0) + IL_0006: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnEta@23 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static class [FSharp.Core]Microsoft.FSharp.Core.Unit Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit x) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call !!0 assembly/C::Echo(!!0) + IL_0006: ret + } + + } + + .method public static void returnsUnit(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + .method public static class [runtime]System.Action`2 voidNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/voidNonEta@9::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action`2 voidEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/voidEta@11::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`2 unitGenericReturnNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnNonEta@21::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) + IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Func`2 unitGenericReturnEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnEta@23::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) + IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs index ccf7d8d41a0..8ab3fa33684 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs @@ -118,3 +118,186 @@ module DirectDelegates = [] let ``DelegatePartialApplication_fs preview`` compilation = compilation |> getCompilation |> verifyPreviewCompilation + + [] + let ``DelegateUnitReturn_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + + [] + let ``DelegateUnitReturn_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + + [] + let ``DelegateStructTarget_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + + [] + let ``DelegateStructTarget_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + + [] + let ``DelegateExtensionMethod_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + + [] + let ``DelegateExtensionMethod_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + + [] + let ``DelegateILMethod_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + + [] + let ``DelegateILMethod_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + + [] + let ``Direct delegates target the real method and dispatch correctly (preview)`` () = + FSharp """ +module DirectDelegateExecution + +open System + +[] +let add (x: int) (y: int) : int = x + y + +type G<'U> = + [] + static member Pick<'T>(x: 'T) (y: 'T) : 'T = x + +[] +type Base() = + abstract M: int -> int + +type Derived() = + inherit Base() + override _.M x = x + 100 + +[] +let main _ = + // Non-eta known function: the delegate points directly at 'add'. + let d = Func(add) + if d.Invoke(2, 3) <> 5 then failwith "add: wrong result" + if d.Method.Name <> "add" then failwithf "add: expected Method.Name 'add' but got '%s'" d.Method.Name + + // Non-eta generic method on a generic type: the delegate points directly at the fully instantiated method. + let gd = Func(G.Pick) + if gd.Invoke(7, 9) <> 7 then failwithf "generic: expected 7 but got %d" (gd.Invoke(7, 9)) + if gd.Method.Name <> "Pick" then failwithf "generic: expected Method.Name 'Pick' but got '%s'" gd.Method.Name + + // Non-eta virtual instance method: dup; ldvirtftn must preserve override dispatch. + let b: Base = Derived() + let vd = Func(b.M) + if vd.Invoke 1 <> 101 then failwithf "virtual: expected 101 but got %d" (vd.Invoke 1) + if vd.Method.Name <> "M" then failwithf "virtual: expected Method.Name 'M' but got '%s'" vd.Method.Name + if not (obj.ReferenceEquals(vd.Target, b)) then failwith "virtual: Target is not the receiver" + + 0 + """ + |> withLangVersionPreview + |> compileExeAndRun + |> shouldSucceed + + [] + let ``Without the feature the delegate goes through a closure (default langversion)`` () = + FSharp """ +module ClosureDelegateExecution + +open System + +[] +let add (x: int) (y: int) : int = x + y + +[] +let main _ = + let d = Func(add) + if d.Invoke(2, 3) <> 5 then failwith "add: wrong result" + // Without the feature the delegate is built over a generated closure method named 'Invoke'. + if d.Method.Name <> "Invoke" then failwithf "expected closure Method.Name 'Invoke' but got '%s'" d.Method.Name + 0 + """ + |> compileExeAndRun + |> shouldSucceed + + // IL (BCL) method target: compiled as TOp.ILCall. With ILCall recognition the optimized eta-expanded + // delegate points directly at the BCL method, so Method.Name is the real method ('Max'), not a closure + // 'Invoke'. Compiled with --optimize+ so the eta forwarding call survives to codegen. + [] + let ``IL method targets are emitted directly when optimized (preview)`` () = + FSharp """ +module IlMethodDelegate + +open System + +[] +let main _ = + let d = Func(fun a b -> Math.Max(a, b)) + if d.Invoke(3, 7) <> 7 then failwith "il: wrong result" + if d.Method.Name <> "Max" then failwithf "il: expected direct 'Max' but got '%s'" d.Method.Name + 0 + """ + |> withLangVersionPreview + |> withOptions [ "--optimize+" ] + |> compileExeAndRun + |> shouldSucceed + + // A closure built from an explicit eta-lambda re-evaluates the receiver on every Invoke; a direct + // delegate would evaluate it once at construction. When the receiver has an effect (here a counter- + // bumping call) that difference is observable, so the closure must be kept even under optimization. + [] + let ``Side-effecting receiver keeps the closure so it is re-evaluated per invoke (preview)`` () = + FSharp """ +module ReceiverEffectDelegate + +open System + +let mutable calls = 0 + +type Box(tag: int) = + member _.Read (_: int) : int = tag + +let getBox () = + calls <- calls + 1 + Box(calls) + +[] +let main _ = + // The receiver 'getBox()' has an effect, so it must run on each invocation, not once at construction. + let d = Func(fun a -> (getBox()).Read a) + let r1 = d.Invoke 0 + let r2 = d.Invoke 0 + if calls <> 2 then failwithf "receiver should be re-evaluated per invoke; calls=%d" calls + if r1 = r2 then failwithf "expected distinct boxes per invoke but got %d and %d" r1 r2 + if d.Method.Name <> "Invoke" then failwithf "expected closure 'Invoke' but got '%s'" d.Method.Name + 0 + """ + |> withLangVersionPreview + |> withOptions [ "--optimize+" ] + |> compileExeAndRun + |> shouldSucceed + + // Instance IL method target: a BCL instance method bound directly. The delegate's Target must be the + // receiver and Method.Name the real method. + [] + let ``Instance IL method targets are emitted directly when optimized (preview)`` () = + FSharp """ +module IlInstanceMethodDelegate + +open System +open System.Text + +[] +let main _ = + let sb = StringBuilder() + // StringBuilder.Append(string) is an instance method on a reference type. + let d = Func(fun s -> sb.Append(s)) + d.Invoke "hello" |> ignore + if sb.ToString() <> "hello" then failwith "il-instance: wrong result" + if d.Method.Name <> "Append" then failwithf "il-instance: expected direct 'Append' but got '%s'" d.Method.Name + if not (obj.ReferenceEquals(d.Target, sb)) then failwith "il-instance: Target is not the receiver" + 0 + """ + |> withLangVersionPreview + |> withOptions [ "--optimize+" ] + |> compileExeAndRun + |> shouldSucceed From 894f6f0e9f5e3bfdbfb50bfd9ef9ad88f4963840 Mon Sep 17 00:00:00 2001 From: kerams Date: Wed, 24 Jun 2026 23:59:32 +0200 Subject: [PATCH 03/16] Release notes, custom delegate tests --- .../.FSharp.Compiler.Service/11.0.100.md | 1 + docs/release-notes/.Language/preview.md | 4 +- .../DirectDelegates/DelegateCustomType.fs | 40 ++ ...rnalSignatureOn.OptimizeOff.Preview.il.bsl | 351 +++++++++++++++ ...RealInternalSignatureOn.OptimizeOff.il.bsl | 417 ++++++++++++++++++ ...ernalSignatureOn.OptimizeOn.Preview.il.bsl | 285 ++++++++++++ ....RealInternalSignatureOn.OptimizeOn.il.bsl | 417 ++++++++++++++++++ .../DirectDelegates/DirectDelegates.fs | 47 ++ 8 files changed, 1561 insertions(+), 1 deletion(-) create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOff.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl create mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOn.il.bsl diff --git a/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md b/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md index 54f5a122d6d..190d8ee8cc7 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md +++ b/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md @@ -108,6 +108,7 @@ ### Improved * Nullness warning FS3261 on dotted method or property access (e.g. `x.Member`) now underlines the receiver expression and includes the member name and (when known) the binding name in the message. ([Issue #19658](https://github.com/dotnet/fsharp/issues/19658), [PR #19814](https://github.com/dotnet/fsharp/pull/19814)) +* Direct delegate construction ([PR ##19993](https://github.com/dotnet/fsharp/pull/19993)) ### Changed diff --git a/docs/release-notes/.Language/preview.md b/docs/release-notes/.Language/preview.md index 90c1aa2faa6..1775f5ba65e 100644 --- a/docs/release-notes/.Language/preview.md +++ b/docs/release-notes/.Language/preview.md @@ -6,4 +6,6 @@ ### Fixed -### Changed \ No newline at end of file +### Changed + +* Direct delegate construction ([PR ##19993](https://github.com/dotnet/fsharp/pull/19993)) \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs new file mode 100644 index 00000000000..0ff380ea4cb --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs @@ -0,0 +1,40 @@ +module DelegateCustomType + +open System + +// Custom, F#-declared delegate types exercise construction with delegates defined in the *compiled* assembly +// (local scope, unlike imported BCL Func/Action) and with Invoke signatures the Func/Action tests do not +// cover: a multi-argument (tupled) signature, a generic delegate, and a byref parameter. (F# forbids curried +// delegate signatures — FS0950 — so every F# delegate has a single tupled Invoke parameter group.) Targets +// are [] so the optimized path genuinely emits the direct form rather than inlining the +// target away (no inline-race). + +type DTupled = delegate of int * int -> int +type DGen<'T> = delegate of 'T -> 'T +type DByref = delegate of byref -> unit + +[] +let acc (x: int) (y: int) : int = x + y + +[] +let ident (x: 'T) : 'T = x + +type C() = + [] + member _.M (x: int) (y: int) : int = x * y + +// Tupled-signature custom delegate: Invoke(int, int). +let tupledNonEta () = DTupled(acc) +let tupledEta () = DTupled(fun a b -> acc a b) + +// Instance member through a custom delegate: the receiver becomes the delegate's Target. +let instanceNonEta (c: C) = DTupled(c.M) +let instanceEta (c: C) = DTupled(fun a b -> c.M a b) + +// Generic custom delegate instantiated at int: Invoke(int):int over the generic target. +let genNonEta () = DGen(ident) +let genEta () = DGen(fun x -> ident x) + +// byref-parameter custom delegate: the body mutates through the byref, so it is not a transparent forwarding +// call and stays a closure. Documents that a byref Invoke parameter does not break the recognizer. +let byrefMutate () = DByref(fun x -> x <- x + 1) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl new file mode 100644 index 00000000000..2dc27dab7c4 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl @@ -0,0 +1,351 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested public DTupled + extends [runtime]System.MulticastDelegate + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public hidebysig specialname rtspecialname instance void .ctor(object 'object', native int 'method') runtime managed + { + } + + .method public hidebysig strict virtual instance int32 Invoke(int32 A_1, int32 A_2) runtime managed + { + } + + .method public hidebysig strict virtual + instance class [runtime]System.IAsyncResult + BeginInvoke(int32 A_1, + int32 A_2, + class [runtime]System.AsyncCallback callback, + object objects) runtime managed + { + } + + .method public hidebysig strict virtual instance int32 EndInvoke(class [runtime]System.IAsyncResult result) runtime managed + { + } + + } + + .class auto ansi serializable sealed nested public DGen`1 + extends [runtime]System.MulticastDelegate + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public hidebysig specialname rtspecialname instance void .ctor(object 'object', native int 'method') runtime managed + { + } + + .method public hidebysig strict virtual instance !T Invoke(!T A_1) runtime managed + { + } + + .method public hidebysig strict virtual + instance class [runtime]System.IAsyncResult + BeginInvoke(!T A_1, + class [runtime]System.AsyncCallback callback, + object objects) runtime managed + { + } + + .method public hidebysig strict virtual instance !T EndInvoke(class [runtime]System.IAsyncResult result) runtime managed + { + } + + } + + .class auto ansi serializable sealed nested public DByref + extends [runtime]System.MulticastDelegate + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public hidebysig specialname rtspecialname instance void .ctor(object 'object', native int 'method') runtime managed + { + } + + .method public hidebysig strict virtual instance void Invoke(int32& A_1) runtime managed + { + } + + .method public hidebysig strict virtual + instance class [runtime]System.IAsyncResult + BeginInvoke(int32& A_1, + class [runtime]System.AsyncCallback callback, + object objects) runtime managed + { + } + + .method public hidebysig strict virtual instance void EndInvoke(class [runtime]System.IAsyncResult result) runtime managed + { + } + + } + + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public specialname rtspecialname instance void .ctor() cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ret + } + + .method public hidebysig instance int32 M(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: mul + IL_0003: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledEta@28 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::acc(int32, + int32) + IL_0007: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname instanceEta@32 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C c + .method public specialname rtspecialname instance void .ctor(class assembly/C c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/instanceEta@32::c + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/instanceEta@32::c + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance int32 assembly/C::M(int32, + int32) + IL_000d: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genEta@36 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 x) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call !!0 assembly::ident(!!0) + IL_0006: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname byrefMutate@40 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32& x) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.0 + IL_0002: ldobj [runtime]System.Int32 + IL_0007: ldc.i4.1 + IL_0008: add + IL_0009: stobj [runtime]System.Int32 + IL_000e: ret + } + + } + + .method public static int32 acc(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + .method public static !!T ident(!!T x) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + .method public static class assembly/DTupled tupledNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly::acc(int32, + int32) + IL_0007: newobj instance void assembly/DTupled::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class assembly/DTupled tupledEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/tupledEta@28::Invoke(int32, + int32) + IL_0007: newobj instance void assembly/DTupled::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class assembly/DTupled instanceNonEta(class assembly/C c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldftn instance int32 assembly/C::M(int32, + int32) + IL_0007: newobj instance void assembly/DTupled::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class assembly/DTupled instanceEta(class assembly/C c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/instanceEta@32::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/instanceEta@32::Invoke(int32, + int32) + IL_000c: newobj instance void assembly/DTupled::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class assembly/DGen`1 genNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn !!0 assembly::ident(!!0) + IL_0007: newobj instance void class assembly/DGen`1::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class assembly/DGen`1 genEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/genEta@36::Invoke(int32) + IL_0007: newobj instance void class assembly/DGen`1::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class assembly/DByref byrefMutate() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/byrefMutate@40::Invoke(int32&) + IL_0007: newobj instance void assembly/DByref::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOff.il.bsl new file mode 100644 index 00000000000..f5f71c0f124 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOff.il.bsl @@ -0,0 +1,417 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested public DTupled + extends [runtime]System.MulticastDelegate + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public hidebysig specialname rtspecialname instance void .ctor(object 'object', native int 'method') runtime managed + { + } + + .method public hidebysig strict virtual instance int32 Invoke(int32 A_1, int32 A_2) runtime managed + { + } + + .method public hidebysig strict virtual + instance class [runtime]System.IAsyncResult + BeginInvoke(int32 A_1, + int32 A_2, + class [runtime]System.AsyncCallback callback, + object objects) runtime managed + { + } + + .method public hidebysig strict virtual instance int32 EndInvoke(class [runtime]System.IAsyncResult result) runtime managed + { + } + + } + + .class auto ansi serializable sealed nested public DGen`1 + extends [runtime]System.MulticastDelegate + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public hidebysig specialname rtspecialname instance void .ctor(object 'object', native int 'method') runtime managed + { + } + + .method public hidebysig strict virtual instance !T Invoke(!T A_1) runtime managed + { + } + + .method public hidebysig strict virtual + instance class [runtime]System.IAsyncResult + BeginInvoke(!T A_1, + class [runtime]System.AsyncCallback callback, + object objects) runtime managed + { + } + + .method public hidebysig strict virtual instance !T EndInvoke(class [runtime]System.IAsyncResult result) runtime managed + { + } + + } + + .class auto ansi serializable sealed nested public DByref + extends [runtime]System.MulticastDelegate + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public hidebysig specialname rtspecialname instance void .ctor(object 'object', native int 'method') runtime managed + { + } + + .method public hidebysig strict virtual instance void Invoke(int32& A_1) runtime managed + { + } + + .method public hidebysig strict virtual + instance class [runtime]System.IAsyncResult + BeginInvoke(int32& A_1, + class [runtime]System.AsyncCallback callback, + object objects) runtime managed + { + } + + .method public hidebysig strict virtual instance void EndInvoke(class [runtime]System.IAsyncResult result) runtime managed + { + } + + } + + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public specialname rtspecialname instance void .ctor() cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ret + } + + .method public hidebysig instance int32 M(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: mul + IL_0003: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledNonEta@27 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::acc(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledEta@28 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::acc(int32, + int32) + IL_0007: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname instanceNonEta@31 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C c + .method public specialname rtspecialname instance void .ctor(class assembly/C c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/instanceNonEta@31::c + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/instanceNonEta@31::c + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance int32 assembly/C::M(int32, + int32) + IL_000d: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname instanceEta@32 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C c + .method public specialname rtspecialname instance void .ctor(class assembly/C c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/instanceEta@32::c + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/instanceEta@32::c + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance int32 assembly/C::M(int32, + int32) + IL_000d: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genNonEta@35 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 delegateArg0) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call !!0 assembly::ident(!!0) + IL_0006: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genEta@36 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 x) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call !!0 assembly::ident(!!0) + IL_0006: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname byrefMutate@40 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32& x) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.0 + IL_0002: ldobj [runtime]System.Int32 + IL_0007: ldc.i4.1 + IL_0008: add + IL_0009: stobj [runtime]System.Int32 + IL_000e: ret + } + + } + + .method public static int32 acc(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + .method public static !!T ident(!!T x) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + .method public static class assembly/DTupled tupledNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/tupledNonEta@27::Invoke(int32, + int32) + IL_0007: newobj instance void assembly/DTupled::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class assembly/DTupled tupledEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/tupledEta@28::Invoke(int32, + int32) + IL_0007: newobj instance void assembly/DTupled::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class assembly/DTupled instanceNonEta(class assembly/C c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/instanceNonEta@31::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/instanceNonEta@31::Invoke(int32, + int32) + IL_000c: newobj instance void assembly/DTupled::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class assembly/DTupled instanceEta(class assembly/C c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/instanceEta@32::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/instanceEta@32::Invoke(int32, + int32) + IL_000c: newobj instance void assembly/DTupled::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class assembly/DGen`1 genNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/genNonEta@35::Invoke(int32) + IL_0007: newobj instance void class assembly/DGen`1::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class assembly/DGen`1 genEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/genEta@36::Invoke(int32) + IL_0007: newobj instance void class assembly/DGen`1::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class assembly/DByref byrefMutate() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/byrefMutate@40::Invoke(int32&) + IL_0007: newobj instance void assembly/DByref::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl new file mode 100644 index 00000000000..e893cc9de1b --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl @@ -0,0 +1,285 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested public DTupled + extends [runtime]System.MulticastDelegate + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public hidebysig specialname rtspecialname instance void .ctor(object 'object', native int 'method') runtime managed + { + } + + .method public hidebysig strict virtual instance int32 Invoke(int32 A_1, int32 A_2) runtime managed + { + } + + .method public hidebysig strict virtual + instance class [runtime]System.IAsyncResult + BeginInvoke(int32 A_1, + int32 A_2, + class [runtime]System.AsyncCallback callback, + object objects) runtime managed + { + } + + .method public hidebysig strict virtual instance int32 EndInvoke(class [runtime]System.IAsyncResult result) runtime managed + { + } + + } + + .class auto ansi serializable sealed nested public DGen`1 + extends [runtime]System.MulticastDelegate + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public hidebysig specialname rtspecialname instance void .ctor(object 'object', native int 'method') runtime managed + { + } + + .method public hidebysig strict virtual instance !T Invoke(!T A_1) runtime managed + { + } + + .method public hidebysig strict virtual + instance class [runtime]System.IAsyncResult + BeginInvoke(!T A_1, + class [runtime]System.AsyncCallback callback, + object objects) runtime managed + { + } + + .method public hidebysig strict virtual instance !T EndInvoke(class [runtime]System.IAsyncResult result) runtime managed + { + } + + } + + .class auto ansi serializable sealed nested public DByref + extends [runtime]System.MulticastDelegate + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public hidebysig specialname rtspecialname instance void .ctor(object 'object', native int 'method') runtime managed + { + } + + .method public hidebysig strict virtual instance void Invoke(int32& A_1) runtime managed + { + } + + .method public hidebysig strict virtual + instance class [runtime]System.IAsyncResult + BeginInvoke(int32& A_1, + class [runtime]System.AsyncCallback callback, + object objects) runtime managed + { + } + + .method public hidebysig strict virtual instance void EndInvoke(class [runtime]System.IAsyncResult result) runtime managed + { + } + + } + + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public specialname rtspecialname instance void .ctor() cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ret + } + + .method public hidebysig instance int32 M(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: mul + IL_0003: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname byrefMutate@40 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32& x) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.0 + IL_0002: ldobj [runtime]System.Int32 + IL_0007: ldc.i4.1 + IL_0008: add + IL_0009: stobj [runtime]System.Int32 + IL_000e: ret + } + + } + + .method public static int32 acc(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + .method public static !!T ident(!!T x) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + .method public static class assembly/DTupled tupledNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly::acc(int32, + int32) + IL_0007: newobj instance void assembly/DTupled::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class assembly/DTupled tupledEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly::acc(int32, + int32) + IL_0007: newobj instance void assembly/DTupled::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class assembly/DTupled instanceNonEta(class assembly/C c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldftn instance int32 assembly/C::M(int32, + int32) + IL_0007: newobj instance void assembly/DTupled::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class assembly/DTupled instanceEta(class assembly/C c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldftn instance int32 assembly/C::M(int32, + int32) + IL_0007: newobj instance void assembly/DTupled::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class assembly/DGen`1 genNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn !!0 assembly::ident(!!0) + IL_0007: newobj instance void class assembly/DGen`1::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class assembly/DGen`1 genEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn !!0 assembly::ident(!!0) + IL_0007: newobj instance void class assembly/DGen`1::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class assembly/DByref byrefMutate() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/byrefMutate@40::Invoke(int32&) + IL_0007: newobj instance void assembly/DByref::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOn.il.bsl new file mode 100644 index 00000000000..f5f71c0f124 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -0,0 +1,417 @@ + + + + + +.assembly extern runtime { } +.assembly extern FSharp.Core { } +.assembly assembly +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + + + + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module assembly.exe + +.imagebase {value} +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 +.corflags 0x00000001 + + + + + +.class public abstract auto ansi sealed assembly + extends [runtime]System.Object +{ + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested public DTupled + extends [runtime]System.MulticastDelegate + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public hidebysig specialname rtspecialname instance void .ctor(object 'object', native int 'method') runtime managed + { + } + + .method public hidebysig strict virtual instance int32 Invoke(int32 A_1, int32 A_2) runtime managed + { + } + + .method public hidebysig strict virtual + instance class [runtime]System.IAsyncResult + BeginInvoke(int32 A_1, + int32 A_2, + class [runtime]System.AsyncCallback callback, + object objects) runtime managed + { + } + + .method public hidebysig strict virtual instance int32 EndInvoke(class [runtime]System.IAsyncResult result) runtime managed + { + } + + } + + .class auto ansi serializable sealed nested public DGen`1 + extends [runtime]System.MulticastDelegate + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public hidebysig specialname rtspecialname instance void .ctor(object 'object', native int 'method') runtime managed + { + } + + .method public hidebysig strict virtual instance !T Invoke(!T A_1) runtime managed + { + } + + .method public hidebysig strict virtual + instance class [runtime]System.IAsyncResult + BeginInvoke(!T A_1, + class [runtime]System.AsyncCallback callback, + object objects) runtime managed + { + } + + .method public hidebysig strict virtual instance !T EndInvoke(class [runtime]System.IAsyncResult result) runtime managed + { + } + + } + + .class auto ansi serializable sealed nested public DByref + extends [runtime]System.MulticastDelegate + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public hidebysig specialname rtspecialname instance void .ctor(object 'object', native int 'method') runtime managed + { + } + + .method public hidebysig strict virtual instance void Invoke(int32& A_1) runtime managed + { + } + + .method public hidebysig strict virtual + instance class [runtime]System.IAsyncResult + BeginInvoke(int32& A_1, + class [runtime]System.AsyncCallback callback, + object objects) runtime managed + { + } + + .method public hidebysig strict virtual instance void EndInvoke(class [runtime]System.IAsyncResult result) runtime managed + { + } + + } + + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public specialname rtspecialname instance void .ctor() cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ret + } + + .method public hidebysig instance int32 M(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: mul + IL_0003: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledNonEta@27 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 x, + int32 y) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::acc(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledEta@28 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::acc(int32, + int32) + IL_0007: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname instanceNonEta@31 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C c + .method public specialname rtspecialname instance void .ctor(class assembly/C c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/instanceNonEta@31::c + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/instanceNonEta@31::c + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance int32 assembly/C::M(int32, + int32) + IL_000d: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname instanceEta@32 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C c + .method public specialname rtspecialname instance void .ctor(class assembly/C c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/instanceEta@32::c + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/instanceEta@32::c + IL_0006: ldarg.1 + IL_0007: ldarg.2 + IL_0008: callvirt instance int32 assembly/C::M(int32, + int32) + IL_000d: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genNonEta@35 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 delegateArg0) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call !!0 assembly::ident(!!0) + IL_0006: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genEta@36 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 x) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call !!0 assembly::ident(!!0) + IL_0006: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname byrefMutate@40 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32& x) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.0 + IL_0002: ldobj [runtime]System.Int32 + IL_0007: ldc.i4.1 + IL_0008: add + IL_0009: stobj [runtime]System.Int32 + IL_000e: ret + } + + } + + .method public static int32 acc(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + .method public static !!T ident(!!T x) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + .method public static class assembly/DTupled tupledNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/tupledNonEta@27::Invoke(int32, + int32) + IL_0007: newobj instance void assembly/DTupled::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class assembly/DTupled tupledEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/tupledEta@28::Invoke(int32, + int32) + IL_0007: newobj instance void assembly/DTupled::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class assembly/DTupled instanceNonEta(class assembly/C c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/instanceNonEta@31::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/instanceNonEta@31::Invoke(int32, + int32) + IL_000c: newobj instance void assembly/DTupled::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class assembly/DTupled instanceEta(class assembly/C c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/instanceEta@32::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/instanceEta@32::Invoke(int32, + int32) + IL_000c: newobj instance void assembly/DTupled::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class assembly/DGen`1 genNonEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/genNonEta@35::Invoke(int32) + IL_0007: newobj instance void class assembly/DGen`1::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class assembly/DGen`1 genEta() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/genEta@36::Invoke(int32) + IL_0007: newobj instance void class assembly/DGen`1::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class assembly/DByref byrefMutate() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/byrefMutate@40::Invoke(int32&) + IL_0007: newobj instance void assembly/DByref::.ctor(object, + native int) + IL_000c: ret + } + +} + +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object +{ + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } + +} + + + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs index 8ab3fa33684..93351130abb 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs @@ -21,6 +21,7 @@ module DirectDelegates = compilation |> coreOptions |> compile + |> shouldSucceed |> verifyILBaseline // Redirect the IL baseline to a distinct *.Preview.il.bsl path so the preview variant can reuse the @@ -45,6 +46,7 @@ module DirectDelegates = |> withLangVersionPreview |> withPreviewBaseline |> compile + |> shouldSucceed |> verifyILBaseline [] @@ -151,6 +153,14 @@ module DirectDelegates = let ``DelegateILMethod_fs preview`` compilation = compilation |> getCompilation |> verifyPreviewCompilation + [] + let ``DelegateCustomType_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + + [] + let ``DelegateCustomType_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + [] let ``Direct delegates target the real method and dispatch correctly (preview)`` () = FSharp """ @@ -301,3 +311,40 @@ let main _ = |> withOptions [ "--optimize+" ] |> compileExeAndRun |> shouldSucceed + + // Custom, F#-declared delegate types (not just BCL Func/Action) point directly at the target method. + // Non-eta targets, so direct in both debug and release. Covers a static target (null Target) and an + // instance target (Target = receiver) through a user-defined delegate. + [] + let ``Custom F# delegate targets the real method and dispatch correctly (preview)`` () = + FSharp """ +module CustomDelegateExecution + +open System + +type DTupled = delegate of int * int -> int + +[] +let acc (x: int) (y: int) : int = x + y + +type C() = + [] + member _.M (x: int) (y: int) : int = x * y + +[] +let main _ = + let ds = DTupled(acc) + if ds.Invoke(2, 3) <> 5 then failwith "static: wrong result" + if ds.Method.Name <> "acc" then failwithf "static: expected 'acc' but got '%s'" ds.Method.Name + if not (isNull ds.Target) then failwith "static: Target should be null" + + let c = C() + let di = DTupled(c.M) + if di.Invoke(4, 5) <> 20 then failwith "instance: wrong result" + if di.Method.Name <> "M" then failwithf "instance: expected 'M' but got '%s'" di.Method.Name + if not (obj.ReferenceEquals(di.Target, c)) then failwith "instance: Target is not the receiver" + 0 + """ + |> withLangVersionPreview + |> compileExeAndRun + |> shouldSucceed From 427050787c88e7104eb7cefd25b8fbe0521b6d3b Mon Sep 17 00:00:00 2001 From: kerams Date: Thu, 25 Jun 2026 18:58:27 +0200 Subject: [PATCH 04/16] verifyPEFileWithSystemDlls, remove realsig keying, RFC <-> baseline test case numbering --- src/Compiler/CodeGen/IlxGen.fs | 32 +- .../DirectDelegates/DelegateCustomType.fs | 7 + ...eCustomType.fs.OptimizeOff.Preview.il.bsl} | 22 +- ... DelegateCustomType.fs.OptimizeOff.il.bsl} | 40 +- ...teCustomType.fs.OptimizeOn.Preview.il.bsl} | 4 +- ...> DelegateCustomType.fs.OptimizeOn.il.bsl} | 40 +- .../DelegateExtensionMethod.fs | 1 + ...nsionMethod.fs.OptimizeOff.Preview.il.bsl} | 10 +- ...gateExtensionMethod.fs.OptimizeOff.il.bsl} | 10 +- ...ensionMethod.fs.OptimizeOn.Preview.il.bsl} | 10 +- ...egateExtensionMethod.fs.OptimizeOn.il.bsl} | 10 +- .../DelegateGenericInstanceMethod.fs | 8 +- ...tanceMethod.fs.OptimizeOff.Preview.il.bsl} | 30 +- ...nericInstanceMethod.fs.OptimizeOff.il.bsl} | 30 +- ...stanceMethod.fs.OptimizeOn.Preview.il.bsl} | 18 +- ...enericInstanceMethod.fs.OptimizeOn.il.bsl} | 18 +- .../DelegateGenericStaticMethod.fs | 12 +- ...taticMethod.fs.OptimizeOff.Preview.il.bsl} | 22 +- ...GenericStaticMethod.fs.OptimizeOff.il.bsl} | 28 +- ...StaticMethod.fs.OptimizeOn.Preview.il.bsl} | 28 +- ...eGenericStaticMethod.fs.OptimizeOn.il.bsl} | 22 +- .../DirectDelegates/DelegateILMethod.fs | 4 +- ...ateILMethod.fs.OptimizeOff.Preview.il.bsl} | 6 +- ...=> DelegateILMethod.fs.OptimizeOff.il.bsl} | 0 ...gateILMethod.fs.OptimizeOn.Preview.il.bsl} | 0 ... => DelegateILMethod.fs.OptimizeOn.il.bsl} | 0 .../DirectDelegates/DelegateInstanceMethod.fs | 16 +- ...tanceMethod.fs.OptimizeOff.Preview.il.bsl} | 38 +- ...egateInstanceMethod.fs.OptimizeOff.il.bsl} | 52 +- ...stanceMethod.fs.OptimizeOn.Preview.il.bsl} | 30 +- ...legateInstanceMethod.fs.OptimizeOn.il.bsl} | 34 +- .../DirectDelegates/DelegateKnownFunction.fs | 17 +- ...ownFunction.fs.OptimizeOff.Preview.il.bsl} | 30 +- ...legateKnownFunction.fs.OptimizeOff.il.bsl} | 28 +- ...nownFunction.fs.OptimizeOn.Preview.il.bsl} | 36 +- ...elegateKnownFunction.fs.OptimizeOn.il.bsl} | 28 +- .../DirectDelegates/DelegateNegativeCases.fs | 17 +- ...gativeCases.fs.OptimizeOff.Preview.il.bsl} | 74 ++- ...legateNegativeCases.fs.OptimizeOff.il.bsl} | 68 +++ ...egativeCases.fs.OptimizeOn.Preview.il.bsl} | 74 ++- ...elegateNegativeCases.fs.OptimizeOn.il.bsl} | 68 +++ .../DirectDelegates/DelegateNonInlinable.fs | 30 +- ...onInlinable.fs.OptimizeOff.Preview.il.bsl} | 36 +- ...elegateNonInlinable.fs.OptimizeOff.il.bsl} | 90 +-- ...NonInlinable.fs.OptimizeOn.Preview.il.bsl} | 34 +- ...DelegateNonInlinable.fs.OptimizeOn.il.bsl} | 90 +-- .../DelegatePartialApplication.fs | 11 +- ...Application.fs.OptimizeOff.Preview.il.bsl} | 34 +- ...ePartialApplication.fs.OptimizeOff.il.bsl} | 40 +- ...lApplication.fs.OptimizeOn.Preview.il.bsl} | 12 +- ...tePartialApplication.fs.OptimizeOn.il.bsl} | 18 +- .../DirectDelegates/DelegateStaticMethod.fs | 18 +- ...taticMethod.fs.OptimizeOff.Preview.il.bsl} | 22 +- ...elegateStaticMethod.fs.OptimizeOff.il.bsl} | 28 +- ...StaticMethod.fs.OptimizeOn.Preview.il.bsl} | 28 +- ...DelegateStaticMethod.fs.OptimizeOn.il.bsl} | 28 +- .../DirectDelegates/DelegateStructTarget.fs | 2 + ...tructTarget.fs.OptimizeOff.Preview.il.bsl} | 20 +- ...elegateStructTarget.fs.OptimizeOff.il.bsl} | 24 +- ...StructTarget.fs.OptimizeOn.Preview.il.bsl} | 20 +- ...DelegateStructTarget.fs.OptimizeOn.il.bsl} | 24 +- .../DirectDelegates/DelegateUnitArg.fs | 4 +- ...gateUnitArg.fs.OptimizeOff.Preview.il.bsl} | 0 ... => DelegateUnitArg.fs.OptimizeOff.il.bsl} | 0 ...egateUnitArg.fs.OptimizeOn.Preview.il.bsl} | 0 ...l => DelegateUnitArg.fs.OptimizeOn.il.bsl} | 0 .../DirectDelegates/DelegateUnitReturn.fs | 4 + ...eUnitReturn.fs.OptimizeOff.Preview.il.bsl} | 16 +- ... DelegateUnitReturn.fs.OptimizeOff.il.bsl} | 18 +- ...teUnitReturn.fs.OptimizeOn.Preview.il.bsl} | 8 +- ...> DelegateUnitReturn.fs.OptimizeOn.il.bsl} | 18 +- .../DirectDelegates/DirectDelegates.fs | 571 +++++++++++------- 72 files changed, 1356 insertions(+), 914 deletions(-) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl => DelegateCustomType.fs.OptimizeOff.Preview.il.bsl} (95%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOff.il.bsl => DelegateCustomType.fs.OptimizeOff.il.bsl} (94%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl => DelegateCustomType.fs.OptimizeOn.Preview.il.bsl} (98%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOn.il.bsl => DelegateCustomType.fs.OptimizeOn.il.bsl} (94%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl => DelegateExtensionMethod.fs.OptimizeOff.Preview.il.bsl} (95%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl => DelegateExtensionMethod.fs.OptimizeOff.il.bsl} (95%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl => DelegateExtensionMethod.fs.OptimizeOn.Preview.il.bsl} (95%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl => DelegateExtensionMethod.fs.OptimizeOn.il.bsl} (95%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl => DelegateGenericInstanceMethod.fs.OptimizeOff.Preview.il.bsl} (84%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl => DelegateGenericInstanceMethod.fs.OptimizeOff.il.bsl} (84%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl => DelegateGenericInstanceMethod.fs.OptimizeOn.Preview.il.bsl} (89%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl => DelegateGenericInstanceMethod.fs.OptimizeOn.il.bsl} (89%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl => DelegateGenericStaticMethod.fs.OptimizeOff.Preview.il.bsl} (90%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl => DelegateGenericStaticMethod.fs.OptimizeOff.il.bsl} (88%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl => DelegateGenericStaticMethod.fs.OptimizeOn.Preview.il.bsl} (87%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl => DelegateGenericStaticMethod.fs.OptimizeOn.il.bsl} (90%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl => DelegateILMethod.fs.OptimizeOff.Preview.il.bsl} (95%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl => DelegateILMethod.fs.OptimizeOff.il.bsl} (100%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl => DelegateILMethod.fs.OptimizeOn.Preview.il.bsl} (100%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl => DelegateILMethod.fs.OptimizeOn.il.bsl} (100%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl => DelegateInstanceMethod.fs.OptimizeOff.Preview.il.bsl} (86%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl => DelegateInstanceMethod.fs.OptimizeOff.il.bsl} (84%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl => DelegateInstanceMethod.fs.OptimizeOn.Preview.il.bsl} (88%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl => DelegateInstanceMethod.fs.OptimizeOn.il.bsl} (87%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl => DelegateKnownFunction.fs.OptimizeOff.Preview.il.bsl} (89%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.il.bsl => DelegateKnownFunction.fs.OptimizeOff.il.bsl} (91%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl => DelegateKnownFunction.fs.OptimizeOn.Preview.il.bsl} (87%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOn.il.bsl => DelegateKnownFunction.fs.OptimizeOn.il.bsl} (89%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOff.il.bsl => DelegateNegativeCases.fs.OptimizeOff.Preview.il.bsl} (78%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl => DelegateNegativeCases.fs.OptimizeOff.il.bsl} (79%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl => DelegateNegativeCases.fs.OptimizeOn.Preview.il.bsl} (76%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOn.il.bsl => DelegateNegativeCases.fs.OptimizeOn.il.bsl} (77%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl => DelegateNonInlinable.fs.OptimizeOff.Preview.il.bsl} (95%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.il.bsl => DelegateNonInlinable.fs.OptimizeOff.il.bsl} (91%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl => DelegateNonInlinable.fs.OptimizeOn.Preview.il.bsl} (93%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.il.bsl => DelegateNonInlinable.fs.OptimizeOn.il.bsl} (91%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl => DelegatePartialApplication.fs.OptimizeOff.Preview.il.bsl} (92%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOff.il.bsl => DelegatePartialApplication.fs.OptimizeOff.il.bsl} (90%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl => DelegatePartialApplication.fs.OptimizeOn.Preview.il.bsl} (95%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOn.il.bsl => DelegatePartialApplication.fs.OptimizeOn.il.bsl} (93%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl => DelegateStaticMethod.fs.OptimizeOff.Preview.il.bsl} (92%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl => DelegateStaticMethod.fs.OptimizeOff.il.bsl} (91%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl => DelegateStaticMethod.fs.OptimizeOn.Preview.il.bsl} (90%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl => DelegateStaticMethod.fs.OptimizeOn.il.bsl} (90%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOff.il.bsl => DelegateStructTarget.fs.OptimizeOff.Preview.il.bsl} (97%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl => DelegateStructTarget.fs.OptimizeOff.il.bsl} (96%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOn.il.bsl => DelegateStructTarget.fs.OptimizeOn.Preview.il.bsl} (97%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl => DelegateStructTarget.fs.OptimizeOn.il.bsl} (96%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl => DelegateUnitArg.fs.OptimizeOff.Preview.il.bsl} (100%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOff.il.bsl => DelegateUnitArg.fs.OptimizeOff.il.bsl} (100%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl => DelegateUnitArg.fs.OptimizeOn.Preview.il.bsl} (100%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOn.il.bsl => DelegateUnitArg.fs.OptimizeOn.il.bsl} (100%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl => DelegateUnitReturn.fs.OptimizeOff.Preview.il.bsl} (92%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOn.il.bsl => DelegateUnitReturn.fs.OptimizeOff.il.bsl} (93%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl => DelegateUnitReturn.fs.OptimizeOn.Preview.il.bsl} (95%) rename tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/{DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOff.il.bsl => DelegateUnitReturn.fs.OptimizeOn.il.bsl} (93%) diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index d95fe298b92..ff83e60226c 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -7514,19 +7514,27 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, // The type checker has already verified that the delegate is built from a compatible function // shape, and the structural match above forwards the Invoke parameters verbatim, so the - // target's signature is compatible with the delegate's Invoke by construction. We just confirm - // the compiled shape lines up: - // - for a non-generic target, identical parameter and return types (cheap and exact); - // - for a generic target, matching parameter count (the formal signature is written in terms - // of type variables, so an exact type comparison here is not meaningful; arity rejects - // unit-elision / param-array / tupled-arity mismatches). - // For an instance method the receiver is implicit and does not appear in FormalArgTypes. + // target's signature is compatible with the delegate's Invoke by construction. We confirm: + // - parameter *count* matches (already guaranteed by the verbatim forwarding, so essentially + // a sanity check). We deliberately do not compare parameter IL *types*: a value-type + // parameter is exact by construction (a widening/boxing argument would not be a verbatim + // Val and so would not have matched), and for reference-type parameters the CLR's delegate + // relaxation permits contravariance, so an exact comparison would only produce false + // negatives (a CLR-legal binding bailing to a closure). + // - for a non-generic target, the return type matches exactly. This is the one IL mismatch + // the recognizer cannot see and the CLR will not relax: notably an F# 'unit' return + // compiled to 'void' versus a delegate whose Invoke returns 'Unit'. For a generic target + // the return is written in terms of type variables, so no exact comparison is meaningful. let signatureMatches (ilEnclArgTys: ILType list) (ilMethArgTys: ILType list) (targetMspec: ILMethodSpec) = - if List.isEmpty ilEnclArgTys && List.isEmpty ilMethArgTys then - typesOfILParams ilDelegeeParams = targetMspec.FormalArgTypes - && ilDelegeeRet.Type = targetMspec.FormalReturnType - else - targetMspec.FormalArgTypes.Length = ilDelegeeParams.Length + let arityMatches = targetMspec.FormalArgTypes.Length = ilDelegeeParams.Length + + let returnMatches = + if List.isEmpty ilEnclArgTys && List.isEmpty ilMethArgTys then + ilDelegeeRet.Type = targetMspec.FormalReturnType + else + true + + arityMatches && returnMatches let receiverInfo virtualCall = match leadingArgs with diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs index 0ff380ea4cb..02f6b3101ad 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs @@ -24,17 +24,24 @@ type C() = member _.M (x: int) (y: int) : int = x * y // Tupled-signature custom delegate: Invoke(int, int). +// 30. non-eta module function, custom delegate let tupledNonEta () = DTupled(acc) +// 15. eta module function, custom delegate let tupledEta () = DTupled(fun a b -> acc a b) // Instance member through a custom delegate: the receiver becomes the delegate's Target. +// 31. non-eta instance member, custom delegate let instanceNonEta (c: C) = DTupled(c.M) +// 16. eta instance member, custom delegate let instanceEta (c: C) = DTupled(fun a b -> c.M a b) // Generic custom delegate instantiated at int: Invoke(int):int over the generic target. +// 32. non-eta generic method, generic custom delegate let genNonEta () = DGen(ident) +// 17. eta generic method, generic custom delegate let genEta () = DGen(fun x -> ident x) // byref-parameter custom delegate: the body mutates through the byref, so it is not a transparent forwarding // call and stays a closure. Documents that a byref Invoke parameter does not break the recognizer. +// 53. byref-parameter delegate (mutating body) let byrefMutate () = DByref(fun x -> x <- x + 1) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOff.Preview.il.bsl similarity index 95% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOff.Preview.il.bsl index 2dc27dab7c4..ebf7fcb3ce1 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOff.Preview.il.bsl @@ -141,7 +141,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledEta@28 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledEta@30 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -159,7 +159,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname instanceEta@32 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname instanceEta@36 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -170,7 +170,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/instanceEta@32::c + IL_0002: stfld class assembly/C assembly/instanceEta@36::c IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -181,7 +181,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/instanceEta@32::c + IL_0001: ldfld class assembly/C assembly/instanceEta@36::c IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance int32 assembly/C::M(int32, @@ -191,7 +191,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genEta@36 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genEta@42 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -206,7 +206,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname byrefMutate@40 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname byrefMutate@47 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -264,7 +264,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/tupledEta@28::Invoke(int32, + IL_0001: ldftn int32 assembly/tupledEta@30::Invoke(int32, int32) IL_0007: newobj instance void assembly/DTupled::.ctor(object, native int) @@ -288,8 +288,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/instanceEta@32::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/instanceEta@32::Invoke(int32, + IL_0001: newobj instance void assembly/instanceEta@36::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/instanceEta@36::Invoke(int32, int32) IL_000c: newobj instance void assembly/DTupled::.ctor(object, native int) @@ -312,7 +312,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/genEta@36::Invoke(int32) + IL_0001: ldftn int32 assembly/genEta@42::Invoke(int32) IL_0007: newobj instance void class assembly/DGen`1::.ctor(object, native int) IL_000c: ret @@ -323,7 +323,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/byrefMutate@40::Invoke(int32&) + IL_0001: ldftn void assembly/byrefMutate@47::Invoke(int32&) IL_0007: newobj instance void assembly/DByref::.ctor(object, native int) IL_000c: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOff.il.bsl similarity index 94% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOff.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOff.il.bsl index f5f71c0f124..0441b15c935 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOff.il.bsl @@ -141,7 +141,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledNonEta@27 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledNonEta@28 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -159,7 +159,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledEta@28 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledEta@30 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -177,7 +177,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname instanceNonEta@31 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname instanceNonEta@34 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -188,7 +188,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/instanceNonEta@31::c + IL_0002: stfld class assembly/C assembly/instanceNonEta@34::c IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -199,7 +199,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/instanceNonEta@31::c + IL_0001: ldfld class assembly/C assembly/instanceNonEta@34::c IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance int32 assembly/C::M(int32, @@ -209,7 +209,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname instanceEta@32 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname instanceEta@36 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -220,7 +220,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/instanceEta@32::c + IL_0002: stfld class assembly/C assembly/instanceEta@36::c IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -231,7 +231,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/instanceEta@32::c + IL_0001: ldfld class assembly/C assembly/instanceEta@36::c IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance int32 assembly/C::M(int32, @@ -241,7 +241,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genNonEta@35 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genNonEta@40 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -256,7 +256,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genEta@36 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genEta@42 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -271,7 +271,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname byrefMutate@40 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname byrefMutate@47 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -317,7 +317,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/tupledNonEta@27::Invoke(int32, + IL_0001: ldftn int32 assembly/tupledNonEta@28::Invoke(int32, int32) IL_0007: newobj instance void assembly/DTupled::.ctor(object, native int) @@ -329,7 +329,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/tupledEta@28::Invoke(int32, + IL_0001: ldftn int32 assembly/tupledEta@30::Invoke(int32, int32) IL_0007: newobj instance void assembly/DTupled::.ctor(object, native int) @@ -341,8 +341,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/instanceNonEta@31::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/instanceNonEta@31::Invoke(int32, + IL_0001: newobj instance void assembly/instanceNonEta@34::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/instanceNonEta@34::Invoke(int32, int32) IL_000c: newobj instance void assembly/DTupled::.ctor(object, native int) @@ -354,8 +354,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/instanceEta@32::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/instanceEta@32::Invoke(int32, + IL_0001: newobj instance void assembly/instanceEta@36::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/instanceEta@36::Invoke(int32, int32) IL_000c: newobj instance void assembly/DTupled::.ctor(object, native int) @@ -367,7 +367,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/genNonEta@35::Invoke(int32) + IL_0001: ldftn int32 assembly/genNonEta@40::Invoke(int32) IL_0007: newobj instance void class assembly/DGen`1::.ctor(object, native int) IL_000c: ret @@ -378,7 +378,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/genEta@36::Invoke(int32) + IL_0001: ldftn int32 assembly/genEta@42::Invoke(int32) IL_0007: newobj instance void class assembly/DGen`1::.ctor(object, native int) IL_000c: ret @@ -389,7 +389,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/byrefMutate@40::Invoke(int32&) + IL_0001: ldftn void assembly/byrefMutate@47::Invoke(int32&) IL_0007: newobj instance void assembly/DByref::.ctor(object, native int) IL_000c: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOn.Preview.il.bsl similarity index 98% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOn.Preview.il.bsl index e893cc9de1b..2b9e0be2d12 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOn.Preview.il.bsl @@ -141,7 +141,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname byrefMutate@40 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname byrefMutate@47 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -257,7 +257,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/byrefMutate@40::Invoke(int32&) + IL_0001: ldftn void assembly/byrefMutate@47::Invoke(int32&) IL_0007: newobj instance void assembly/DByref::.ctor(object, native int) IL_000c: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOn.il.bsl similarity index 94% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOn.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOn.il.bsl index f5f71c0f124..0441b15c935 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOn.il.bsl @@ -141,7 +141,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledNonEta@27 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledNonEta@28 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -159,7 +159,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledEta@28 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledEta@30 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -177,7 +177,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname instanceNonEta@31 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname instanceNonEta@34 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -188,7 +188,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/instanceNonEta@31::c + IL_0002: stfld class assembly/C assembly/instanceNonEta@34::c IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -199,7 +199,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/instanceNonEta@31::c + IL_0001: ldfld class assembly/C assembly/instanceNonEta@34::c IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance int32 assembly/C::M(int32, @@ -209,7 +209,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname instanceEta@32 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname instanceEta@36 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -220,7 +220,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/instanceEta@32::c + IL_0002: stfld class assembly/C assembly/instanceEta@36::c IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -231,7 +231,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/instanceEta@32::c + IL_0001: ldfld class assembly/C assembly/instanceEta@36::c IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance int32 assembly/C::M(int32, @@ -241,7 +241,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genNonEta@35 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genNonEta@40 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -256,7 +256,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genEta@36 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genEta@42 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -271,7 +271,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname byrefMutate@40 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname byrefMutate@47 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -317,7 +317,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/tupledNonEta@27::Invoke(int32, + IL_0001: ldftn int32 assembly/tupledNonEta@28::Invoke(int32, int32) IL_0007: newobj instance void assembly/DTupled::.ctor(object, native int) @@ -329,7 +329,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/tupledEta@28::Invoke(int32, + IL_0001: ldftn int32 assembly/tupledEta@30::Invoke(int32, int32) IL_0007: newobj instance void assembly/DTupled::.ctor(object, native int) @@ -341,8 +341,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/instanceNonEta@31::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/instanceNonEta@31::Invoke(int32, + IL_0001: newobj instance void assembly/instanceNonEta@34::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/instanceNonEta@34::Invoke(int32, int32) IL_000c: newobj instance void assembly/DTupled::.ctor(object, native int) @@ -354,8 +354,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/instanceEta@32::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/instanceEta@32::Invoke(int32, + IL_0001: newobj instance void assembly/instanceEta@36::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/instanceEta@36::Invoke(int32, int32) IL_000c: newobj instance void assembly/DTupled::.ctor(object, native int) @@ -367,7 +367,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/genNonEta@35::Invoke(int32) + IL_0001: ldftn int32 assembly/genNonEta@40::Invoke(int32) IL_0007: newobj instance void class assembly/DGen`1::.ctor(object, native int) IL_000c: ret @@ -378,7 +378,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/genEta@36::Invoke(int32) + IL_0001: ldftn int32 assembly/genEta@42::Invoke(int32) IL_0007: newobj instance void class assembly/DGen`1::.ctor(object, native int) IL_000c: ret @@ -389,7 +389,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/byrefMutate@40::Invoke(int32&) + IL_0001: ldftn void assembly/byrefMutate@47::Invoke(int32&) IL_0007: newobj instance void assembly/DByref::.ctor(object, native int) IL_000c: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs index 7eba16766c9..e1118463d0b 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs @@ -15,4 +15,5 @@ type HolderExtensions = // An extension member compiles to a static method whose first parameter is the receiver, so using it as a // delegate target binds that receiver as a leading argument - a partial application, which has no closed // direct-delegate form. A closure must remain regardless of langversion. +// 52. extension member (receiver is a leading static arg) let extensionEta (h: Holder) = Func(fun a b -> h.Combine(a, b)) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOff.Preview.il.bsl similarity index 95% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOff.Preview.il.bsl index 7347dab3c0d..66377f64db4 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOff.Preview.il.bsl @@ -71,7 +71,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname extensionEta@18 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname extensionEta@19 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -82,7 +82,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/Holder assembly/extensionEta@18::h + IL_0002: stfld class assembly/Holder assembly/extensionEta@19::h IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -93,7 +93,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/Holder assembly/extensionEta@18::h + IL_0001: ldfld class assembly/Holder assembly/extensionEta@19::h IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: call int32 assembly/HolderExtensions::Combine(class assembly/Holder, @@ -109,8 +109,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/extensionEta@18::.ctor(class assembly/Holder) - IL_0006: ldftn instance int32 assembly/extensionEta@18::Invoke(int32, + IL_0001: newobj instance void assembly/extensionEta@19::.ctor(class assembly/Holder) + IL_0006: ldftn instance int32 assembly/extensionEta@19::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOff.il.bsl similarity index 95% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOff.il.bsl index 0b7acdc3542..bdc4971648a 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOff.il.bsl @@ -71,7 +71,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname extensionEta@18 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname extensionEta@19 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -82,7 +82,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/Holder assembly/extensionEta@18::h + IL_0002: stfld class assembly/Holder assembly/extensionEta@19::h IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -93,7 +93,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/Holder assembly/extensionEta@18::h + IL_0001: ldfld class assembly/Holder assembly/extensionEta@19::h IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: call int32 assembly/HolderExtensions::Combine(class assembly/Holder, @@ -109,8 +109,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/extensionEta@18::.ctor(class assembly/Holder) - IL_0006: ldftn instance int32 assembly/extensionEta@18::Invoke(int32, + IL_0001: newobj instance void assembly/extensionEta@19::.ctor(class assembly/Holder) + IL_0006: ldftn instance int32 assembly/extensionEta@19::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOn.Preview.il.bsl similarity index 95% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOn.Preview.il.bsl index 7347dab3c0d..66377f64db4 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOn.Preview.il.bsl @@ -71,7 +71,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname extensionEta@18 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname extensionEta@19 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -82,7 +82,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/Holder assembly/extensionEta@18::h + IL_0002: stfld class assembly/Holder assembly/extensionEta@19::h IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -93,7 +93,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/Holder assembly/extensionEta@18::h + IL_0001: ldfld class assembly/Holder assembly/extensionEta@19::h IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: call int32 assembly/HolderExtensions::Combine(class assembly/Holder, @@ -109,8 +109,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/extensionEta@18::.ctor(class assembly/Holder) - IL_0006: ldftn instance int32 assembly/extensionEta@18::Invoke(int32, + IL_0001: newobj instance void assembly/extensionEta@19::.ctor(class assembly/Holder) + IL_0006: ldftn instance int32 assembly/extensionEta@19::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOn.il.bsl similarity index 95% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOn.il.bsl index 0b7acdc3542..bdc4971648a 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOn.il.bsl @@ -71,7 +71,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname extensionEta@18 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname extensionEta@19 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -82,7 +82,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/Holder assembly/extensionEta@18::h + IL_0002: stfld class assembly/Holder assembly/extensionEta@19::h IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -93,7 +93,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/Holder assembly/extensionEta@18::h + IL_0001: ldfld class assembly/Holder assembly/extensionEta@19::h IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: call int32 assembly/HolderExtensions::Combine(class assembly/Holder, @@ -109,8 +109,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/extensionEta@18::.ctor(class assembly/Holder) - IL_0006: ldftn instance int32 assembly/extensionEta@18::Invoke(int32, + IL_0001: newobj instance void assembly/extensionEta@19::.ctor(class assembly/Holder) + IL_0006: ldftn instance int32 assembly/extensionEta@19::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs index 6f3e738f6fa..76adc561105 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs @@ -6,8 +6,8 @@ type C() = member _.IMc<'T> (x: 'T) (y: 'T) : unit = () member _.IMt<'T> (x: 'T, y: 'T) : unit = () -// 13. eta-expanded, generic instance method, curried application -let case13_etaCurried (o: C) = Action(fun a b -> o.IMc a b) +// 5. eta generic instance method (curried application) +let case5_etaCurried (o: C) = Action(fun a b -> o.IMc a b) -// 14. eta-expanded, generic instance method, tupled application -let case14_etaTupled (o: C) = Action(fun a b -> o.IMt(a, b)) +// 37. eta generic instance method, tupled application +let case37_etaTupled (o: C) = Action(fun a b -> o.IMt(a, b)) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOff.Preview.il.bsl similarity index 84% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOff.Preview.il.bsl index b9299772df1..154f0d0415a 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOff.Preview.il.bsl @@ -65,7 +65,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname case13_etaCurried@10 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case5_etaCurried@10 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -76,7 +76,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/case13_etaCurried@10::o + IL_0002: stfld class assembly/C assembly/case5_etaCurried@10::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -87,7 +87,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/case13_etaCurried@10::o + IL_0001: ldfld class assembly/C assembly/case5_etaCurried@10::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance void assembly/C::IMc(!!0, @@ -98,7 +98,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname case14_etaTupled@13 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case37_etaTupled@13 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -109,7 +109,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/case14_etaTupled@13::o + IL_0002: stfld class assembly/C assembly/case37_etaTupled@13::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -120,7 +120,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/case14_etaTupled@13::o + IL_0001: ldfld class assembly/C assembly/case37_etaTupled@13::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance void assembly/C::IMt(!!0, @@ -131,29 +131,29 @@ } - .method public static class [runtime]System.Action`2 case13_etaCurried(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case5_etaCurried(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/case13_etaCurried@10::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/case13_etaCurried@10::Invoke(int32, - int32) + IL_0001: newobj instance void assembly/case5_etaCurried@10::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case5_etaCurried@10::Invoke(int32, + int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_0011: ret } - .method public static class [runtime]System.Action`2 case14_etaTupled(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case37_etaTupled(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/case14_etaTupled@13::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/case14_etaTupled@13::Invoke(int32, + IL_0001: newobj instance void assembly/case37_etaTupled@13::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case37_etaTupled@13::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_0011: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOff.il.bsl similarity index 84% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOff.il.bsl index b9299772df1..154f0d0415a 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOff.il.bsl @@ -65,7 +65,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname case13_etaCurried@10 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case5_etaCurried@10 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -76,7 +76,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/case13_etaCurried@10::o + IL_0002: stfld class assembly/C assembly/case5_etaCurried@10::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -87,7 +87,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/case13_etaCurried@10::o + IL_0001: ldfld class assembly/C assembly/case5_etaCurried@10::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance void assembly/C::IMc(!!0, @@ -98,7 +98,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname case14_etaTupled@13 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case37_etaTupled@13 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -109,7 +109,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/case14_etaTupled@13::o + IL_0002: stfld class assembly/C assembly/case37_etaTupled@13::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -120,7 +120,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/case14_etaTupled@13::o + IL_0001: ldfld class assembly/C assembly/case37_etaTupled@13::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance void assembly/C::IMt(!!0, @@ -131,29 +131,29 @@ } - .method public static class [runtime]System.Action`2 case13_etaCurried(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case5_etaCurried(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/case13_etaCurried@10::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/case13_etaCurried@10::Invoke(int32, - int32) + IL_0001: newobj instance void assembly/case5_etaCurried@10::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case5_etaCurried@10::Invoke(int32, + int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_0011: ret } - .method public static class [runtime]System.Action`2 case14_etaTupled(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case37_etaTupled(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/case14_etaTupled@13::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/case14_etaTupled@13::Invoke(int32, + IL_0001: newobj instance void assembly/case37_etaTupled@13::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case37_etaTupled@13::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_0011: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOn.Preview.il.bsl similarity index 89% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOn.Preview.il.bsl index 6836a936968..9e16587d173 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOn.Preview.il.bsl @@ -65,7 +65,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case13_etaCurried@10 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case5_etaCurried@10 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -79,7 +79,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case14_etaTupled@13 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case37_etaTupled@13 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -93,27 +93,27 @@ } - .method public static class [runtime]System.Action`2 case13_etaCurried(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case5_etaCurried(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case13_etaCurried@10::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case5_etaCurried@10::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case14_etaTupled(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case37_etaTupled(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case14_etaTupled@13::Invoke(int32, + IL_0001: ldftn void assembly/case37_etaTupled@13::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOn.il.bsl similarity index 89% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOn.il.bsl index 6836a936968..9e16587d173 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOn.il.bsl @@ -65,7 +65,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case13_etaCurried@10 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case5_etaCurried@10 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -79,7 +79,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case14_etaTupled@13 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case37_etaTupled@13 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -93,27 +93,27 @@ } - .method public static class [runtime]System.Action`2 case13_etaCurried(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case5_etaCurried(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case13_etaCurried@10::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case5_etaCurried@10::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case14_etaTupled(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case37_etaTupled(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case14_etaTupled@13::Invoke(int32, + IL_0001: ldftn void assembly/case37_etaTupled@13::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs index b48e9130735..f35b3caf46d 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs @@ -6,11 +6,11 @@ type G<'U> = static member SMc<'T> (x: 'T) (y: 'T) : unit = () static member SMt<'T> (x: 'T, y: 'T) : unit = () -// 7. non-eta-expanded generic static method (generic type + generic method) -let case7_nonEta () = Action(G.SMc) +// 20. non-eta generic static method (generic type + generic method) +let case20_nonEta () = Action(G.SMc) -// 8. eta-expanded, curried application -let case8_etaCurried () = Action(fun a b -> G.SMc a b) +// 3. eta generic static method (curried application) +let case3_etaCurried () = Action(fun a b -> G.SMc a b) -// 9. eta-expanded, tupled application -let case9_etaTupled () = Action(fun a b -> G.SMt(a, b)) +// 35. eta generic static method, tupled application +let case35_etaTupled () = Action(fun a b -> G.SMt(a, b)) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOff.Preview.il.bsl similarity index 90% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOff.Preview.il.bsl index bc63a786879..0f0dd9201ea 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOff.Preview.il.bsl @@ -56,7 +56,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case8_etaCurried@13 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case3_etaCurried@13 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -75,7 +75,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case9_etaTupled@16 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case35_etaTupled@16 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -94,7 +94,7 @@ } - .method public static class [runtime]System.Action`2 case7_nonEta() cil managed + .method public static class [runtime]System.Action`2 case20_nonEta() cil managed { .maxstack 8 @@ -102,31 +102,31 @@ IL_0001: ldftn void class assembly/G`1::SMc(!!0, !!0) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case8_etaCurried() cil managed + .method public static class [runtime]System.Action`2 case3_etaCurried() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case8_etaCurried@13::Invoke(int32, + IL_0001: ldftn void assembly/case3_etaCurried@13::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case9_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case35_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case9_etaTupled@16::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case35_etaTupled@16::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOff.il.bsl similarity index 88% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOff.il.bsl index 91c5b9cd522..f22ac83b012 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOff.il.bsl @@ -56,7 +56,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case7_nonEta@10 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case20_nonEta@10 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -75,7 +75,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case8_etaCurried@13 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case3_etaCurried@13 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -94,7 +94,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case9_etaTupled@16 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case35_etaTupled@16 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -113,39 +113,39 @@ } - .method public static class [runtime]System.Action`2 case7_nonEta() cil managed + .method public static class [runtime]System.Action`2 case20_nonEta() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case7_nonEta@10::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case20_nonEta@10::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case8_etaCurried() cil managed + .method public static class [runtime]System.Action`2 case3_etaCurried() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case8_etaCurried@13::Invoke(int32, + IL_0001: ldftn void assembly/case3_etaCurried@13::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case9_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case35_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case9_etaTupled@16::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case35_etaTupled@16::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOn.Preview.il.bsl similarity index 87% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOn.Preview.il.bsl index e6bb3aa83fc..d29d01ad424 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOn.Preview.il.bsl @@ -56,7 +56,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case7_nonEta@10 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case20_nonEta@10 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -70,7 +70,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case8_etaCurried@13 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case3_etaCurried@13 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -84,7 +84,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case9_etaTupled@16 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case35_etaTupled@16 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -98,39 +98,39 @@ } - .method public static class [runtime]System.Action`2 case7_nonEta() cil managed + .method public static class [runtime]System.Action`2 case20_nonEta() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case7_nonEta@10::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case20_nonEta@10::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case8_etaCurried() cil managed + .method public static class [runtime]System.Action`2 case3_etaCurried() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case8_etaCurried@13::Invoke(int32, + IL_0001: ldftn void assembly/case3_etaCurried@13::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case9_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case35_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case9_etaTupled@16::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case35_etaTupled@16::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOn.il.bsl similarity index 90% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOn.il.bsl index e6bb3aa83fc..6d706bf6afb 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOn.il.bsl @@ -56,7 +56,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case7_nonEta@10 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case20_nonEta@10 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -70,7 +70,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case8_etaCurried@13 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case3_etaCurried@13 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -84,7 +84,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case9_etaTupled@16 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case35_etaTupled@16 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -98,37 +98,37 @@ } - .method public static class [runtime]System.Action`2 case7_nonEta() cil managed + .method public static class [runtime]System.Action`2 case20_nonEta() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case7_nonEta@10::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case20_nonEta@10::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case8_etaCurried() cil managed + .method public static class [runtime]System.Action`2 case3_etaCurried() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case8_etaCurried@13::Invoke(int32, + IL_0001: ldftn void assembly/case3_etaCurried@13::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case9_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case35_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case9_etaTupled@16::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case35_etaTupled@16::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs index db933f2f73e..04304ab05d0 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs @@ -8,9 +8,9 @@ open System.Text // unoptimized builds the eta form keeps a closure (matching the F# eta policy). See DelegateNonInlinable // for the F#-value equivalent. -// Static IL method (System.Math.Max), eta-expanded. +// 13. eta IL/BCL static method (System.Math.Max). let ilStaticEta () = Func(fun a b -> Math.Max(a, b)) -// Instance IL method (StringBuilder.Append(string)) on a reference type, eta-expanded. The receiver is a +// 14. eta IL/BCL instance method (StringBuilder.Append(string)) on a reference type. The receiver is a // parameter, evaluated at the construction site and carried as the delegate's Target. let ilInstanceEta (sb: StringBuilder) = Func(fun s -> sb.Append(s)) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.OptimizeOff.Preview.il.bsl similarity index 95% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.OptimizeOff.Preview.il.bsl index 718255efb91..12ffd3cce34 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.OptimizeOff.Preview.il.bsl @@ -45,7 +45,7 @@ IL_0000: ldarg.0 IL_0001: ldarg.1 IL_0002: call int32 [runtime]System.Math::Max(int32, - int32) + int32) IL_0007: ret } @@ -89,7 +89,7 @@ IL_0001: ldftn int32 assembly/ilStaticEta@12::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -101,7 +101,7 @@ IL_0001: newobj instance void assembly/ilInstanceEta@16::.ctor(class [runtime]System.Text.StringBuilder) IL_0006: ldftn instance class [runtime]System.Text.StringBuilder assembly/ilInstanceEta@16::Invoke(string) IL_000c: newobj instance void class [runtime]System.Func`2::.ctor(object, - native int) + native int) IL_0011: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.OptimizeOff.il.bsl similarity index 100% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.OptimizeOff.il.bsl diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.OptimizeOn.Preview.il.bsl similarity index 100% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.OptimizeOn.Preview.il.bsl diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.OptimizeOn.il.bsl similarity index 100% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.OptimizeOn.il.bsl diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs index 1701b1c35e6..c76c310d5e9 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs @@ -8,14 +8,14 @@ type C(k: int) = abstract V : int -> int -> unit default _.V (x: int) (y: int) : unit = ignore k -// 10. non-eta-expanded instance method target -let case10_nonEta (o: C) = Action(o.AddC) +// 21. non-eta instance method +let case21_nonEta (o: C) = Action(o.AddC) -// 11. eta-expanded, curried application -let case11_etaCurried (o: C) = Action(fun a b -> o.AddC a b) +// 4. eta instance method (curried application) +let case4_etaCurried (o: C) = Action(fun a b -> o.AddC a b) -// 12. eta-expanded, tupled application -let case12_etaTupled (o: C) = Action(fun a b -> o.AddT(a, b)) +// 36. eta instance method, tupled application +let case36_etaTupled (o: C) = Action(fun a b -> o.AddT(a, b)) -// virtual instance method: a direct delegate must use ldvirtftn (with dup) to preserve dispatch -let caseVirtual (o: C) = Action(o.V) +// 22. non-eta virtual instance method: a direct delegate must use ldvirtftn (with dup) to preserve dispatch +let case22_virtual (o: C) = Action(o.V) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOff.Preview.il.bsl similarity index 86% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOff.Preview.il.bsl index 4e57d30669e..f01abe41e4a 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOff.Preview.il.bsl @@ -89,7 +89,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname case11_etaCurried@15 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case4_etaCurried@15 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -100,7 +100,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/case11_etaCurried@15::o + IL_0002: stfld class assembly/C assembly/case4_etaCurried@15::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -111,7 +111,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/case11_etaCurried@15::o + IL_0001: ldfld class assembly/C assembly/case4_etaCurried@15::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance void assembly/C::AddC(int32, @@ -122,7 +122,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname case12_etaTupled@18 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case36_etaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -133,7 +133,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/case12_etaTupled@18::o + IL_0002: stfld class assembly/C assembly/case36_etaTupled@18::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -144,7 +144,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/case12_etaTupled@18::o + IL_0001: ldfld class assembly/C assembly/case36_etaTupled@18::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance void assembly/C::AddT(int32, @@ -155,7 +155,7 @@ } - .method public static class [runtime]System.Action`2 case10_nonEta(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case21_nonEta(class assembly/C o) cil managed { .maxstack 8 @@ -163,37 +163,37 @@ IL_0001: ldftn instance void assembly/C::AddC(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case11_etaCurried(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case4_etaCurried(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/case11_etaCurried@15::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/case11_etaCurried@15::Invoke(int32, - int32) + IL_0001: newobj instance void assembly/case4_etaCurried@15::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case4_etaCurried@15::Invoke(int32, + int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_0011: ret } - .method public static class [runtime]System.Action`2 case12_etaTupled(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case36_etaTupled(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/case12_etaTupled@18::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/case12_etaTupled@18::Invoke(int32, + IL_0001: newobj instance void assembly/case36_etaTupled@18::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case36_etaTupled@18::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_0011: ret } - .method public static class [runtime]System.Action`2 caseVirtual(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case22_virtual(class assembly/C o) cil managed { .maxstack 8 @@ -202,7 +202,7 @@ IL_0002: ldvirtftn instance void assembly/C::V(int32, int32) IL_0008: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000d: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOff.il.bsl similarity index 84% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOff.il.bsl index b908fa4c200..c5e6b7997f6 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOff.il.bsl @@ -89,7 +89,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname case10_nonEta@12 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case21_nonEta@12 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -100,7 +100,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/case10_nonEta@12::o + IL_0002: stfld class assembly/C assembly/case21_nonEta@12::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -111,7 +111,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/case10_nonEta@12::o + IL_0001: ldfld class assembly/C assembly/case21_nonEta@12::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance void assembly/C::AddC(int32, @@ -122,7 +122,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname case11_etaCurried@15 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case4_etaCurried@15 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -133,7 +133,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/case11_etaCurried@15::o + IL_0002: stfld class assembly/C assembly/case4_etaCurried@15::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -144,7 +144,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/case11_etaCurried@15::o + IL_0001: ldfld class assembly/C assembly/case4_etaCurried@15::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance void assembly/C::AddC(int32, @@ -155,7 +155,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname case12_etaTupled@18 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case36_etaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -166,7 +166,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/case12_etaTupled@18::o + IL_0002: stfld class assembly/C assembly/case36_etaTupled@18::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -177,7 +177,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/case12_etaTupled@18::o + IL_0001: ldfld class assembly/C assembly/case36_etaTupled@18::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance void assembly/C::AddT(int32, @@ -188,7 +188,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname caseVirtual@21 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case22_virtual@21 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -199,7 +199,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/caseVirtual@21::o + IL_0002: stfld class assembly/C assembly/case22_virtual@21::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -210,7 +210,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/caseVirtual@21::o + IL_0001: ldfld class assembly/C assembly/case22_virtual@21::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: tail. @@ -221,53 +221,53 @@ } - .method public static class [runtime]System.Action`2 case10_nonEta(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case21_nonEta(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/case10_nonEta@12::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/case10_nonEta@12::Invoke(int32, + IL_0001: newobj instance void assembly/case21_nonEta@12::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case21_nonEta@12::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_0011: ret } - .method public static class [runtime]System.Action`2 case11_etaCurried(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case4_etaCurried(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/case11_etaCurried@15::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/case11_etaCurried@15::Invoke(int32, - int32) + IL_0001: newobj instance void assembly/case4_etaCurried@15::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case4_etaCurried@15::Invoke(int32, + int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_0011: ret } - .method public static class [runtime]System.Action`2 case12_etaTupled(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case36_etaTupled(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/case12_etaTupled@18::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/case12_etaTupled@18::Invoke(int32, + IL_0001: newobj instance void assembly/case36_etaTupled@18::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case36_etaTupled@18::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_0011: ret } - .method public static class [runtime]System.Action`2 caseVirtual(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case22_virtual(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/caseVirtual@21::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/caseVirtual@21::Invoke(int32, - int32) + IL_0001: newobj instance void assembly/case22_virtual@21::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case22_virtual@21::Invoke(int32, + int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_0011: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOn.Preview.il.bsl similarity index 88% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOn.Preview.il.bsl index 0297f76438f..84816e669f0 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOn.Preview.il.bsl @@ -77,7 +77,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case10_nonEta@12 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case21_nonEta@12 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -91,7 +91,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case11_etaCurried@15 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case4_etaCurried@15 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -105,7 +105,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case12_etaTupled@18 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case36_etaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -119,43 +119,43 @@ } - .method public static class [runtime]System.Action`2 case10_nonEta(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case21_nonEta(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case10_nonEta@12::Invoke(int32, + IL_0001: ldftn void assembly/case21_nonEta@12::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case11_etaCurried(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case4_etaCurried(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case11_etaCurried@15::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case4_etaCurried@15::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case12_etaTupled(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case36_etaTupled(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case12_etaTupled@18::Invoke(int32, + IL_0001: ldftn void assembly/case36_etaTupled@18::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 caseVirtual(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case22_virtual(class assembly/C o) cil managed { .maxstack 8 @@ -164,7 +164,7 @@ IL_0002: ldvirtftn instance void assembly/C::V(int32, int32) IL_0008: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000d: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOn.il.bsl similarity index 87% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOn.il.bsl index 44b0b4cbbd5..71fd756ac65 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOn.il.bsl @@ -77,7 +77,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case10_nonEta@12 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case21_nonEta@12 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -91,7 +91,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case11_etaCurried@15 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case4_etaCurried@15 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -105,7 +105,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case12_etaTupled@18 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case36_etaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -119,7 +119,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname caseVirtual@21 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case22_virtual@21 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -130,7 +130,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/caseVirtual@21::o + IL_0002: stfld class assembly/C assembly/case22_virtual@21::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -141,7 +141,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/caseVirtual@21::o + IL_0001: ldfld class assembly/C assembly/case22_virtual@21::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: tail. @@ -152,50 +152,50 @@ } - .method public static class [runtime]System.Action`2 case10_nonEta(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case21_nonEta(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case10_nonEta@12::Invoke(int32, + IL_0001: ldftn void assembly/case21_nonEta@12::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case11_etaCurried(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case4_etaCurried(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case11_etaCurried@15::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case4_etaCurried@15::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case12_etaTupled(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case36_etaTupled(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case12_etaTupled@18::Invoke(int32, + IL_0001: ldftn void assembly/case36_etaTupled@18::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 caseVirtual(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case22_virtual(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/caseVirtual@21::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/caseVirtual@21::Invoke(int32, - int32) + IL_0001: newobj instance void assembly/case22_virtual@21::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case22_virtual@21::Invoke(int32, + int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_0011: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs index e89b00afc72..50debc1ffcb 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs @@ -7,15 +7,14 @@ let handlerCurried (x: int) (y: int) : unit = () let handlerTupled (x: int, y: int) : unit = () let handler3 (x: int) (y: int) (z: int) : unit = () -// 1. non-eta-expanded known target -let case1_nonEta () = Action(handlerCurried) +// 18. non-eta module function +let case18_nonEta () = Action(handlerCurried) -// 2. eta-expanded known target (curried application) -let case2_etaCurried () = Action(fun a b -> handlerCurried a b) +// 1. eta module function (curried application) +let case1_etaCurried () = Action(fun a b -> handlerCurried a b) -// 3. eta-expanded known target, tupled application, same compiled representation -let case3_etaTupled () = Action(fun a b -> handlerTupled (a, b)) +// 33. eta module function, tupled application (same compiled representation) +let case33_etaTupled () = Action(fun a b -> handlerTupled (a, b)) -// 15. non-eta-expanded known target via partial application -// (currently a closure with "delegateArg0"-style names; proposal: use elided arg names y, z) -let case15_partial () = Action(handler3 1) +// 39. partial application of module function (constant arg) +let case39_partial () = Action(handler3 1) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOff.Preview.il.bsl similarity index 89% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOff.Preview.il.bsl index 977948fe928..e34b7189e73 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOff.Preview.il.bsl @@ -33,7 +33,7 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case2_etaCurried@14 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case1_etaCurried@14 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -52,7 +52,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case3_etaTupled@17 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case33_etaTupled@17 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -71,7 +71,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case15_partial@21 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case39_partial@20 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -120,7 +120,7 @@ IL_0000: ret } - .method public static class [runtime]System.Action`2 case1_nonEta() cil managed + .method public static class [runtime]System.Action`2 case18_nonEta() cil managed { .maxstack 8 @@ -128,43 +128,43 @@ IL_0001: ldftn void assembly::handlerCurried(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case2_etaCurried() cil managed + .method public static class [runtime]System.Action`2 case1_etaCurried() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case2_etaCurried@14::Invoke(int32, + IL_0001: ldftn void assembly/case1_etaCurried@14::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case3_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case33_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case3_etaTupled@17::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case33_etaTupled@17::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case15_partial() cil managed + .method public static class [runtime]System.Action`2 case39_partial() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case15_partial@21::Invoke(int32, + IL_0001: ldftn void assembly/case39_partial@20::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOff.il.bsl similarity index 91% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOff.il.bsl index 9c87cb38678..b1169b274d3 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOff.il.bsl @@ -33,7 +33,7 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case1_nonEta@11 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case18_nonEta@11 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -52,7 +52,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case2_etaCurried@14 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case1_etaCurried@14 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -71,7 +71,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case3_etaTupled@17 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case33_etaTupled@17 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -90,7 +90,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case15_partial@21 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case39_partial@20 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -139,48 +139,48 @@ IL_0000: ret } - .method public static class [runtime]System.Action`2 case1_nonEta() cil managed + .method public static class [runtime]System.Action`2 case18_nonEta() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case1_nonEta@11::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case18_nonEta@11::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case2_etaCurried() cil managed + .method public static class [runtime]System.Action`2 case1_etaCurried() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case2_etaCurried@14::Invoke(int32, + IL_0001: ldftn void assembly/case1_etaCurried@14::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case3_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case33_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case3_etaTupled@17::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case33_etaTupled@17::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case15_partial() cil managed + .method public static class [runtime]System.Action`2 case39_partial() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case15_partial@21::Invoke(int32, + IL_0001: ldftn void assembly/case39_partial@20::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOn.Preview.il.bsl similarity index 87% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOn.Preview.il.bsl index 548f0ecb854..43d1a477c17 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOn.Preview.il.bsl @@ -33,7 +33,7 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case1_nonEta@11 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case18_nonEta@11 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -47,7 +47,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case2_etaCurried@14 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case1_etaCurried@14 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -61,7 +61,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case3_etaTupled@17 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case33_etaTupled@17 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -75,7 +75,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case15_partial@21 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case39_partial@20 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -117,51 +117,51 @@ IL_0000: ret } - .method public static class [runtime]System.Action`2 case1_nonEta() cil managed + .method public static class [runtime]System.Action`2 case18_nonEta() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case1_nonEta@11::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case18_nonEta@11::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case2_etaCurried() cil managed + .method public static class [runtime]System.Action`2 case1_etaCurried() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case2_etaCurried@14::Invoke(int32, + IL_0001: ldftn void assembly/case1_etaCurried@14::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case3_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case33_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case3_etaTupled@17::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case33_etaTupled@17::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case15_partial() cil managed + .method public static class [runtime]System.Action`2 case39_partial() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case15_partial@21::Invoke(int32, + IL_0001: ldftn void assembly/case39_partial@20::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOn.il.bsl similarity index 89% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOn.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOn.il.bsl index 548f0ecb854..6d997901f37 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOn.il.bsl @@ -33,7 +33,7 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case1_nonEta@11 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case18_nonEta@11 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -47,7 +47,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case2_etaCurried@14 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case1_etaCurried@14 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -61,7 +61,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case3_etaTupled@17 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case33_etaTupled@17 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -75,7 +75,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case15_partial@21 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case39_partial@20 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -117,48 +117,48 @@ IL_0000: ret } - .method public static class [runtime]System.Action`2 case1_nonEta() cil managed + .method public static class [runtime]System.Action`2 case18_nonEta() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case1_nonEta@11::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case18_nonEta@11::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case2_etaCurried() cil managed + .method public static class [runtime]System.Action`2 case1_etaCurried() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case2_etaCurried@14::Invoke(int32, + IL_0001: ldftn void assembly/case1_etaCurried@14::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case3_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case33_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case3_etaTupled@17::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case33_etaTupled@17::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case15_partial() cil managed + .method public static class [runtime]System.Action`2 case39_partial() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case15_partial@21::Invoke(int32, + IL_0001: ldftn void assembly/case39_partial@20::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs index 8f177b36053..a18125b447b 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs @@ -2,13 +2,24 @@ module DelegateNegativeCases open System -// first-class function value: there is no target method to point at, so a closure must remain +// 44. first-class function value: there is no target method to point at, so a closure must remain let firstClass (handler: int -> int -> unit) = Action(handler) -// lambda body is not a single direct forwarding call to a known target (the argument is computed, +// 45. lambda body is not a single direct forwarding call to a known target (the argument is computed, // not the delegate parameters forwarded as-is): a closure must remain let private sink (x: int) : unit = () let notDirect (k: int) = Action(fun a b -> sink (a + b + k)) -// arguments reordered: not a transparent forwarding, so a closure must remain +// 46. arguments reordered: not a transparent forwarding, so a closure must remain let reordered (handler: int -> int -> unit) = Action(fun a b -> handler b a) + +type Holder() = + [] + member _.TakesObj (x: obj) : int = 1 + +// 47. Reference-parameter contravariance: the delegate's Invoke is (string):int and the target is (object):int. +// The CLR would accept this binding directly (a delegate may bind a method whose parameter is a supertype), +// but it stays a closure: F# elaborates the 'string -> obj' argument upcast as a coercion, so the forwarded +// argument is no longer a verbatim Invoke parameter and the direct-delegate recognizer does not match. (The +// signature check is not involved - it never even runs here.) +let contra (h: Holder) = System.Func(fun s -> h.TakesObj s) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.Preview.il.bsl similarity index 78% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOff.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.Preview.il.bsl index 32cd386fabb..ca393fa812c 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.Preview.il.bsl @@ -33,6 +33,32 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public Holder + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public specialname rtspecialname instance void .ctor() cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ret + } + + .method public hidebysig instance int32 TakesObj(object x) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.1 + IL_0001: ret + } + + } + .class auto autochar serializable sealed nested assembly beforefieldinit specialname firstClass@6 extends [runtime]System.Object { @@ -135,6 +161,36 @@ } + .class auto autochar serializable sealed nested assembly beforefieldinit specialname contra@25 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/Holder h + .method public specialname rtspecialname instance void .ctor(class assembly/Holder h) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/Holder assembly/contra@25::h + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(string s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/Holder assembly/contra@25::h + IL_0006: ldarg.1 + IL_0007: callvirt instance int32 assembly/Holder::TakesObj(object) + IL_000c: ret + } + + } + .method public static class [runtime]System.Action`2 firstClass(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed { @@ -144,7 +200,7 @@ IL_0006: ldftn instance void assembly/firstClass@6::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_0011: ret } @@ -164,7 +220,7 @@ IL_0006: ldftn instance void assembly/notDirect@11::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_0011: ret } @@ -177,7 +233,19 @@ IL_0006: ldftn instance void assembly/reordered@14::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Func`2 contra(class assembly/Holder h) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/contra@25::.ctor(class assembly/Holder) + IL_0006: ldftn instance int32 assembly/contra@25::Invoke(string) + IL_000c: newobj instance void class [runtime]System.Func`2::.ctor(object, + native int) IL_0011: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.il.bsl similarity index 79% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.il.bsl index 32cd386fabb..8498432adc8 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.il.bsl @@ -33,6 +33,32 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public Holder + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public specialname rtspecialname instance void .ctor() cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ret + } + + .method public hidebysig instance int32 TakesObj(object x) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.1 + IL_0001: ret + } + + } + .class auto autochar serializable sealed nested assembly beforefieldinit specialname firstClass@6 extends [runtime]System.Object { @@ -135,6 +161,36 @@ } + .class auto autochar serializable sealed nested assembly beforefieldinit specialname contra@25 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/Holder h + .method public specialname rtspecialname instance void .ctor(class assembly/Holder h) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/Holder assembly/contra@25::h + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(string s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/Holder assembly/contra@25::h + IL_0006: ldarg.1 + IL_0007: callvirt instance int32 assembly/Holder::TakesObj(object) + IL_000c: ret + } + + } + .method public static class [runtime]System.Action`2 firstClass(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed { @@ -181,6 +237,18 @@ IL_0011: ret } + .method public static class [runtime]System.Func`2 contra(class assembly/Holder h) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/contra@25::.ctor(class assembly/Holder) + IL_0006: ldftn instance int32 assembly/contra@25::Invoke(string) + IL_000c: newobj instance void class [runtime]System.Func`2::.ctor(object, + native int) + IL_0011: ret + } + } .class private abstract auto ansi sealed ''.$assembly diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.Preview.il.bsl similarity index 76% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.Preview.il.bsl index 39878c4a64b..00a429b94a5 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.Preview.il.bsl @@ -33,6 +33,32 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public Holder + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public specialname rtspecialname instance void .ctor() cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ret + } + + .method public hidebysig instance int32 TakesObj(object x) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.1 + IL_0001: ret + } + + } + .class auto autochar serializable sealed nested assembly beforefieldinit specialname firstClass@6 extends [runtime]System.Object { @@ -115,6 +141,36 @@ } + .class auto autochar serializable sealed nested assembly beforefieldinit specialname contra@25 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/Holder h + .method public specialname rtspecialname instance void .ctor(class assembly/Holder h) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/Holder assembly/contra@25::h + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(string s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/Holder assembly/contra@25::h + IL_0006: ldarg.1 + IL_0007: callvirt instance int32 assembly/Holder::TakesObj(object) + IL_000c: ret + } + + } + .method public static class [runtime]System.Action`2 firstClass(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed { @@ -124,7 +180,7 @@ IL_0006: ldftn instance void assembly/firstClass@6::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_0011: ret } @@ -143,7 +199,7 @@ IL_0001: ldftn void assembly/notDirect@11::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } @@ -156,7 +212,19 @@ IL_0006: ldftn instance void assembly/reordered@14::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Func`2 contra(class assembly/Holder h) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/contra@25::.ctor(class assembly/Holder) + IL_0006: ldftn instance int32 assembly/contra@25::Invoke(string) + IL_000c: newobj instance void class [runtime]System.Func`2::.ctor(object, + native int) IL_0011: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.il.bsl similarity index 77% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOn.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.il.bsl index 39878c4a64b..25621c1ba07 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.il.bsl @@ -33,6 +33,32 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable nested public Holder + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public specialname rtspecialname instance void .ctor() cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ret + } + + .method public hidebysig instance int32 TakesObj(object x) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.1 + IL_0001: ret + } + + } + .class auto autochar serializable sealed nested assembly beforefieldinit specialname firstClass@6 extends [runtime]System.Object { @@ -115,6 +141,36 @@ } + .class auto autochar serializable sealed nested assembly beforefieldinit specialname contra@25 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/Holder h + .method public specialname rtspecialname instance void .ctor(class assembly/Holder h) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/Holder assembly/contra@25::h + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance int32 Invoke(string s) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/Holder assembly/contra@25::h + IL_0006: ldarg.1 + IL_0007: callvirt instance int32 assembly/Holder::TakesObj(object) + IL_000c: ret + } + + } + .method public static class [runtime]System.Action`2 firstClass(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed { @@ -160,6 +216,18 @@ IL_0011: ret } + .method public static class [runtime]System.Func`2 contra(class assembly/Holder h) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/contra@25::.ctor(class assembly/Holder) + IL_0006: ldftn instance int32 assembly/contra@25::Invoke(string) + IL_000c: newobj instance void class [runtime]System.Func`2::.ctor(object, + native int) + IL_0011: ret + } + } .class private abstract auto ansi sealed ''.$assembly diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs index 1cf2e00e70f..d1457922935 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs @@ -2,37 +2,29 @@ module DelegateNonInlinable open System -// Section D, bullet 1: the optimizer inlines small function bodies before IlxGen runs. If a delegate -// target is inlined away in release/Optimize+ builds, the forwarding call no longer survives and the -// direct-delegate recognizer has nothing to fire on. To prove the release path is actually exercised we -// need targets the optimizer will NOT inline. [] forces ValInline.Never, so the -// forwarding call is guaranteed to reach IlxGen regardless of how small the body is (see -// ComputeInlineFlag in CheckExpressions.fs). Bodies are arithmetic only (TFM-stable, no BCL calls) and -// Func<_,_,_> is used so the result is observable. - [] let accCurried (x: int) (y: int) : int = x + y [] let accTupled (x: int, y: int) : int = x + y -// non-inlinable known target, non-eta-expanded +// 23. non-eta module function, non-inlinable let niNonEta () = Func(accCurried) -// non-inlinable known target, eta-expanded, curried application +// 6. eta module function, non-inlinable (curried application) let niEtaCurried () = Func(fun a b -> accCurried a b) -// non-inlinable known target, eta-expanded, tupled application +// 38. eta module function, non-inlinable, tupled application let niEtaTupled () = Func(fun a b -> accTupled (a, b)) type S = [] static member AccS (x: int) (y: int) : int = x + y -// non-inlinable static target, non-eta-expanded +// 24. non-eta static method, non-inlinable let niStaticNonEta () = Func(S.AccS) -// non-inlinable static target, eta-expanded +// 7. eta static method, non-inlinable let niStaticEta () = Func(fun a b -> S.AccS a b) type C(k: int) = @@ -42,24 +34,26 @@ type C(k: int) = [] member _.GPick<'T> (x: 'T) (y: 'T) : 'T = x -// non-inlinable instance target, non-eta-expanded +// 25. non-eta instance method, non-inlinable let niInstanceNonEta (o: C) = Func(o.AccC) -// non-inlinable instance target, eta-expanded +// 8. eta instance method, non-inlinable let niInstanceEta (o: C) = Func(fun a b -> o.AccC a b) -// non-inlinable generic instance target, non-eta-expanded +// 26. non-eta generic instance method, non-inlinable let niGenericInstanceNonEta (o: C) = Func(o.GPick) -// non-inlinable generic instance target, eta-expanded +// 9. eta generic instance method, non-inlinable let niGenericInstanceEta (o: C) = Func(fun a b -> o.GPick a b) -// Section D, bullet 1 (the contrast case): a trivial, inlinable target kept on purpose to document and +// A trivial, inlinable target kept on purpose to document and // guard the inline-vs-direct interaction. In release the optimizer may inline the body before the // recognizer runs; the recognizer must therefore act in the optimizer (before the head call is inlined) // for this to still become a direct delegate. let trivial (x: int) (y: int) : int = x + y +// 27. non-eta inlinable trivial target (inline-race contrast) let niTrivialNonEta () = Func(trivial) +// 10. eta inlinable trivial target (inline-race) let niTrivialEta () = Func(fun a b -> trivial a b) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.Preview.il.bsl similarity index 95% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.Preview.il.bsl index b31ec227850..b359893da86 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.Preview.il.bsl @@ -98,7 +98,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaCurried@23 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaCurried@15 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -116,7 +116,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaTupled@26 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -134,7 +134,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticEta@36 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticEta@28 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -152,7 +152,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceEta@49 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceEta@41 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -163,7 +163,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niInstanceEta@49::o + IL_0002: stfld class assembly/C assembly/niInstanceEta@41::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -174,7 +174,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niInstanceEta@49::o + IL_0001: ldfld class assembly/C assembly/niInstanceEta@41::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: tail. @@ -185,7 +185,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niGenericInstanceEta@55 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niGenericInstanceEta@47 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -196,7 +196,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niGenericInstanceEta@55::o + IL_0002: stfld class assembly/C assembly/niGenericInstanceEta@47::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -207,7 +207,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niGenericInstanceEta@55::o + IL_0001: ldfld class assembly/C assembly/niGenericInstanceEta@47::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance !!0 assembly/C::GPick(!!0, @@ -217,7 +217,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@65 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@59 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -277,7 +277,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niEtaCurried@23::Invoke(int32, + IL_0001: ldftn int32 assembly/niEtaCurried@15::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) @@ -289,7 +289,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niEtaTupled@26::Invoke(int32, + IL_0001: ldftn int32 assembly/niEtaTupled@18::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) @@ -313,7 +313,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niStaticEta@36::Invoke(int32, + IL_0001: ldftn int32 assembly/niStaticEta@28::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) @@ -337,8 +337,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niInstanceEta@49::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niInstanceEta@49::Invoke(int32, + IL_0001: newobj instance void assembly/niInstanceEta@41::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niInstanceEta@41::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) @@ -362,8 +362,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niGenericInstanceEta@55::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niGenericInstanceEta@55::Invoke(int32, + IL_0001: newobj instance void assembly/niGenericInstanceEta@47::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niGenericInstanceEta@47::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) @@ -399,7 +399,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialEta@65::Invoke(int32, + IL_0001: ldftn int32 assembly/niTrivialEta@59::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.il.bsl similarity index 91% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.il.bsl index 075811968d9..123299f5ca8 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.il.bsl @@ -98,7 +98,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niNonEta@20 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niNonEta@12 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -116,7 +116,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaCurried@23 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaCurried@15 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -134,7 +134,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaTupled@26 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -152,7 +152,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticNonEta@33 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticNonEta@25 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -170,7 +170,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticEta@36 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticEta@28 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -188,7 +188,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceNonEta@46 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceNonEta@38 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -199,7 +199,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niInstanceNonEta@46::o + IL_0002: stfld class assembly/C assembly/niInstanceNonEta@38::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -210,7 +210,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niInstanceNonEta@46::o + IL_0001: ldfld class assembly/C assembly/niInstanceNonEta@38::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: tail. @@ -221,7 +221,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceEta@49 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceEta@41 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -232,7 +232,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niInstanceEta@49::o + IL_0002: stfld class assembly/C assembly/niInstanceEta@41::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -243,7 +243,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niInstanceEta@49::o + IL_0001: ldfld class assembly/C assembly/niInstanceEta@41::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: tail. @@ -254,7 +254,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niGenericInstanceNonEta@52 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niGenericInstanceNonEta@44 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -265,7 +265,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niGenericInstanceNonEta@52::o + IL_0002: stfld class assembly/C assembly/niGenericInstanceNonEta@44::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -276,7 +276,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niGenericInstanceNonEta@52::o + IL_0001: ldfld class assembly/C assembly/niGenericInstanceNonEta@44::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance !!0 assembly/C::GPick(!!0, @@ -286,7 +286,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niGenericInstanceEta@55 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niGenericInstanceEta@47 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -297,7 +297,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niGenericInstanceEta@55::o + IL_0002: stfld class assembly/C assembly/niGenericInstanceEta@47::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -308,7 +308,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niGenericInstanceEta@55::o + IL_0001: ldfld class assembly/C assembly/niGenericInstanceEta@47::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance !!0 assembly/C::GPick(!!0, @@ -318,7 +318,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@63 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@56 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -336,7 +336,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@65 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@59 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -384,10 +384,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niNonEta@20::Invoke(int32, + IL_0001: ldftn int32 assembly/niNonEta@12::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -396,10 +396,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niEtaCurried@23::Invoke(int32, + IL_0001: ldftn int32 assembly/niEtaCurried@15::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -408,10 +408,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niEtaTupled@26::Invoke(int32, + IL_0001: ldftn int32 assembly/niEtaTupled@18::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -420,10 +420,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niStaticNonEta@33::Invoke(int32, + IL_0001: ldftn int32 assembly/niStaticNonEta@25::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -432,10 +432,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niStaticEta@36::Invoke(int32, + IL_0001: ldftn int32 assembly/niStaticEta@28::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -444,11 +444,11 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niInstanceNonEta@46::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niInstanceNonEta@46::Invoke(int32, + IL_0001: newobj instance void assembly/niInstanceNonEta@38::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niInstanceNonEta@38::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_0011: ret } @@ -457,11 +457,11 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niInstanceEta@49::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niInstanceEta@49::Invoke(int32, + IL_0001: newobj instance void assembly/niInstanceEta@41::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niInstanceEta@41::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_0011: ret } @@ -470,11 +470,11 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niGenericInstanceNonEta@52::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niGenericInstanceNonEta@52::Invoke(int32, + IL_0001: newobj instance void assembly/niGenericInstanceNonEta@44::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niGenericInstanceNonEta@44::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_0011: ret } @@ -483,11 +483,11 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niGenericInstanceEta@55::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niGenericInstanceEta@55::Invoke(int32, + IL_0001: newobj instance void assembly/niGenericInstanceEta@47::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niGenericInstanceEta@47::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_0011: ret } @@ -508,10 +508,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialNonEta@63::Invoke(int32, + IL_0001: ldftn int32 assembly/niTrivialNonEta@56::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -520,10 +520,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialEta@65::Invoke(int32, + IL_0001: ldftn int32 assembly/niTrivialEta@59::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.Preview.il.bsl similarity index 93% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.Preview.il.bsl index 769f5764703..4f7a18609ca 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.Preview.il.bsl @@ -98,7 +98,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaTupled@26 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -116,7 +116,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@63 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@56 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -133,7 +133,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@65 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@59 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -183,7 +183,7 @@ IL_0001: ldftn int32 assembly::accCurried(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -195,7 +195,7 @@ IL_0001: ldftn int32 assembly::accCurried(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -204,10 +204,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niEtaTupled@26::Invoke(int32, + IL_0001: ldftn int32 assembly/niEtaTupled@18::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -219,7 +219,7 @@ IL_0001: ldftn int32 assembly/S::AccS(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -231,7 +231,7 @@ IL_0001: ldftn int32 assembly/S::AccS(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -243,7 +243,7 @@ IL_0001: ldftn instance int32 assembly/C::AccC(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -255,7 +255,7 @@ IL_0001: ldftn instance int32 assembly/C::AccC(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -267,7 +267,7 @@ IL_0001: ldftn instance !!0 assembly/C::GPick(!!0, !!0) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -279,7 +279,7 @@ IL_0001: ldftn instance !!0 assembly/C::GPick(!!0, !!0) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -300,10 +300,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialNonEta@63::Invoke(int32, + IL_0001: ldftn int32 assembly/niTrivialNonEta@56::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -312,10 +312,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialEta@65::Invoke(int32, + IL_0001: ldftn int32 assembly/niTrivialEta@59::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.il.bsl similarity index 91% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.il.bsl index a10586e3a2e..8a4ce549f4a 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.il.bsl @@ -98,7 +98,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niNonEta@20 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niNonEta@12 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -116,7 +116,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaCurried@23 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaCurried@15 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -134,7 +134,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaTupled@26 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -152,7 +152,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticNonEta@33 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticNonEta@25 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -170,7 +170,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticEta@36 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticEta@28 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -188,7 +188,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceNonEta@46 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceNonEta@38 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -199,7 +199,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niInstanceNonEta@46::o + IL_0002: stfld class assembly/C assembly/niInstanceNonEta@38::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -210,7 +210,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niInstanceNonEta@46::o + IL_0001: ldfld class assembly/C assembly/niInstanceNonEta@38::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance int32 assembly/C::AccC(int32, @@ -220,7 +220,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceEta@49 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceEta@41 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -231,7 +231,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niInstanceEta@49::o + IL_0002: stfld class assembly/C assembly/niInstanceEta@41::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -242,7 +242,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niInstanceEta@49::o + IL_0001: ldfld class assembly/C assembly/niInstanceEta@41::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance int32 assembly/C::AccC(int32, @@ -252,7 +252,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niGenericInstanceNonEta@52 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niGenericInstanceNonEta@44 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -263,7 +263,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niGenericInstanceNonEta@52::o + IL_0002: stfld class assembly/C assembly/niGenericInstanceNonEta@44::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -274,7 +274,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niGenericInstanceNonEta@52::o + IL_0001: ldfld class assembly/C assembly/niGenericInstanceNonEta@44::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance !!0 assembly/C::GPick(!!0, @@ -284,7 +284,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niGenericInstanceEta@55 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niGenericInstanceEta@47 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -295,7 +295,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niGenericInstanceEta@55::o + IL_0002: stfld class assembly/C assembly/niGenericInstanceEta@47::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -306,7 +306,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niGenericInstanceEta@55::o + IL_0001: ldfld class assembly/C assembly/niGenericInstanceEta@47::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance !!0 assembly/C::GPick(!!0, @@ -316,7 +316,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@63 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@56 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -333,7 +333,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@65 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@59 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -380,10 +380,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niNonEta@20::Invoke(int32, + IL_0001: ldftn int32 assembly/niNonEta@12::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -392,10 +392,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niEtaCurried@23::Invoke(int32, + IL_0001: ldftn int32 assembly/niEtaCurried@15::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -404,10 +404,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niEtaTupled@26::Invoke(int32, + IL_0001: ldftn int32 assembly/niEtaTupled@18::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -416,10 +416,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niStaticNonEta@33::Invoke(int32, + IL_0001: ldftn int32 assembly/niStaticNonEta@25::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -428,10 +428,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niStaticEta@36::Invoke(int32, + IL_0001: ldftn int32 assembly/niStaticEta@28::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -440,11 +440,11 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niInstanceNonEta@46::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niInstanceNonEta@46::Invoke(int32, + IL_0001: newobj instance void assembly/niInstanceNonEta@38::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niInstanceNonEta@38::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_0011: ret } @@ -453,11 +453,11 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niInstanceEta@49::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niInstanceEta@49::Invoke(int32, + IL_0001: newobj instance void assembly/niInstanceEta@41::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niInstanceEta@41::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_0011: ret } @@ -466,11 +466,11 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niGenericInstanceNonEta@52::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niGenericInstanceNonEta@52::Invoke(int32, + IL_0001: newobj instance void assembly/niGenericInstanceNonEta@44::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niGenericInstanceNonEta@44::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_0011: ret } @@ -479,11 +479,11 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niGenericInstanceEta@55::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niGenericInstanceEta@55::Invoke(int32, + IL_0001: newobj instance void assembly/niGenericInstanceEta@47::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/niGenericInstanceEta@47::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_0011: ret } @@ -504,10 +504,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialNonEta@63::Invoke(int32, + IL_0001: ldftn int32 assembly/niTrivialNonEta@56::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } @@ -516,10 +516,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialEta@65::Invoke(int32, + IL_0001: ldftn int32 assembly/niTrivialEta@59::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_000c: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs index 8b12ee25545..05dce73a5ee 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs @@ -2,12 +2,11 @@ module DelegatePartialApplication open System -// Section D, bullet 2: cases 15/16 (in DelegateKnownFunction.fs / DelegateStaticMethod.fs) capture a +// Cases 15/16 (in DelegateKnownFunction.fs / DelegateStaticMethod.fs) capture a // constant first argument, so their closure can stay static (the constant is re-materialised in Invoke // with no instance field). Capturing a runtime VALUE instead forces the closure to carry an instance // field, which exercises a distinct emit path. None of these can ever become a direct delegate (the -// target has more parameters than the delegate's Invoke), so a closure must remain regardless of -// langversion; the only proposed change here is friendlier elided argument names. +// target has more parameters than the delegate's Invoke), so a closure must remain. let handler3 (x: int) (y: int) (z: int) : unit = () @@ -17,11 +16,11 @@ type C = type I(k: int) = member _.Add3 (x: int) (y: int) (z: int) : unit = ignore k -// variable-capture partial application of a known function (instance-field capture of n) +// 41. partial application of module function (captured var: instance-field capture of n) let papKnownVar (n: int) = Action(handler3 n) -// variable-capture partial application of a static method +// 42. partial application of static method (captured var) let papStaticVar (n: int) = Action(C.Add3 n) -// variable-capture partial application of an instance method (captures both the receiver and n) +// 43. partial application of instance method (captures both the receiver and n) let papInstanceVar (o: I) (n: int) = Action(o.Add3 n) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOff.Preview.il.bsl similarity index 92% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOff.Preview.il.bsl index 1b719dd6d94..c4365038d12 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOff.Preview.il.bsl @@ -87,7 +87,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname papKnownVar@21 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname papKnownVar@20 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -98,7 +98,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld int32 assembly/papKnownVar@21::n + IL_0002: stfld int32 assembly/papKnownVar@20::n IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -109,7 +109,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld int32 assembly/papKnownVar@21::n + IL_0001: ldfld int32 assembly/papKnownVar@20::n IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: call void assembly::handler3(int32, @@ -121,7 +121,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname papStaticVar@24 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname papStaticVar@23 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -132,7 +132,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld int32 assembly/papStaticVar@24::n + IL_0002: stfld int32 assembly/papStaticVar@23::n IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -143,7 +143,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld int32 assembly/papStaticVar@24::n + IL_0001: ldfld int32 assembly/papStaticVar@23::n IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: call void assembly/C::Add3(int32, @@ -155,7 +155,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname papInstanceVar@27 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname papInstanceVar@26 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -167,10 +167,10 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/I assembly/papInstanceVar@27::o + IL_0002: stfld class assembly/I assembly/papInstanceVar@26::o IL_0007: ldarg.0 IL_0008: ldarg.2 - IL_0009: stfld int32 assembly/papInstanceVar@27::n + IL_0009: stfld int32 assembly/papInstanceVar@26::n IL_000e: ldarg.0 IL_000f: call instance void [runtime]System.Object::.ctor() IL_0014: ret @@ -181,9 +181,9 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/I assembly/papInstanceVar@27::o + IL_0001: ldfld class assembly/I assembly/papInstanceVar@26::o IL_0006: ldarg.0 - IL_0007: ldfld int32 assembly/papInstanceVar@27::n + IL_0007: ldfld int32 assembly/papInstanceVar@26::n IL_000c: ldarg.1 IL_000d: ldarg.2 IL_000e: callvirt instance void assembly/I::Add3(int32, @@ -211,8 +211,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/papKnownVar@21::.ctor(int32) - IL_0006: ldftn instance void assembly/papKnownVar@21::Invoke(int32, + IL_0001: newobj instance void assembly/papKnownVar@20::.ctor(int32) + IL_0006: ldftn instance void assembly/papKnownVar@20::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -224,8 +224,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/papStaticVar@24::.ctor(int32) - IL_0006: ldftn instance void assembly/papStaticVar@24::Invoke(int32, + IL_0001: newobj instance void assembly/papStaticVar@23::.ctor(int32) + IL_0006: ldftn instance void assembly/papStaticVar@23::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -239,9 +239,9 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: newobj instance void assembly/papInstanceVar@27::.ctor(class assembly/I, + IL_0002: newobj instance void assembly/papInstanceVar@26::.ctor(class assembly/I, int32) - IL_0007: ldftn instance void assembly/papInstanceVar@27::Invoke(int32, + IL_0007: ldftn instance void assembly/papInstanceVar@26::Invoke(int32, int32) IL_000d: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOff.il.bsl similarity index 90% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOff.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOff.il.bsl index fc1e7bc6303..c4365038d12 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOff.il.bsl @@ -87,7 +87,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname papKnownVar@21 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname papKnownVar@20 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -98,7 +98,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld int32 assembly/papKnownVar@21::n + IL_0002: stfld int32 assembly/papKnownVar@20::n IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -109,7 +109,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld int32 assembly/papKnownVar@21::n + IL_0001: ldfld int32 assembly/papKnownVar@20::n IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: call void assembly::handler3(int32, @@ -121,7 +121,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname papStaticVar@24 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname papStaticVar@23 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -132,7 +132,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld int32 assembly/papStaticVar@24::n + IL_0002: stfld int32 assembly/papStaticVar@23::n IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -143,7 +143,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld int32 assembly/papStaticVar@24::n + IL_0001: ldfld int32 assembly/papStaticVar@23::n IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: call void assembly/C::Add3(int32, @@ -155,7 +155,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname papInstanceVar@27 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname papInstanceVar@26 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -167,10 +167,10 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/I assembly/papInstanceVar@27::o + IL_0002: stfld class assembly/I assembly/papInstanceVar@26::o IL_0007: ldarg.0 IL_0008: ldarg.2 - IL_0009: stfld int32 assembly/papInstanceVar@27::n + IL_0009: stfld int32 assembly/papInstanceVar@26::n IL_000e: ldarg.0 IL_000f: call instance void [runtime]System.Object::.ctor() IL_0014: ret @@ -181,9 +181,9 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/I assembly/papInstanceVar@27::o + IL_0001: ldfld class assembly/I assembly/papInstanceVar@26::o IL_0006: ldarg.0 - IL_0007: ldfld int32 assembly/papInstanceVar@27::n + IL_0007: ldfld int32 assembly/papInstanceVar@26::n IL_000c: ldarg.1 IL_000d: ldarg.2 IL_000e: callvirt instance void assembly/I::Add3(int32, @@ -211,11 +211,11 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/papKnownVar@21::.ctor(int32) - IL_0006: ldftn instance void assembly/papKnownVar@21::Invoke(int32, + IL_0001: newobj instance void assembly/papKnownVar@20::.ctor(int32) + IL_0006: ldftn instance void assembly/papKnownVar@20::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_0011: ret } @@ -224,11 +224,11 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/papStaticVar@24::.ctor(int32) - IL_0006: ldftn instance void assembly/papStaticVar@24::Invoke(int32, + IL_0001: newobj instance void assembly/papStaticVar@23::.ctor(int32) + IL_0006: ldftn instance void assembly/papStaticVar@23::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_0011: ret } @@ -239,12 +239,12 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: newobj instance void assembly/papInstanceVar@27::.ctor(class assembly/I, + IL_0002: newobj instance void assembly/papInstanceVar@26::.ctor(class assembly/I, int32) - IL_0007: ldftn instance void assembly/papInstanceVar@27::Invoke(int32, + IL_0007: ldftn instance void assembly/papInstanceVar@26::Invoke(int32, int32) IL_000d: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_0012: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOn.Preview.il.bsl similarity index 95% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOn.Preview.il.bsl index f9efcbd168b..61c73994f65 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOn.Preview.il.bsl @@ -83,7 +83,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papKnownVar@21 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papKnownVar@20 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -97,7 +97,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papStaticVar@24 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papStaticVar@23 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -111,7 +111,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papInstanceVar@27 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papInstanceVar@26 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -141,7 +141,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/papKnownVar@21::Invoke(int32, + IL_0001: ldftn void assembly/papKnownVar@20::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -153,7 +153,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/papStaticVar@24::Invoke(int32, + IL_0001: ldftn void assembly/papStaticVar@23::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -166,7 +166,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/papInstanceVar@27::Invoke(int32, + IL_0001: ldftn void assembly/papInstanceVar@26::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOn.il.bsl similarity index 93% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOn.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOn.il.bsl index afb6d8c3f64..61c73994f65 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOn.il.bsl @@ -83,7 +83,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papKnownVar@21 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papKnownVar@20 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -97,7 +97,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papStaticVar@24 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papStaticVar@23 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -111,7 +111,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papInstanceVar@27 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papInstanceVar@26 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -141,10 +141,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/papKnownVar@21::Invoke(int32, + IL_0001: ldftn void assembly/papKnownVar@20::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } @@ -153,10 +153,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/papStaticVar@24::Invoke(int32, + IL_0001: ldftn void assembly/papStaticVar@23::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } @@ -166,10 +166,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/papInstanceVar@27::Invoke(int32, + IL_0001: ldftn void assembly/papInstanceVar@26::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs index 5f3ec7b724e..c77a2fc19dc 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs @@ -7,15 +7,15 @@ type C = static member AddT (x: int, y: int) : unit = () static member Add3 (x: int) (y: int) (z: int) : unit = () -// 4. non-eta-expanded static method target -// (a tupled member is seen as a single tuple-arg value and will not coerce non-eta; use the curried member) -let case4_nonEta () = Action(C.AddC) +// 19. non-eta static method +// (a tupled member is seen as a single tuple-arg value and will not coerce non-eta; use the curried member) +let case19_nonEta () = Action(C.AddC) -// 5. eta-expanded, curried application -let case5_etaCurried () = Action(fun a b -> C.AddC a b) +// 2. eta static method (curried application) +let case2_etaCurried () = Action(fun a b -> C.AddC a b) -// 6. eta-expanded, tupled application -let case6_etaTupled () = Action(fun a b -> C.AddT(a, b)) +// 34. eta static method, tupled application +let case34_etaTupled () = Action(fun a b -> C.AddT(a, b)) -// 16. non-eta-expanded static method via partial application -let case16_partial () = Action(C.Add3 1) +// 40. partial application of static method (constant arg) +let case40_partial () = Action(C.Add3 1) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOff.Preview.il.bsl similarity index 92% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOff.Preview.il.bsl index d9c7305029d..d7b33e7d72b 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOff.Preview.il.bsl @@ -67,7 +67,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case5_etaCurried@15 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case2_etaCurried@15 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -86,7 +86,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case6_etaTupled@18 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case34_etaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -105,7 +105,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case16_partial@21 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case40_partial@21 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -126,7 +126,7 @@ } - .method public static class [runtime]System.Action`2 case4_nonEta() cil managed + .method public static class [runtime]System.Action`2 case19_nonEta() cil managed { .maxstack 8 @@ -138,36 +138,36 @@ IL_000c: ret } - .method public static class [runtime]System.Action`2 case5_etaCurried() cil managed + .method public static class [runtime]System.Action`2 case2_etaCurried() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case5_etaCurried@15::Invoke(int32, + IL_0001: ldftn void assembly/case2_etaCurried@15::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case6_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case34_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case6_etaTupled@18::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case34_etaTupled@18::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case16_partial() cil managed + .method public static class [runtime]System.Action`2 case40_partial() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case16_partial@21::Invoke(int32, + IL_0001: ldftn void assembly/case40_partial@21::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOff.il.bsl similarity index 91% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOff.il.bsl index 15590de3edc..f1d3a8474e1 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOff.il.bsl @@ -67,7 +67,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case4_nonEta@12 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case19_nonEta@12 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -86,7 +86,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case5_etaCurried@15 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case2_etaCurried@15 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -105,7 +105,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case6_etaTupled@18 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case34_etaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -124,7 +124,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case16_partial@21 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case40_partial@21 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -145,48 +145,48 @@ } - .method public static class [runtime]System.Action`2 case4_nonEta() cil managed + .method public static class [runtime]System.Action`2 case19_nonEta() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case4_nonEta@12::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case19_nonEta@12::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case5_etaCurried() cil managed + .method public static class [runtime]System.Action`2 case2_etaCurried() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case5_etaCurried@15::Invoke(int32, + IL_0001: ldftn void assembly/case2_etaCurried@15::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case6_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case34_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case6_etaTupled@18::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case34_etaTupled@18::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case16_partial() cil managed + .method public static class [runtime]System.Action`2 case40_partial() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case16_partial@21::Invoke(int32, + IL_0001: ldftn void assembly/case40_partial@21::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOn.Preview.il.bsl similarity index 90% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOn.Preview.il.bsl index eadfc7c3f13..f2dd2579e43 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOn.Preview.il.bsl @@ -67,7 +67,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case4_nonEta@12 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case19_nonEta@12 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -81,7 +81,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case5_etaCurried@15 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case2_etaCurried@15 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -95,7 +95,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case6_etaTupled@18 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case34_etaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -109,7 +109,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case16_partial@21 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case40_partial@21 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -123,48 +123,48 @@ } - .method public static class [runtime]System.Action`2 case4_nonEta() cil managed + .method public static class [runtime]System.Action`2 case19_nonEta() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case4_nonEta@12::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case19_nonEta@12::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case5_etaCurried() cil managed + .method public static class [runtime]System.Action`2 case2_etaCurried() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case5_etaCurried@15::Invoke(int32, + IL_0001: ldftn void assembly/case2_etaCurried@15::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case6_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case34_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case6_etaTupled@18::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case34_etaTupled@18::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case16_partial() cil managed + .method public static class [runtime]System.Action`2 case40_partial() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case16_partial@21::Invoke(int32, + IL_0001: ldftn void assembly/case40_partial@21::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOn.il.bsl similarity index 90% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOn.il.bsl index eadfc7c3f13..f2dd2579e43 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOn.il.bsl @@ -67,7 +67,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case4_nonEta@12 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case19_nonEta@12 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -81,7 +81,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case5_etaCurried@15 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case2_etaCurried@15 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -95,7 +95,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case6_etaTupled@18 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case34_etaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -109,7 +109,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case16_partial@21 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case40_partial@21 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -123,48 +123,48 @@ } - .method public static class [runtime]System.Action`2 case4_nonEta() cil managed + .method public static class [runtime]System.Action`2 case19_nonEta() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case4_nonEta@12::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case19_nonEta@12::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case5_etaCurried() cil managed + .method public static class [runtime]System.Action`2 case2_etaCurried() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case5_etaCurried@15::Invoke(int32, + IL_0001: ldftn void assembly/case2_etaCurried@15::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case6_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case34_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case6_etaTupled@18::Invoke(int32, - int32) + IL_0001: ldftn void assembly/case34_etaTupled@18::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case16_partial() cil managed + .method public static class [runtime]System.Action`2 case40_partial() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case16_partial@21::Invoke(int32, + IL_0001: ldftn void assembly/case40_partial@21::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs index b7f55d44097..84785eda906 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs @@ -10,6 +10,8 @@ type S = // The target is an instance method on a value type. A delegate's Target is an object, so a direct delegate // would have to box the receiver; until that is implemented a closure is kept. (See DelegateInstanceMethod // for the reference-type case, which is emitted directly.) +// 50. non-eta struct (value-type) receiver let structInstanceNonEta (s: S) = Func(s.Add) +// 51. eta struct (value-type) receiver let structInstanceEta (s: S) = Func(fun a b -> s.Add a b) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOff.Preview.il.bsl similarity index 97% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOff.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOff.Preview.il.bsl index 3c01648fc8d..291dc96be7c 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOff.Preview.il.bsl @@ -199,7 +199,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceNonEta@13 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceNonEta@14 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -210,7 +210,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld valuetype assembly/S assembly/structInstanceNonEta@13::s + IL_0002: stfld valuetype assembly/S assembly/structInstanceNonEta@14::s IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -222,7 +222,7 @@ .maxstack 7 .locals init (valuetype assembly/S V_0) IL_0000: ldarg.0 - IL_0001: ldfld valuetype assembly/S assembly/structInstanceNonEta@13::s + IL_0001: ldfld valuetype assembly/S assembly/structInstanceNonEta@14::s IL_0006: stloc.0 IL_0007: ldloca.s V_0 IL_0009: ldarg.1 @@ -234,7 +234,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceEta@15 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceEta@17 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -245,7 +245,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld valuetype assembly/S assembly/structInstanceEta@15::s + IL_0002: stfld valuetype assembly/S assembly/structInstanceEta@17::s IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -257,7 +257,7 @@ .maxstack 7 .locals init (valuetype assembly/S V_0) IL_0000: ldarg.0 - IL_0001: ldfld valuetype assembly/S assembly/structInstanceEta@15::s + IL_0001: ldfld valuetype assembly/S assembly/structInstanceEta@17::s IL_0006: stloc.0 IL_0007: ldloca.s V_0 IL_0009: ldarg.1 @@ -274,8 +274,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/structInstanceNonEta@13::.ctor(valuetype assembly/S) - IL_0006: ldftn instance int32 assembly/structInstanceNonEta@13::Invoke(int32, + IL_0001: newobj instance void assembly/structInstanceNonEta@14::.ctor(valuetype assembly/S) + IL_0006: ldftn instance int32 assembly/structInstanceNonEta@14::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) @@ -287,8 +287,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/structInstanceEta@15::.ctor(valuetype assembly/S) - IL_0006: ldftn instance int32 assembly/structInstanceEta@15::Invoke(int32, + IL_0001: newobj instance void assembly/structInstanceEta@17::.ctor(valuetype assembly/S) + IL_0006: ldftn instance int32 assembly/structInstanceEta@17::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOff.il.bsl similarity index 96% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOff.il.bsl index 8055c451a93..291dc96be7c 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOff.il.bsl @@ -199,7 +199,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceNonEta@13 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceNonEta@14 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -210,7 +210,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld valuetype assembly/S assembly/structInstanceNonEta@13::s + IL_0002: stfld valuetype assembly/S assembly/structInstanceNonEta@14::s IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -222,7 +222,7 @@ .maxstack 7 .locals init (valuetype assembly/S V_0) IL_0000: ldarg.0 - IL_0001: ldfld valuetype assembly/S assembly/structInstanceNonEta@13::s + IL_0001: ldfld valuetype assembly/S assembly/structInstanceNonEta@14::s IL_0006: stloc.0 IL_0007: ldloca.s V_0 IL_0009: ldarg.1 @@ -234,7 +234,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceEta@15 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceEta@17 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -245,7 +245,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld valuetype assembly/S assembly/structInstanceEta@15::s + IL_0002: stfld valuetype assembly/S assembly/structInstanceEta@17::s IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -257,7 +257,7 @@ .maxstack 7 .locals init (valuetype assembly/S V_0) IL_0000: ldarg.0 - IL_0001: ldfld valuetype assembly/S assembly/structInstanceEta@15::s + IL_0001: ldfld valuetype assembly/S assembly/structInstanceEta@17::s IL_0006: stloc.0 IL_0007: ldloca.s V_0 IL_0009: ldarg.1 @@ -274,11 +274,11 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/structInstanceNonEta@13::.ctor(valuetype assembly/S) - IL_0006: ldftn instance int32 assembly/structInstanceNonEta@13::Invoke(int32, + IL_0001: newobj instance void assembly/structInstanceNonEta@14::.ctor(valuetype assembly/S) + IL_0006: ldftn instance int32 assembly/structInstanceNonEta@14::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_0011: ret } @@ -287,11 +287,11 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/structInstanceEta@15::.ctor(valuetype assembly/S) - IL_0006: ldftn instance int32 assembly/structInstanceEta@15::Invoke(int32, + IL_0001: newobj instance void assembly/structInstanceEta@17::.ctor(valuetype assembly/S) + IL_0006: ldftn instance int32 assembly/structInstanceEta@17::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_0011: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOn.Preview.il.bsl similarity index 97% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOn.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOn.Preview.il.bsl index ae22fd38d8a..f83c608dc89 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOn.Preview.il.bsl @@ -172,7 +172,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceNonEta@13 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceNonEta@14 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -183,7 +183,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld valuetype assembly/S assembly/structInstanceNonEta@13::s + IL_0002: stfld valuetype assembly/S assembly/structInstanceNonEta@14::s IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -194,7 +194,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldflda valuetype assembly/S assembly/structInstanceNonEta@13::s + IL_0001: ldflda valuetype assembly/S assembly/structInstanceNonEta@14::s IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: call instance int32 assembly/S::Add(int32, @@ -204,7 +204,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceEta@15 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceEta@17 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -215,7 +215,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld valuetype assembly/S assembly/structInstanceEta@15::s + IL_0002: stfld valuetype assembly/S assembly/structInstanceEta@17::s IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -226,7 +226,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldflda valuetype assembly/S assembly/structInstanceEta@15::s + IL_0001: ldflda valuetype assembly/S assembly/structInstanceEta@17::s IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: call instance int32 assembly/S::Add(int32, @@ -241,8 +241,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/structInstanceNonEta@13::.ctor(valuetype assembly/S) - IL_0006: ldftn instance int32 assembly/structInstanceNonEta@13::Invoke(int32, + IL_0001: newobj instance void assembly/structInstanceNonEta@14::.ctor(valuetype assembly/S) + IL_0006: ldftn instance int32 assembly/structInstanceNonEta@14::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) @@ -254,8 +254,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/structInstanceEta@15::.ctor(valuetype assembly/S) - IL_0006: ldftn instance int32 assembly/structInstanceEta@15::Invoke(int32, + IL_0001: newobj instance void assembly/structInstanceEta@17::.ctor(valuetype assembly/S) + IL_0006: ldftn instance int32 assembly/structInstanceEta@17::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOn.il.bsl similarity index 96% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOn.il.bsl index 1cbf8a76d65..f83c608dc89 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOn.il.bsl @@ -172,7 +172,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceNonEta@13 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceNonEta@14 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -183,7 +183,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld valuetype assembly/S assembly/structInstanceNonEta@13::s + IL_0002: stfld valuetype assembly/S assembly/structInstanceNonEta@14::s IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -194,7 +194,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldflda valuetype assembly/S assembly/structInstanceNonEta@13::s + IL_0001: ldflda valuetype assembly/S assembly/structInstanceNonEta@14::s IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: call instance int32 assembly/S::Add(int32, @@ -204,7 +204,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceEta@15 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceEta@17 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -215,7 +215,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld valuetype assembly/S assembly/structInstanceEta@15::s + IL_0002: stfld valuetype assembly/S assembly/structInstanceEta@17::s IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -226,7 +226,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldflda valuetype assembly/S assembly/structInstanceEta@15::s + IL_0001: ldflda valuetype assembly/S assembly/structInstanceEta@17::s IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: call instance int32 assembly/S::Add(int32, @@ -241,11 +241,11 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/structInstanceNonEta@13::.ctor(valuetype assembly/S) - IL_0006: ldftn instance int32 assembly/structInstanceNonEta@13::Invoke(int32, + IL_0001: newobj instance void assembly/structInstanceNonEta@14::.ctor(valuetype assembly/S) + IL_0006: ldftn instance int32 assembly/structInstanceNonEta@14::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_0011: ret } @@ -254,11 +254,11 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/structInstanceEta@15::.ctor(valuetype assembly/S) - IL_0006: ldftn instance int32 assembly/structInstanceEta@15::Invoke(int32, + IL_0001: newobj instance void assembly/structInstanceEta@17::.ctor(valuetype assembly/S) + IL_0006: ldftn instance int32 assembly/structInstanceEta@17::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) + native int) IL_0011: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs index 7b27fb8611b..a72fe20cf80 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs @@ -4,8 +4,8 @@ open System let handler () : unit = () -// unit-argument delegate, non-eta-expanded known target +// 48. non-eta unit-argument delegate let caseUnitNonEta () = Action(handler) -// unit-argument delegate, eta-expanded +// 49. eta unit-argument delegate let caseUnitEta () = Action(fun () -> handler ()) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOff.Preview.il.bsl similarity index 100% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOff.Preview.il.bsl diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOff.il.bsl similarity index 100% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOff.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOff.il.bsl diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOn.Preview.il.bsl similarity index 100% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOn.Preview.il.bsl diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOn.il.bsl similarity index 100% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.RealInternalSignatureOn.OptimizeOn.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOn.il.bsl diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs index 7e2b1c5e31a..10e8032a87c 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs @@ -6,8 +6,10 @@ open System [] let returnsUnit (x: int) (y: int) : unit = () +// 28. non-eta unit-returning member (compiled to void) let voidNonEta () = Action(returnsUnit) +// 11. eta unit-returning member let voidEta () = Action(fun a b -> returnsUnit a b) type C = @@ -18,6 +20,8 @@ type C = static member Echo<'T>(x: 'T) : 'T = x // Generic return type variable instantiated to unit; the delegate likewise returns unit. +// 29. non-eta generic return tyvar instantiated to unit (compiled return is Unit, not void) let unitGenericReturnNonEta () = Func(C.Echo) +// 12. eta generic unit-returning method let unitGenericReturnEta () = Func(fun (x: unit) -> C.Echo x) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOff.Preview.il.bsl similarity index 92% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOff.Preview.il.bsl index 1ac412d919c..97b1e27f918 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOff.Preview.il.bsl @@ -48,7 +48,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidEta@11 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidEta@13 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -67,7 +67,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnEta@23 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnEta@27 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -100,7 +100,7 @@ IL_0001: ldftn void assembly::returnsUnit(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } @@ -109,10 +109,10 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/voidEta@11::Invoke(int32, + IL_0001: ldftn void assembly/voidEta@13::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } @@ -123,7 +123,7 @@ IL_0000: ldnull IL_0001: ldftn !!0 assembly/C::Echo(!!0) IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, - native int) + native int) IL_000c: ret } @@ -132,9 +132,9 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnEta@23::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) + IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnEta@27::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, - native int) + native int) IL_000c: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOff.il.bsl similarity index 93% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOn.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOff.il.bsl index 2169ff70e6f..72f76894471 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOff.il.bsl @@ -48,7 +48,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidNonEta@9 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidNonEta@10 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -67,7 +67,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidEta@11 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidEta@13 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -86,7 +86,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnNonEta@21 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnNonEta@24 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -101,7 +101,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnEta@23 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnEta@27 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -131,8 +131,8 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/voidNonEta@9::Invoke(int32, - int32) + IL_0001: ldftn void assembly/voidNonEta@10::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret @@ -143,7 +143,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/voidEta@11::Invoke(int32, + IL_0001: ldftn void assembly/voidEta@13::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -155,7 +155,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnNonEta@21::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) + IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnNonEta@24::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, native int) IL_000c: ret @@ -166,7 +166,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnEta@23::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) + IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnEta@27::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, native int) IL_000c: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOn.Preview.il.bsl similarity index 95% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOn.Preview.il.bsl index 02e82fd6e93..2f7c62741e0 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOn.Preview.il.bsl @@ -66,7 +66,7 @@ IL_0001: ldftn void assembly::returnsUnit(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } @@ -78,7 +78,7 @@ IL_0001: ldftn void assembly::returnsUnit(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, - native int) + native int) IL_000c: ret } @@ -89,7 +89,7 @@ IL_0000: ldnull IL_0001: ldftn !!0 assembly/C::Echo(!!0) IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, - native int) + native int) IL_000c: ret } @@ -100,7 +100,7 @@ IL_0000: ldnull IL_0001: ldftn !!0 assembly/C::Echo(!!0) IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, - native int) + native int) IL_000c: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOn.il.bsl similarity index 93% rename from tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOff.il.bsl rename to tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOn.il.bsl index 2169ff70e6f..72f76894471 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.RealInternalSignatureOn.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOn.il.bsl @@ -48,7 +48,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidNonEta@9 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidNonEta@10 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -67,7 +67,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidEta@11 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidEta@13 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -86,7 +86,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnNonEta@21 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnNonEta@24 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -101,7 +101,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnEta@23 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnEta@27 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -131,8 +131,8 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/voidNonEta@9::Invoke(int32, - int32) + IL_0001: ldftn void assembly/voidNonEta@10::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret @@ -143,7 +143,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/voidEta@11::Invoke(int32, + IL_0001: ldftn void assembly/voidEta@13::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -155,7 +155,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnNonEta@21::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) + IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnNonEta@24::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, native int) IL_000c: ret @@ -166,7 +166,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnEta@23::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) + IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnEta@27::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, native int) IL_000c: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs index 93351130abb..f14d00e5586 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs @@ -1,169 +1,165 @@ -namespace EmittedIL.RealInternalSignature +module EmittedIL.RealInternalSignature.DirectDelegates open System.IO open Xunit open FSharp.Test open FSharp.Test.Compiler -module DirectDelegates = - - let private coreOptions compilation = - compilation - |> withOptions [ "--test:EmitFeeFeeAs100001" ] - |> asExe - |> withEmbeddedPdb - |> withEmbedAllSource - |> ignoreWarnings - - // Default langversion: direct delegates must NOT be emitted (a closure is still generated). - // Baselines: ..il.bsl -- these should remain unchanged when the feature lands. - let verifyCompilation compilation = - compilation - |> coreOptions - |> compile - |> shouldSucceed - |> verifyILBaseline - - // Redirect the IL baseline to a distinct *.Preview.il.bsl path so the preview variant can reuse the - // very same input .fs file (no input duplication / drift) without clobbering the default baseline. - let private withPreviewBaseline (cUnit: CompilationUnit) : CompilationUnit = - match cUnit with - | FS src -> - let baseline = - src.Baseline - |> Option.map (fun bsl -> - let path = bsl.ILBaseline.BslSource.Replace(".il.bsl", ".Preview.il.bsl") - let content = if File.Exists path then Some(File.ReadAllText path) else None - { bsl with ILBaseline = { bsl.ILBaseline with BslSource = path; Content = content } }) - FS { src with Baseline = baseline } - | other -> other - - // Preview langversion: direct delegates ARE emitted once the feature lands. - // Baselines: ..Preview.il.bsl -- these are the ones that will change. - let verifyPreviewCompilation compilation = - compilation - |> coreOptions - |> withLangVersionPreview - |> withPreviewBaseline - |> compile - |> shouldSucceed - |> verifyILBaseline - - [] - let ``DelegateKnownFunction_fs`` compilation = - compilation |> getCompilation |> verifyCompilation - - [] - let ``DelegateKnownFunction_fs preview`` compilation = - compilation |> getCompilation |> verifyPreviewCompilation - - [] - let ``DelegateStaticMethod_fs`` compilation = - compilation |> getCompilation |> verifyCompilation - - [] - let ``DelegateStaticMethod_fs preview`` compilation = - compilation |> getCompilation |> verifyPreviewCompilation - - [] - let ``DelegateGenericStaticMethod_fs`` compilation = - compilation |> getCompilation |> verifyCompilation - - [] - let ``DelegateGenericStaticMethod_fs preview`` compilation = - compilation |> getCompilation |> verifyPreviewCompilation - - [] - let ``DelegateInstanceMethod_fs`` compilation = - compilation |> getCompilation |> verifyCompilation - - [] - let ``DelegateInstanceMethod_fs preview`` compilation = - compilation |> getCompilation |> verifyPreviewCompilation - - [] - let ``DelegateGenericInstanceMethod_fs`` compilation = - compilation |> getCompilation |> verifyCompilation - - [] - let ``DelegateGenericInstanceMethod_fs preview`` compilation = - compilation |> getCompilation |> verifyPreviewCompilation - - [] - let ``DelegateUnitArg_fs`` compilation = - compilation |> getCompilation |> verifyCompilation - - [] - let ``DelegateUnitArg_fs preview`` compilation = - compilation |> getCompilation |> verifyPreviewCompilation - - [] - let ``DelegateNegativeCases_fs`` compilation = - compilation |> getCompilation |> verifyCompilation - - [] - let ``DelegateNegativeCases_fs preview`` compilation = - compilation |> getCompilation |> verifyPreviewCompilation - - [] - let ``DelegateNonInlinable_fs`` compilation = - compilation |> getCompilation |> verifyCompilation - - [] - let ``DelegateNonInlinable_fs preview`` compilation = - compilation |> getCompilation |> verifyPreviewCompilation - - [] - let ``DelegatePartialApplication_fs`` compilation = - compilation |> getCompilation |> verifyCompilation - - [] - let ``DelegatePartialApplication_fs preview`` compilation = - compilation |> getCompilation |> verifyPreviewCompilation - - [] - let ``DelegateUnitReturn_fs`` compilation = - compilation |> getCompilation |> verifyCompilation - - [] - let ``DelegateUnitReturn_fs preview`` compilation = - compilation |> getCompilation |> verifyPreviewCompilation - - [] - let ``DelegateStructTarget_fs`` compilation = - compilation |> getCompilation |> verifyCompilation - - [] - let ``DelegateStructTarget_fs preview`` compilation = - compilation |> getCompilation |> verifyPreviewCompilation - - [] - let ``DelegateExtensionMethod_fs`` compilation = - compilation |> getCompilation |> verifyCompilation - - [] - let ``DelegateExtensionMethod_fs preview`` compilation = - compilation |> getCompilation |> verifyPreviewCompilation - - [] - let ``DelegateILMethod_fs`` compilation = - compilation |> getCompilation |> verifyCompilation +let private coreOptions compilation = + compilation + |> withOptions [ "--test:EmitFeeFeeAs100001" ] + |> asExe + |> withEmbeddedPdb + |> withEmbedAllSource + |> ignoreWarnings + +let verifyCompilation compilation = + compilation + |> coreOptions + |> compile + |> shouldSucceed + |> verifyPEFileWithSystemDlls + |> verifyILBaseline + +// Redirect the IL baseline to a distinct *.Preview.il.bsl path so the preview variant can reuse the +// very same input .fs file (no input duplication / drift) without clobbering the default baseline. +let private withPreviewBaseline (cUnit: CompilationUnit) : CompilationUnit = + match cUnit with + | FS src -> + let baseline = + src.Baseline + |> Option.map (fun bsl -> + let path = bsl.ILBaseline.BslSource.Replace(".il.bsl", ".Preview.il.bsl") + let content = if File.Exists path then Some(File.ReadAllText path) else None + { bsl with ILBaseline = { bsl.ILBaseline with BslSource = path; Content = content } }) + FS { src with Baseline = baseline } + | other -> other + +let verifyPreviewCompilation compilation = + compilation + |> coreOptions + |> withLangVersionPreview + |> withPreviewBaseline + |> compile + |> shouldSucceed + |> verifyPEFileWithSystemDlls + |> verifyILBaseline + +[] +let ``DelegateKnownFunction_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + +[] +let ``DelegateKnownFunction_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + +[] +let ``DelegateStaticMethod_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + +[] +let ``DelegateStaticMethod_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + +[] +let ``DelegateGenericStaticMethod_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + +[] +let ``DelegateGenericStaticMethod_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + +[] +let ``DelegateInstanceMethod_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + +[] +let ``DelegateInstanceMethod_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + +[] +let ``DelegateGenericInstanceMethod_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + +[] +let ``DelegateGenericInstanceMethod_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + +[] +let ``DelegateUnitArg_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + +[] +let ``DelegateUnitArg_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + +[] +let ``DelegateNegativeCases_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + +[] +let ``DelegateNegativeCases_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + +[] +let ``DelegateNonInlinable_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + +[] +let ``DelegateNonInlinable_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + +[] +let ``DelegatePartialApplication_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + +[] +let ``DelegatePartialApplication_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + +[] +let ``DelegateUnitReturn_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + +[] +let ``DelegateUnitReturn_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + +[] +let ``DelegateStructTarget_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + +[] +let ``DelegateStructTarget_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + +[] +let ``DelegateExtensionMethod_fs`` compilation = + compilation |> getCompilation |> verifyCompilation + +[] +let ``DelegateExtensionMethod_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation + +[] +let ``DelegateILMethod_fs`` compilation = + compilation |> getCompilation |> verifyCompilation - [] - let ``DelegateILMethod_fs preview`` compilation = - compilation |> getCompilation |> verifyPreviewCompilation +[] +let ``DelegateILMethod_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation - [] - let ``DelegateCustomType_fs`` compilation = - compilation |> getCompilation |> verifyCompilation +[] +let ``DelegateCustomType_fs`` compilation = + compilation |> getCompilation |> verifyCompilation - [] - let ``DelegateCustomType_fs preview`` compilation = - compilation |> getCompilation |> verifyPreviewCompilation +[] +let ``DelegateCustomType_fs preview`` compilation = + compilation |> getCompilation |> verifyPreviewCompilation - [] - let ``Direct delegates target the real method and dispatch correctly (preview)`` () = - FSharp """ +[] +let ``Direct delegates target the real method and dispatch correctly (preview)`` () = + FSharp """ module DirectDelegateExecution open System @@ -203,14 +199,14 @@ let main _ = if not (obj.ReferenceEquals(vd.Target, b)) then failwith "virtual: Target is not the receiver" 0 - """ - |> withLangVersionPreview - |> compileExeAndRun - |> shouldSucceed - - [] - let ``Without the feature the delegate goes through a closure (default langversion)`` () = - FSharp """ + """ + |> withLangVersionPreview + |> compileExeAndRun + |> shouldSucceed + +[] +let ``Without the feature the delegate goes through a closure (default langversion)`` () = + FSharp """ module ClosureDelegateExecution open System @@ -225,16 +221,16 @@ let main _ = // Without the feature the delegate is built over a generated closure method named 'Invoke'. if d.Method.Name <> "Invoke" then failwithf "expected closure Method.Name 'Invoke' but got '%s'" d.Method.Name 0 - """ - |> compileExeAndRun - |> shouldSucceed - - // IL (BCL) method target: compiled as TOp.ILCall. With ILCall recognition the optimized eta-expanded - // delegate points directly at the BCL method, so Method.Name is the real method ('Max'), not a closure - // 'Invoke'. Compiled with --optimize+ so the eta forwarding call survives to codegen. - [] - let ``IL method targets are emitted directly when optimized (preview)`` () = - FSharp """ + """ + |> compileExeAndRun + |> shouldSucceed + +// IL (BCL) method target: compiled as TOp.ILCall. With ILCall recognition the optimized eta-expanded +// delegate points directly at the BCL method, so Method.Name is the real method ('Max'), not a closure +// 'Invoke'. Compiled with --optimize+ so the eta forwarding call survives to codegen. +[] +let ``IL method targets are emitted directly when optimized (preview)`` () = + FSharp """ module IlMethodDelegate open System @@ -245,18 +241,18 @@ let main _ = if d.Invoke(3, 7) <> 7 then failwith "il: wrong result" if d.Method.Name <> "Max" then failwithf "il: expected direct 'Max' but got '%s'" d.Method.Name 0 - """ - |> withLangVersionPreview - |> withOptions [ "--optimize+" ] - |> compileExeAndRun - |> shouldSucceed - - // A closure built from an explicit eta-lambda re-evaluates the receiver on every Invoke; a direct - // delegate would evaluate it once at construction. When the receiver has an effect (here a counter- - // bumping call) that difference is observable, so the closure must be kept even under optimization. - [] - let ``Side-effecting receiver keeps the closure so it is re-evaluated per invoke (preview)`` () = - FSharp """ + """ + |> withLangVersionPreview + |> withOptions [ "--optimize+" ] + |> compileExeAndRun + |> shouldSucceed + +// A closure built from an explicit eta-lambda re-evaluates the receiver on every Invoke; a direct +// delegate would evaluate it once at construction. When the receiver has an effect (here a counter- +// bumping call) that difference is observable, so the closure must be kept even under optimization. +[] +let ``Side-effecting receiver keeps the closure so it is re-evaluated per invoke (preview)`` () = + FSharp """ module ReceiverEffectDelegate open System @@ -280,17 +276,17 @@ let main _ = if r1 = r2 then failwithf "expected distinct boxes per invoke but got %d and %d" r1 r2 if d.Method.Name <> "Invoke" then failwithf "expected closure 'Invoke' but got '%s'" d.Method.Name 0 - """ - |> withLangVersionPreview - |> withOptions [ "--optimize+" ] - |> compileExeAndRun - |> shouldSucceed - - // Instance IL method target: a BCL instance method bound directly. The delegate's Target must be the - // receiver and Method.Name the real method. - [] - let ``Instance IL method targets are emitted directly when optimized (preview)`` () = - FSharp """ + """ + |> withLangVersionPreview + |> withOptions [ "--optimize+" ] + |> compileExeAndRun + |> shouldSucceed + +// Instance IL method target: a BCL instance method bound directly. The delegate's Target must be the +// receiver and Method.Name the real method. +[] +let ``Instance IL method targets are emitted directly when optimized (preview)`` () = + FSharp """ module IlInstanceMethodDelegate open System @@ -306,18 +302,18 @@ let main _ = if d.Method.Name <> "Append" then failwithf "il-instance: expected direct 'Append' but got '%s'" d.Method.Name if not (obj.ReferenceEquals(d.Target, sb)) then failwith "il-instance: Target is not the receiver" 0 - """ - |> withLangVersionPreview - |> withOptions [ "--optimize+" ] - |> compileExeAndRun - |> shouldSucceed - - // Custom, F#-declared delegate types (not just BCL Func/Action) point directly at the target method. - // Non-eta targets, so direct in both debug and release. Covers a static target (null Target) and an - // instance target (Target = receiver) through a user-defined delegate. - [] - let ``Custom F# delegate targets the real method and dispatch correctly (preview)`` () = - FSharp """ + """ + |> withLangVersionPreview + |> withOptions [ "--optimize+" ] + |> compileExeAndRun + |> shouldSucceed + +// Custom, F#-declared delegate types (not just BCL Func/Action) point directly at the target method. +// Non-eta targets, so direct in both debug and release. Covers a static target (null Target) and an +// instance target (Target = receiver) through a user-defined delegate. +[] +let ``Custom F# delegate targets the real method and dispatch correctly (preview)`` () = + FSharp """ module CustomDelegateExecution open System @@ -344,7 +340,156 @@ let main _ = if di.Method.Name <> "M" then failwithf "instance: expected 'M' but got '%s'" di.Method.Name if not (obj.ReferenceEquals(di.Target, c)) then failwith "instance: Target is not the receiver" 0 - """ - |> withLangVersionPreview - |> compileExeAndRun - |> shouldSucceed + """ + |> withLangVersionPreview + |> compileExeAndRun + |> shouldSucceed + +// Cases 33-38: a tupled application forwards a single tuple, not the Invoke parameters verbatim, so the +// shape is not recognized and a closure is kept even in release. +[] +let ``Tupled application stays a closure (preview)`` () = + FSharp """ +module TupledClosure + +open System + +[] +let accT (x: int, y: int) : int = x + y + +[] +let main _ = + let d = Func(fun a b -> accT (a, b)) + if d.Invoke(2, 3) <> 5 then failwith "wrong result" + if d.Method.Name <> "Invoke" then failwithf "expected closure 'Invoke' but got '%s'" d.Method.Name + 0 + """ + |> withLangVersionPreview + |> withOptions [ "--optimize+" ] + |> compileExeAndRun + |> shouldSucceed + +// Cases 39-43: a partial application leaves the target with more parameters than the delegate's Invoke, +// so there is no closed direct form and a closure is kept. +[] +let ``Partial application stays a closure (preview)`` () = + FSharp """ +module PartialClosure + +open System + +[] +let add3 (x: int) (y: int) (z: int) : int = x + y + z + +[] +let main _ = + let d = Func(add3 1) + if d.Invoke(2, 3) <> 6 then failwith "wrong result" + if d.Method.Name <> "Invoke" then failwithf "expected closure 'Invoke' but got '%s'" d.Method.Name + 0 + """ + |> withLangVersionPreview + |> compileExeAndRun + |> shouldSucceed + +// Cases 48-49: the synthesized unit argument is seen as a leading argument for a static target, so a +// unit-argument delegate stays a closure (and still runs). +[] +let ``Unit-argument delegate stays a closure (preview)`` () = + FSharp """ +module UnitArgClosure + +open System + +let mutable ran = false +let handler () : unit = ran <- true + +[] +let main _ = + let d = Action(handler) + d.Invoke() + if not ran then failwith "did not run" + if d.Method.Name <> "Invoke" then failwithf "expected closure 'Invoke' but got '%s'" d.Method.Name + 0 + """ + |> withLangVersionPreview + |> compileExeAndRun + |> shouldSucceed + +// Cases 50-51: a value-type receiver would need boxing (a delegate Target is object); not implemented, so +// it stays a closure and still dispatches correctly. +[] +let ``Struct value-type receiver stays a closure (preview)`` () = + FSharp """ +module StructClosure + +open System + +[] +type S = + member _.Add (x: int) (y: int) : int = x + y + +[] +let main _ = + let s = S() + let d = Func(s.Add) + if d.Invoke(2, 3) <> 5 then failwith "wrong result" + if d.Method.Name <> "Invoke" then failwithf "expected closure 'Invoke' but got '%s'" d.Method.Name + 0 + """ + |> withLangVersionPreview + |> compileExeAndRun + |> shouldSucceed + +// Case 52: an extension member compiles to a static method whose first parameter is the receiver, so it is +// bound as a leading argument (a partial application) and stays a closure. +[] +let ``Extension member stays a closure (preview)`` () = + FSharp """ +module ExtensionClosure + +open System +open System.Runtime.CompilerServices + +type Holder() = class end + +[] +type HolderExtensions = + [] + static member Combine (h: Holder, x: int, y: int) : int = x + y + +[] +let main _ = + let h = Holder() + let d = Func(fun a b -> h.Combine(a, b)) + if d.Invoke(2, 3) <> 5 then failwith "wrong result" + if d.Method.Name <> "Invoke" then failwithf "expected closure 'Invoke' but got '%s'" d.Method.Name + 0 + """ + |> withLangVersionPreview + |> compileExeAndRun + |> shouldSucceed + +// Case 53: a byref Invoke parameter with a mutating body is not a transparent forwarding call, so it stays +// a closure and mutates through the byref correctly. +[] +let ``Byref-parameter delegate stays a closure and mutates (preview)`` () = + FSharp """ +module ByrefClosure + +open System + +type D = delegate of byref -> unit + +[] +let main _ = + let d = D(fun x -> x <- x + 1) + let mutable v = 10 + d.Invoke(&v) + if v <> 11 then failwithf "expected 11 but got %d" v + if d.Method.Name <> "Invoke" then failwithf "expected closure 'Invoke' but got '%s'" d.Method.Name + 0 + """ + |> withLangVersionPreview + |> compileExeAndRun + |> shouldSucceed From 2d60fe4ef18419f8c8c2b637cb836ff76503b2c4 Mon Sep 17 00:00:00 2001 From: kerams Date: Thu, 25 Jun 2026 19:36:07 +0200 Subject: [PATCH 05/16] Remove duplicate test cases --- .../DirectDelegates/DelegateCustomType.fs | 14 ++-- .../DelegateExtensionMethod.fs | 2 +- .../DelegateGenericInstanceMethod.fs | 4 +- ...stanceMethod.fs.OptimizeOff.Preview.il.bsl | 12 ++-- ...enericInstanceMethod.fs.OptimizeOff.il.bsl | 12 ++-- ...nstanceMethod.fs.OptimizeOn.Preview.il.bsl | 6 +- ...GenericInstanceMethod.fs.OptimizeOn.il.bsl | 6 +- .../DelegateGenericStaticMethod.fs | 8 +-- ...StaticMethod.fs.OptimizeOff.Preview.il.bsl | 8 +-- ...eGenericStaticMethod.fs.OptimizeOff.il.bsl | 12 ++-- ...cStaticMethod.fs.OptimizeOn.Preview.il.bsl | 12 ++-- ...teGenericStaticMethod.fs.OptimizeOn.il.bsl | 12 ++-- .../DirectDelegates/DelegateILMethod.fs | 4 +- .../DirectDelegates/DelegateInstanceMethod.fs | 12 ++-- ...stanceMethod.fs.OptimizeOff.Preview.il.bsl | 16 ++--- ...legateInstanceMethod.fs.OptimizeOff.il.bsl | 36 +++++----- ...nstanceMethod.fs.OptimizeOn.Preview.il.bsl | 14 ++-- ...elegateInstanceMethod.fs.OptimizeOn.il.bsl | 24 +++---- .../DirectDelegates/DelegateKnownFunction.fs | 12 ++-- ...nownFunction.fs.OptimizeOff.Preview.il.bsl | 14 ++-- ...elegateKnownFunction.fs.OptimizeOff.il.bsl | 18 ++--- ...KnownFunction.fs.OptimizeOn.Preview.il.bsl | 18 ++--- ...DelegateKnownFunction.fs.OptimizeOn.il.bsl | 18 ++--- .../DirectDelegates/DelegateNegativeCases.fs | 8 +-- .../DirectDelegates/DelegateNonInlinable.fs | 22 ++---- ...NonInlinable.fs.OptimizeOff.Preview.il.bsl | 54 -------------- ...DelegateNonInlinable.fs.OptimizeOff.il.bsl | 72 ------------------- ...eNonInlinable.fs.OptimizeOn.Preview.il.bsl | 70 ------------------ .../DelegateNonInlinable.fs.OptimizeOn.il.bsl | 70 ------------------ .../DelegatePartialApplication.fs | 8 +-- .../DirectDelegates/DelegateStaticMethod.fs | 12 ++-- ...StaticMethod.fs.OptimizeOff.Preview.il.bsl | 14 ++-- ...DelegateStaticMethod.fs.OptimizeOff.il.bsl | 18 ++--- ...eStaticMethod.fs.OptimizeOn.Preview.il.bsl | 18 ++--- .../DelegateStaticMethod.fs.OptimizeOn.il.bsl | 18 ++--- .../DirectDelegates/DelegateStructTarget.fs | 4 +- .../DirectDelegates/DelegateUnitArg.fs | 4 +- .../DirectDelegates/DelegateUnitReturn.fs | 8 +-- .../DirectDelegates/DirectDelegates.fs | 12 ++-- 39 files changed, 214 insertions(+), 492 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs index 02f6b3101ad..c53cbdbec35 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs @@ -24,24 +24,24 @@ type C() = member _.M (x: int) (y: int) : int = x * y // Tupled-signature custom delegate: Invoke(int, int). -// 30. non-eta module function, custom delegate +// 28. non-eta module function, custom delegate let tupledNonEta () = DTupled(acc) -// 15. eta module function, custom delegate +// 14. eta module function, custom delegate let tupledEta () = DTupled(fun a b -> acc a b) // Instance member through a custom delegate: the receiver becomes the delegate's Target. -// 31. non-eta instance member, custom delegate +// 29. non-eta instance member, custom delegate let instanceNonEta (c: C) = DTupled(c.M) -// 16. eta instance member, custom delegate +// 15. eta instance member, custom delegate let instanceEta (c: C) = DTupled(fun a b -> c.M a b) // Generic custom delegate instantiated at int: Invoke(int):int over the generic target. -// 32. non-eta generic method, generic custom delegate +// 30. non-eta generic method, generic custom delegate let genNonEta () = DGen(ident) -// 17. eta generic method, generic custom delegate +// 16. eta generic method, generic custom delegate let genEta () = DGen(fun x -> ident x) // byref-parameter custom delegate: the body mutates through the byref, so it is not a transparent forwarding // call and stays a closure. Documents that a byref Invoke parameter does not break the recognizer. -// 53. byref-parameter delegate (mutating body) +// 51. byref-parameter delegate (mutating body) let byrefMutate () = DByref(fun x -> x <- x + 1) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs index e1118463d0b..b21ed6be396 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs @@ -15,5 +15,5 @@ type HolderExtensions = // An extension member compiles to a static method whose first parameter is the receiver, so using it as a // delegate target binds that receiver as a leading argument - a partial application, which has no closed // direct-delegate form. A closure must remain regardless of langversion. -// 52. extension member (receiver is a leading static arg) +// 50. extension member (receiver is a leading static arg) let extensionEta (h: Holder) = Func(fun a b -> h.Combine(a, b)) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs index 76adc561105..535bee3d582 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs @@ -9,5 +9,5 @@ type C() = // 5. eta generic instance method (curried application) let case5_etaCurried (o: C) = Action(fun a b -> o.IMc a b) -// 37. eta generic instance method, tupled application -let case37_etaTupled (o: C) = Action(fun a b -> o.IMt(a, b)) +// 35. eta generic instance method, tupled application +let case35_etaTupled (o: C) = Action(fun a b -> o.IMt(a, b)) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOff.Preview.il.bsl index 154f0d0415a..12696733399 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOff.Preview.il.bsl @@ -98,7 +98,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname case37_etaTupled@13 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case35_etaTupled@13 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -109,7 +109,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/case37_etaTupled@13::o + IL_0002: stfld class assembly/C assembly/case35_etaTupled@13::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -120,7 +120,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/case37_etaTupled@13::o + IL_0001: ldfld class assembly/C assembly/case35_etaTupled@13::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance void assembly/C::IMt(!!0, @@ -144,13 +144,13 @@ IL_0011: ret } - .method public static class [runtime]System.Action`2 case37_etaTupled(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case35_etaTupled(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/case37_etaTupled@13::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/case37_etaTupled@13::Invoke(int32, + IL_0001: newobj instance void assembly/case35_etaTupled@13::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case35_etaTupled@13::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOff.il.bsl index 154f0d0415a..12696733399 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOff.il.bsl @@ -98,7 +98,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname case37_etaTupled@13 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case35_etaTupled@13 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -109,7 +109,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/case37_etaTupled@13::o + IL_0002: stfld class assembly/C assembly/case35_etaTupled@13::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -120,7 +120,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/case37_etaTupled@13::o + IL_0001: ldfld class assembly/C assembly/case35_etaTupled@13::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance void assembly/C::IMt(!!0, @@ -144,13 +144,13 @@ IL_0011: ret } - .method public static class [runtime]System.Action`2 case37_etaTupled(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case35_etaTupled(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/case37_etaTupled@13::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/case37_etaTupled@13::Invoke(int32, + IL_0001: newobj instance void assembly/case35_etaTupled@13::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case35_etaTupled@13::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOn.Preview.il.bsl index 9e16587d173..74be77228f1 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOn.Preview.il.bsl @@ -79,7 +79,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case37_etaTupled@13 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case35_etaTupled@13 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -105,12 +105,12 @@ IL_000c: ret } - .method public static class [runtime]System.Action`2 case37_etaTupled(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case35_etaTupled(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case37_etaTupled@13::Invoke(int32, + IL_0001: ldftn void assembly/case35_etaTupled@13::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOn.il.bsl index 9e16587d173..74be77228f1 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOn.il.bsl @@ -79,7 +79,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case37_etaTupled@13 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case35_etaTupled@13 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -105,12 +105,12 @@ IL_000c: ret } - .method public static class [runtime]System.Action`2 case37_etaTupled(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case35_etaTupled(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case37_etaTupled@13::Invoke(int32, + IL_0001: ldftn void assembly/case35_etaTupled@13::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs index f35b3caf46d..a4e30bdaf08 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs @@ -6,11 +6,11 @@ type G<'U> = static member SMc<'T> (x: 'T) (y: 'T) : unit = () static member SMt<'T> (x: 'T, y: 'T) : unit = () -// 20. non-eta generic static method (generic type + generic method) -let case20_nonEta () = Action(G.SMc) +// 19. non-eta generic static method (generic type + generic method) +let case19_nonEta () = Action(G.SMc) // 3. eta generic static method (curried application) let case3_etaCurried () = Action(fun a b -> G.SMc a b) -// 35. eta generic static method, tupled application -let case35_etaTupled () = Action(fun a b -> G.SMt(a, b)) +// 33. eta generic static method, tupled application +let case33_etaTupled () = Action(fun a b -> G.SMt(a, b)) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOff.Preview.il.bsl index 0f0dd9201ea..39cb26442a6 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOff.Preview.il.bsl @@ -75,7 +75,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case35_etaTupled@16 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case33_etaTupled@16 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -94,7 +94,7 @@ } - .method public static class [runtime]System.Action`2 case20_nonEta() cil managed + .method public static class [runtime]System.Action`2 case19_nonEta() cil managed { .maxstack 8 @@ -118,12 +118,12 @@ IL_000c: ret } - .method public static class [runtime]System.Action`2 case35_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case33_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case35_etaTupled@16::Invoke(int32, + IL_0001: ldftn void assembly/case33_etaTupled@16::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOff.il.bsl index f22ac83b012..52f0ce42863 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOff.il.bsl @@ -56,7 +56,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case20_nonEta@10 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case19_nonEta@10 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -94,7 +94,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case35_etaTupled@16 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case33_etaTupled@16 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -113,12 +113,12 @@ } - .method public static class [runtime]System.Action`2 case20_nonEta() cil managed + .method public static class [runtime]System.Action`2 case19_nonEta() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case20_nonEta@10::Invoke(int32, + IL_0001: ldftn void assembly/case19_nonEta@10::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -137,12 +137,12 @@ IL_000c: ret } - .method public static class [runtime]System.Action`2 case35_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case33_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case35_etaTupled@16::Invoke(int32, + IL_0001: ldftn void assembly/case33_etaTupled@16::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOn.Preview.il.bsl index d29d01ad424..b3e611b286a 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOn.Preview.il.bsl @@ -56,7 +56,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case20_nonEta@10 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case19_nonEta@10 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -84,7 +84,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case35_etaTupled@16 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case33_etaTupled@16 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -98,12 +98,12 @@ } - .method public static class [runtime]System.Action`2 case20_nonEta() cil managed + .method public static class [runtime]System.Action`2 case19_nonEta() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case20_nonEta@10::Invoke(int32, + IL_0001: ldftn void assembly/case19_nonEta@10::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -122,12 +122,12 @@ IL_000c: ret } - .method public static class [runtime]System.Action`2 case35_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case33_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case35_etaTupled@16::Invoke(int32, + IL_0001: ldftn void assembly/case33_etaTupled@16::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOn.il.bsl index 6d706bf6afb..97f8c55b9dc 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOn.il.bsl @@ -56,7 +56,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case20_nonEta@10 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case19_nonEta@10 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -84,7 +84,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case35_etaTupled@16 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case33_etaTupled@16 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -98,12 +98,12 @@ } - .method public static class [runtime]System.Action`2 case20_nonEta() cil managed + .method public static class [runtime]System.Action`2 case19_nonEta() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case20_nonEta@10::Invoke(int32, + IL_0001: ldftn void assembly/case19_nonEta@10::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -122,12 +122,12 @@ IL_000c: ret } - .method public static class [runtime]System.Action`2 case35_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case33_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case35_etaTupled@16::Invoke(int32, + IL_0001: ldftn void assembly/case33_etaTupled@16::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs index 04304ab05d0..5be6e249aff 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs @@ -8,9 +8,9 @@ open System.Text // unoptimized builds the eta form keeps a closure (matching the F# eta policy). See DelegateNonInlinable // for the F#-value equivalent. -// 13. eta IL/BCL static method (System.Math.Max). +// 12. eta IL/BCL static method (System.Math.Max). let ilStaticEta () = Func(fun a b -> Math.Max(a, b)) -// 14. eta IL/BCL instance method (StringBuilder.Append(string)) on a reference type. The receiver is a +// 13. eta IL/BCL instance method (StringBuilder.Append(string)) on a reference type. The receiver is a // parameter, evaluated at the construction site and carried as the delegate's Target. let ilInstanceEta (sb: StringBuilder) = Func(fun s -> sb.Append(s)) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs index c76c310d5e9..76c6c53e334 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs @@ -8,14 +8,14 @@ type C(k: int) = abstract V : int -> int -> unit default _.V (x: int) (y: int) : unit = ignore k -// 21. non-eta instance method -let case21_nonEta (o: C) = Action(o.AddC) +// 20. non-eta instance method +let case20_nonEta (o: C) = Action(o.AddC) // 4. eta instance method (curried application) let case4_etaCurried (o: C) = Action(fun a b -> o.AddC a b) -// 36. eta instance method, tupled application -let case36_etaTupled (o: C) = Action(fun a b -> o.AddT(a, b)) +// 34. eta instance method, tupled application +let case34_etaTupled (o: C) = Action(fun a b -> o.AddT(a, b)) -// 22. non-eta virtual instance method: a direct delegate must use ldvirtftn (with dup) to preserve dispatch -let case22_virtual (o: C) = Action(o.V) +// 21. non-eta virtual instance method: a direct delegate must use ldvirtftn (with dup) to preserve dispatch +let case21_virtual (o: C) = Action(o.V) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOff.Preview.il.bsl index f01abe41e4a..876f6a1aaee 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOff.Preview.il.bsl @@ -122,7 +122,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname case36_etaTupled@18 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case34_etaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -133,7 +133,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/case36_etaTupled@18::o + IL_0002: stfld class assembly/C assembly/case34_etaTupled@18::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -144,7 +144,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/case36_etaTupled@18::o + IL_0001: ldfld class assembly/C assembly/case34_etaTupled@18::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance void assembly/C::AddT(int32, @@ -155,7 +155,7 @@ } - .method public static class [runtime]System.Action`2 case21_nonEta(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case20_nonEta(class assembly/C o) cil managed { .maxstack 8 @@ -180,20 +180,20 @@ IL_0011: ret } - .method public static class [runtime]System.Action`2 case36_etaTupled(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case34_etaTupled(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/case36_etaTupled@18::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/case36_etaTupled@18::Invoke(int32, + IL_0001: newobj instance void assembly/case34_etaTupled@18::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case34_etaTupled@18::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_0011: ret } - .method public static class [runtime]System.Action`2 case22_virtual(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case21_virtual(class assembly/C o) cil managed { .maxstack 8 diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOff.il.bsl index c5e6b7997f6..a9c6bfae607 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOff.il.bsl @@ -89,7 +89,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname case21_nonEta@12 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case20_nonEta@12 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -100,7 +100,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/case21_nonEta@12::o + IL_0002: stfld class assembly/C assembly/case20_nonEta@12::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -111,7 +111,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/case21_nonEta@12::o + IL_0001: ldfld class assembly/C assembly/case20_nonEta@12::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance void assembly/C::AddC(int32, @@ -155,7 +155,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname case36_etaTupled@18 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case34_etaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -166,7 +166,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/case36_etaTupled@18::o + IL_0002: stfld class assembly/C assembly/case34_etaTupled@18::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -177,7 +177,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/case36_etaTupled@18::o + IL_0001: ldfld class assembly/C assembly/case34_etaTupled@18::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance void assembly/C::AddT(int32, @@ -188,7 +188,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname case22_virtual@21 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case21_virtual@21 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -199,7 +199,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/case22_virtual@21::o + IL_0002: stfld class assembly/C assembly/case21_virtual@21::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -210,7 +210,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/case22_virtual@21::o + IL_0001: ldfld class assembly/C assembly/case21_virtual@21::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: tail. @@ -221,13 +221,13 @@ } - .method public static class [runtime]System.Action`2 case21_nonEta(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case20_nonEta(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/case21_nonEta@12::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/case21_nonEta@12::Invoke(int32, + IL_0001: newobj instance void assembly/case20_nonEta@12::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case20_nonEta@12::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -247,26 +247,26 @@ IL_0011: ret } - .method public static class [runtime]System.Action`2 case36_etaTupled(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case34_etaTupled(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/case36_etaTupled@18::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/case36_etaTupled@18::Invoke(int32, + IL_0001: newobj instance void assembly/case34_etaTupled@18::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case34_etaTupled@18::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_0011: ret } - .method public static class [runtime]System.Action`2 case22_virtual(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case21_virtual(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/case22_virtual@21::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/case22_virtual@21::Invoke(int32, + IL_0001: newobj instance void assembly/case21_virtual@21::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case21_virtual@21::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOn.Preview.il.bsl index 84816e669f0..0395005c4a6 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOn.Preview.il.bsl @@ -77,7 +77,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case21_nonEta@12 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case20_nonEta@12 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -105,7 +105,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case36_etaTupled@18 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case34_etaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -119,12 +119,12 @@ } - .method public static class [runtime]System.Action`2 case21_nonEta(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case20_nonEta(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case21_nonEta@12::Invoke(int32, + IL_0001: ldftn void assembly/case20_nonEta@12::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -143,19 +143,19 @@ IL_000c: ret } - .method public static class [runtime]System.Action`2 case36_etaTupled(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case34_etaTupled(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case36_etaTupled@18::Invoke(int32, + IL_0001: ldftn void assembly/case34_etaTupled@18::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case22_virtual(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case21_virtual(class assembly/C o) cil managed { .maxstack 8 diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOn.il.bsl index 71fd756ac65..b3569cf1a24 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOn.il.bsl @@ -77,7 +77,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case21_nonEta@12 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case20_nonEta@12 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -105,7 +105,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case36_etaTupled@18 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case34_etaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -119,7 +119,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname case22_virtual@21 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname case21_virtual@21 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -130,7 +130,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/case22_virtual@21::o + IL_0002: stfld class assembly/C assembly/case21_virtual@21::o IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -141,7 +141,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/case22_virtual@21::o + IL_0001: ldfld class assembly/C assembly/case21_virtual@21::o IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: tail. @@ -152,12 +152,12 @@ } - .method public static class [runtime]System.Action`2 case21_nonEta(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case20_nonEta(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case21_nonEta@12::Invoke(int32, + IL_0001: ldftn void assembly/case20_nonEta@12::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -176,25 +176,25 @@ IL_000c: ret } - .method public static class [runtime]System.Action`2 case36_etaTupled(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case34_etaTupled(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case36_etaTupled@18::Invoke(int32, + IL_0001: ldftn void assembly/case34_etaTupled@18::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case22_virtual(class assembly/C o) cil managed + .method public static class [runtime]System.Action`2 case21_virtual(class assembly/C o) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/case22_virtual@21::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/case22_virtual@21::Invoke(int32, + IL_0001: newobj instance void assembly/case21_virtual@21::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/case21_virtual@21::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs index 50debc1ffcb..8e550999ddf 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs @@ -7,14 +7,14 @@ let handlerCurried (x: int) (y: int) : unit = () let handlerTupled (x: int, y: int) : unit = () let handler3 (x: int) (y: int) (z: int) : unit = () -// 18. non-eta module function -let case18_nonEta () = Action(handlerCurried) +// 17. non-eta module function +let case17_nonEta () = Action(handlerCurried) // 1. eta module function (curried application) let case1_etaCurried () = Action(fun a b -> handlerCurried a b) -// 33. eta module function, tupled application (same compiled representation) -let case33_etaTupled () = Action(fun a b -> handlerTupled (a, b)) +// 31. eta module function, tupled application (same compiled representation) +let case31_etaTupled () = Action(fun a b -> handlerTupled (a, b)) -// 39. partial application of module function (constant arg) -let case39_partial () = Action(handler3 1) +// 37. partial application of module function (constant arg) +let case37_partial () = Action(handler3 1) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOff.Preview.il.bsl index e34b7189e73..dcd46c650c9 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOff.Preview.il.bsl @@ -52,7 +52,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case33_etaTupled@17 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case31_etaTupled@17 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -71,7 +71,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case39_partial@20 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case37_partial@20 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -120,7 +120,7 @@ IL_0000: ret } - .method public static class [runtime]System.Action`2 case18_nonEta() cil managed + .method public static class [runtime]System.Action`2 case17_nonEta() cil managed { .maxstack 8 @@ -144,24 +144,24 @@ IL_000c: ret } - .method public static class [runtime]System.Action`2 case33_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case31_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case33_etaTupled@17::Invoke(int32, + IL_0001: ldftn void assembly/case31_etaTupled@17::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case39_partial() cil managed + .method public static class [runtime]System.Action`2 case37_partial() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case39_partial@20::Invoke(int32, + IL_0001: ldftn void assembly/case37_partial@20::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOff.il.bsl index b1169b274d3..4d080c7c4a9 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOff.il.bsl @@ -33,7 +33,7 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case18_nonEta@11 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case17_nonEta@11 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -71,7 +71,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case33_etaTupled@17 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case31_etaTupled@17 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -90,7 +90,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case39_partial@20 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case37_partial@20 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -139,12 +139,12 @@ IL_0000: ret } - .method public static class [runtime]System.Action`2 case18_nonEta() cil managed + .method public static class [runtime]System.Action`2 case17_nonEta() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case18_nonEta@11::Invoke(int32, + IL_0001: ldftn void assembly/case17_nonEta@11::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -163,24 +163,24 @@ IL_000c: ret } - .method public static class [runtime]System.Action`2 case33_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case31_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case33_etaTupled@17::Invoke(int32, + IL_0001: ldftn void assembly/case31_etaTupled@17::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case39_partial() cil managed + .method public static class [runtime]System.Action`2 case37_partial() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case39_partial@20::Invoke(int32, + IL_0001: ldftn void assembly/case37_partial@20::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOn.Preview.il.bsl index 43d1a477c17..c737dc4e5dd 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOn.Preview.il.bsl @@ -33,7 +33,7 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case18_nonEta@11 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case17_nonEta@11 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -61,7 +61,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case33_etaTupled@17 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case31_etaTupled@17 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -75,7 +75,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case39_partial@20 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case37_partial@20 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -117,12 +117,12 @@ IL_0000: ret } - .method public static class [runtime]System.Action`2 case18_nonEta() cil managed + .method public static class [runtime]System.Action`2 case17_nonEta() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case18_nonEta@11::Invoke(int32, + IL_0001: ldftn void assembly/case17_nonEta@11::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -141,24 +141,24 @@ IL_000c: ret } - .method public static class [runtime]System.Action`2 case33_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case31_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case33_etaTupled@17::Invoke(int32, + IL_0001: ldftn void assembly/case31_etaTupled@17::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case39_partial() cil managed + .method public static class [runtime]System.Action`2 case37_partial() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case39_partial@20::Invoke(int32, + IL_0001: ldftn void assembly/case37_partial@20::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOn.il.bsl index 6d997901f37..2ac94696387 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOn.il.bsl @@ -33,7 +33,7 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case18_nonEta@11 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case17_nonEta@11 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -61,7 +61,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case33_etaTupled@17 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case31_etaTupled@17 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -75,7 +75,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case39_partial@20 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case37_partial@20 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -117,12 +117,12 @@ IL_0000: ret } - .method public static class [runtime]System.Action`2 case18_nonEta() cil managed + .method public static class [runtime]System.Action`2 case17_nonEta() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case18_nonEta@11::Invoke(int32, + IL_0001: ldftn void assembly/case17_nonEta@11::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -141,24 +141,24 @@ IL_000c: ret } - .method public static class [runtime]System.Action`2 case33_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case31_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case33_etaTupled@17::Invoke(int32, + IL_0001: ldftn void assembly/case31_etaTupled@17::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case39_partial() cil managed + .method public static class [runtime]System.Action`2 case37_partial() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case39_partial@20::Invoke(int32, + IL_0001: ldftn void assembly/case37_partial@20::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs index a18125b447b..4f1c2e34a96 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs @@ -2,22 +2,22 @@ module DelegateNegativeCases open System -// 44. first-class function value: there is no target method to point at, so a closure must remain +// 42. first-class function value: there is no target method to point at, so a closure must remain let firstClass (handler: int -> int -> unit) = Action(handler) -// 45. lambda body is not a single direct forwarding call to a known target (the argument is computed, +// 43. lambda body is not a single direct forwarding call to a known target (the argument is computed, // not the delegate parameters forwarded as-is): a closure must remain let private sink (x: int) : unit = () let notDirect (k: int) = Action(fun a b -> sink (a + b + k)) -// 46. arguments reordered: not a transparent forwarding, so a closure must remain +// 44. arguments reordered: not a transparent forwarding, so a closure must remain let reordered (handler: int -> int -> unit) = Action(fun a b -> handler b a) type Holder() = [] member _.TakesObj (x: obj) : int = 1 -// 47. Reference-parameter contravariance: the delegate's Invoke is (string):int and the target is (object):int. +// 45. Reference-parameter contravariance: the delegate's Invoke is (string):int and the target is (object):int. // The CLR would accept this binding directly (a delegate may bind a method whose parameter is a supertype), // but it stays a closure: F# elaborates the 'string -> obj' argument upcast as a coercion, so the forwarded // argument is no longer a verbatim Invoke parameter and the direct-delegate recognizer does not match. (The diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs index d1457922935..0cdba8a007a 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs @@ -8,20 +8,20 @@ let accCurried (x: int) (y: int) : int = x + y [] let accTupled (x: int, y: int) : int = x + y -// 23. non-eta module function, non-inlinable +// 22. non-eta module function, non-inlinable let niNonEta () = Func(accCurried) // 6. eta module function, non-inlinable (curried application) let niEtaCurried () = Func(fun a b -> accCurried a b) -// 38. eta module function, non-inlinable, tupled application +// 36. eta module function, non-inlinable, tupled application let niEtaTupled () = Func(fun a b -> accTupled (a, b)) type S = [] static member AccS (x: int) (y: int) : int = x + y -// 24. non-eta static method, non-inlinable +// 23. non-eta static method, non-inlinable let niStaticNonEta () = Func(S.AccS) // 7. eta static method, non-inlinable @@ -34,26 +34,14 @@ type C(k: int) = [] member _.GPick<'T> (x: 'T) (y: 'T) : 'T = x -// 25. non-eta instance method, non-inlinable +// 24. non-eta instance method, non-inlinable let niInstanceNonEta (o: C) = Func(o.AccC) // 8. eta instance method, non-inlinable let niInstanceEta (o: C) = Func(fun a b -> o.AccC a b) -// 26. non-eta generic instance method, non-inlinable +// 25. non-eta generic instance method, non-inlinable let niGenericInstanceNonEta (o: C) = Func(o.GPick) // 9. eta generic instance method, non-inlinable let niGenericInstanceEta (o: C) = Func(fun a b -> o.GPick a b) - -// A trivial, inlinable target kept on purpose to document and -// guard the inline-vs-direct interaction. In release the optimizer may inline the body before the -// recognizer runs; the recognizer must therefore act in the optimizer (before the head call is inlined) -// for this to still become a direct delegate. -let trivial (x: int) (y: int) : int = x + y - -// 27. non-eta inlinable trivial target (inline-race contrast) -let niTrivialNonEta () = Func(trivial) - -// 10. eta inlinable trivial target (inline-race) -let niTrivialEta () = Func(fun a b -> trivial a b) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.Preview.il.bsl index b359893da86..15f41614e90 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.Preview.il.bsl @@ -217,24 +217,6 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@59 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 a, - int32 b) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call int32 assembly::trivial(int32, - int32) - IL_0007: ret - } - - } - .method public static int32 accCurried(int32 x, int32 y) cil managed { @@ -370,42 +352,6 @@ IL_0011: ret } - .method public static int32 trivial(int32 x, - int32 y) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: add - IL_0003: ret - } - - .method public static class [runtime]System.Func`3 niTrivialNonEta() cil managed - { - - .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn int32 assembly::trivial(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - - .method public static class [runtime]System.Func`3 niTrivialEta() cil managed - { - - .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialEta@59::Invoke(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - } .class private abstract auto ansi sealed ''.$assembly diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.il.bsl index 123299f5ca8..dea6f5753aa 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.il.bsl @@ -318,42 +318,6 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@56 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 x, - int32 y) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call int32 assembly::trivial(int32, - int32) - IL_0007: ret - } - - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@59 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 a, - int32 b) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call int32 assembly::trivial(int32, - int32) - IL_0007: ret - } - - } - .method public static int32 accCurried(int32 x, int32 y) cil managed { @@ -491,42 +455,6 @@ IL_0011: ret } - .method public static int32 trivial(int32 x, - int32 y) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: add - IL_0003: ret - } - - .method public static class [runtime]System.Func`3 niTrivialNonEta() cil managed - { - - .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialNonEta@56::Invoke(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - - .method public static class [runtime]System.Func`3 niTrivialEta() cil managed - { - - .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialEta@59::Invoke(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - } .class private abstract auto ansi sealed ''.$assembly diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.Preview.il.bsl index 4f7a18609ca..f2ac084ccbb 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.Preview.il.bsl @@ -116,40 +116,6 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@56 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 x, - int32 y) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: add - IL_0003: ret - } - - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@59 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 a, - int32 b) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: add - IL_0003: ret - } - - } - .method public static int32 accCurried(int32 x, int32 y) cil managed { @@ -283,42 +249,6 @@ IL_000c: ret } - .method public static int32 trivial(int32 x, - int32 y) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: add - IL_0003: ret - } - - .method public static class [runtime]System.Func`3 niTrivialNonEta() cil managed - { - - .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialNonEta@56::Invoke(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - - .method public static class [runtime]System.Func`3 niTrivialEta() cil managed - { - - .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialEta@59::Invoke(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - } .class private abstract auto ansi sealed ''.$assembly diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.il.bsl index 8a4ce549f4a..3f3f5dc01ed 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.il.bsl @@ -316,40 +316,6 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialNonEta@56 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 x, - int32 y) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: add - IL_0003: ret - } - - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niTrivialEta@59 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 a, - int32 b) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: add - IL_0003: ret - } - - } - .method public static int32 accCurried(int32 x, int32 y) cil managed { @@ -487,42 +453,6 @@ IL_0011: ret } - .method public static int32 trivial(int32 x, - int32 y) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: add - IL_0003: ret - } - - .method public static class [runtime]System.Func`3 niTrivialNonEta() cil managed - { - - .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialNonEta@56::Invoke(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - - .method public static class [runtime]System.Func`3 niTrivialEta() cil managed - { - - .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn int32 assembly/niTrivialEta@59::Invoke(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - } .class private abstract auto ansi sealed ''.$assembly diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs index 05dce73a5ee..2e1a9a13c4e 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs @@ -2,7 +2,7 @@ module DelegatePartialApplication open System -// Cases 15/16 (in DelegateKnownFunction.fs / DelegateStaticMethod.fs) capture a +// Cases 37/38 (in DelegateKnownFunction.fs / DelegateStaticMethod.fs) capture a // constant first argument, so their closure can stay static (the constant is re-materialised in Invoke // with no instance field). Capturing a runtime VALUE instead forces the closure to carry an instance // field, which exercises a distinct emit path. None of these can ever become a direct delegate (the @@ -16,11 +16,11 @@ type C = type I(k: int) = member _.Add3 (x: int) (y: int) (z: int) : unit = ignore k -// 41. partial application of module function (captured var: instance-field capture of n) +// 39. partial application of module function (captured var: instance-field capture of n) let papKnownVar (n: int) = Action(handler3 n) -// 42. partial application of static method (captured var) +// 40. partial application of static method (captured var) let papStaticVar (n: int) = Action(C.Add3 n) -// 43. partial application of instance method (captures both the receiver and n) +// 41. partial application of instance method (captures both the receiver and n) let papInstanceVar (o: I) (n: int) = Action(o.Add3 n) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs index c77a2fc19dc..a78c9c97dac 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs @@ -7,15 +7,15 @@ type C = static member AddT (x: int, y: int) : unit = () static member Add3 (x: int) (y: int) (z: int) : unit = () -// 19. non-eta static method +// 18. non-eta static method // (a tupled member is seen as a single tuple-arg value and will not coerce non-eta; use the curried member) -let case19_nonEta () = Action(C.AddC) +let case18_nonEta () = Action(C.AddC) // 2. eta static method (curried application) let case2_etaCurried () = Action(fun a b -> C.AddC a b) -// 34. eta static method, tupled application -let case34_etaTupled () = Action(fun a b -> C.AddT(a, b)) +// 32. eta static method, tupled application +let case32_etaTupled () = Action(fun a b -> C.AddT(a, b)) -// 40. partial application of static method (constant arg) -let case40_partial () = Action(C.Add3 1) +// 38. partial application of static method (constant arg) +let case38_partial () = Action(C.Add3 1) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOff.Preview.il.bsl index d7b33e7d72b..2b90acb082f 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOff.Preview.il.bsl @@ -86,7 +86,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case34_etaTupled@18 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case32_etaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -105,7 +105,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case40_partial@21 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case38_partial@21 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -126,7 +126,7 @@ } - .method public static class [runtime]System.Action`2 case19_nonEta() cil managed + .method public static class [runtime]System.Action`2 case18_nonEta() cil managed { .maxstack 8 @@ -150,24 +150,24 @@ IL_000c: ret } - .method public static class [runtime]System.Action`2 case34_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case32_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case34_etaTupled@18::Invoke(int32, + IL_0001: ldftn void assembly/case32_etaTupled@18::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case40_partial() cil managed + .method public static class [runtime]System.Action`2 case38_partial() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case40_partial@21::Invoke(int32, + IL_0001: ldftn void assembly/case38_partial@21::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOff.il.bsl index f1d3a8474e1..ce68901f780 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOff.il.bsl @@ -67,7 +67,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case19_nonEta@12 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case18_nonEta@12 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -105,7 +105,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case34_etaTupled@18 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case32_etaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -124,7 +124,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case40_partial@21 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case38_partial@21 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -145,12 +145,12 @@ } - .method public static class [runtime]System.Action`2 case19_nonEta() cil managed + .method public static class [runtime]System.Action`2 case18_nonEta() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case19_nonEta@12::Invoke(int32, + IL_0001: ldftn void assembly/case18_nonEta@12::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -169,24 +169,24 @@ IL_000c: ret } - .method public static class [runtime]System.Action`2 case34_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case32_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case34_etaTupled@18::Invoke(int32, + IL_0001: ldftn void assembly/case32_etaTupled@18::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case40_partial() cil managed + .method public static class [runtime]System.Action`2 case38_partial() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case40_partial@21::Invoke(int32, + IL_0001: ldftn void assembly/case38_partial@21::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOn.Preview.il.bsl index f2dd2579e43..1de6bfcc577 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOn.Preview.il.bsl @@ -67,7 +67,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case19_nonEta@12 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case18_nonEta@12 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -95,7 +95,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case34_etaTupled@18 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case32_etaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -109,7 +109,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case40_partial@21 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case38_partial@21 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -123,12 +123,12 @@ } - .method public static class [runtime]System.Action`2 case19_nonEta() cil managed + .method public static class [runtime]System.Action`2 case18_nonEta() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case19_nonEta@12::Invoke(int32, + IL_0001: ldftn void assembly/case18_nonEta@12::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -147,24 +147,24 @@ IL_000c: ret } - .method public static class [runtime]System.Action`2 case34_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case32_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case34_etaTupled@18::Invoke(int32, + IL_0001: ldftn void assembly/case32_etaTupled@18::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case40_partial() cil managed + .method public static class [runtime]System.Action`2 case38_partial() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case40_partial@21::Invoke(int32, + IL_0001: ldftn void assembly/case38_partial@21::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOn.il.bsl index f2dd2579e43..1de6bfcc577 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOn.il.bsl @@ -67,7 +67,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case19_nonEta@12 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case18_nonEta@12 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -95,7 +95,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case34_etaTupled@18 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case32_etaTupled@18 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -109,7 +109,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case40_partial@21 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case38_partial@21 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -123,12 +123,12 @@ } - .method public static class [runtime]System.Action`2 case19_nonEta() cil managed + .method public static class [runtime]System.Action`2 case18_nonEta() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case19_nonEta@12::Invoke(int32, + IL_0001: ldftn void assembly/case18_nonEta@12::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -147,24 +147,24 @@ IL_000c: ret } - .method public static class [runtime]System.Action`2 case34_etaTupled() cil managed + .method public static class [runtime]System.Action`2 case32_etaTupled() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case34_etaTupled@18::Invoke(int32, + IL_0001: ldftn void assembly/case32_etaTupled@18::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret } - .method public static class [runtime]System.Action`2 case40_partial() cil managed + .method public static class [runtime]System.Action`2 case38_partial() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case40_partial@21::Invoke(int32, + IL_0001: ldftn void assembly/case38_partial@21::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs index 84785eda906..c856d1f5c7b 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs @@ -10,8 +10,8 @@ type S = // The target is an instance method on a value type. A delegate's Target is an object, so a direct delegate // would have to box the receiver; until that is implemented a closure is kept. (See DelegateInstanceMethod // for the reference-type case, which is emitted directly.) -// 50. non-eta struct (value-type) receiver +// 48. non-eta struct (value-type) receiver let structInstanceNonEta (s: S) = Func(s.Add) -// 51. eta struct (value-type) receiver +// 49. eta struct (value-type) receiver let structInstanceEta (s: S) = Func(fun a b -> s.Add a b) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs index a72fe20cf80..7a164ad4045 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs @@ -4,8 +4,8 @@ open System let handler () : unit = () -// 48. non-eta unit-argument delegate +// 46. non-eta unit-argument delegate let caseUnitNonEta () = Action(handler) -// 49. eta unit-argument delegate +// 47. eta unit-argument delegate let caseUnitEta () = Action(fun () -> handler ()) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs index 10e8032a87c..eca9f6e4b1f 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs @@ -6,10 +6,10 @@ open System [] let returnsUnit (x: int) (y: int) : unit = () -// 28. non-eta unit-returning member (compiled to void) +// 26. non-eta unit-returning member (compiled to void) let voidNonEta () = Action(returnsUnit) -// 11. eta unit-returning member +// 10. eta unit-returning member let voidEta () = Action(fun a b -> returnsUnit a b) type C = @@ -20,8 +20,8 @@ type C = static member Echo<'T>(x: 'T) : 'T = x // Generic return type variable instantiated to unit; the delegate likewise returns unit. -// 29. non-eta generic return tyvar instantiated to unit (compiled return is Unit, not void) +// 27. non-eta generic return tyvar instantiated to unit (compiled return is Unit, not void) let unitGenericReturnNonEta () = Func(C.Echo) -// 12. eta generic unit-returning method +// 11. eta generic unit-returning method let unitGenericReturnEta () = Func(fun (x: unit) -> C.Echo x) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs index f14d00e5586..6bc35cbc296 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs @@ -345,7 +345,7 @@ let main _ = |> compileExeAndRun |> shouldSucceed -// Cases 33-38: a tupled application forwards a single tuple, not the Invoke parameters verbatim, so the +// Cases 31-36: a tupled application forwards a single tuple, not the Invoke parameters verbatim, so the // shape is not recognized and a closure is kept even in release. [] let ``Tupled application stays a closure (preview)`` () = @@ -369,7 +369,7 @@ let main _ = |> compileExeAndRun |> shouldSucceed -// Cases 39-43: a partial application leaves the target with more parameters than the delegate's Invoke, +// Cases 37-41: a partial application leaves the target with more parameters than the delegate's Invoke, // so there is no closed direct form and a closure is kept. [] let ``Partial application stays a closure (preview)`` () = @@ -392,7 +392,7 @@ let main _ = |> compileExeAndRun |> shouldSucceed -// Cases 48-49: the synthesized unit argument is seen as a leading argument for a static target, so a +// Cases 46-47: the synthesized unit argument is seen as a leading argument for a static target, so a // unit-argument delegate stays a closure (and still runs). [] let ``Unit-argument delegate stays a closure (preview)`` () = @@ -416,7 +416,7 @@ let main _ = |> compileExeAndRun |> shouldSucceed -// Cases 50-51: a value-type receiver would need boxing (a delegate Target is object); not implemented, so +// Cases 48-49: a value-type receiver would need boxing (a delegate Target is object); not implemented, so // it stays a closure and still dispatches correctly. [] let ``Struct value-type receiver stays a closure (preview)`` () = @@ -441,7 +441,7 @@ let main _ = |> compileExeAndRun |> shouldSucceed -// Case 52: an extension member compiles to a static method whose first parameter is the receiver, so it is +// Case 50: an extension member compiles to a static method whose first parameter is the receiver, so it is // bound as a leading argument (a partial application) and stays a closure. [] let ``Extension member stays a closure (preview)`` () = @@ -470,7 +470,7 @@ let main _ = |> compileExeAndRun |> shouldSucceed -// Case 53: a byref Invoke parameter with a mutating body is not a transparent forwarding call, so it stays +// Case 51: a byref Invoke parameter with a mutating body is not a transparent forwarding call, so it stays // a closure and mutates through the byref correctly. [] let ``Byref-parameter delegate stays a closure and mutates (preview)`` () = From dc32fcdbd736bbaeab616a0c494531852c67e753 Mon Sep 17 00:00:00 2001 From: kerams Date: Fri, 26 Jun 2026 18:45:46 +0200 Subject: [PATCH 06/16] Refactor --- src/Compiler/CodeGen/IlxGen.Delegates.fs | 168 +++++++++++++++ src/Compiler/CodeGen/IlxGen.fs | 192 +++++------------- src/Compiler/FSharp.Compiler.Service.fsproj | 1 + .../TypedTree/TypedTreeOps.ExprOps.fs | 65 ------ .../TypedTree/TypedTreeOps.ExprOps.fsi | 26 --- .../DirectDelegates/DirectDelegates.fs | 74 +++++++ 6 files changed, 296 insertions(+), 230 deletions(-) create mode 100644 src/Compiler/CodeGen/IlxGen.Delegates.fs diff --git a/src/Compiler/CodeGen/IlxGen.Delegates.fs b/src/Compiler/CodeGen/IlxGen.Delegates.fs new file mode 100644 index 00000000000..4d7e8c7a2a8 --- /dev/null +++ b/src/Compiler/CodeGen/IlxGen.Delegates.fs @@ -0,0 +1,168 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +/// Helpers for delegate construction in the ILX generator +[] +module internal FSharp.Compiler.IlxGenDelegates + +open Internal.Utilities.Collections +open Internal.Utilities.Library.Extras + +open FSharp.Compiler +open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.TcGlobals +open FSharp.Compiler.TypedTree +open FSharp.Compiler.TypedTreeBasics +open FSharp.Compiler.TypedTreeOps + +/// The target of a delegate forwarding call +[] +type DelegateForwardingTarget = + /// A known F# value: a module-level function or a member + | FSharpVal of vref: ValRef * valUseFlags: ValUseFlag * tyargs: TypeInst * leadingArgs: Expr list + /// A direct IL method call (e.g. a BCL method) + | ILMethod of + isVirtual: bool * + isStruct: bool * + isCtor: bool * + valUseFlags: ValUseFlag * + ilMethRef: ILMethodRef * + enclTypeInst: TypeInst * + methInst: TypeInst * + leadingArgs: Expr list + | Other + +let classifyForwardingTarget g (invokeParams: Val list) expr = + // The trailing arguments of the call must be exactly the delegate's Invoke parameters, forwarded + // verbatim and in order. The remaining leading arguments (e.g. an instance receiver) are returned + // for the consumer to handle. + let matchForwarding (args: Expr list) = + let numLeading = args.Length - invokeParams.Length + + if numLeading >= 0 then + let leadingArgs, forwardedArgs = List.splitAt numLeading args + + if + List.forall2 + (fun (a: Expr) (tv: Val) -> + match stripDebugPoints a with + | Expr.Val(avref, _, _) -> valRefEq g avref (mkLocalValRef tv) + | _ -> false) + forwardedArgs + invokeParams + then + ValueSome leadingArgs + else + ValueNone + else + ValueNone + + match stripDebugPoints expr with + | Expr.App(Expr.Val(vref, valUseFlags, _), _, tyargs, args, _) -> + match matchForwarding args with + | ValueSome leadingArgs -> DelegateForwardingTarget.FSharpVal(vref, valUseFlags, tyargs, leadingArgs) + | ValueNone -> DelegateForwardingTarget.Other + | Expr.Op(TOp.ILCall(isVirtual, _, isStruct, isCtor, valUseFlag, _, _, ilMethRef, enclTypeInst, methInst, _), _, args, _) -> + match matchForwarding args with + | ValueSome leadingArgs -> + DelegateForwardingTarget.ILMethod(isVirtual, isStruct, isCtor, valUseFlag, ilMethRef, enclTypeInst, methInst, leadingArgs) + | ValueNone -> DelegateForwardingTarget.Other + | _ -> DelegateForwardingTarget.Other + +/// For an instance method the single leading argument is the receiver; a static method or module function +/// must have no leading arguments (otherwise it is a partial application). +let private receiverShapeOk (leadingArgs: Expr list) takesInstanceArg = + if takesInstanceArg then + match leadingArgs with + | [ _ ] -> true + | _ -> false + else + List.isEmpty leadingArgs + +/// The receiver is hoisted to the delegate-construction site, so a direct delegate is only sound when it can +/// be evaluated there exactly once and as the Target: +/// - A closure built from an explicit eta-lambda (e.g. `fun a -> recv.M a`) re-evaluates the receiver on +/// every Invoke; evaluating it once instead is observable unless it is side-effect free (a non-mutable +/// value, a constant, a pure field read). +/// - It must not reference the delegate's own Invoke parameters, which only exist inside the delegee method. +/// ExprHasEffect short-circuits before the freeInExpr allocation, so disqualified delegates skip the traversal. +let private receiverBindable g (invokeParams: Val list) (leadingArgs: Expr list) = + match leadingArgs with + | [ recv ] -> + let recvFreeLocals = (freeInExpr CollectLocals recv).FreeLocals + + not (Optimizer.ExprHasEffect g recv) + && (not (invokeParams |> List.exists (fun tv -> Zset.contains tv recvFreeLocals))) + | _ -> true + +/// An F# value target can be pointed at directly only when the call needs no witnesses and is not a +/// constructor / base / self-init call, when the receiver shape is right, and when the receiver can be safely +/// hoisted to the construction site. Only the witness fact is passed in (it needs the IlxGen environment); the +/// newobj / super-init / self-init / instance-receiver facts are derived here from the member's call info, and +/// the base-call flag from valUseFlags. +let fsharpValDirectlyBindable g (invokeParams: Val list) (leadingArgs: Expr list) (vrefM: ValRef) (valUseFlags: ValUseFlag) hasWitnesses = + let _, _, newobj, isSuperInit, isSelfInit, takesInstanceArg, _, _ = + GetMemberCallInfo g (vrefM, valUseFlags) + + not hasWitnesses + && not newobj + && not isSuperInit + && not isSelfInit + && not valUseFlags.IsVSlotDirectCall + && receiverShapeOk leadingArgs takesInstanceArg + && receiverBindable g invokeParams leadingArgs + +/// An IL method target can be pointed at directly only when it is not a constructor / base / constrained call, +/// when the receiver shape is right, when the receiver is not a value type (boxing is not yet implemented), and +/// when the receiver can be safely hoisted to the construction site. The instance-receiver flag is derived here +/// from ilMethRef and the base/constrained-call flags from valUseFlag. +let ilMethodDirectlyBindable + g + (invokeParams: Val list) + (leadingArgs: Expr list) + (ilMethRef: ILMethodRef) + isStruct + (valUseFlag: ValUseFlag) + isCtor + = + let takesInstanceArg = ilMethRef.CallingConv.IsInstance + + not isCtor + && not valUseFlag.IsVSlotDirectCall + && not valUseFlag.IsPossibleConstrainedCall + && receiverShapeOk leadingArgs takesInstanceArg + && not (takesInstanceArg && isStruct) + && receiverBindable g invokeParams leadingArgs + +/// Confirm the target's IL signature is compatible with the delegate's Invoke. The type checker has already +/// verified the delegate is built from a compatible function shape and the forwarding match pins the arity, +/// so this is the residual check: +/// - parameter *count* matches (essentially a sanity check). Parameter IL *types* are deliberately not +/// compared: a value-type parameter is exact by construction (a widening/boxing argument would not be a +/// verbatim Val and so would not have matched), and for reference-type parameters the CLR's delegate +/// relaxation permits contravariance, so an exact comparison would only produce false negatives. +/// - for a non-generic target, the return type matches exactly. This is the one IL mismatch the recognizer +/// cannot see and the CLR will not relax: notably an F# 'unit' return compiled to 'void' versus a delegate +/// whose Invoke returns 'Unit'. For a generic target the return is written in terms of type variables, so +/// no exact comparison is meaningful. +let signatureMatches + (ilDelegeeParams: ILParameter list) + (ilDelegeeRet: ILReturn) + (ilEnclArgTys: ILType list) + (ilMethArgTys: ILType list) + (targetMspec: ILMethodSpec) + = + let arityMatches = targetMspec.FormalArgTypes.Length = ilDelegeeParams.Length + + let returnMatches = + if List.isEmpty ilEnclArgTys && List.isEmpty ilMethArgTys then + ilDelegeeRet.Type = targetMspec.FormalReturnType + else + true + + arityMatches && returnMatches + +/// Package the receiver (if any) with the virtual-call flag for the consumer to emit. +let receiverInfo (leadingArgs: Expr list) virtualCall = + match leadingArgs with + | [ recv ] -> Some(recv, virtualCall) + | _ -> None diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index ff83e60226c..a4433bfcedf 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -7464,17 +7464,14 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, // Direct delegate construction: when the delegate body is a saturated, transparent forwarding call to a // known static method, module-level function, or instance method, point the delegate straight at that - // method instead of generating an intermediate closure class. For a static target the receiver is null - // (ldnull; ldftn target); for an instance target the receiver is evaluated and the function pointer is - // bound with ldftn, or dup; ldvirtftn for a virtual target so dispatch is preserved. A strict - // IL-signature check makes the rewrite provably equivalent to the closure form; anything that does not - // match exactly falls back to the closure path below. Gated by LanguageFeature.DirectDelegateConstruction. + // method instead of generating an intermediate closure class. Anything that does not match exactly + // falls back to the closure path below. let directDelegateTarget = if not (g.langVersion.SupportsFeature LanguageFeature.DirectDelegateConstruction) then None elif not cenv.options.localOptimizationsEnabled - && tmvs |> List.exists (fun (v: Val) -> not v.IsCompilerGenerated) + && tmvs |> List.exists (fun v -> not v.IsCompilerGenerated) then // Eta-expanded delegate in an unoptimized build: the Invoke parameters are the user's own lambda // variables, so keep the closure to preserve their names for debugging. Non-eta delegates (whose @@ -7483,152 +7480,69 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, // forwarding call survives to here. None else - match body with - | DirectDelegateForwardingCall g tmvs (target, leadingArgs) -> - // For an instance method the single leading argument is the receiver; a static method or - // module function must have no leading arguments (otherwise it is a partial application). - let receiverShapeOk takesInstanceArg = - if takesInstanceArg then - match leadingArgs with - | [ _ ] -> true - | _ -> false - else - List.isEmpty leadingArgs - - // The receiver is hoisted to the delegate-construction site, so a direct delegate is only sound - // when it can be evaluated there exactly once and as the Target: - // - A closure built from an explicit eta-lambda (e.g. `fun a -> recv.M a`) re-evaluates the - // receiver on every Invoke; evaluating it once instead is observable unless it is - // side-effect free (a non-mutable value, a constant, a pure field read). - // - It must not reference the delegate's own Invoke parameters, which only exist inside the - // delegee method. - // Checked lazily (and after the cheaper structural bails) so disqualified delegates skip the - // receiver traversal; ExprHasEffect short-circuits before the freeInExpr allocation. - let receiverNotBindable () = - match leadingArgs with - | [ recv ] -> - Optimizer.ExprHasEffect g recv - || (let recvFreeLocals = (freeInExpr CollectLocals recv).FreeLocals - tmvs |> List.exists (fun tv -> Zset.contains tv recvFreeLocals)) - | _ -> false - - // The type checker has already verified that the delegate is built from a compatible function - // shape, and the structural match above forwards the Invoke parameters verbatim, so the - // target's signature is compatible with the delegate's Invoke by construction. We confirm: - // - parameter *count* matches (already guaranteed by the verbatim forwarding, so essentially - // a sanity check). We deliberately do not compare parameter IL *types*: a value-type - // parameter is exact by construction (a widening/boxing argument would not be a verbatim - // Val and so would not have matched), and for reference-type parameters the CLR's delegate - // relaxation permits contravariance, so an exact comparison would only produce false - // negatives (a CLR-legal binding bailing to a closure). - // - for a non-generic target, the return type matches exactly. This is the one IL mismatch - // the recognizer cannot see and the CLR will not relax: notably an F# 'unit' return - // compiled to 'void' versus a delegate whose Invoke returns 'Unit'. For a generic target - // the return is written in terms of type variables, so no exact comparison is meaningful. - let signatureMatches (ilEnclArgTys: ILType list) (ilMethArgTys: ILType list) (targetMspec: ILMethodSpec) = - let arityMatches = targetMspec.FormalArgTypes.Length = ilDelegeeParams.Length - - let returnMatches = - if List.isEmpty ilEnclArgTys && List.isEmpty ilMethArgTys then - ilDelegeeRet.Type = targetMspec.FormalReturnType - else - true + match classifyForwardingTarget g tmvs body with + | DelegateForwardingTarget.FSharpVal(vref, valUseFlags, tyargs, leadingArgs) -> + match StorageForValRef m vref eenvouter with + | Method(valReprInfo, vrefM, mspec, _, _, ctps, _, _, _, _, _, _) -> + let _, witnessInfos, _, _, _ = + GetValReprTypeInCompiledForm g valReprInfo ctps.Length vrefM.Type m - arityMatches && returnMatches + let hasWitnesses = ComputeGenerateWitnesses g eenvouter && not witnessInfos.IsEmpty - let receiverInfo virtualCall = - match leadingArgs with - | [ recv ] -> Some(recv, virtualCall) - | _ -> None - - match target with - | DirectDelegateForwardingTarget.FSharpVal(vref, valUseFlags, tyargs) -> - match StorageForValRef m vref eenvouter with - | Method(valReprInfo, vrefM, mspec, _, _, ctps, _, _, _, _, _, _) -> - let _, witnessInfos, _, _, _ = - GetValReprTypeInCompiledForm g valReprInfo ctps.Length vrefM.Type m - - let hasWitnesses = ComputeGenerateWitnesses g eenvouter && not witnessInfos.IsEmpty - - let _, virtualCall, newobj, isSuperInit, isSelfInit, takesInstanceArg, _, _ = + if fsharpValDirectlyBindable g tmvs leadingArgs vrefM valUseFlags hasWitnesses then + let _, virtualCall, _, _, _, takesInstanceArg, _, _ = GetMemberCallInfo g (vrefM, valUseFlags) - let isBaseCall = valUseFlags.IsVSlotDirectCall + let ilTyArgs = GenTypeArgs cenv m eenvouter.tyenv tyargs - if - hasWitnesses - || newobj - || isSuperInit - || isSelfInit - || isBaseCall - || not (receiverShapeOk takesInstanceArg) - || receiverNotBindable () - then + let numEnclILTypeArgs = + if vrefM.MemberInfo.IsSome && not vrefM.IsExtensionMember then + List.length (vrefM.MemberApparentEntity.Typars |> DropErasedTypars) + else + 0 + + if ilTyArgs.Length < numEnclILTypeArgs then None else - let ilTyArgs = GenTypeArgs cenv m eenvouter.tyenv tyargs + let ilEnclArgTys, ilMethArgTys = List.splitAt numEnclILTypeArgs ilTyArgs + let boxity = mspec.DeclaringType.Boxity + let targetMspec = mkILMethSpec (mspec.MethodRef, boxity, ilEnclArgTys, ilMethArgTys) - let numEnclILTypeArgs = - if vrefM.MemberInfo.IsSome && not vrefM.IsExtensionMember then - List.length (vrefM.MemberApparentEntity.Typars |> DropErasedTypars) - else - 0 - - if ilTyArgs.Length < numEnclILTypeArgs then + if takesInstanceArg <> targetMspec.MethodRef.CallingConv.IsInstance then + None + elif takesInstanceArg && boxity.IsAsValue then + // value-type receivers not handled None + elif signatureMatches ilDelegeeParams ilDelegeeRet ilEnclArgTys ilMethArgTys targetMspec then + Some(targetMspec, receiverInfo leadingArgs virtualCall) else - let ilEnclArgTys, ilMethArgTys = List.splitAt numEnclILTypeArgs ilTyArgs - let boxity = mspec.DeclaringType.Boxity - let targetMspec = mkILMethSpec (mspec.MethodRef, boxity, ilEnclArgTys, ilMethArgTys) - - if takesInstanceArg <> targetMspec.MethodRef.CallingConv.IsInstance then - None - elif takesInstanceArg && boxity = AsValue then - // value-type receivers not handled - None - elif signatureMatches ilEnclArgTys ilMethArgTys targetMspec then - Some(targetMspec, receiverInfo virtualCall) - else - None - | _ -> None - - | DirectDelegateForwardingTarget.ILMethod(isVirtual, isStruct, isCtor, valUseFlag, ilMethRef, enclTypeInst, methInst) -> - // A direct IL call (e.g. a BCL method). Everything needed to build the method spec is on - // the node, so there is no storage/witness resolution; we still bail on the shapes that - // have no closed direct-delegate form. - let isBaseCall = valUseFlag.IsVSlotDirectCall - - let isConstrainedCall = valUseFlag.IsPossibleConstrainedCall + None + else + None + | _ -> None - let takesInstanceArg = ilMethRef.CallingConv.IsInstance + | DelegateForwardingTarget.ILMethod(isVirtual, isStruct, isCtor, valUseFlag, ilMethRef, enclTypeInst, methInst, leadingArgs) -> + if ilMethodDirectlyBindable g tmvs leadingArgs ilMethRef isStruct valUseFlag isCtor then + let ilEnclArgTys = GenTypeArgs cenv m eenvouter.tyenv enclTypeInst + let ilMethArgTys = GenTypeArgs cenv m eenvouter.tyenv methInst let boxity = if isStruct then AsValue else AsObject - - if - isCtor - || isBaseCall - || isConstrainedCall - || not (receiverShapeOk takesInstanceArg) - || (takesInstanceArg && boxity = AsValue) - || receiverNotBindable () - then - None + let targetMspec = mkILMethSpec (ilMethRef, boxity, ilEnclArgTys, ilMethArgTys) + + // Unlike the F# case we cannot compare parameter/return IL types here: the target's + // types come from imported metadata, whose assembly scope refs differ from the + // compiler-generated delegee types (e.g. `System.Int32, System.Runtime` vs the bare + // primary-assembly form), so structural equality reports false negatives for the very + // primitives that always match. The forwarding match already pins the arity, and the + // type checker has verified the call is well-typed, so element compatibility holds by + // construction; an arity check is the sound guard (matching the generic case). + if targetMspec.FormalArgTypes.Length = ilDelegeeParams.Length then + Some(targetMspec, receiverInfo leadingArgs isVirtual) else - let ilEnclArgTys = GenTypeArgs cenv m eenvouter.tyenv enclTypeInst - let ilMethArgTys = GenTypeArgs cenv m eenvouter.tyenv methInst - let targetMspec = mkILMethSpec (ilMethRef, boxity, ilEnclArgTys, ilMethArgTys) - - // Unlike the F# case we cannot compare parameter/return IL types here: the target's - // types come from imported metadata, whose assembly scope refs differ from the - // compiler-generated delegee types (e.g. `System.Int32, System.Runtime` vs the bare - // primary-assembly form), so structural equality reports false negatives for the very - // primitives that always match. The forwarding match already pins the arity, and the - // type checker has verified the call is well-typed, so element compatibility holds by - // construction; an arity check is the sound guard (matching the generic case). - if targetMspec.FormalArgTypes.Length = ilDelegeeParams.Length then - Some(targetMspec, receiverInfo isVirtual) - else - None - | _ -> None + None + else + None + + | DelegateForwardingTarget.Other -> None match directDelegateTarget with | Some(targetMspec, receiverInfo) -> diff --git a/src/Compiler/FSharp.Compiler.Service.fsproj b/src/Compiler/FSharp.Compiler.Service.fsproj index 5510af6b3f6..d088eee527f 100644 --- a/src/Compiler/FSharp.Compiler.Service.fsproj +++ b/src/Compiler/FSharp.Compiler.Service.fsproj @@ -442,6 +442,7 @@ + diff --git a/src/Compiler/TypedTree/TypedTreeOps.ExprOps.fs b/src/Compiler/TypedTree/TypedTreeOps.ExprOps.fs index 54c28c13c18..bdebaf40ff5 100644 --- a/src/Compiler/TypedTree/TypedTreeOps.ExprOps.fs +++ b/src/Compiler/TypedTree/TypedTreeOps.ExprOps.fs @@ -33,24 +33,6 @@ open FSharp.Compiler.TypedTreeBasics open FSharp.Compiler.TypeProviders #endif -/// The target of a direct-delegate forwarding call recognized by (|DirectDelegateForwardingCall|_|). -[] -type internal DirectDelegateForwardingTarget = - /// A known F# value: a module-level function or a member. Carries the value reference, its use flags - /// and the call's type arguments; the consumer resolves storage to a method spec. - | FSharpVal of vref: ValRef * valUseFlags: ValUseFlag * tyargs: TypeInst - /// A direct IL method call (e.g. a BCL method), compiled as TOp.ILCall. Carries everything needed to - /// build the method spec directly: virtual/struct/ctor flags, use flags, the IL method reference and - /// the enclosing-type and method type instantiations. - | ILMethod of - isVirtual: bool * - isStruct: bool * - isCtor: bool * - valUseFlags: ValUseFlag * - ilMethRef: ILMethodRef * - enclTypeInst: TypeInst * - methInst: TypeInst - [] module internal AddressOps = @@ -1833,53 +1815,6 @@ module internal ExprTransforms = ) | _ -> ValueNone - /// Recognizes the body of a delegate's Invoke method when it is a saturated, transparent forwarding - /// call `target leading... p0 p1 ...` to a known method, whose trailing arguments are exactly the - /// delegate's Invoke parameters in order. This is the shape that lets a delegate point directly at - /// `target` instead of an intermediate closure. Any leading arguments (e.g. an instance method's - /// receiver) are returned to the consumer, which decides whether a direct delegate can actually be - /// emitted (matching IL signature, receiver shape, no witnesses, etc.). - [] - let (|DirectDelegateForwardingCall|_|) g (invokeParams: Val list) expr = - // The trailing arguments of the call must be exactly the delegate's Invoke parameters, forwarded - // verbatim and in order. The remaining leading arguments (e.g. an instance receiver) are returned - // for the consumer to handle. - let matchForwarding (args: Expr list) = - let numLeading = args.Length - invokeParams.Length - - if numLeading >= 0 then - let leadingArgs, forwardedArgs = List.splitAt numLeading args - - if - List.forall2 - (fun (a: Expr) (tv: Val) -> - match stripDebugPoints a with - | Expr.Val(avref, _, _) -> valRefEq g avref (mkLocalValRef tv) - | _ -> false) - forwardedArgs - invokeParams - then - ValueSome leadingArgs - else - ValueNone - else - ValueNone - - match stripDebugPoints expr with - | Expr.App(Expr.Val(vref, valUseFlags, _), _, tyargs, args, _) -> - match matchForwarding args with - | ValueSome leadingArgs -> ValueSome(DirectDelegateForwardingTarget.FSharpVal(vref, valUseFlags, tyargs), leadingArgs) - | ValueNone -> ValueNone - | Expr.Op(TOp.ILCall(isVirtual, _, isStruct, isCtor, valUseFlag, _, _, ilMethRef, enclTypeInst, methInst, _), _, args, _) -> - match matchForwarding args with - | ValueSome leadingArgs -> - ValueSome( - DirectDelegateForwardingTarget.ILMethod(isVirtual, isStruct, isCtor, valUseFlag, ilMethRef, enclTypeInst, methInst), - leadingArgs - ) - | ValueNone -> ValueNone - | _ -> ValueNone - [] let (|DelegateInvokeExpr|_|) g expr = match expr with diff --git a/src/Compiler/TypedTree/TypedTreeOps.ExprOps.fsi b/src/Compiler/TypedTree/TypedTreeOps.ExprOps.fsi index afb4874f70d..ad90c5c818c 100644 --- a/src/Compiler/TypedTree/TypedTreeOps.ExprOps.fsi +++ b/src/Compiler/TypedTree/TypedTreeOps.ExprOps.fsi @@ -12,24 +12,6 @@ open FSharp.Compiler.TypedTree open FSharp.Compiler.TypedTreeBasics open FSharp.Compiler.Syntax -/// The target of a direct-delegate forwarding call recognized by (|DirectDelegateForwardingCall|_|). -[] -type internal DirectDelegateForwardingTarget = - /// A known F# value: a module-level function or a member. Carries the value reference, its use flags - /// and the call's type arguments; the consumer resolves storage to a method spec. - | FSharpVal of vref: ValRef * valUseFlags: ValUseFlag * tyargs: TypeInst - /// A direct IL method call (e.g. a BCL method), compiled as TOp.ILCall. Carries everything needed to - /// build the method spec directly: virtual/struct/ctor flags, use flags, the IL method reference and - /// the enclosing-type and method type instantiations. - | ILMethod of - isVirtual: bool * - isStruct: bool * - isCtor: bool * - valUseFlags: ValUseFlag * - ilMethRef: ILMethodRef * - enclTypeInst: TypeInst * - methInst: TypeInst - [] module internal AddressOps = @@ -562,14 +544,6 @@ module internal ExprTransforms = [] val (|NewDelegateExpr|_|): TcGlobals -> Expr -> (Unique * Val list * Expr * range * (Expr -> Expr)) voption - /// Recognizes the body of a delegate's Invoke method when it is a saturated, transparent forwarding - /// call to a known method (an F# value or a direct IL call) whose trailing arguments are exactly the - /// delegate's Invoke parameters in order. Returns the resolved target and any leading (non-forwarded) - /// argument expressions, e.g. an instance method's receiver. - [] - val (|DirectDelegateForwardingCall|_|): - TcGlobals -> Val list -> Expr -> (DirectDelegateForwardingTarget * Expr list) voption - [] val (|DelegateInvokeExpr|_|): TcGlobals -> Expr -> (Expr * TType * TypeInst * Expr * Expr * range) voption diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs index 6bc35cbc296..d23f9038694 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs @@ -493,3 +493,77 @@ let main _ = |> withLangVersionPreview |> compileExeAndRun |> shouldSucceed + +// Cross-assembly targets: the recognizer has no locality guard, so a delegate over an F# function imported +// from a *referenced* assembly takes the same FSharpVal direct path (StorageForValRef resolution + method-spec +// build across an assembly boundary) that the same-compiland baseline suite never reaches. The targets are +// [] so cross-assembly inlining cannot dissolve the forwarding call before codegen. +let private crossAssemblyLibrary = + FSharp """ +module DelegateLib + +[] +let add (x: int) (y: int) : int = x + y + +type Calc(k: int) = + [] + member _.Scale (x: int) (y: int) : int = (x + y) * k + +// A small inline function: its body is serialized into the referenced assembly and is always inlined at the +// use site (independent of --optimize), so a delegate over it can never see a forwarding call. +let inline addInline (x: int) (y: int) : int = x + y + """ + |> asLibrary + +[] +let ``Cross-assembly F# target is emitted directly (preview)`` () = + FSharp """ +module CrossAsmDirect + +open System +open DelegateLib + +[] +let main _ = + // Static module function imported from another assembly: direct, null Target, real Method.Name. + let ds = Func(add) + if ds.Invoke(2, 3) <> 5 then failwith "static: wrong result" + if ds.Method.Name <> "add" then failwithf "static: expected 'add' but got '%s'" ds.Method.Name + if not (isNull ds.Target) then failwith "static: Target should be null" + + // Instance member imported from another assembly: direct, Target is the receiver. + let c = Calc(10) + let di = Func(c.Scale) + if di.Invoke(2, 3) <> 50 then failwithf "instance: expected 50 but got %d" (di.Invoke(2, 3)) + if di.Method.Name <> "Scale" then failwithf "instance: expected 'Scale' but got '%s'" di.Method.Name + if not (obj.ReferenceEquals(di.Target, c)) then failwith "instance: Target is not the receiver" + 0 + """ + |> withReferences [ crossAssemblyLibrary ] + |> withLangVersionPreview + |> withOptions [ "--optimize+" ] + |> compileExeAndRun + |> shouldSucceed + +// An inline target from a referenced assembly is always inlined before the recognizer runs, so the forwarding +// call vanishes and a closure is kept even in release - the deterministic cross-assembly end of the inline-race. +[] +let ``Cross-assembly inline target stays a closure (preview)`` () = + FSharp """ +module CrossAsmInline + +open System +open DelegateLib + +[] +let main _ = + let d = Func(fun a b -> addInline a b) + if d.Invoke(2, 3) <> 5 then failwith "wrong result" + if d.Method.Name <> "Invoke" then failwithf "expected closure 'Invoke' but got '%s'" d.Method.Name + 0 + """ + |> withReferences [ crossAssemblyLibrary ] + |> withLangVersionPreview + |> withOptions [ "--optimize+" ] + |> compileExeAndRun + |> shouldSucceed From 8017ff02cee30f97b7bd841cebf36d20c7e80936 Mon Sep 17 00:00:00 2001 From: kerams Date: Fri, 26 Jun 2026 20:10:12 +0200 Subject: [PATCH 07/16] Build fix --- src/Compiler/FSharp.Compiler.Service.fsproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Compiler/FSharp.Compiler.Service.fsproj b/src/Compiler/FSharp.Compiler.Service.fsproj index d088eee527f..5dd9af61ccc 100644 --- a/src/Compiler/FSharp.Compiler.Service.fsproj +++ b/src/Compiler/FSharp.Compiler.Service.fsproj @@ -442,7 +442,7 @@ - + From cd6e3c6650a76036ac08905425c75dd048360fc6 Mon Sep 17 00:00:00 2001 From: kerams Date: Fri, 26 Jun 2026 20:35:59 +0200 Subject: [PATCH 08/16] Build fix --- src/Compiler/CodeGen/IlxGen.Delegates.fs | 16 +++++++--------- src/Compiler/CodeGen/IlxGen.fs | 6 +++--- src/Compiler/FSharp.Compiler.Service.fsproj | 2 +- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/Compiler/CodeGen/IlxGen.Delegates.fs b/src/Compiler/CodeGen/IlxGen.Delegates.fs index 4d7e8c7a2a8..858f61c6821 100644 --- a/src/Compiler/CodeGen/IlxGen.Delegates.fs +++ b/src/Compiler/CodeGen/IlxGen.Delegates.fs @@ -5,18 +5,16 @@ module internal FSharp.Compiler.IlxGenDelegates open Internal.Utilities.Collections -open Internal.Utilities.Library.Extras open FSharp.Compiler open FSharp.Compiler.AbstractIL.IL -open FSharp.Compiler.TcGlobals open FSharp.Compiler.TypedTree open FSharp.Compiler.TypedTreeBasics open FSharp.Compiler.TypedTreeOps -/// The target of a delegate forwarding call +/// A delegate target that can potentially be forwarded to directly, without an intermediate closure [] -type DelegateForwardingTarget = +type DirectDelegateForwardingTargetCandidate = /// A known F# value: a module-level function or a member | FSharpVal of vref: ValRef * valUseFlags: ValUseFlag * tyargs: TypeInst * leadingArgs: Expr list /// A direct IL method call (e.g. a BCL method) @@ -59,14 +57,14 @@ let classifyForwardingTarget g (invokeParams: Val list) expr = match stripDebugPoints expr with | Expr.App(Expr.Val(vref, valUseFlags, _), _, tyargs, args, _) -> match matchForwarding args with - | ValueSome leadingArgs -> DelegateForwardingTarget.FSharpVal(vref, valUseFlags, tyargs, leadingArgs) - | ValueNone -> DelegateForwardingTarget.Other + | ValueSome leadingArgs -> DirectDelegateForwardingTargetCandidate.FSharpVal(vref, valUseFlags, tyargs, leadingArgs) + | ValueNone -> DirectDelegateForwardingTargetCandidate.Other | Expr.Op(TOp.ILCall(isVirtual, _, isStruct, isCtor, valUseFlag, _, _, ilMethRef, enclTypeInst, methInst, _), _, args, _) -> match matchForwarding args with | ValueSome leadingArgs -> - DelegateForwardingTarget.ILMethod(isVirtual, isStruct, isCtor, valUseFlag, ilMethRef, enclTypeInst, methInst, leadingArgs) - | ValueNone -> DelegateForwardingTarget.Other - | _ -> DelegateForwardingTarget.Other + DirectDelegateForwardingTargetCandidate.ILMethod(isVirtual, isStruct, isCtor, valUseFlag, ilMethRef, enclTypeInst, methInst, leadingArgs) + | ValueNone -> DirectDelegateForwardingTargetCandidate.Other + | _ -> DirectDelegateForwardingTargetCandidate.Other /// For an instance method the single leading argument is the receiver; a static method or module function /// must have no leading arguments (otherwise it is a partial application). diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index a4433bfcedf..fda1a18a440 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -7481,7 +7481,7 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, None else match classifyForwardingTarget g tmvs body with - | DelegateForwardingTarget.FSharpVal(vref, valUseFlags, tyargs, leadingArgs) -> + | DirectDelegateForwardingTargetCandidate.FSharpVal(vref, valUseFlags, tyargs, leadingArgs) -> match StorageForValRef m vref eenvouter with | Method(valReprInfo, vrefM, mspec, _, _, ctps, _, _, _, _, _, _) -> let _, witnessInfos, _, _, _ = @@ -7521,7 +7521,7 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, None | _ -> None - | DelegateForwardingTarget.ILMethod(isVirtual, isStruct, isCtor, valUseFlag, ilMethRef, enclTypeInst, methInst, leadingArgs) -> + | DirectDelegateForwardingTargetCandidate.ILMethod(isVirtual, isStruct, isCtor, valUseFlag, ilMethRef, enclTypeInst, methInst, leadingArgs) -> if ilMethodDirectlyBindable g tmvs leadingArgs ilMethRef isStruct valUseFlag isCtor then let ilEnclArgTys = GenTypeArgs cenv m eenvouter.tyenv enclTypeInst let ilMethArgTys = GenTypeArgs cenv m eenvouter.tyenv methInst @@ -7542,7 +7542,7 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, else None - | DelegateForwardingTarget.Other -> None + | DirectDelegateForwardingTargetCandidate.Other -> None match directDelegateTarget with | Some(targetMspec, receiverInfo) -> diff --git a/src/Compiler/FSharp.Compiler.Service.fsproj b/src/Compiler/FSharp.Compiler.Service.fsproj index 5dd9af61ccc..50492504777 100644 --- a/src/Compiler/FSharp.Compiler.Service.fsproj +++ b/src/Compiler/FSharp.Compiler.Service.fsproj @@ -442,7 +442,7 @@ - + From be7517d14ab50d78020a1e420921a03a8252dc22 Mon Sep 17 00:00:00 2001 From: kerams Date: Mon, 29 Jun 2026 14:47:36 +0200 Subject: [PATCH 09/16] Unit arg --- src/Compiler/CodeGen/IlxGen.Delegates.fs | 55 +++++++- src/Compiler/CodeGen/IlxGen.fs | 30 +++-- src/Compiler/Facilities/LanguageFeatures.fs | 3 - .../DirectDelegates/DelegateCustomType.fs | 2 +- .../DelegateExtensionMethod.fs | 2 +- ...nstanceMethod.fs.OptimizeOn.Preview.il.bsl | 4 +- ...nownFunction.fs.OptimizeOff.Preview.il.bsl | 4 +- ...KnownFunction.fs.OptimizeOn.Preview.il.bsl | 4 +- ...egativeCases.fs.OptimizeOff.Preview.il.bsl | 2 +- ...NegativeCases.fs.OptimizeOn.Preview.il.bsl | 2 +- ...lApplication.fs.OptimizeOff.Preview.il.bsl | 6 +- ...alApplication.fs.OptimizeOn.Preview.il.bsl | 12 +- ...StaticMethod.fs.OptimizeOff.Preview.il.bsl | 4 +- ...eStaticMethod.fs.OptimizeOn.Preview.il.bsl | 4 +- .../DirectDelegates/DelegateStructTarget.fs | 4 +- ...StructTarget.fs.OptimizeOff.Preview.il.bsl | 2 +- ...eStructTarget.fs.OptimizeOn.Preview.il.bsl | 2 +- .../DirectDelegates/DelegateUnitArg.fs | 11 ++ ...egateUnitArg.fs.OptimizeOff.Preview.il.bsl | 80 +++++++++-- .../DelegateUnitArg.fs.OptimizeOff.il.bsl | 121 ++++++++++++++++- ...legateUnitArg.fs.OptimizeOn.Preview.il.bsl | 48 +++++-- .../DelegateUnitArg.fs.OptimizeOn.il.bsl | 126 +++++++++++++++++- .../DirectDelegates/DirectDelegates.fs | 42 ++++-- 23 files changed, 483 insertions(+), 87 deletions(-) diff --git a/src/Compiler/CodeGen/IlxGen.Delegates.fs b/src/Compiler/CodeGen/IlxGen.Delegates.fs index 858f61c6821..a511021e33b 100644 --- a/src/Compiler/CodeGen/IlxGen.Delegates.fs +++ b/src/Compiler/CodeGen/IlxGen.Delegates.fs @@ -29,11 +29,48 @@ type DirectDelegateForwardingTargetCandidate = leadingArgs: Expr list | Other +let private isUnitValue e = + match stripDebugPoints e with + | Expr.Const(Const.Unit, _, _) -> true + | _ -> false + +// The forwarding call may be wrapped in let-bindings the recognizer must see through, in any combination: +// - a 'let unitVar = () in …' that BindUnitVars (or the elaborator) inserts for the elided unit parameter +// of a zero-parameter Invoke (e.g. System.Action), and +// - a side-effect-free receiver binding 'let v = recv in v.M …' that a non-eta delegate over an instance +// method value (e.g. Action(c.M)) produces to evaluate the receiver once. +// Peel them repeatedly: unit bindings are dropped; a receiver binding is dropped while recording 'v -> recv' +// so the receiver, which appears in the leading args as 'v', is mapped back to 'recv'. The downstream +// bindability check confirms 'recv' may be hoisted to the construction site. +let rec private peel g expr mapReceiver = + match stripDebugPoints expr with + | Expr.Let(TBind(v, rhs, _), inner, _, _) when isUnitTy g v.Type && isUnitValue rhs -> peel g inner mapReceiver + | Expr.Let(TBind(v, recv, _), inner, _, _) when not (Optimizer.ExprHasEffect g recv) -> + let mapReceiver leadingArgs = + mapReceiver ( + leadingArgs + |> List.map (fun a -> + match stripDebugPoints a with + | Expr.Val(vref, _, _) when valRefEq g vref (mkLocalValRef v) -> recv + | _ -> a) + ) + + peel g inner mapReceiver + | e -> e, mapReceiver + let classifyForwardingTarget g (invokeParams: Val list) expr = + let body, mapReceiver = peel g expr id + // The trailing arguments of the call must be exactly the delegate's Invoke parameters, forwarded // verbatim and in order. The remaining leading arguments (e.g. an instance receiver) are returned // for the consumer to handle. let matchForwarding (args: Expr list) = + // Drop the elided unit argument when the Invoke takes no parameters. + let args = + match List.tryLast args with + | Some last when List.isEmpty invokeParams && isUnitValue last -> List.truncate (args.Length - 1) args + | _ -> args + let numLeading = args.Length - invokeParams.Length if numLeading >= 0 then @@ -48,13 +85,13 @@ let classifyForwardingTarget g (invokeParams: Val list) expr = forwardedArgs invokeParams then - ValueSome leadingArgs + ValueSome(mapReceiver leadingArgs) else ValueNone else ValueNone - match stripDebugPoints expr with + match body with | Expr.App(Expr.Val(vref, valUseFlags, _), _, tyargs, args, _) -> match matchForwarding args with | ValueSome leadingArgs -> DirectDelegateForwardingTargetCandidate.FSharpVal(vref, valUseFlags, tyargs, leadingArgs) @@ -62,7 +99,16 @@ let classifyForwardingTarget g (invokeParams: Val list) expr = | Expr.Op(TOp.ILCall(isVirtual, _, isStruct, isCtor, valUseFlag, _, _, ilMethRef, enclTypeInst, methInst, _), _, args, _) -> match matchForwarding args with | ValueSome leadingArgs -> - DirectDelegateForwardingTargetCandidate.ILMethod(isVirtual, isStruct, isCtor, valUseFlag, ilMethRef, enclTypeInst, methInst, leadingArgs) + DirectDelegateForwardingTargetCandidate.ILMethod( + isVirtual, + isStruct, + isCtor, + valUseFlag, + ilMethRef, + enclTypeInst, + methInst, + leadingArgs + ) | ValueNone -> DirectDelegateForwardingTargetCandidate.Other | _ -> DirectDelegateForwardingTargetCandidate.Other @@ -82,7 +128,6 @@ let private receiverShapeOk (leadingArgs: Expr list) takesInstanceArg = /// every Invoke; evaluating it once instead is observable unless it is side-effect free (a non-mutable /// value, a constant, a pure field read). /// - It must not reference the delegate's own Invoke parameters, which only exist inside the delegee method. -/// ExprHasEffect short-circuits before the freeInExpr allocation, so disqualified delegates skip the traversal. let private receiverBindable g (invokeParams: Val list) (leadingArgs: Expr list) = match leadingArgs with | [ recv ] -> @@ -127,8 +172,8 @@ let ilMethodDirectlyBindable not isCtor && not valUseFlag.IsVSlotDirectCall && not valUseFlag.IsPossibleConstrainedCall - && receiverShapeOk leadingArgs takesInstanceArg && not (takesInstanceArg && isStruct) + && receiverShapeOk leadingArgs takesInstanceArg && receiverBindable g invokeParams leadingArgs /// Confirm the target's IL signature is compatible with the delegate's Invoke. The type checker has already diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index fda1a18a440..4583073537f 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -7454,8 +7454,15 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, let numthis = if useStaticClosure then 0 else 1 - let tmvs, body = - BindUnitVars g (tmvs, List.replicate (List.concat slotsig.FormalParams).Length ValReprInfo.unnamedTopArg1, body) + let invokeParamInfos = + List.replicate (List.concat slotsig.FormalParams).Length ValReprInfo.unnamedTopArg1 + + let etaUnitDelegate = + match tmvs, invokeParamInfos with + | [ _ ], [] -> true + | _ -> false + + let tmvs, body = BindUnitVars g (tmvs, invokeParamInfos, body) // The slot sig contains a formal instantiation. When creating delegates we're only // interested in the actual instantiation since we don't have to emit a method impl. @@ -7471,13 +7478,13 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, None elif not cenv.options.localOptimizationsEnabled - && tmvs |> List.exists (fun v -> not v.IsCompilerGenerated) + && (etaUnitDelegate || tmvs |> List.exists (fun v -> not v.IsCompilerGenerated)) then // Eta-expanded delegate in an unoptimized build: the Invoke parameters are the user's own lambda - // variables, so keep the closure to preserve their names for debugging. Non-eta delegates (whose - // parameters are synthesized by BuildNewDelegateExpr) are always made direct; eta-expanded ones - // are made direct only in optimized builds, where debuggability is not a concern and the - // forwarding call survives to here. + // variables (or, for a unit-argument eta delegate, an elided unit parameter), so keep the closure + // to preserve the user's lambda for debugging. Non-eta delegates (whose parameters are synthesized + // by BuildNewDelegateExpr) are always made direct; eta-expanded ones are made direct only in + // optimized builds, where debuggability is not a concern and the forwarding call survives to here. None else match classifyForwardingTarget g tmvs body with @@ -7521,7 +7528,14 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, None | _ -> None - | DirectDelegateForwardingTargetCandidate.ILMethod(isVirtual, isStruct, isCtor, valUseFlag, ilMethRef, enclTypeInst, methInst, leadingArgs) -> + | DirectDelegateForwardingTargetCandidate.ILMethod(isVirtual, + isStruct, + isCtor, + valUseFlag, + ilMethRef, + enclTypeInst, + methInst, + leadingArgs) -> if ilMethodDirectlyBindable g tmvs leadingArgs ilMethRef isStruct valUseFlag isCtor then let ilEnclArgTys = GenTypeArgs cenv m eenvouter.tyenv enclTypeInst let ilMethArgTys = GenTypeArgs cenv m eenvouter.tyenv methInst diff --git a/src/Compiler/Facilities/LanguageFeatures.fs b/src/Compiler/Facilities/LanguageFeatures.fs index 842d81f9cfd..33070d178ef 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fs +++ b/src/Compiler/Facilities/LanguageFeatures.fs @@ -463,11 +463,8 @@ type LanguageVersion(versionText, ?disabledFeaturesArray: LanguageFeature array) | LanguageFeature.PreprocessorElif -> FSComp.SR.featurePreprocessorElif () | LanguageFeature.ExceptionFieldSerializationSupport -> FSComp.SR.featureExceptionFieldSerializationSupport () | LanguageFeature.ErrorOnMissingSignatureAttribute -> FSComp.SR.featureErrorOnMissingSignatureAttribute () -<<<<<<< HEAD | LanguageFeature.DirectDelegateConstruction -> FSComp.SR.featureDirectDelegateConstruction () -======= | LanguageFeature.ImprovedImpliedArgumentNamesPartTwo -> FSComp.SR.featureImprovedImpliedArgumentNamesPartTwo () ->>>>>>> ae00c30e997ae54e8a68a095849e95efa0056bef /// Get a version string associated with the given feature. static member GetFeatureVersionString feature = diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs index c53cbdbec35..a8ad289fc43 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs @@ -43,5 +43,5 @@ let genEta () = DGen(fun x -> ident x) // byref-parameter custom delegate: the body mutates through the byref, so it is not a transparent forwarding // call and stays a closure. Documents that a byref Invoke parameter does not break the recognizer. -// 51. byref-parameter delegate (mutating body) +// 53. byref-parameter delegate (mutating body) let byrefMutate () = DByref(fun x -> x <- x + 1) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs index b21ed6be396..e1118463d0b 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs @@ -15,5 +15,5 @@ type HolderExtensions = // An extension member compiles to a static method whose first parameter is the receiver, so using it as a // delegate target binds that receiver as a leading argument - a partial application, which has no closed // direct-delegate form. A closure must remain regardless of langversion. -// 50. extension member (receiver is a leading static arg) +// 52. extension member (receiver is a leading static arg) let extensionEta (h: Holder) = Func(fun a b -> h.Combine(a, b)) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOn.Preview.il.bsl index 0395005c4a6..8b34df3492b 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOn.Preview.il.bsl @@ -81,8 +81,8 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static void Invoke(int32 delegateArg0, - int32 delegateArg1) cil managed + .method assembly static void Invoke(int32 arg1, + int32 arg2) cil managed { .maxstack 8 diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOff.Preview.il.bsl index dcd46c650c9..dd1c081a62f 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOff.Preview.il.bsl @@ -75,8 +75,8 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static void Invoke(int32 delegateArg0, - int32 delegateArg1) cil managed + .method assembly static void Invoke(int32 arg1, + int32 arg2) cil managed { .maxstack 8 diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOn.Preview.il.bsl index c737dc4e5dd..1d21f52cfe8 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOn.Preview.il.bsl @@ -79,8 +79,8 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static void Invoke(int32 delegateArg0, - int32 delegateArg1) cil managed + .method assembly static void Invoke(int32 arg1, + int32 arg2) cil managed { .maxstack 8 diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.Preview.il.bsl index ca393fa812c..0ab53817b3b 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.Preview.il.bsl @@ -76,7 +76,7 @@ IL_000d: ret } - .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + .method assembly hidebysig instance void Invoke(int32 arg1, int32 arg2) cil managed { .maxstack 8 diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.Preview.il.bsl index 00a429b94a5..010d82ae420 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.Preview.il.bsl @@ -76,7 +76,7 @@ IL_000d: ret } - .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + .method assembly hidebysig instance void Invoke(int32 arg1, int32 arg2) cil managed { .maxstack 8 diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOff.Preview.il.bsl index c4365038d12..236f68901ed 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOff.Preview.il.bsl @@ -104,7 +104,7 @@ IL_000d: ret } - .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + .method assembly hidebysig instance void Invoke(int32 arg1, int32 arg2) cil managed { .maxstack 8 @@ -138,7 +138,7 @@ IL_000d: ret } - .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + .method assembly hidebysig instance void Invoke(int32 arg1, int32 arg2) cil managed { .maxstack 8 @@ -176,7 +176,7 @@ IL_0014: ret } - .method assembly hidebysig instance void Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + .method assembly hidebysig instance void Invoke(int32 arg1, int32 arg2) cil managed { .maxstack 8 diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOn.Preview.il.bsl index 61c73994f65..27785cff18d 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOn.Preview.il.bsl @@ -87,8 +87,8 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static void Invoke(int32 delegateArg0, - int32 delegateArg1) cil managed + .method assembly static void Invoke(int32 arg1, + int32 arg2) cil managed { .maxstack 8 @@ -101,8 +101,8 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static void Invoke(int32 delegateArg0, - int32 delegateArg1) cil managed + .method assembly static void Invoke(int32 arg1, + int32 arg2) cil managed { .maxstack 8 @@ -115,8 +115,8 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static void Invoke(int32 delegateArg0, - int32 delegateArg1) cil managed + .method assembly static void Invoke(int32 arg1, + int32 arg2) cil managed { .maxstack 8 diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOff.Preview.il.bsl index 2b90acb082f..35c6be20bc0 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOff.Preview.il.bsl @@ -109,8 +109,8 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static void Invoke(int32 delegateArg0, - int32 delegateArg1) cil managed + .method assembly static void Invoke(int32 arg1, + int32 arg2) cil managed { .maxstack 8 diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOn.Preview.il.bsl index 1de6bfcc577..13f63f205dd 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOn.Preview.il.bsl @@ -113,8 +113,8 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static void Invoke(int32 delegateArg0, - int32 delegateArg1) cil managed + .method assembly static void Invoke(int32 arg1, + int32 arg2) cil managed { .maxstack 8 diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs index c856d1f5c7b..84785eda906 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs @@ -10,8 +10,8 @@ type S = // The target is an instance method on a value type. A delegate's Target is an object, so a direct delegate // would have to box the receiver; until that is implemented a closure is kept. (See DelegateInstanceMethod // for the reference-type case, which is emitted directly.) -// 48. non-eta struct (value-type) receiver +// 50. non-eta struct (value-type) receiver let structInstanceNonEta (s: S) = Func(s.Add) -// 49. eta struct (value-type) receiver +// 51. eta struct (value-type) receiver let structInstanceEta (s: S) = Func(fun a b -> s.Add a b) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOff.Preview.il.bsl index 291dc96be7c..abc2a402a57 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOff.Preview.il.bsl @@ -216,7 +216,7 @@ IL_000d: ret } - .method assembly hidebysig instance int32 Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + .method assembly hidebysig instance int32 Invoke(int32 arg1, int32 arg2) cil managed { .maxstack 7 diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOn.Preview.il.bsl index f83c608dc89..28e50465f0e 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOn.Preview.il.bsl @@ -189,7 +189,7 @@ IL_000d: ret } - .method assembly hidebysig instance int32 Invoke(int32 delegateArg0, int32 delegateArg1) cil managed + .method assembly hidebysig instance int32 Invoke(int32 arg1, int32 arg2) cil managed { .maxstack 8 diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs index 7a164ad4045..da6b1ae9203 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs @@ -2,10 +2,21 @@ module DelegateUnitArg open System +[] let handler () : unit = () +type C() = + [] + member _.M () : unit = () + // 46. non-eta unit-argument delegate let caseUnitNonEta () = Action(handler) // 47. eta unit-argument delegate let caseUnitEta () = Action(fun () -> handler ()) + +// 48. non-eta unit-argument delegate, instance method (receiver kept, unit stripped) +let caseUnitInstanceNonEta (c: C) = Action(c.M) + +// 49. eta unit-argument delegate, instance method +let caseUnitInstanceEta (c: C) = Action(fun () -> c.M ()) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOff.Preview.il.bsl index b91d58c4597..6e416b73ea9 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOff.Preview.il.bsl @@ -33,7 +33,32 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitNonEta@8 + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public specialname rtspecialname instance void .ctor() cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ret + } + + .method public hidebysig instance void M() cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitEta@16 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -48,23 +73,39 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitEta@11 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitInstanceEta@22 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static void Invoke() cil managed + .field public class assembly/C c + .method public specialname rtspecialname instance void .ctor(class assembly/C c) cil managed { .maxstack 8 - IL_0000: call void assembly::'handler'() - IL_0005: nop - IL_0006: ret + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/caseUnitInstanceEta@22::c + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke() cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/caseUnitInstanceEta@22::c + IL_0006: callvirt instance void assembly/C::M() + IL_000b: nop + IL_000c: ret } } .method public static void 'handler'() cil managed { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .maxstack 8 IL_0000: ret @@ -75,7 +116,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/caseUnitNonEta@8::Invoke() + IL_0001: ldftn void assembly::'handler'() IL_0007: newobj instance void [runtime]System.Action::.ctor(object, native int) IL_000c: ret @@ -86,12 +127,35 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/caseUnitEta@11::Invoke() + IL_0001: ldftn void assembly/caseUnitEta@16::Invoke() + IL_0007: newobj instance void [runtime]System.Action::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action caseUnitInstanceNonEta(class assembly/C c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldftn instance void assembly/C::M() IL_0007: newobj instance void [runtime]System.Action::.ctor(object, native int) IL_000c: ret } + .method public static class [runtime]System.Action caseUnitInstanceEta(class assembly/C c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/caseUnitInstanceEta@22::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/caseUnitInstanceEta@22::Invoke() + IL_000c: newobj instance void [runtime]System.Action::.ctor(object, + native int) + IL_0011: ret + } + } .class private abstract auto ansi sealed ''.$assembly diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOff.il.bsl index b91d58c4597..840fdad920e 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOff.il.bsl @@ -33,7 +33,32 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitNonEta@8 + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public specialname rtspecialname instance void .ctor() cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ret + } + + .method public hidebysig instance void M() cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitNonEta@13 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -48,7 +73,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitEta@11 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitEta@16 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -63,8 +88,72 @@ } + .class auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitInstanceNonEta@19 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C c + .method public specialname rtspecialname instance void .ctor(class assembly/C c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/caseUnitInstanceNonEta@19::c + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke() cil managed + { + + .maxstack 5 + .locals init (class assembly/C V_0) + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/caseUnitInstanceNonEta@19::c + IL_0006: stloc.0 + IL_0007: ldloc.0 + IL_0008: callvirt instance void assembly/C::M() + IL_000d: nop + IL_000e: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitInstanceEta@22 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C c + .method public specialname rtspecialname instance void .ctor(class assembly/C c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/caseUnitInstanceEta@22::c + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke() cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/caseUnitInstanceEta@22::c + IL_0006: callvirt instance void assembly/C::M() + IL_000b: nop + IL_000c: ret + } + + } + .method public static void 'handler'() cil managed { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .maxstack 8 IL_0000: ret @@ -75,7 +164,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/caseUnitNonEta@8::Invoke() + IL_0001: ldftn void assembly/caseUnitNonEta@13::Invoke() IL_0007: newobj instance void [runtime]System.Action::.ctor(object, native int) IL_000c: ret @@ -86,12 +175,36 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/caseUnitEta@11::Invoke() + IL_0001: ldftn void assembly/caseUnitEta@16::Invoke() IL_0007: newobj instance void [runtime]System.Action::.ctor(object, native int) IL_000c: ret } + .method public static class [runtime]System.Action caseUnitInstanceNonEta(class assembly/C c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/caseUnitInstanceNonEta@19::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/caseUnitInstanceNonEta@19::Invoke() + IL_000c: newobj instance void [runtime]System.Action::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Action caseUnitInstanceEta(class assembly/C c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/caseUnitInstanceEta@22::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/caseUnitInstanceEta@22::Invoke() + IL_000c: newobj instance void [runtime]System.Action::.ctor(object, + native int) + IL_0011: ret + } + } .class private abstract auto ansi sealed ''.$assembly diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOn.Preview.il.bsl index 3684e4e4a6b..cdbc92236f5 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOn.Preview.il.bsl @@ -33,25 +33,24 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitNonEta@8 + .class auto ansi serializable nested public C extends [runtime]System.Object { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static void Invoke() cil managed + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public specialname rtspecialname instance void .ctor() cil managed { .maxstack 8 - IL_0000: ret + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ret } - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitEta@11 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static void Invoke() cil managed + .method public hidebysig instance void M() cil managed { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .maxstack 8 IL_0000: ret @@ -61,6 +60,7 @@ .method public static void 'handler'() cil managed { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .maxstack 8 IL_0000: ret @@ -71,7 +71,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/caseUnitNonEta@8::Invoke() + IL_0001: ldftn void assembly::'handler'() IL_0007: newobj instance void [runtime]System.Action::.ctor(object, native int) IL_000c: ret @@ -82,7 +82,29 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/caseUnitEta@11::Invoke() + IL_0001: ldftn void assembly::'handler'() + IL_0007: newobj instance void [runtime]System.Action::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action caseUnitInstanceNonEta(class assembly/C c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldftn instance void assembly/C::M() + IL_0007: newobj instance void [runtime]System.Action::.ctor(object, + native int) + IL_000c: ret + } + + .method public static class [runtime]System.Action caseUnitInstanceEta(class assembly/C c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldftn instance void assembly/C::M() IL_0007: newobj instance void [runtime]System.Action::.ctor(object, native int) IL_000c: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOn.il.bsl index 3684e4e4a6b..5a5fcf30ef7 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOn.il.bsl @@ -33,7 +33,32 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitNonEta@8 + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public specialname rtspecialname instance void .ctor() cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ret + } + + .method public hidebysig instance void M() cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitNonEta@13 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -41,12 +66,14 @@ { .maxstack 8 - IL_0000: ret + IL_0000: call void assembly::'handler'() + IL_0005: nop + IL_0006: ret } } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitEta@11 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitEta@16 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -54,13 +81,76 @@ { .maxstack 8 - IL_0000: ret + IL_0000: call void assembly::'handler'() + IL_0005: nop + IL_0006: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitInstanceNonEta@19 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C c + .method public specialname rtspecialname instance void .ctor(class assembly/C c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/caseUnitInstanceNonEta@19::c + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke() cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/caseUnitInstanceNonEta@19::c + IL_0006: callvirt instance void assembly/C::M() + IL_000b: nop + IL_000c: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitInstanceEta@22 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .field public class assembly/C c + .method public specialname rtspecialname instance void .ctor(class assembly/C c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: stfld class assembly/C assembly/caseUnitInstanceEta@22::c + IL_0007: ldarg.0 + IL_0008: call instance void [runtime]System.Object::.ctor() + IL_000d: ret + } + + .method assembly hidebysig instance void Invoke() cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld class assembly/C assembly/caseUnitInstanceEta@22::c + IL_0006: callvirt instance void assembly/C::M() + IL_000b: nop + IL_000c: ret } } .method public static void 'handler'() cil managed { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .maxstack 8 IL_0000: ret @@ -71,7 +161,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/caseUnitNonEta@8::Invoke() + IL_0001: ldftn void assembly/caseUnitNonEta@13::Invoke() IL_0007: newobj instance void [runtime]System.Action::.ctor(object, native int) IL_000c: ret @@ -82,12 +172,36 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/caseUnitEta@11::Invoke() + IL_0001: ldftn void assembly/caseUnitEta@16::Invoke() IL_0007: newobj instance void [runtime]System.Action::.ctor(object, native int) IL_000c: ret } + .method public static class [runtime]System.Action caseUnitInstanceNonEta(class assembly/C c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/caseUnitInstanceNonEta@19::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/caseUnitInstanceNonEta@19::Invoke() + IL_000c: newobj instance void [runtime]System.Action::.ctor(object, + native int) + IL_0011: ret + } + + .method public static class [runtime]System.Action caseUnitInstanceEta(class assembly/C c) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: newobj instance void assembly/caseUnitInstanceEta@22::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/caseUnitInstanceEta@22::Invoke() + IL_000c: newobj instance void [runtime]System.Action::.ctor(object, + native int) + IL_0011: ret + } + } .class private abstract auto ansi sealed ''.$assembly diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs index d23f9038694..6c90e1ac264 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs @@ -392,31 +392,47 @@ let main _ = |> compileExeAndRun |> shouldSucceed -// Cases 46-47: the synthesized unit argument is seen as a leading argument for a static target, so a -// unit-argument delegate stays a closure (and still runs). +// Cases 46-49: the forwarded unit argument is stripped, so a unit-argument delegate points directly at the +// target - a static target carries a null Target, an instance target carries the receiver. [] -let ``Unit-argument delegate stays a closure (preview)`` () = +let ``Unit-argument delegate targets the real method (preview)`` () = FSharp """ -module UnitArgClosure +module UnitArgDirect open System -let mutable ran = false -let handler () : unit = ran <- true +let mutable ran = 0 + +[] +let handler () : unit = ran <- ran + 1 + +type C() = + [] + member _.M () : unit = ran <- ran + 10 [] let main _ = - let d = Action(handler) - d.Invoke() - if not ran then failwith "did not run" - if d.Method.Name <> "Invoke" then failwithf "expected closure 'Invoke' but got '%s'" d.Method.Name + // Static unit-argument target: direct, null Target, real Method.Name. + let ds = Action(handler) + ds.Invoke() + if ds.Method.Name <> "handler" then failwithf "static: expected 'handler' but got '%s'" ds.Method.Name + if not (isNull ds.Target) then failwith "static: Target should be null" + + // Instance unit-argument target: direct, Target is the receiver. + let c = C() + let di = Action(c.M) + di.Invoke() + if di.Method.Name <> "M" then failwithf "instance: expected 'M' but got '%s'" di.Method.Name + if not (obj.ReferenceEquals(di.Target, c)) then failwith "instance: Target is not the receiver" + + if ran <> 11 then failwithf "expected both targets to run (ran=%d)" ran 0 """ |> withLangVersionPreview |> compileExeAndRun |> shouldSucceed -// Cases 48-49: a value-type receiver would need boxing (a delegate Target is object); not implemented, so +// Cases 50-51: a value-type receiver would need boxing (a delegate Target is object); not implemented, so // it stays a closure and still dispatches correctly. [] let ``Struct value-type receiver stays a closure (preview)`` () = @@ -441,7 +457,7 @@ let main _ = |> compileExeAndRun |> shouldSucceed -// Case 50: an extension member compiles to a static method whose first parameter is the receiver, so it is +// Case 52: an extension member compiles to a static method whose first parameter is the receiver, so it is // bound as a leading argument (a partial application) and stays a closure. [] let ``Extension member stays a closure (preview)`` () = @@ -470,7 +486,7 @@ let main _ = |> compileExeAndRun |> shouldSucceed -// Case 51: a byref Invoke parameter with a mutating body is not a transparent forwarding call, so it stays +// Case 53: a byref Invoke parameter with a mutating body is not a transparent forwarding call, so it stays // a closure and mutates through the byref correctly. [] let ``Byref-parameter delegate stays a closure and mutates (preview)`` () = From 80a8668e69eda04c857b0efb07a049670264de38 Mon Sep 17 00:00:00 2001 From: kerams Date: Mon, 29 Jun 2026 19:05:06 +0200 Subject: [PATCH 10/16] Extension methods --- src/Compiler/CodeGen/IlxGen.Delegates.fs | 56 +++++++++++- src/Compiler/CodeGen/IlxGen.fs | 13 ++- .../DelegateExtensionMethod.fs | 11 ++- ...ensionMethod.fs.OptimizeOff.Preview.il.bsl | 10 +- ...egateExtensionMethod.fs.OptimizeOff.il.bsl | 10 +- ...tensionMethod.fs.OptimizeOn.Preview.il.bsl | 43 +-------- ...legateExtensionMethod.fs.OptimizeOn.il.bsl | 10 +- ...eNonInlinable.fs.OptimizeOn.Preview.il.bsl | 22 +---- .../DelegatePartialApplication.fs | 10 +- ...lApplication.fs.OptimizeOff.Preview.il.bsl | 34 +++---- ...tePartialApplication.fs.OptimizeOff.il.bsl | 34 +++---- ...alApplication.fs.OptimizeOn.Preview.il.bsl | 12 +-- ...atePartialApplication.fs.OptimizeOn.il.bsl | 12 +-- .../DirectDelegates/DirectDelegates.fs | 91 ++++++++++++++++--- 14 files changed, 223 insertions(+), 145 deletions(-) diff --git a/src/Compiler/CodeGen/IlxGen.Delegates.fs b/src/Compiler/CodeGen/IlxGen.Delegates.fs index a511021e33b..7ca4adee03e 100644 --- a/src/Compiler/CodeGen/IlxGen.Delegates.fs +++ b/src/Compiler/CodeGen/IlxGen.Delegates.fs @@ -34,6 +34,27 @@ let private isUnitValue e = | Expr.Const(Const.Unit, _, _) -> true | _ -> false +// The forwarding call of a *tupled* target carries each tupled argument group as a single tuple node: e.g. for +// `accTupled (x, y)` (a value of arity [2]) the call `accTupled (a, b)` is one `(a, b)` argument, exactly the +// shape BuildFSharpMethodApp produced from the value's arity. The code generator de-tuples these by the value's +// arity when it emits the call, so the compiled target takes the elements as separate IL parameters and is +// perfectly compatible with the delegate (a tupled target is as direct-able as a curried one). Mirror that +// de-tupling here so the forwarding match sees the flattened argument list: expand a tuple-construction argument +// whose size matches its arity group into the group's elements; leave anything else (including a target with no +// arity info) untouched, which conservatively falls back to a closure. +let private flattenTupledArgs (vref: ValRef) (args: Expr list) = + let arities = (arityOfVal vref.Deref).AritiesOfArgs + + if arities.Length <> args.Length then + args + else + (arities, args) + ||> List.map2 (fun arity arg -> + match stripDebugPoints arg with + | Expr.Op(TOp.Tuple _, _, elems, _) when arity >= 2 && elems.Length = arity -> elems + | _ -> [ arg ]) + |> List.concat + // The forwarding call may be wrapped in let-bindings the recognizer must see through, in any combination: // - a 'let unitVar = () in …' that BindUnitVars (or the elaborator) inserts for the elided unit parameter // of a zero-parameter Invoke (e.g. System.Action), and @@ -93,7 +114,7 @@ let classifyForwardingTarget g (invokeParams: Val list) expr = match body with | Expr.App(Expr.Val(vref, valUseFlags, _), _, tyargs, args, _) -> - match matchForwarding args with + match matchForwarding (flattenTupledArgs vref args) with | ValueSome leadingArgs -> DirectDelegateForwardingTargetCandidate.FSharpVal(vref, valUseFlags, tyargs, leadingArgs) | ValueNone -> DirectDelegateForwardingTargetCandidate.Other | Expr.Op(TOp.ILCall(isVirtual, _, isStruct, isCtor, valUseFlag, _, _, ilMethRef, enclTypeInst, methInst, _), _, args, _) -> @@ -112,15 +133,32 @@ let classifyForwardingTarget g (invokeParams: Val list) expr = | ValueNone -> DirectDelegateForwardingTargetCandidate.Other | _ -> DirectDelegateForwardingTargetCandidate.Other -/// For an instance method the single leading argument is the receiver; a static method or module function -/// must have no leading arguments (otherwise it is a partial application). +/// At most one leading argument can be hoisted to the construction site and stored as the delegate's Target: +/// - for an instance method it is the receiver (not part of the IL signature), and +/// - for a static method it is the first IL parameter, bound via the CLR's "closed over the first argument" +/// delegate mechanism (this is how an extension member's receiver, or a one-argument partial application of +/// a static method / module function, becomes direct). +/// Two or more leading arguments (e.g. a partial application that also fixes a receiver) have no closed +/// direct-delegate form, so they stay a closure. let private receiverShapeOk (leadingArgs: Expr list) takesInstanceArg = if takesInstanceArg then match leadingArgs with | [ _ ] -> true | _ -> false else - List.isEmpty leadingArgs + match leadingArgs with + | [] + | [ _ ] -> true + | _ -> false + +/// A leading argument of a *static* target is stored as the delegate's Target, which is typed `object`. A +/// value-type leading argument would have to be boxed (changing identity/copy semantics), which is not yet +/// supported, so it disqualifies the direct form (the same boxing gap that excludes value-type instance +/// receivers). Targets with no leading argument, or an instance receiver, are unaffected here. +let private staticLeadingArgIsRefType g takesInstanceArg (leadingArgs: Expr list) = + match leadingArgs with + | [ recv ] when not takesInstanceArg -> not (isStructTy g (tyOfExpr g recv)) + | _ -> true /// The receiver is hoisted to the delegate-construction site, so a direct delegate is only sound when it can /// be evaluated there exactly once and as the Target: @@ -153,6 +191,7 @@ let fsharpValDirectlyBindable g (invokeParams: Val list) (leadingArgs: Expr list && not valUseFlags.IsVSlotDirectCall && receiverShapeOk leadingArgs takesInstanceArg && receiverBindable g invokeParams leadingArgs + && staticLeadingArgIsRefType g takesInstanceArg leadingArgs /// An IL method target can be pointed at directly only when it is not a constructor / base / constrained call, /// when the receiver shape is right, when the receiver is not a value type (boxing is not yet implemented), and @@ -175,6 +214,7 @@ let ilMethodDirectlyBindable && not (takesInstanceArg && isStruct) && receiverShapeOk leadingArgs takesInstanceArg && receiverBindable g invokeParams leadingArgs + && staticLeadingArgIsRefType g takesInstanceArg leadingArgs /// Confirm the target's IL signature is compatible with the delegate's Invoke. The type checker has already /// verified the delegate is built from a compatible function shape and the forwarding match pins the arity, @@ -187,14 +227,20 @@ let ilMethodDirectlyBindable /// cannot see and the CLR will not relax: notably an F# 'unit' return compiled to 'void' versus a delegate /// whose Invoke returns 'Unit'. For a generic target the return is written in terms of type variables, so /// no exact comparison is meaningful. +/// +/// 'numBoundLeadingFormals' is the number of leading IL parameters consumed by a hoisted Target (1 for a +/// static method whose first argument is bound, e.g. an extension receiver; 0 otherwise - an instance +/// receiver is not part of the IL signature), so it is subtracted from the target's formal-argument count. let signatureMatches + numBoundLeadingFormals (ilDelegeeParams: ILParameter list) (ilDelegeeRet: ILReturn) (ilEnclArgTys: ILType list) (ilMethArgTys: ILType list) (targetMspec: ILMethodSpec) = - let arityMatches = targetMspec.FormalArgTypes.Length = ilDelegeeParams.Length + let arityMatches = + targetMspec.FormalArgTypes.Length - numBoundLeadingFormals = ilDelegeeParams.Length let returnMatches = if List.isEmpty ilEnclArgTys && List.isEmpty ilMethArgTys then diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index 4583073537f..3dd8d210e6b 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -7514,13 +7514,16 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, let ilEnclArgTys, ilMethArgTys = List.splitAt numEnclILTypeArgs ilTyArgs let boxity = mspec.DeclaringType.Boxity let targetMspec = mkILMethSpec (mspec.MethodRef, boxity, ilEnclArgTys, ilMethArgTys) + let numBoundLeadingFormals = if takesInstanceArg then 0 else leadingArgs.Length if takesInstanceArg <> targetMspec.MethodRef.CallingConv.IsInstance then None elif takesInstanceArg && boxity.IsAsValue then // value-type receivers not handled None - elif signatureMatches ilDelegeeParams ilDelegeeRet ilEnclArgTys ilMethArgTys targetMspec then + elif + signatureMatches numBoundLeadingFormals ilDelegeeParams ilDelegeeRet ilEnclArgTys ilMethArgTys targetMspec + then Some(targetMspec, receiverInfo leadingArgs virtualCall) else None @@ -7542,6 +7545,12 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, let boxity = if isStruct then AsValue else AsObject let targetMspec = mkILMethSpec (ilMethRef, boxity, ilEnclArgTys, ilMethArgTys) + let numBoundLeadingFormals = + if ilMethRef.CallingConv.IsInstance then + 0 + else + leadingArgs.Length + // Unlike the F# case we cannot compare parameter/return IL types here: the target's // types come from imported metadata, whose assembly scope refs differ from the // compiler-generated delegee types (e.g. `System.Int32, System.Runtime` vs the bare @@ -7549,7 +7558,7 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, // primitives that always match. The forwarding match already pins the arity, and the // type checker has verified the call is well-typed, so element compatibility holds by // construction; an arity check is the sound guard (matching the generic case). - if targetMspec.FormalArgTypes.Length = ilDelegeeParams.Length then + if targetMspec.FormalArgTypes.Length - numBoundLeadingFormals = ilDelegeeParams.Length then Some(targetMspec, receiverInfo leadingArgs isVirtual) else None diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs index e1118463d0b..6a06814a03d 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs @@ -12,8 +12,11 @@ type HolderExtensions = [] static member Combine (h: Holder, x: int, y: int) : int = x + y -// An extension member compiles to a static method whose first parameter is the receiver, so using it as a -// delegate target binds that receiver as a leading argument - a partial application, which has no closed -// direct-delegate form. A closure must remain regardless of langversion. -// 52. extension member (receiver is a leading static arg) +// An extension member compiles to a static method whose first parameter is the receiver. Using it as a +// delegate target binds that receiver as a leading argument, which the CLR's "closed over the first argument" +// delegate stores as the Target while the function pointer points at the static method - a direct delegate. +// (The member here is tupled, 'Combine(h, x, y)'; the recognizer de-tuples the forwarding call by the target's +// arity, exactly as the code generator does when emitting the call.) As an eta-expanded delegate it is direct +// only in optimized builds, where the user's lambda need not survive for debugging. +// 52. extension member (receiver is a leading static arg, bound as Target) let extensionEta (h: Holder) = Func(fun a b -> h.Combine(a, b)) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOff.Preview.il.bsl index 66377f64db4..38de9585694 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOff.Preview.il.bsl @@ -71,7 +71,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname extensionEta@19 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname extensionEta@22 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -82,7 +82,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/Holder assembly/extensionEta@19::h + IL_0002: stfld class assembly/Holder assembly/extensionEta@22::h IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -93,7 +93,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/Holder assembly/extensionEta@19::h + IL_0001: ldfld class assembly/Holder assembly/extensionEta@22::h IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: call int32 assembly/HolderExtensions::Combine(class assembly/Holder, @@ -109,8 +109,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/extensionEta@19::.ctor(class assembly/Holder) - IL_0006: ldftn instance int32 assembly/extensionEta@19::Invoke(int32, + IL_0001: newobj instance void assembly/extensionEta@22::.ctor(class assembly/Holder) + IL_0006: ldftn instance int32 assembly/extensionEta@22::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOff.il.bsl index bdc4971648a..a410776454a 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOff.il.bsl @@ -71,7 +71,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname extensionEta@19 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname extensionEta@22 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -82,7 +82,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/Holder assembly/extensionEta@19::h + IL_0002: stfld class assembly/Holder assembly/extensionEta@22::h IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -93,7 +93,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/Holder assembly/extensionEta@19::h + IL_0001: ldfld class assembly/Holder assembly/extensionEta@22::h IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: call int32 assembly/HolderExtensions::Combine(class assembly/Holder, @@ -109,8 +109,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/extensionEta@19::.ctor(class assembly/Holder) - IL_0006: ldftn instance int32 assembly/extensionEta@19::Invoke(int32, + IL_0001: newobj instance void assembly/extensionEta@22::.ctor(class assembly/Holder) + IL_0006: ldftn instance int32 assembly/extensionEta@22::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOn.Preview.il.bsl index 66377f64db4..4ec8ad308a3 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOn.Preview.il.bsl @@ -71,50 +71,17 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname extensionEta@19 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .field public class assembly/Holder h - .method public specialname rtspecialname instance void .ctor(class assembly/Holder h) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: stfld class assembly/Holder assembly/extensionEta@19::h - IL_0007: ldarg.0 - IL_0008: call instance void [runtime]System.Object::.ctor() - IL_000d: ret - } - - .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldfld class assembly/Holder assembly/extensionEta@19::h - IL_0006: ldarg.1 - IL_0007: ldarg.2 - IL_0008: call int32 assembly/HolderExtensions::Combine(class assembly/Holder, - int32, - int32) - IL_000d: ret - } - - } - .method public static class [runtime]System.Func`3 extensionEta(class assembly/Holder h) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/extensionEta@19::.ctor(class assembly/Holder) - IL_0006: ldftn instance int32 assembly/extensionEta@19::Invoke(int32, - int32) - IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + IL_0001: ldftn int32 assembly/HolderExtensions::Combine(class assembly/Holder, + int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) - IL_0011: ret + IL_000c: ret } } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOn.il.bsl index bdc4971648a..a410776454a 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOn.il.bsl @@ -71,7 +71,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname extensionEta@19 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname extensionEta@22 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -82,7 +82,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/Holder assembly/extensionEta@19::h + IL_0002: stfld class assembly/Holder assembly/extensionEta@22::h IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -93,7 +93,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/Holder assembly/extensionEta@19::h + IL_0001: ldfld class assembly/Holder assembly/extensionEta@22::h IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: call int32 assembly/HolderExtensions::Combine(class assembly/Holder, @@ -109,8 +109,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/extensionEta@19::.ctor(class assembly/Holder) - IL_0006: ldftn instance int32 assembly/extensionEta@19::Invoke(int32, + IL_0001: newobj instance void assembly/extensionEta@22::.ctor(class assembly/Holder) + IL_0006: ldftn instance int32 assembly/extensionEta@22::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.Preview.il.bsl index f2ac084ccbb..110adc677fb 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.Preview.il.bsl @@ -98,24 +98,6 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaTupled@18 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 a, - int32 b) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call int32 assembly::accTupled(int32, - int32) - IL_0007: ret - } - - } - .method public static int32 accCurried(int32 x, int32 y) cil managed { @@ -170,8 +152,8 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/niEtaTupled@18::Invoke(int32, - int32) + IL_0001: ldftn int32 assembly::accTupled(int32, + int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) IL_000c: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs index 2e1a9a13c4e..a77f70c8adb 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs @@ -5,8 +5,14 @@ open System // Cases 37/38 (in DelegateKnownFunction.fs / DelegateStaticMethod.fs) capture a // constant first argument, so their closure can stay static (the constant is re-materialised in Invoke // with no instance field). Capturing a runtime VALUE instead forces the closure to carry an instance -// field, which exercises a distinct emit path. None of these can ever become a direct delegate (the -// target has more parameters than the delegate's Invoke), so a closure must remain. +// field, which exercises a distinct emit path. None of the cases below can become a direct delegate: +// - The CLR's closed delegate binds exactly ONE leading value as the Target. papInstanceVar fixes two +// leading values (the receiver 'o' and the argument 'n'), so there is no closed form. +// - papKnownVar / papStaticVar fix a single leading value, but it is an 'int'. The closed-delegate thunk +// passes the Target (an 'object') straight into the method's first parameter with NO unboxing, so a +// value-type first parameter has no closed form at all (the same reason a value-type receiver is +// excluded). A reference-type fixed argument, by contrast, IS emitted directly (see the execution test +// `Reference-type single-argument partial application is direct`). let handler3 (x: int) (y: int) (z: int) : unit = () diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOff.Preview.il.bsl index 236f68901ed..64b30067a6b 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOff.Preview.il.bsl @@ -87,7 +87,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname papKnownVar@20 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname papKnownVar@26 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -98,7 +98,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld int32 assembly/papKnownVar@20::n + IL_0002: stfld int32 assembly/papKnownVar@26::n IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -109,7 +109,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld int32 assembly/papKnownVar@20::n + IL_0001: ldfld int32 assembly/papKnownVar@26::n IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: call void assembly::handler3(int32, @@ -121,7 +121,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname papStaticVar@23 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname papStaticVar@29 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -132,7 +132,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld int32 assembly/papStaticVar@23::n + IL_0002: stfld int32 assembly/papStaticVar@29::n IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -143,7 +143,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld int32 assembly/papStaticVar@23::n + IL_0001: ldfld int32 assembly/papStaticVar@29::n IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: call void assembly/C::Add3(int32, @@ -155,7 +155,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname papInstanceVar@26 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname papInstanceVar@32 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -167,10 +167,10 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/I assembly/papInstanceVar@26::o + IL_0002: stfld class assembly/I assembly/papInstanceVar@32::o IL_0007: ldarg.0 IL_0008: ldarg.2 - IL_0009: stfld int32 assembly/papInstanceVar@26::n + IL_0009: stfld int32 assembly/papInstanceVar@32::n IL_000e: ldarg.0 IL_000f: call instance void [runtime]System.Object::.ctor() IL_0014: ret @@ -181,9 +181,9 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/I assembly/papInstanceVar@26::o + IL_0001: ldfld class assembly/I assembly/papInstanceVar@32::o IL_0006: ldarg.0 - IL_0007: ldfld int32 assembly/papInstanceVar@26::n + IL_0007: ldfld int32 assembly/papInstanceVar@32::n IL_000c: ldarg.1 IL_000d: ldarg.2 IL_000e: callvirt instance void assembly/I::Add3(int32, @@ -211,8 +211,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/papKnownVar@20::.ctor(int32) - IL_0006: ldftn instance void assembly/papKnownVar@20::Invoke(int32, + IL_0001: newobj instance void assembly/papKnownVar@26::.ctor(int32) + IL_0006: ldftn instance void assembly/papKnownVar@26::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -224,8 +224,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/papStaticVar@23::.ctor(int32) - IL_0006: ldftn instance void assembly/papStaticVar@23::Invoke(int32, + IL_0001: newobj instance void assembly/papStaticVar@29::.ctor(int32) + IL_0006: ldftn instance void assembly/papStaticVar@29::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -239,9 +239,9 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: newobj instance void assembly/papInstanceVar@26::.ctor(class assembly/I, + IL_0002: newobj instance void assembly/papInstanceVar@32::.ctor(class assembly/I, int32) - IL_0007: ldftn instance void assembly/papInstanceVar@26::Invoke(int32, + IL_0007: ldftn instance void assembly/papInstanceVar@32::Invoke(int32, int32) IL_000d: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOff.il.bsl index c4365038d12..d8ecbf83e0c 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOff.il.bsl @@ -87,7 +87,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname papKnownVar@20 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname papKnownVar@26 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -98,7 +98,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld int32 assembly/papKnownVar@20::n + IL_0002: stfld int32 assembly/papKnownVar@26::n IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -109,7 +109,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld int32 assembly/papKnownVar@20::n + IL_0001: ldfld int32 assembly/papKnownVar@26::n IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: call void assembly::handler3(int32, @@ -121,7 +121,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname papStaticVar@23 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname papStaticVar@29 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -132,7 +132,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld int32 assembly/papStaticVar@23::n + IL_0002: stfld int32 assembly/papStaticVar@29::n IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -143,7 +143,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld int32 assembly/papStaticVar@23::n + IL_0001: ldfld int32 assembly/papStaticVar@29::n IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: call void assembly/C::Add3(int32, @@ -155,7 +155,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname papInstanceVar@26 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname papInstanceVar@32 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -167,10 +167,10 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/I assembly/papInstanceVar@26::o + IL_0002: stfld class assembly/I assembly/papInstanceVar@32::o IL_0007: ldarg.0 IL_0008: ldarg.2 - IL_0009: stfld int32 assembly/papInstanceVar@26::n + IL_0009: stfld int32 assembly/papInstanceVar@32::n IL_000e: ldarg.0 IL_000f: call instance void [runtime]System.Object::.ctor() IL_0014: ret @@ -181,9 +181,9 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/I assembly/papInstanceVar@26::o + IL_0001: ldfld class assembly/I assembly/papInstanceVar@32::o IL_0006: ldarg.0 - IL_0007: ldfld int32 assembly/papInstanceVar@26::n + IL_0007: ldfld int32 assembly/papInstanceVar@32::n IL_000c: ldarg.1 IL_000d: ldarg.2 IL_000e: callvirt instance void assembly/I::Add3(int32, @@ -211,8 +211,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/papKnownVar@20::.ctor(int32) - IL_0006: ldftn instance void assembly/papKnownVar@20::Invoke(int32, + IL_0001: newobj instance void assembly/papKnownVar@26::.ctor(int32) + IL_0006: ldftn instance void assembly/papKnownVar@26::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -224,8 +224,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/papStaticVar@23::.ctor(int32) - IL_0006: ldftn instance void assembly/papStaticVar@23::Invoke(int32, + IL_0001: newobj instance void assembly/papStaticVar@29::.ctor(int32) + IL_0006: ldftn instance void assembly/papStaticVar@29::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -239,9 +239,9 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: newobj instance void assembly/papInstanceVar@26::.ctor(class assembly/I, + IL_0002: newobj instance void assembly/papInstanceVar@32::.ctor(class assembly/I, int32) - IL_0007: ldftn instance void assembly/papInstanceVar@26::Invoke(int32, + IL_0007: ldftn instance void assembly/papInstanceVar@32::Invoke(int32, int32) IL_000d: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOn.Preview.il.bsl index 27785cff18d..bfbde14b661 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOn.Preview.il.bsl @@ -83,7 +83,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papKnownVar@20 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papKnownVar@26 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -97,7 +97,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papStaticVar@23 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papStaticVar@29 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -111,7 +111,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papInstanceVar@26 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papInstanceVar@32 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -141,7 +141,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/papKnownVar@20::Invoke(int32, + IL_0001: ldftn void assembly/papKnownVar@26::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -153,7 +153,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/papStaticVar@23::Invoke(int32, + IL_0001: ldftn void assembly/papStaticVar@29::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -166,7 +166,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/papInstanceVar@26::Invoke(int32, + IL_0001: ldftn void assembly/papInstanceVar@32::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOn.il.bsl index 61c73994f65..4c748f45b02 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegatePartialApplication.fs.OptimizeOn.il.bsl @@ -83,7 +83,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papKnownVar@20 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papKnownVar@26 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -97,7 +97,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papStaticVar@23 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papStaticVar@29 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -111,7 +111,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papInstanceVar@26 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname papInstanceVar@32 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -141,7 +141,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/papKnownVar@20::Invoke(int32, + IL_0001: ldftn void assembly/papKnownVar@26::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -153,7 +153,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/papStaticVar@23::Invoke(int32, + IL_0001: ldftn void assembly/papStaticVar@29::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -166,7 +166,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/papInstanceVar@26::Invoke(int32, + IL_0001: ldftn void assembly/papInstanceVar@32::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs index 6c90e1ac264..1033d24c75a 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs @@ -345,12 +345,13 @@ let main _ = |> compileExeAndRun |> shouldSucceed -// Cases 31-36: a tupled application forwards a single tuple, not the Invoke parameters verbatim, so the -// shape is not recognized and a closure is kept even in release. +// Cases 31-36: a tupled application carries each tupled group as a single tuple node, exactly the shape the +// code generator de-tuples by the target's arity when it emits the call. The recognizer de-tuples the same +// way, so a tupled target is as direct-able as its curried counterpart and points at the real method. [] -let ``Tupled application stays a closure (preview)`` () = +let ``Tupled application targets the real method (preview)`` () = FSharp """ -module TupledClosure +module TupledDirect open System @@ -361,7 +362,8 @@ let accT (x: int, y: int) : int = x + y let main _ = let d = Func(fun a b -> accT (a, b)) if d.Invoke(2, 3) <> 5 then failwith "wrong result" - if d.Method.Name <> "Invoke" then failwithf "expected closure 'Invoke' but got '%s'" d.Method.Name + if d.Method.Name <> "accT" then failwithf "expected direct 'accT' but got '%s'" d.Method.Name + if not (isNull d.Target) then failwith "Target should be null for a static target" 0 """ |> withLangVersionPreview @@ -369,8 +371,11 @@ let main _ = |> compileExeAndRun |> shouldSucceed -// Cases 37-41: a partial application leaves the target with more parameters than the delegate's Invoke, -// so there is no closed direct form and a closure is kept. +// Cases 37-41: the CLR's closed delegate binds exactly one leading argument as the Target, so a partial +// application that fixes two or more arguments (or also fixes a receiver) has no closed direct form and stays +// a closure. A one-argument partial application could be closed, but only if that argument is a reference type +// (a value-type Target would need boxing - the same gap as a value-type receiver), so fixing a value-type +// argument keeps a closure too. [] let ``Partial application stays a closure (preview)`` () = FSharp """ @@ -383,6 +388,7 @@ let add3 (x: int) (y: int) (z: int) : int = x + y + z [] let main _ = + // One fixed argument, but it is a value type: a value-type Target would need boxing, so a closure is kept. let d = Func(add3 1) if d.Invoke(2, 3) <> 6 then failwith "wrong result" if d.Method.Name <> "Invoke" then failwithf "expected closure 'Invoke' but got '%s'" d.Method.Name @@ -392,6 +398,32 @@ let main _ = |> compileExeAndRun |> shouldSucceed +// A one-argument partial application whose fixed argument is a reference type is expressible as a closed +// delegate: the argument is bound as the Target and the delegate points directly at the static method. +[] +let ``Reference-type single-argument partial application is direct (preview)`` () = + FSharp """ +module PartialDirect + +open System + +[] +let prepend (prefix: string) (x: int) (y: int) : string = sprintf "%s%d%d" prefix x y + +[] +let main _ = + let p = "p" + let d = Func(prepend p) + if d.Invoke(2, 3) <> "p23" then failwith "wrong result" + if d.Method.Name <> "prepend" then failwithf "expected direct 'prepend' but got '%s'" d.Method.Name + if not (obj.ReferenceEquals(d.Target, p)) then failwith "Target is not the fixed argument" + 0 + """ + |> withLangVersionPreview + |> withOptions [ "--optimize+" ] + |> compileExeAndRun + |> shouldSucceed + // Cases 46-49: the forwarded unit argument is stripped, so a unit-argument delegate points directly at the // target - a static target carries a null Target, an instance target carries the receiver. [] @@ -457,12 +489,13 @@ let main _ = |> compileExeAndRun |> shouldSucceed -// Case 52: an extension member compiles to a static method whose first parameter is the receiver, so it is -// bound as a leading argument (a partial application) and stays a closure. +// Case 52: an extension member compiles to a static method whose first parameter is the receiver. The CLR's +// "closed over the first argument" delegate binds that receiver as the Target, so the delegate points directly +// at the static extension method (in release, where the eta-lambda does not need to survive for debugging). [] -let ``Extension member stays a closure (preview)`` () = +let ``Extension member targets the real method (preview)`` () = FSharp """ -module ExtensionClosure +module ExtensionDirect open System open System.Runtime.CompilerServices @@ -471,7 +504,7 @@ type Holder() = class end [] type HolderExtensions = - [] + [] static member Combine (h: Holder, x: int, y: int) : int = x + y [] @@ -479,10 +512,42 @@ let main _ = let h = Holder() let d = Func(fun a b -> h.Combine(a, b)) if d.Invoke(2, 3) <> 5 then failwith "wrong result" - if d.Method.Name <> "Invoke" then failwithf "expected closure 'Invoke' but got '%s'" d.Method.Name + if d.Method.Name <> "Combine" then failwithf "expected direct 'Combine' but got '%s'" d.Method.Name + if not (obj.ReferenceEquals(d.Target, h)) then failwith "Target is not the extension receiver" 0 """ |> withLangVersionPreview + |> withOptions [ "--optimize+" ] + |> compileExeAndRun + |> shouldSucceed + +// A generic extension member whose receiver type uses the method's type parameter ('T list) still binds the +// receiver as the Target: the type argument is threaded through as a method instantiation (an extension member +// has no enclosing type arguments), and the receiver - a reference type - is the closed-over first argument. +[] +let ``Generic extension member receiver targets the real method (preview)`` () = + FSharp """ +module GenericExtensionDirect + +open System +open System.Runtime.CompilerServices + +[] +type ListExtensions = + [] + static member CountWith<'T> (xs: 'T list, x: int, y: int) : int = List.length xs + x + y + +[] +let main _ = + let xs = [ "a"; "b"; "c" ] + let d = Func(fun a b -> xs.CountWith(a, b)) + if d.Invoke(2, 3) <> 8 then failwithf "wrong result: %d" (d.Invoke(2, 3)) + if d.Method.Name <> "CountWith" then failwithf "expected direct 'CountWith' but got '%s'" d.Method.Name + if not (obj.ReferenceEquals(d.Target, xs)) then failwith "Target is not the extension receiver" + 0 + """ + |> withLangVersionPreview + |> withOptions [ "--optimize+" ] |> compileExeAndRun |> shouldSucceed From 9ddc0f19c1aec85d985496766797af3849bd1d5b Mon Sep 17 00:00:00 2001 From: kerams Date: Mon, 29 Jun 2026 23:01:59 +0200 Subject: [PATCH 11/16] Value types --- src/Compiler/CodeGen/IlxGen.Delegates.fs | 106 +++++++++++------- src/Compiler/CodeGen/IlxGen.fs | 16 ++- .../DirectDelegates/DelegateNegativeCases.fs | 13 +++ ...egativeCases.fs.OptimizeOff.Preview.il.bsl | 91 +++++++++++---- ...elegateNegativeCases.fs.OptimizeOff.il.bsl | 91 +++++++++++---- ...NegativeCases.fs.OptimizeOn.Preview.il.bsl | 85 +++++++++++--- ...DelegateNegativeCases.fs.OptimizeOn.il.bsl | 85 +++++++++++--- .../DirectDelegates/DelegateStructTarget.fs | 6 +- ...StructTarget.fs.OptimizeOff.Preview.il.bsl | 41 +------ ...eStructTarget.fs.OptimizeOn.Preview.il.bsl | 76 +------------ .../DirectDelegates/DirectDelegates.fs | 30 +++-- 11 files changed, 397 insertions(+), 243 deletions(-) diff --git a/src/Compiler/CodeGen/IlxGen.Delegates.fs b/src/Compiler/CodeGen/IlxGen.Delegates.fs index 7ca4adee03e..1a3204274c7 100644 --- a/src/Compiler/CodeGen/IlxGen.Delegates.fs +++ b/src/Compiler/CodeGen/IlxGen.Delegates.fs @@ -79,47 +79,58 @@ let rec private peel g expr mapReceiver = peel g inner mapReceiver | e -> e, mapReceiver -let classifyForwardingTarget g (invokeParams: Val list) expr = - let body, mapReceiver = peel g expr id +// The trailing arguments of the call must be exactly the delegate's Invoke parameters, forwarded +// verbatim and in order. The remaining leading arguments (e.g. an instance receiver) are returned +// for the consumer to handle. +let private matchForwarding g invokeParams (args: Expr list) mapReceiver = + // Drop the elided unit argument when the Invoke takes no parameters. + let args = + match List.tryLast args with + | Some last when List.isEmpty invokeParams && isUnitValue last -> List.truncate (args.Length - 1) args + | _ -> args - // The trailing arguments of the call must be exactly the delegate's Invoke parameters, forwarded - // verbatim and in order. The remaining leading arguments (e.g. an instance receiver) are returned - // for the consumer to handle. - let matchForwarding (args: Expr list) = - // Drop the elided unit argument when the Invoke takes no parameters. - let args = - match List.tryLast args with - | Some last when List.isEmpty invokeParams && isUnitValue last -> List.truncate (args.Length - 1) args - | _ -> args + let numLeading = args.Length - invokeParams.Length - let numLeading = args.Length - invokeParams.Length + if numLeading >= 0 then + let leadingArgs, forwardedArgs = List.splitAt numLeading args - if numLeading >= 0 then - let leadingArgs, forwardedArgs = List.splitAt numLeading args + if + List.forall2 + (fun (a: Expr) (tv: Val) -> + match stripDebugPoints a with + | Expr.Val(avref, _, _) -> valRefEq g avref (mkLocalValRef tv) + | _ -> false) + forwardedArgs + invokeParams + then + // A value-type receiver is passed to its instance method by address ('&recv'); recover the + // underlying value so it can be boxed and stored as the delegate Target (the unboxing stub + // supplies the 'this' pointer on invocation). When the receiver is a side-effect-free let that + // 'peel' removed, this also re-exposes the let-bound variable so 'mapReceiver' can map it back. + let leadingArgs = + leadingArgs + |> List.map (fun a -> + match stripDebugPoints a with + | Expr.Op(TOp.LValueOp(LAddrOf _, vref), _, _, m) -> exprForValRef m vref + | _ -> a) - if - List.forall2 - (fun (a: Expr) (tv: Val) -> - match stripDebugPoints a with - | Expr.Val(avref, _, _) -> valRefEq g avref (mkLocalValRef tv) - | _ -> false) - forwardedArgs - invokeParams - then - ValueSome(mapReceiver leadingArgs) - else - ValueNone + Some(mapReceiver leadingArgs) else - ValueNone + None + else + None + +let classifyForwardingTarget g (invokeParams: Val list) expr = + let body, mapReceiver = peel g expr id match body with | Expr.App(Expr.Val(vref, valUseFlags, _), _, tyargs, args, _) -> - match matchForwarding (flattenTupledArgs vref args) with - | ValueSome leadingArgs -> DirectDelegateForwardingTargetCandidate.FSharpVal(vref, valUseFlags, tyargs, leadingArgs) - | ValueNone -> DirectDelegateForwardingTargetCandidate.Other + match matchForwarding g invokeParams (flattenTupledArgs vref args) mapReceiver with + | Some leadingArgs -> DirectDelegateForwardingTargetCandidate.FSharpVal(vref, valUseFlags, tyargs, leadingArgs) + | None -> DirectDelegateForwardingTargetCandidate.Other | Expr.Op(TOp.ILCall(isVirtual, _, isStruct, isCtor, valUseFlag, _, _, ilMethRef, enclTypeInst, methInst, _), _, args, _) -> - match matchForwarding args with - | ValueSome leadingArgs -> + match matchForwarding g invokeParams args mapReceiver with + | Some leadingArgs -> DirectDelegateForwardingTargetCandidate.ILMethod( isVirtual, isStruct, @@ -130,7 +141,7 @@ let classifyForwardingTarget g (invokeParams: Val list) expr = methInst, leadingArgs ) - | ValueNone -> DirectDelegateForwardingTargetCandidate.Other + | None -> DirectDelegateForwardingTargetCandidate.Other | _ -> DirectDelegateForwardingTargetCandidate.Other /// At most one leading argument can be hoisted to the construction site and stored as the delegate's Target: @@ -151,15 +162,25 @@ let private receiverShapeOk (leadingArgs: Expr list) takesInstanceArg = | [ _ ] -> true | _ -> false -/// A leading argument of a *static* target is stored as the delegate's Target, which is typed `object`. A -/// value-type leading argument would have to be boxed (changing identity/copy semantics), which is not yet -/// supported, so it disqualifies the direct form (the same boxing gap that excludes value-type instance -/// receivers). Targets with no leading argument, or an instance receiver, are unaffected here. +/// A leading argument of a *static* target is stored as the delegate's Target (typed `object`) and the +/// delegate thunk passes it straight into the method's first by-value parameter with no unboxing. A value-type +/// leading argument therefore has no closed form at all, so it disqualifies the direct form. (This is unlike a +/// value-type *instance* receiver, which is boxed and reached through the method's unboxing stub - see the +/// emit - and so is supported.) Targets with no leading argument, or an instance receiver, are unaffected here. let private staticLeadingArgIsRefType g takesInstanceArg (leadingArgs: Expr list) = match leadingArgs with | [ recv ] when not takesInstanceArg -> not (isStructTy g (tyOfExpr g recv)) | _ -> true +/// A value-type receiver is boxed at the construction site, which needs the receiver as a *value*. A struct +/// receiver is normally taken by address ('&recv'); the recognizer recovers the value from '&localVar', but any +/// other address form (e.g. '&someField') would leave a byref the box cannot consume, so disqualify it and keep +/// the closure. +let private receiverNotByref g (leadingArgs: Expr list) = + match leadingArgs with + | [ recv ] -> not (isByrefTy g (tyOfExpr g recv)) + | _ -> true + /// The receiver is hoisted to the delegate-construction site, so a direct delegate is only sound when it can /// be evaluated there exactly once and as the Target: /// - A closure built from an explicit eta-lambda (e.g. `fun a -> recv.M a`) re-evaluates the receiver on @@ -192,17 +213,18 @@ let fsharpValDirectlyBindable g (invokeParams: Val list) (leadingArgs: Expr list && receiverShapeOk leadingArgs takesInstanceArg && receiverBindable g invokeParams leadingArgs && staticLeadingArgIsRefType g takesInstanceArg leadingArgs + && receiverNotByref g leadingArgs /// An IL method target can be pointed at directly only when it is not a constructor / base / constrained call, -/// when the receiver shape is right, when the receiver is not a value type (boxing is not yet implemented), and -/// when the receiver can be safely hoisted to the construction site. The instance-receiver flag is derived here -/// from ilMethRef and the base/constrained-call flags from valUseFlag. +/// when the receiver shape is right, and when the receiver can be safely hoisted to the construction site. A +/// value-type instance receiver is boxed at the construction site (see the emit), matching the closure's +/// by-value capture. The instance-receiver flag is derived here from ilMethRef and the base/constrained-call +/// flags from valUseFlag. let ilMethodDirectlyBindable g (invokeParams: Val list) (leadingArgs: Expr list) (ilMethRef: ILMethodRef) - isStruct (valUseFlag: ValUseFlag) isCtor = @@ -211,10 +233,10 @@ let ilMethodDirectlyBindable not isCtor && not valUseFlag.IsVSlotDirectCall && not valUseFlag.IsPossibleConstrainedCall - && not (takesInstanceArg && isStruct) && receiverShapeOk leadingArgs takesInstanceArg && receiverBindable g invokeParams leadingArgs && staticLeadingArgIsRefType g takesInstanceArg leadingArgs + && receiverNotByref g leadingArgs /// Confirm the target's IL signature is compatible with the delegate's Invoke. The type checker has already /// verified the delegate is built from a compatible function shape and the forwarding match pins the arity, diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index 3dd8d210e6b..a70067b3bb2 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -7512,15 +7512,11 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, None else let ilEnclArgTys, ilMethArgTys = List.splitAt numEnclILTypeArgs ilTyArgs - let boxity = mspec.DeclaringType.Boxity - let targetMspec = mkILMethSpec (mspec.MethodRef, boxity, ilEnclArgTys, ilMethArgTys) + let targetMspec = mkILMethSpec (mspec.MethodRef, mspec.DeclaringType.Boxity, ilEnclArgTys, ilMethArgTys) let numBoundLeadingFormals = if takesInstanceArg then 0 else leadingArgs.Length if takesInstanceArg <> targetMspec.MethodRef.CallingConv.IsInstance then None - elif takesInstanceArg && boxity.IsAsValue then - // value-type receivers not handled - None elif signatureMatches numBoundLeadingFormals ilDelegeeParams ilDelegeeRet ilEnclArgTys ilMethArgTys targetMspec then @@ -7539,7 +7535,7 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, enclTypeInst, methInst, leadingArgs) -> - if ilMethodDirectlyBindable g tmvs leadingArgs ilMethRef isStruct valUseFlag isCtor then + if ilMethodDirectlyBindable g tmvs leadingArgs ilMethRef valUseFlag isCtor then let ilEnclArgTys = GenTypeArgs cenv m eenvouter.tyenv enclTypeInst let ilMethArgTys = GenTypeArgs cenv m eenvouter.tyenv methInst let boxity = if isStruct then AsValue else AsObject @@ -7578,6 +7574,14 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, // Instance target: evaluate the receiver as the delegate's target object. GenExpr cenv cgbuf eenvouter receiverExpr Continue + if targetMspec.DeclaringType.Boxity.IsAsValue then + // Value-type receiver: box a copy so it can be stored as the delegate's 'object' Target. The + // runtime binds the function pointer to the method's unboxing stub, which re-derives the 'this' + // pointer from the box on each invocation. This matches the closure form, which likewise + // captures the struct by value. (Struct instance methods are non-virtual, so isVirtual is + // false here and the ldftn path below is taken.) + CG.EmitInstr cgbuf (pop 1) (Push [ g.ilg.typ_Object ]) (I_box targetMspec.DeclaringType) + if isVirtual then // dup the receiver and bind the function pointer to its runtime type's override. CG.EmitInstr cgbuf (pop 0) (Push [ targetMspec.DeclaringType ]) AI_dup diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs index 4f1c2e34a96..14716ed1e4c 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs @@ -1,6 +1,7 @@ module DelegateNegativeCases open System +open System.Runtime.CompilerServices // 42. first-class function value: there is no target method to point at, so a closure must remain let firstClass (handler: int -> int -> unit) = Action(handler) @@ -23,3 +24,15 @@ type Holder() = // argument is no longer a verbatim Invoke parameter and the direct-delegate recognizer does not match. (The // signature check is not involved - it never even runs here.) let contra (h: Holder) = System.Func(fun s -> h.TakesObj s) + +[] +type Extensions = + [] + static member Echo<'T> (x: 'T, y: int, z: int) : 'T = x + +// 54. extension member on a VALUE-TYPE receiver: an extension member compiles to a static method whose first +// parameter is the receiver, which the closed-delegate mechanism would store as the 'object' Target and pass +// straight into that first by-value parameter with no unboxing. A value-type receiver therefore has no closed +// form (unlike a value-type *instance* receiver, which is reached through the method's unboxing stub), so a +// closure must remain. +let valueTypeExtension () = Func(fun a b -> (3).Echo(a, b)) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.Preview.il.bsl index 0ab53817b3b..d5cdc33872d 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.Preview.il.bsl @@ -59,7 +59,26 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname firstClass@6 + .class auto ansi serializable nested public Extensions + extends [runtime]System.Object + { + .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public static !!T Echo(!!T x, + int32 y, + int32 z) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname firstClass@7 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -70,7 +89,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/firstClass@6::'handler' + IL_0002: stfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/firstClass@7::'handler' IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -81,7 +100,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/firstClass@6::'handler' + IL_0001: ldfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/firstClass@7::'handler' IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: call !!0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::InvokeFast(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>, @@ -93,7 +112,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname notDirect@11 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname notDirect@12 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -104,7 +123,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld int32 assembly/notDirect@11::k + IL_0002: stfld int32 assembly/notDirect@12::k IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -118,7 +137,7 @@ IL_0001: ldarg.2 IL_0002: add IL_0003: ldarg.0 - IL_0004: ldfld int32 assembly/notDirect@11::k + IL_0004: ldfld int32 assembly/notDirect@12::k IL_0009: add IL_000a: call void assembly::sink(int32) IL_000f: nop @@ -127,7 +146,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname reordered@14 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname reordered@15 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -138,7 +157,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/reordered@14::'handler' + IL_0002: stfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/reordered@15::'handler' IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -149,7 +168,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/reordered@14::'handler' + IL_0001: ldfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/reordered@15::'handler' IL_0006: ldarg.2 IL_0007: ldarg.1 IL_0008: call !!0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::InvokeFast(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>, @@ -161,7 +180,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname contra@25 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname contra@26 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -172,7 +191,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/Holder assembly/contra@25::h + IL_0002: stfld class assembly/Holder assembly/contra@26::h IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -183,7 +202,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/Holder assembly/contra@25::h + IL_0001: ldfld class assembly/Holder assembly/contra@26::h IL_0006: ldarg.1 IL_0007: callvirt instance int32 assembly/Holder::TakesObj(object) IL_000c: ret @@ -191,13 +210,33 @@ } + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname valueTypeExtension@38 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.3 + IL_0001: ldarg.0 + IL_0002: ldarg.1 + IL_0003: call !!0 assembly/Extensions::Echo(!!0, + int32, + int32) + IL_0008: ret + } + + } + .method public static class [runtime]System.Action`2 firstClass(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/firstClass@6::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>) - IL_0006: ldftn instance void assembly/firstClass@6::Invoke(int32, + IL_0001: newobj instance void assembly/firstClass@7::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>) + IL_0006: ldftn instance void assembly/firstClass@7::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -216,8 +255,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/notDirect@11::.ctor(int32) - IL_0006: ldftn instance void assembly/notDirect@11::Invoke(int32, + IL_0001: newobj instance void assembly/notDirect@12::.ctor(int32) + IL_0006: ldftn instance void assembly/notDirect@12::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -229,8 +268,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/reordered@14::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>) - IL_0006: ldftn instance void assembly/reordered@14::Invoke(int32, + IL_0001: newobj instance void assembly/reordered@15::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>) + IL_0006: ldftn instance void assembly/reordered@15::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -242,13 +281,25 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/contra@25::.ctor(class assembly/Holder) - IL_0006: ldftn instance int32 assembly/contra@25::Invoke(string) + IL_0001: newobj instance void assembly/contra@26::.ctor(class assembly/Holder) + IL_0006: ldftn instance int32 assembly/contra@26::Invoke(string) IL_000c: newobj instance void class [runtime]System.Func`2::.ctor(object, native int) IL_0011: ret } + .method public static class [runtime]System.Func`3 valueTypeExtension() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/valueTypeExtension@38::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + } .class private abstract auto ansi sealed ''.$assembly diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.il.bsl index 8498432adc8..75511746827 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.il.bsl @@ -59,7 +59,26 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname firstClass@6 + .class auto ansi serializable nested public Extensions + extends [runtime]System.Object + { + .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public static !!T Echo(!!T x, + int32 y, + int32 z) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname firstClass@7 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -70,7 +89,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/firstClass@6::'handler' + IL_0002: stfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/firstClass@7::'handler' IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -81,7 +100,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/firstClass@6::'handler' + IL_0001: ldfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/firstClass@7::'handler' IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: call !!0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::InvokeFast(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>, @@ -93,7 +112,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname notDirect@11 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname notDirect@12 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -104,7 +123,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld int32 assembly/notDirect@11::k + IL_0002: stfld int32 assembly/notDirect@12::k IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -118,7 +137,7 @@ IL_0001: ldarg.2 IL_0002: add IL_0003: ldarg.0 - IL_0004: ldfld int32 assembly/notDirect@11::k + IL_0004: ldfld int32 assembly/notDirect@12::k IL_0009: add IL_000a: call void assembly::sink(int32) IL_000f: nop @@ -127,7 +146,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname reordered@14 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname reordered@15 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -138,7 +157,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/reordered@14::'handler' + IL_0002: stfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/reordered@15::'handler' IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -149,7 +168,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/reordered@14::'handler' + IL_0001: ldfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/reordered@15::'handler' IL_0006: ldarg.2 IL_0007: ldarg.1 IL_0008: call !!0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::InvokeFast(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>, @@ -161,7 +180,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname contra@25 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname contra@26 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -172,7 +191,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/Holder assembly/contra@25::h + IL_0002: stfld class assembly/Holder assembly/contra@26::h IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -183,7 +202,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/Holder assembly/contra@25::h + IL_0001: ldfld class assembly/Holder assembly/contra@26::h IL_0006: ldarg.1 IL_0007: callvirt instance int32 assembly/Holder::TakesObj(object) IL_000c: ret @@ -191,13 +210,33 @@ } + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname valueTypeExtension@38 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.3 + IL_0001: ldarg.0 + IL_0002: ldarg.1 + IL_0003: call !!0 assembly/Extensions::Echo(!!0, + int32, + int32) + IL_0008: ret + } + + } + .method public static class [runtime]System.Action`2 firstClass(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/firstClass@6::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>) - IL_0006: ldftn instance void assembly/firstClass@6::Invoke(int32, + IL_0001: newobj instance void assembly/firstClass@7::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>) + IL_0006: ldftn instance void assembly/firstClass@7::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -216,8 +255,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/notDirect@11::.ctor(int32) - IL_0006: ldftn instance void assembly/notDirect@11::Invoke(int32, + IL_0001: newobj instance void assembly/notDirect@12::.ctor(int32) + IL_0006: ldftn instance void assembly/notDirect@12::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -229,8 +268,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/reordered@14::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>) - IL_0006: ldftn instance void assembly/reordered@14::Invoke(int32, + IL_0001: newobj instance void assembly/reordered@15::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>) + IL_0006: ldftn instance void assembly/reordered@15::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -242,13 +281,25 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/contra@25::.ctor(class assembly/Holder) - IL_0006: ldftn instance int32 assembly/contra@25::Invoke(string) + IL_0001: newobj instance void assembly/contra@26::.ctor(class assembly/Holder) + IL_0006: ldftn instance int32 assembly/contra@26::Invoke(string) IL_000c: newobj instance void class [runtime]System.Func`2::.ctor(object, native int) IL_0011: ret } + .method public static class [runtime]System.Func`3 valueTypeExtension() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/valueTypeExtension@38::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + } .class private abstract auto ansi sealed ''.$assembly diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.Preview.il.bsl index 010d82ae420..b08109defb3 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.Preview.il.bsl @@ -59,7 +59,26 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname firstClass@6 + .class auto ansi serializable nested public Extensions + extends [runtime]System.Object + { + .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public static !!T Echo(!!T x, + int32 y, + int32 z) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname firstClass@7 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -70,7 +89,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/firstClass@6::'handler' + IL_0002: stfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/firstClass@7::'handler' IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -81,7 +100,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/firstClass@6::'handler' + IL_0001: ldfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/firstClass@7::'handler' IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: call !!0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::InvokeFast(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>, @@ -93,7 +112,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname notDirect@11 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname notDirect@12 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -107,7 +126,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname reordered@14 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname reordered@15 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -118,7 +137,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/reordered@14::'handler' + IL_0002: stfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/reordered@15::'handler' IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -129,7 +148,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/reordered@14::'handler' + IL_0001: ldfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/reordered@15::'handler' IL_0006: ldarg.2 IL_0007: ldarg.1 IL_0008: call !!0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::InvokeFast(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>, @@ -141,7 +160,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname contra@25 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname contra@26 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -152,7 +171,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/Holder assembly/contra@25::h + IL_0002: stfld class assembly/Holder assembly/contra@26::h IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -163,7 +182,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/Holder assembly/contra@25::h + IL_0001: ldfld class assembly/Holder assembly/contra@26::h IL_0006: ldarg.1 IL_0007: callvirt instance int32 assembly/Holder::TakesObj(object) IL_000c: ret @@ -171,13 +190,33 @@ } + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname valueTypeExtension@38 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.3 + IL_0001: ldarg.0 + IL_0002: ldarg.1 + IL_0003: call !!0 assembly/Extensions::Echo(!!0, + int32, + int32) + IL_0008: ret + } + + } + .method public static class [runtime]System.Action`2 firstClass(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/firstClass@6::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>) - IL_0006: ldftn instance void assembly/firstClass@6::Invoke(int32, + IL_0001: newobj instance void assembly/firstClass@7::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>) + IL_0006: ldftn instance void assembly/firstClass@7::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -196,7 +235,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/notDirect@11::Invoke(int32, + IL_0001: ldftn void assembly/notDirect@12::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -208,8 +247,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/reordered@14::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>) - IL_0006: ldftn instance void assembly/reordered@14::Invoke(int32, + IL_0001: newobj instance void assembly/reordered@15::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>) + IL_0006: ldftn instance void assembly/reordered@15::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -221,13 +260,25 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/contra@25::.ctor(class assembly/Holder) - IL_0006: ldftn instance int32 assembly/contra@25::Invoke(string) + IL_0001: newobj instance void assembly/contra@26::.ctor(class assembly/Holder) + IL_0006: ldftn instance int32 assembly/contra@26::Invoke(string) IL_000c: newobj instance void class [runtime]System.Func`2::.ctor(object, native int) IL_0011: ret } + .method public static class [runtime]System.Func`3 valueTypeExtension() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/valueTypeExtension@38::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + } .class private abstract auto ansi sealed ''.$assembly diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.il.bsl index 25621c1ba07..8506c29cad9 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.il.bsl @@ -59,7 +59,26 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname firstClass@6 + .class auto ansi serializable nested public Extensions + extends [runtime]System.Object + { + .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public static !!T Echo(!!T x, + int32 y, + int32 z) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + } + + .class auto autochar serializable sealed nested assembly beforefieldinit specialname firstClass@7 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -70,7 +89,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/firstClass@6::'handler' + IL_0002: stfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/firstClass@7::'handler' IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -81,7 +100,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/firstClass@6::'handler' + IL_0001: ldfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/firstClass@7::'handler' IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: call !!0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::InvokeFast(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>, @@ -93,7 +112,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname notDirect@11 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname notDirect@12 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -107,7 +126,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname reordered@14 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname reordered@15 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -118,7 +137,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/reordered@14::'handler' + IL_0002: stfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/reordered@15::'handler' IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -129,7 +148,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/reordered@14::'handler' + IL_0001: ldfld class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> assembly/reordered@15::'handler' IL_0006: ldarg.2 IL_0007: ldarg.1 IL_0008: call !!0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::InvokeFast(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>, @@ -141,7 +160,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname contra@25 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname contra@26 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -152,7 +171,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/Holder assembly/contra@25::h + IL_0002: stfld class assembly/Holder assembly/contra@26::h IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -163,7 +182,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/Holder assembly/contra@25::h + IL_0001: ldfld class assembly/Holder assembly/contra@26::h IL_0006: ldarg.1 IL_0007: callvirt instance int32 assembly/Holder::TakesObj(object) IL_000c: ret @@ -171,13 +190,33 @@ } + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname valueTypeExtension@38 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.3 + IL_0001: ldarg.0 + IL_0002: ldarg.1 + IL_0003: call !!0 assembly/Extensions::Echo(!!0, + int32, + int32) + IL_0008: ret + } + + } + .method public static class [runtime]System.Action`2 firstClass(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/firstClass@6::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>) - IL_0006: ldftn instance void assembly/firstClass@6::Invoke(int32, + IL_0001: newobj instance void assembly/firstClass@7::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>) + IL_0006: ldftn instance void assembly/firstClass@7::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -196,7 +235,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/notDirect@11::Invoke(int32, + IL_0001: ldftn void assembly/notDirect@12::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -208,8 +247,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/reordered@14::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>) - IL_0006: ldftn instance void assembly/reordered@14::Invoke(int32, + IL_0001: newobj instance void assembly/reordered@15::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>) + IL_0006: ldftn instance void assembly/reordered@15::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -221,13 +260,25 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/contra@25::.ctor(class assembly/Holder) - IL_0006: ldftn instance int32 assembly/contra@25::Invoke(string) + IL_0001: newobj instance void assembly/contra@26::.ctor(class assembly/Holder) + IL_0006: ldftn instance int32 assembly/contra@26::Invoke(string) IL_000c: newobj instance void class [runtime]System.Func`2::.ctor(object, native int) IL_0011: ret } + .method public static class [runtime]System.Func`3 valueTypeExtension() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn int32 assembly/valueTypeExtension@38::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, + native int) + IL_000c: ret + } + } .class private abstract auto ansi sealed ''.$assembly diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs index 84785eda906..c88a9ada21f 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs @@ -7,9 +7,9 @@ type S = [] member _.Add (x: int) (y: int) : int = x + y -// The target is an instance method on a value type. A delegate's Target is an object, so a direct delegate -// would have to box the receiver; until that is implemented a closure is kept. (See DelegateInstanceMethod -// for the reference-type case, which is emitted directly.) +// The target is an instance method on a value type. A delegate's Target is an 'object', so the receiver is +// boxed (a copy) at the construction site and the runtime binds the unboxing stub; this matches the closure +// form, which also captures the struct by value. (See DelegateInstanceMethod for the reference-type case.) // 50. non-eta struct (value-type) receiver let structInstanceNonEta (s: S) = Func(s.Add) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOff.Preview.il.bsl index abc2a402a57..29c8d30ba49 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOff.Preview.il.bsl @@ -199,41 +199,6 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceNonEta@14 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .field public valuetype assembly/S s - .method public specialname rtspecialname instance void .ctor(valuetype assembly/S s) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: stfld valuetype assembly/S assembly/structInstanceNonEta@14::s - IL_0007: ldarg.0 - IL_0008: call instance void [runtime]System.Object::.ctor() - IL_000d: ret - } - - .method assembly hidebysig instance int32 Invoke(int32 arg1, int32 arg2) cil managed - { - - .maxstack 7 - .locals init (valuetype assembly/S V_0) - IL_0000: ldarg.0 - IL_0001: ldfld valuetype assembly/S assembly/structInstanceNonEta@14::s - IL_0006: stloc.0 - IL_0007: ldloca.s V_0 - IL_0009: ldarg.1 - IL_000a: ldarg.2 - IL_000b: call instance int32 assembly/S::Add(int32, - int32) - IL_0010: ret - } - - } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceEta@17 extends [runtime]System.Object { @@ -274,9 +239,9 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/structInstanceNonEta@14::.ctor(valuetype assembly/S) - IL_0006: ldftn instance int32 assembly/structInstanceNonEta@14::Invoke(int32, - int32) + IL_0001: box assembly/S + IL_0006: ldftn instance int32 assembly/S::Add(int32, + int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) IL_0011: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOn.Preview.il.bsl index 28e50465f0e..05cfb2da6b4 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOn.Preview.il.bsl @@ -172,78 +172,14 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceNonEta@14 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .field public valuetype assembly/S s - .method public specialname rtspecialname instance void .ctor(valuetype assembly/S s) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: stfld valuetype assembly/S assembly/structInstanceNonEta@14::s - IL_0007: ldarg.0 - IL_0008: call instance void [runtime]System.Object::.ctor() - IL_000d: ret - } - - .method assembly hidebysig instance int32 Invoke(int32 arg1, int32 arg2) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldflda valuetype assembly/S assembly/structInstanceNonEta@14::s - IL_0006: ldarg.1 - IL_0007: ldarg.2 - IL_0008: call instance int32 assembly/S::Add(int32, - int32) - IL_000d: ret - } - - } - - .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceEta@17 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .field public valuetype assembly/S s - .method public specialname rtspecialname instance void .ctor(valuetype assembly/S s) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: stfld valuetype assembly/S assembly/structInstanceEta@17::s - IL_0007: ldarg.0 - IL_0008: call instance void [runtime]System.Object::.ctor() - IL_000d: ret - } - - .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldflda valuetype assembly/S assembly/structInstanceEta@17::s - IL_0006: ldarg.1 - IL_0007: ldarg.2 - IL_0008: call instance int32 assembly/S::Add(int32, - int32) - IL_000d: ret - } - - } - .method public static class [runtime]System.Func`3 structInstanceNonEta(valuetype assembly/S s) cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/structInstanceNonEta@14::.ctor(valuetype assembly/S) - IL_0006: ldftn instance int32 assembly/structInstanceNonEta@14::Invoke(int32, - int32) + IL_0001: box assembly/S + IL_0006: ldftn instance int32 assembly/S::Add(int32, + int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) IL_0011: ret @@ -254,9 +190,9 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/structInstanceEta@17::.ctor(valuetype assembly/S) - IL_0006: ldftn instance int32 assembly/structInstanceEta@17::Invoke(int32, - int32) + IL_0001: box assembly/S + IL_0006: ldftn instance int32 assembly/S::Add(int32, + int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) IL_0011: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs index 1033d24c75a..cec3a4604db 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs @@ -464,25 +464,35 @@ let main _ = |> compileExeAndRun |> shouldSucceed -// Cases 50-51: a value-type receiver would need boxing (a delegate Target is object); not implemented, so -// it stays a closure and still dispatches correctly. +// Cases 50-51: a value-type receiver is boxed (a copy) and stored as the delegate's Target; the runtime binds +// the unboxing stub, so the delegate points at the real struct method and dispatches correctly, with the boxed +// copy carrying the receiver's value. The receiver must be effect-free, so it comes from a (non-mutable) +// parameter here. (By-value capture cannot be observed via external mutation on a *direct* struct delegate: a +// mutable receiver - or the defensive copy it forces - reads a mutable value, which counts as an effect, so it +// is kept as a closure instead. The boxing itself guarantees the by-value copy.) [] -let ``Struct value-type receiver stays a closure (preview)`` () = +let ``Struct value-type receiver targets the real method (preview)`` () = FSharp """ -module StructClosure +module StructDirect open System [] type S = - member _.Add (x: int) (y: int) : int = x + y + val V : int + new (v: int) = { V = v } + [] + member this.AddV (x: int) (y: int) : int = this.V + x + y + +let makeAdder (s: S) = Func(s.AddV) [] let main _ = - let s = S() - let d = Func(s.Add) - if d.Invoke(2, 3) <> 5 then failwith "wrong result" - if d.Method.Name <> "Invoke" then failwithf "expected closure 'Invoke' but got '%s'" d.Method.Name + let d = makeAdder (S(100)) + if d.Invoke(2, 3) <> 105 then failwithf "wrong result: %d" (d.Invoke(2, 3)) + if d.Method.Name <> "AddV" then failwithf "expected direct 'AddV' but got '%s'" d.Method.Name + if isNull d.Target then failwith "Target should be the boxed receiver, not null" + if not (d.Target :? S) then failwith "Target should be a boxed S" 0 """ |> withLangVersionPreview @@ -503,7 +513,7 @@ open System.Runtime.CompilerServices type Holder() = class end [] -type HolderExtensions = +type Extensions = [] static member Combine (h: Holder, x: int, y: int) : int = x + y From 1f6ea380fc3fca456137ae1a1512f04bfd5cb0f8 Mon Sep 17 00:00:00 2001 From: kerams Date: Mon, 29 Jun 2026 23:09:24 +0200 Subject: [PATCH 12/16] Reformat --- src/Compiler/CodeGen/IlxGen.Delegates.fs | 9 +-------- src/Compiler/CodeGen/IlxGen.fs | 5 ++++- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/Compiler/CodeGen/IlxGen.Delegates.fs b/src/Compiler/CodeGen/IlxGen.Delegates.fs index 1a3204274c7..f215246d107 100644 --- a/src/Compiler/CodeGen/IlxGen.Delegates.fs +++ b/src/Compiler/CodeGen/IlxGen.Delegates.fs @@ -220,14 +220,7 @@ let fsharpValDirectlyBindable g (invokeParams: Val list) (leadingArgs: Expr list /// value-type instance receiver is boxed at the construction site (see the emit), matching the closure's /// by-value capture. The instance-receiver flag is derived here from ilMethRef and the base/constrained-call /// flags from valUseFlag. -let ilMethodDirectlyBindable - g - (invokeParams: Val list) - (leadingArgs: Expr list) - (ilMethRef: ILMethodRef) - (valUseFlag: ValUseFlag) - isCtor - = +let ilMethodDirectlyBindable g (invokeParams: Val list) (leadingArgs: Expr list) (ilMethRef: ILMethodRef) (valUseFlag: ValUseFlag) isCtor = let takesInstanceArg = ilMethRef.CallingConv.IsInstance not isCtor diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index a922f368f0b..48a30540b74 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -7603,7 +7603,10 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, None else let ilEnclArgTys, ilMethArgTys = List.splitAt numEnclILTypeArgs ilTyArgs - let targetMspec = mkILMethSpec (mspec.MethodRef, mspec.DeclaringType.Boxity, ilEnclArgTys, ilMethArgTys) + + let targetMspec = + mkILMethSpec (mspec.MethodRef, mspec.DeclaringType.Boxity, ilEnclArgTys, ilMethArgTys) + let numBoundLeadingFormals = if takesInstanceArg then 0 else leadingArgs.Length if takesInstanceArg <> targetMspec.MethodRef.CallingConv.IsInstance then From fa4c43bfbc671fa387e1ae5a9168985881b79296 Mon Sep 17 00:00:00 2001 From: kerams Date: Tue, 30 Jun 2026 01:34:13 +0200 Subject: [PATCH 13/16] ASP.NET smoke test --- ...egativeCases.fs.OptimizeOff.Preview.il.bsl | 90 ++++++------ ...elegateNegativeCases.fs.OptimizeOff.il.bsl | 90 ++++++------ ...NegativeCases.fs.OptimizeOn.Preview.il.bsl | 90 ++++++------ ...DelegateNegativeCases.fs.OptimizeOn.il.bsl | 90 ++++++------ ...NonInlinable.fs.OptimizeOff.Preview.il.bsl | 108 +++++++-------- ...DelegateNonInlinable.fs.OptimizeOff.il.bsl | 130 +++++++++--------- .../DelegateNonInlinable.fs.OptimizeOn.il.bsl | 130 +++++++++--------- ...teUnitReturn.fs.OptimizeOff.Preview.il.bsl | 28 ++-- .../DelegateUnitReturn.fs.OptimizeOff.il.bsl | 30 ++-- .../DelegateUnitReturn.fs.OptimizeOn.il.bsl | 30 ++-- .../DirectDelegates/DirectDelegates.fs | 49 +++++++ 11 files changed, 457 insertions(+), 408 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.Preview.il.bsl index d5cdc33872d..4320a5bf0eb 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.Preview.il.bsl @@ -33,51 +33,6 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class auto ansi serializable nested public Holder - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) - .method public specialname rtspecialname instance void .ctor() cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: callvirt instance void [runtime]System.Object::.ctor() - IL_0006: ldarg.0 - IL_0007: pop - IL_0008: ret - } - - .method public hidebysig instance int32 TakesObj(object x) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) - - .maxstack 8 - IL_0000: ldc.i4.1 - IL_0001: ret - } - - } - - .class auto ansi serializable nested public Extensions - extends [runtime]System.Object - { - .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) - .method public static !!T Echo(!!T x, - int32 y, - int32 z) cil managed - { - .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ret - } - - } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname firstClass@7 extends [runtime]System.Object { @@ -180,6 +135,32 @@ } + .class auto ansi serializable nested public Holder + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public specialname rtspecialname instance void .ctor() cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ret + } + + .method public hidebysig instance int32 TakesObj(object x) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.1 + IL_0001: ret + } + + } + .class auto autochar serializable sealed nested assembly beforefieldinit specialname contra@26 extends [runtime]System.Object { @@ -210,6 +191,25 @@ } + .class auto ansi serializable nested public Extensions + extends [runtime]System.Object + { + .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public static !!T Echo(!!T x, + int32 y, + int32 z) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + } + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname valueTypeExtension@38 extends [runtime]System.Object { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.il.bsl index 75511746827..e2543d21f33 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.il.bsl @@ -33,51 +33,6 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class auto ansi serializable nested public Holder - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) - .method public specialname rtspecialname instance void .ctor() cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: callvirt instance void [runtime]System.Object::.ctor() - IL_0006: ldarg.0 - IL_0007: pop - IL_0008: ret - } - - .method public hidebysig instance int32 TakesObj(object x) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) - - .maxstack 8 - IL_0000: ldc.i4.1 - IL_0001: ret - } - - } - - .class auto ansi serializable nested public Extensions - extends [runtime]System.Object - { - .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) - .method public static !!T Echo(!!T x, - int32 y, - int32 z) cil managed - { - .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ret - } - - } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname firstClass@7 extends [runtime]System.Object { @@ -180,6 +135,32 @@ } + .class auto ansi serializable nested public Holder + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public specialname rtspecialname instance void .ctor() cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ret + } + + .method public hidebysig instance int32 TakesObj(object x) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.1 + IL_0001: ret + } + + } + .class auto autochar serializable sealed nested assembly beforefieldinit specialname contra@26 extends [runtime]System.Object { @@ -210,6 +191,25 @@ } + .class auto ansi serializable nested public Extensions + extends [runtime]System.Object + { + .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public static !!T Echo(!!T x, + int32 y, + int32 z) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + } + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname valueTypeExtension@38 extends [runtime]System.Object { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.Preview.il.bsl index b08109defb3..dbeaeb2ede2 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.Preview.il.bsl @@ -33,51 +33,6 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class auto ansi serializable nested public Holder - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) - .method public specialname rtspecialname instance void .ctor() cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: callvirt instance void [runtime]System.Object::.ctor() - IL_0006: ldarg.0 - IL_0007: pop - IL_0008: ret - } - - .method public hidebysig instance int32 TakesObj(object x) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) - - .maxstack 8 - IL_0000: ldc.i4.1 - IL_0001: ret - } - - } - - .class auto ansi serializable nested public Extensions - extends [runtime]System.Object - { - .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) - .method public static !!T Echo(!!T x, - int32 y, - int32 z) cil managed - { - .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ret - } - - } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname firstClass@7 extends [runtime]System.Object { @@ -160,6 +115,32 @@ } + .class auto ansi serializable nested public Holder + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public specialname rtspecialname instance void .ctor() cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ret + } + + .method public hidebysig instance int32 TakesObj(object x) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.1 + IL_0001: ret + } + + } + .class auto autochar serializable sealed nested assembly beforefieldinit specialname contra@26 extends [runtime]System.Object { @@ -190,6 +171,25 @@ } + .class auto ansi serializable nested public Extensions + extends [runtime]System.Object + { + .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public static !!T Echo(!!T x, + int32 y, + int32 z) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + } + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname valueTypeExtension@38 extends [runtime]System.Object { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.il.bsl index 8506c29cad9..21e52bb70f7 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.il.bsl @@ -33,51 +33,6 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class auto ansi serializable nested public Holder - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) - .method public specialname rtspecialname instance void .ctor() cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: callvirt instance void [runtime]System.Object::.ctor() - IL_0006: ldarg.0 - IL_0007: pop - IL_0008: ret - } - - .method public hidebysig instance int32 TakesObj(object x) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) - - .maxstack 8 - IL_0000: ldc.i4.1 - IL_0001: ret - } - - } - - .class auto ansi serializable nested public Extensions - extends [runtime]System.Object - { - .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) - .method public static !!T Echo(!!T x, - int32 y, - int32 z) cil managed - { - .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ret - } - - } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname firstClass@7 extends [runtime]System.Object { @@ -160,6 +115,32 @@ } + .class auto ansi serializable nested public Holder + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public specialname rtspecialname instance void .ctor() cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ret + } + + .method public hidebysig instance int32 TakesObj(object x) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldc.i4.1 + IL_0001: ret + } + + } + .class auto autochar serializable sealed nested assembly beforefieldinit specialname contra@26 extends [runtime]System.Object { @@ -190,6 +171,25 @@ } + .class auto ansi serializable nested public Extensions + extends [runtime]System.Object + { + .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public static !!T Echo(!!T x, + int32 y, + int32 z) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + } + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname valueTypeExtension@38 extends [runtime]System.Object { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.Preview.il.bsl index 15f41614e90..8117927a131 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.Preview.il.bsl @@ -33,6 +33,42 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaCurried@15 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::accCurried(int32, + int32) + IL_0007: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaTupled@18 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly::accTupled(int32, + int32) + IL_0007: ret + } + + } + .class auto ansi serializable nested public S extends [runtime]System.Object { @@ -52,6 +88,24 @@ } + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticEta@28 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call int32 assembly/S::AccS(int32, + int32) + IL_0007: ret + } + + } + .class auto ansi serializable nested public C extends [runtime]System.Object { @@ -98,60 +152,6 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaCurried@15 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 a, - int32 b) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call int32 assembly::accCurried(int32, - int32) - IL_0007: ret - } - - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaTupled@18 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 a, - int32 b) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call int32 assembly::accTupled(int32, - int32) - IL_0007: ret - } - - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticEta@28 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 a, - int32 b) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call int32 assembly/S::AccS(int32, - int32) - IL_0007: ret - } - - } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceEta@41 extends [runtime]System.Object { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.il.bsl index dea6f5753aa..7a19b3b9516 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.il.bsl @@ -33,71 +33,6 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class auto ansi serializable nested public S - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) - .method public static int32 AccS(int32 x, - int32 y) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: add - IL_0003: ret - } - - } - - .class auto ansi serializable nested public C - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) - .field assembly int32 k - .method public specialname rtspecialname instance void .ctor(int32 k) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: callvirt instance void [runtime]System.Object::.ctor() - IL_0006: ldarg.0 - IL_0007: pop - IL_0008: ldarg.0 - IL_0009: ldarg.1 - IL_000a: stfld int32 assembly/C::k - IL_000f: ret - } - - .method public hidebysig instance int32 AccC(int32 x, int32 y) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.1 - IL_0001: ldarg.2 - IL_0002: add - IL_0003: ldarg.0 - IL_0004: ldfld int32 assembly/C::k - IL_0009: add - IL_000a: ret - } - - .method public hidebysig instance !!T GPick(!!T x, !!T y) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.1 - IL_0001: ret - } - - } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niNonEta@12 extends [runtime]System.Object { @@ -152,6 +87,25 @@ } + .class auto ansi serializable nested public S + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public static int32 AccS(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + } + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticNonEta@25 extends [runtime]System.Object { @@ -188,6 +142,52 @@ } + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .field assembly int32 k + .method public specialname rtspecialname instance void .ctor(int32 k) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ldarg.0 + IL_0009: ldarg.1 + IL_000a: stfld int32 assembly/C::k + IL_000f: ret + } + + .method public hidebysig instance int32 AccC(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: add + IL_0003: ldarg.0 + IL_0004: ldfld int32 assembly/C::k + IL_0009: add + IL_000a: ret + } + + .method public hidebysig instance !!T GPick(!!T x, !!T y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ret + } + + } + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceNonEta@38 extends [runtime]System.Object { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.il.bsl index 3f3f5dc01ed..e8bf92f5780 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.il.bsl @@ -33,71 +33,6 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class auto ansi serializable nested public S - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) - .method public static int32 AccS(int32 x, - int32 y) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: add - IL_0003: ret - } - - } - - .class auto ansi serializable nested public C - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) - .field assembly int32 k - .method public specialname rtspecialname instance void .ctor(int32 k) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: callvirt instance void [runtime]System.Object::.ctor() - IL_0006: ldarg.0 - IL_0007: pop - IL_0008: ldarg.0 - IL_0009: ldarg.1 - IL_000a: stfld int32 assembly/C::k - IL_000f: ret - } - - .method public hidebysig instance int32 AccC(int32 x, int32 y) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.1 - IL_0001: ldarg.2 - IL_0002: add - IL_0003: ldarg.0 - IL_0004: ldfld int32 assembly/C::k - IL_0009: add - IL_000a: ret - } - - .method public hidebysig instance !!T GPick(!!T x, !!T y) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.1 - IL_0001: ret - } - - } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niNonEta@12 extends [runtime]System.Object { @@ -152,6 +87,25 @@ } + .class auto ansi serializable nested public S + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public static int32 AccS(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + } + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticNonEta@25 extends [runtime]System.Object { @@ -188,6 +142,52 @@ } + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .field assembly int32 k + .method public specialname rtspecialname instance void .ctor(int32 k) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ldarg.0 + IL_0009: ldarg.1 + IL_000a: stfld int32 assembly/C::k + IL_000f: ret + } + + .method public hidebysig instance int32 AccC(int32 x, int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.2 + IL_0002: add + IL_0003: ldarg.0 + IL_0004: ldfld int32 assembly/C::k + IL_0009: add + IL_000a: ret + } + + .method public hidebysig instance !!T GPick(!!T x, !!T y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ret + } + + } + .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceNonEta@38 extends [runtime]System.Object { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOff.Preview.il.bsl index 97b1e27f918..7f4edf52dfd 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOff.Preview.il.bsl @@ -33,36 +33,36 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class auto ansi serializable nested public C + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidEta@13 extends [runtime]System.Object { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) - .method public static !!T Echo(!!T x) cil managed + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke(int32 a, + int32 b) cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .maxstack 8 IL_0000: ldarg.0 - IL_0001: ret + IL_0001: ldarg.1 + IL_0002: call void assembly::returnsUnit(int32, + int32) + IL_0007: nop + IL_0008: ret } } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidEta@13 + .class auto ansi serializable nested public C extends [runtime]System.Object { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static void Invoke(int32 a, - int32 b) cil managed + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public static !!T Echo(!!T x) cil managed { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call void assembly::returnsUnit(int32, - int32) - IL_0007: nop - IL_0008: ret + IL_0001: ret } } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOff.il.bsl index 72f76894471..5fe407f3027 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOff.il.bsl @@ -33,21 +33,6 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class auto ansi serializable nested public C - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) - .method public static !!T Echo(!!T x) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ret - } - - } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidNonEta@10 extends [runtime]System.Object { @@ -86,6 +71,21 @@ } + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public static !!T Echo(!!T x) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + } + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnNonEta@24 extends [runtime]System.Object { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOn.il.bsl index 72f76894471..5fe407f3027 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOn.il.bsl @@ -33,21 +33,6 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class auto ansi serializable nested public C - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) - .method public static !!T Echo(!!T x) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ret - } - - } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidNonEta@10 extends [runtime]System.Object { @@ -86,6 +71,21 @@ } + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .method public static !!T Echo(!!T x) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ret + } + + } + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnNonEta@24 extends [runtime]System.Object { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs index cec3a4604db..5417349e1f4 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs @@ -4,6 +4,7 @@ open System.IO open Xunit open FSharp.Test open FSharp.Test.Compiler +open FSharp.Test.ProjectGeneration let private coreOptions compilation = compilation @@ -658,3 +659,51 @@ let main _ = |> withOptions [ "--optimize+" ] |> compileExeAndRun |> shouldSucceed + +#if NETCOREAPP +[] +let ``Minimal API binds a direct delegate handler by parameter name (preview)`` () = + let aspNetFrameworkReferences = + ReferenceHelpers.getFrameworkReference { Name = "Microsoft.AspNetCore.App"; Version = None } + + Fsx (aspNetFrameworkReferences + """ +module X = + open System + open System.Net + open System.Net.Http + open System.Net.Sockets + open Microsoft.AspNetCore.Builder + open Microsoft.AspNetCore.Http + + [] + let add (x: int) (y: int) : int = x + y + + let run () = + let port = + let listener = new TcpListener(IPAddress.Loopback, 0) + listener.Start() + let p = (listener.LocalEndpoint :?> IPEndPoint).Port + listener.Stop() + p + + let url = sprintf "http://127.0.0.1:%d" port + let app = WebApplication.CreateBuilder().Build() + + // Route parameters {x}/{y} bind to the handler's parameters by name, which requires delegate.Method to be the + // real 'add' (a direct delegate), not a synthesized closure 'Invoke'. + app.MapGet("/add/{x}/{y}", Func(fun z w -> add z w)) |> ignore + app.Urls.Add url + app.StartAsync().GetAwaiter().GetResult() + + try + let client = new HttpClient() + let body = client.GetStringAsync(url + "/add/2/3").GetAwaiter().GetResult() + if body.Trim() <> "5" then failwithf "minimal API returned '%s', expected '5'" body + finally + app.StopAsync().GetAwaiter().GetResult() + +X.run () """) + |> withLangVersionPreview + |> runFsi + |> shouldSucceed +#endif From 0e5d1ce8846d9648bb4051d1733f9d9d73a09834 Mon Sep 17 00:00:00 2001 From: kerams Date: Thu, 2 Jul 2026 18:52:31 +0200 Subject: [PATCH 14/16] Fix inline race --- src/Compiler/CodeGen/IlxGen.fs | 93 ++-- src/Compiler/FSharp.Compiler.Service.fsproj | 2 +- .../DelegateForwarding.fs} | 207 +++++--- src/Compiler/Optimize/Optimizer.fs | 53 +- .../DirectDelegates/DelegateCustomType.fs | 7 +- ...teCustomType.fs.OptimizeOff.Preview.il.bsl | 25 +- .../DelegateCustomType.fs.OptimizeOff.il.bsl | 43 +- ...ateCustomType.fs.OptimizeOn.Preview.il.bsl | 7 +- .../DelegateCustomType.fs.OptimizeOn.il.bsl | 111 ++-- .../DelegateExtensionMethod.fs | 2 +- ...ensionMethod.fs.OptimizeOff.Preview.il.bsl | 1 - ...egateExtensionMethod.fs.OptimizeOff.il.bsl | 1 - ...tensionMethod.fs.OptimizeOn.Preview.il.bsl | 1 - ...legateExtensionMethod.fs.OptimizeOn.il.bsl | 38 +- ...nstanceMethod.fs.OptimizeOn.Preview.il.bsl | 40 +- ...cStaticMethod.fs.OptimizeOn.Preview.il.bsl | 54 +- .../DirectDelegates/DelegateILMethod.fs | 5 +- ...gateILMethod.fs.OptimizeOff.Preview.il.bsl | 14 +- .../DelegateILMethod.fs.OptimizeOff.il.bsl | 14 +- .../DelegateILMethod.fs.OptimizeOn.il.bsl | 14 +- ...nstanceMethod.fs.OptimizeOn.Preview.il.bsl | 60 +-- ...KnownFunction.fs.OptimizeOn.Preview.il.bsl | 54 +- .../DirectDelegates/DelegateNegativeCases.fs | 8 +- ...egativeCases.fs.OptimizeOff.Preview.il.bsl | 57 ++- ...elegateNegativeCases.fs.OptimizeOff.il.bsl | 57 ++- ...NegativeCases.fs.OptimizeOn.Preview.il.bsl | 92 ++-- ...DelegateNegativeCases.fs.OptimizeOn.il.bsl | 92 ++-- .../DirectDelegates/DelegateNonInlinable.fs | 47 -- ...NonInlinable.fs.OptimizeOff.Preview.il.bsl | 374 -------------- ...DelegateNonInlinable.fs.OptimizeOff.il.bsl | 477 ------------------ ...eNonInlinable.fs.OptimizeOn.Preview.il.bsl | 253 ---------- .../DelegateNonInlinable.fs.OptimizeOn.il.bsl | 475 ----------------- ...eStaticMethod.fs.OptimizeOn.Preview.il.bsl | 54 +- .../DirectDelegates/DelegateStructTarget.fs | 1 - ...StructTarget.fs.OptimizeOff.Preview.il.bsl | 11 +- ...DelegateStructTarget.fs.OptimizeOff.il.bsl | 21 +- ...eStructTarget.fs.OptimizeOn.Preview.il.bsl | 1 - .../DelegateStructTarget.fs.OptimizeOn.il.bsl | 73 +-- .../DirectDelegates/DelegateUnitArg.fs | 2 - ...egateUnitArg.fs.OptimizeOff.Preview.il.bsl | 16 +- .../DelegateUnitArg.fs.OptimizeOff.il.bsl | 30 +- ...legateUnitArg.fs.OptimizeOn.Preview.il.bsl | 2 - .../DelegateUnitArg.fs.OptimizeOn.il.bsl | 82 +-- .../DirectDelegates/DelegateUnitReturn.fs | 2 - ...teUnitReturn.fs.OptimizeOff.Preview.il.bsl | 10 +- .../DelegateUnitReturn.fs.OptimizeOff.il.bsl | 20 +- ...ateUnitReturn.fs.OptimizeOn.Preview.il.bsl | 2 - .../DelegateUnitReturn.fs.OptimizeOn.il.bsl | 40 +- .../DirectDelegates/DirectDelegates.fs | 81 +-- 49 files changed, 748 insertions(+), 2478 deletions(-) rename src/Compiler/{CodeGen/IlxGen.Delegates.fs => Optimize/DelegateForwarding.fs} (56%) delete mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs delete mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.Preview.il.bsl delete mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.il.bsl delete mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.Preview.il.bsl delete mode 100644 tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.il.bsl diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index be833b996bd..db35a784bdf 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -25,6 +25,7 @@ open FSharp.Compiler.AbstractIL.ILX open FSharp.Compiler.AbstractIL.ILX.Types open FSharp.Compiler.AttributeChecking open FSharp.Compiler.CompilerGlobalState +open FSharp.Compiler.DelegateForwarding open FSharp.Compiler.DiagnosticsLogger open FSharp.Compiler.Features open FSharp.Compiler.Infos @@ -7558,29 +7559,11 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, with _ -> false - // Work out the free type variables for the morphing thunk - let takenNames = List.map nameOfVal tmvs - - let cloFreeTyvars, cloWitnessInfos, cloFreeVars, ilDelegeeTypeRef, ilCloAllFreeVars, eenvinner = - GetIlxClosureFreeVars cenv m [] ILBoxity.AsObject eenvouter takenNames expr - - let ilDelegeeGenericParams = GenGenericParams cenv eenvinner cloFreeTyvars - let ilDelegeeGenericActualsInner = mkILFormalGenericArgs 0 ilDelegeeGenericParams - - // When creating a delegate that does not capture any variables, we can instead create a static closure and directly reference the method. - let useStaticClosure = cloFreeVars.IsEmpty - - // Create a new closure class with a single "delegee" method that implements the delegate. - let delegeeMethName = "Invoke" - let ilDelegeeTyInner = mkILBoxedTy ilDelegeeTypeRef ilDelegeeGenericActualsInner - - let envForDelegeeUnderTypars = AddTyparsToEnv methTyparsOfOverridingMethod eenvinner - - let numthis = if useStaticClosure then 0 else 1 - let invokeParamInfos = List.replicate (List.concat slotsig.FormalParams).Length ValReprInfo.unnamedTopArg1 + let numDelegeeParams = invokeParamInfos.Length + let etaUnitDelegate = match tmvs, invokeParamInfos with | [ _ ], [] -> true @@ -7588,11 +7571,6 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, let tmvs, body = BindUnitVars g (tmvs, invokeParamInfos, body) - // The slot sig contains a formal instantiation. When creating delegates we're only - // interested in the actual instantiation since we don't have to emit a method impl. - let ilDelegeeParams, ilDelegeeRet = - GenActualSlotsig m cenv envForDelegeeUnderTypars slotsig methTyparsOfOverridingMethod tmvs - // Direct delegate construction: when the delegate body is a saturated, transparent forwarding call to a // known static method, module-level function, or instance method, point the delegate straight at that // method instead of generating an intermediate closure class. Anything that does not match exactly @@ -7611,7 +7589,7 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, // optimized builds, where debuggability is not a concern and the forwarding call survives to here. None else - match classifyForwardingTarget g tmvs body with + match classifyForwardingTarget (Optimizer.ExprHasEffect g) g tmvs body with | DirectDelegateForwardingTargetCandidate.FSharpVal(vref, valUseFlags, tyargs, leadingArgs) -> match StorageForValRef m vref eenvouter with | Method(valReprInfo, vrefM, mspec, _, _, ctps, _, _, _, _, _, _) -> @@ -7620,10 +7598,8 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, let hasWitnesses = ComputeGenerateWitnesses g eenvouter && not witnessInfos.IsEmpty - if fsharpValDirectlyBindable g tmvs leadingArgs vrefM valUseFlags hasWitnesses then - let _, virtualCall, _, _, _, takesInstanceArg, _, _ = - GetMemberCallInfo g (vrefM, valUseFlags) - + match fsharpValDirectlyBindable (Optimizer.ExprHasEffect g) g tmvs leadingArgs vrefM valUseFlags hasWitnesses with + | ValueSome(virtualCall, takesInstanceArg) -> let ilTyArgs = GenTypeArgs cenv m eenvouter.tyenv tyargs let numEnclILTypeArgs = @@ -7644,14 +7620,28 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, if takesInstanceArg <> targetMspec.MethodRef.CallingConv.IsInstance then None - elif - signatureMatches numBoundLeadingFormals ilDelegeeParams ilDelegeeRet ilEnclArgTys ilMethArgTys targetMspec - then - Some(targetMspec, receiverInfo leadingArgs virtualCall) else - None - else - None + let ilDelegeeRetTy = + let envUnderTypars = AddTyparsToEnv methTyparsOfOverridingMethod eenvouter + + let _, ilDelegeeRet = + GenActualSlotsig m cenv envUnderTypars slotsig methTyparsOfOverridingMethod tmvs + + ilDelegeeRet.Type + + if + signatureMatches + numBoundLeadingFormals + numDelegeeParams + ilDelegeeRetTy + ilEnclArgTys + ilMethArgTys + targetMspec + then + Some(targetMspec, receiverInfo leadingArgs virtualCall) + else + None + | ValueNone -> None | _ -> None | DirectDelegateForwardingTargetCandidate.ILMethod(isVirtual, @@ -7662,7 +7652,7 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, enclTypeInst, methInst, leadingArgs) -> - if ilMethodDirectlyBindable g tmvs leadingArgs ilMethRef valUseFlag isCtor then + if ilMethodDirectlyBindable (Optimizer.ExprHasEffect g) g tmvs leadingArgs ilMethRef valUseFlag isCtor then let ilEnclArgTys = GenTypeArgs cenv m eenvouter.tyenv enclTypeInst let ilMethArgTys = GenTypeArgs cenv m eenvouter.tyenv methInst let boxity = if isStruct then AsValue else AsObject @@ -7681,7 +7671,7 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, // primitives that always match. The forwarding match already pins the arity, and the // type checker has verified the call is well-typed, so element compatibility holds by // construction; an arity check is the sound guard (matching the generic case). - if targetMspec.FormalArgTypes.Length - numBoundLeadingFormals = ilDelegeeParams.Length then + if targetMspec.FormalArgTypes.Length - numBoundLeadingFormals = numDelegeeParams then Some(targetMspec, receiverInfo leadingArgs isVirtual) else None @@ -7724,6 +7714,31 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, GenSequel cenv eenvouter.cloc cgbuf sequel | None -> + let takenNames = List.map nameOfVal tmvs + + // Work out the free type variables for the morphing thunk + let cloFreeTyvars, cloWitnessInfos, cloFreeVars, ilDelegeeTypeRef, ilCloAllFreeVars, eenvinner = + GetIlxClosureFreeVars cenv m [] ILBoxity.AsObject eenvouter takenNames expr + + let ilDelegeeGenericParams = GenGenericParams cenv eenvinner cloFreeTyvars + let ilDelegeeGenericActualsInner = mkILFormalGenericArgs 0 ilDelegeeGenericParams + + // When creating a delegate that does not capture any variables, we can instead create a static closure and directly reference the method. + let useStaticClosure = cloFreeVars.IsEmpty + + // Create a new closure class with a single "delegee" method that implements the delegate. + let delegeeMethName = "Invoke" + let ilDelegeeTyInner = mkILBoxedTy ilDelegeeTypeRef ilDelegeeGenericActualsInner + + let envForDelegeeUnderTypars = AddTyparsToEnv methTyparsOfOverridingMethod eenvinner + + let numthis = if useStaticClosure then 0 else 1 + + // The slot sig contains a formal instantiation. When creating delegates we're only + // interested in the actual instantiation since we don't have to emit a method impl. + let ilDelegeeParams, ilDelegeeRet = + GenActualSlotsig m cenv envForDelegeeUnderTypars slotsig methTyparsOfOverridingMethod tmvs + let envForDelegeeMeth = AddStorageForLocalVals g (List.mapi (fun i v -> (v, Arg(i + numthis))) tmvs) envForDelegeeUnderTypars diff --git a/src/Compiler/FSharp.Compiler.Service.fsproj b/src/Compiler/FSharp.Compiler.Service.fsproj index 50492504777..c29afb5c369 100644 --- a/src/Compiler/FSharp.Compiler.Service.fsproj +++ b/src/Compiler/FSharp.Compiler.Service.fsproj @@ -418,6 +418,7 @@ + @@ -442,7 +443,6 @@ - diff --git a/src/Compiler/CodeGen/IlxGen.Delegates.fs b/src/Compiler/Optimize/DelegateForwarding.fs similarity index 56% rename from src/Compiler/CodeGen/IlxGen.Delegates.fs rename to src/Compiler/Optimize/DelegateForwarding.fs index f215246d107..26ed6827151 100644 --- a/src/Compiler/CodeGen/IlxGen.Delegates.fs +++ b/src/Compiler/Optimize/DelegateForwarding.fs @@ -1,8 +1,10 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. -/// Helpers for delegate construction in the ILX generator -[] -module internal FSharp.Compiler.IlxGenDelegates +/// Recognition of delegate constructions whose Invoke body is a transparent forwarding call to a known +/// method, shared by the optimizer (which preserves the call from inlining) and the ILX generator (which +/// points the delegate directly at the target). The 'exprHasEffect' parameter is Optimizer.ExprHasEffect; +/// it is passed in because this file compiles before the optimizer. +module internal FSharp.Compiler.DelegateForwarding open Internal.Utilities.Collections @@ -40,13 +42,19 @@ let private isUnitValue e = // arity when it emits the call, so the compiled target takes the elements as separate IL parameters and is // perfectly compatible with the delegate (a tupled target is as direct-able as a curried one). Mirror that // de-tupling here so the forwarding match sees the flattened argument list: expand a tuple-construction argument -// whose size matches its arity group into the group's elements; leave anything else (including a target with no -// arity info) untouched, which conservatively falls back to a closure. -let private flattenTupledArgs (vref: ValRef) (args: Expr list) = +// whose size matches its arity group into the group's elements. +// +// The argument-group count must equal the target's arity *exactly*: fewer groups is a partial application of +// a group, and more is an over-application - e.g. 'Action(failwith "x")' eta-expands to '(failwith "x") ()' - +// where the extra trailing arguments are consumed by the target's *result*, not by the target itself, so +// there is no saturated call to point the delegate at. (This also rejects targets with no arity information, +// such as parameters and locals, which have no compiled method form.) A mismatch fails the match and +// conservatively keeps the closure. +let private tryFlattenTupledArgs (vref: ValRef) (args: Expr list) = let arities = (arityOfVal vref.Deref).AritiesOfArgs if arities.Length <> args.Length then - args + None else (arities, args) ||> List.map2 (fun arity arg -> @@ -54,35 +62,26 @@ let private flattenTupledArgs (vref: ValRef) (args: Expr list) = | Expr.Op(TOp.Tuple _, _, elems, _) when arity >= 2 && elems.Length = arity -> elems | _ -> [ arg ]) |> List.concat + |> Some -// The forwarding call may be wrapped in let-bindings the recognizer must see through, in any combination: -// - a 'let unitVar = () in …' that BindUnitVars (or the elaborator) inserts for the elided unit parameter -// of a zero-parameter Invoke (e.g. System.Action), and -// - a side-effect-free receiver binding 'let v = recv in v.M …' that a non-eta delegate over an instance -// method value (e.g. Action(c.M)) produces to evaluate the receiver once. -// Peel them repeatedly: unit bindings are dropped; a receiver binding is dropped while recording 'v -> recv' -// so the receiver, which appears in the leading args as 'v', is mapped back to 'recv'. The downstream -// bindability check confirms 'recv' may be hoisted to the construction site. -let rec private peel g expr mapReceiver = - match stripDebugPoints expr with - | Expr.Let(TBind(v, rhs, _), inner, _, _) when isUnitTy g v.Type && isUnitValue rhs -> peel g inner mapReceiver - | Expr.Let(TBind(v, recv, _), inner, _, _) when not (Optimizer.ExprHasEffect g recv) -> - let mapReceiver leadingArgs = - mapReceiver ( - leadingArgs - |> List.map (fun a -> - match stripDebugPoints a with - | Expr.Val(vref, _, _) when valRefEq g vref (mkLocalValRef v) -> recv - | _ -> a) - ) +/// Resolve a value reference through the aliases recorded while peeling wrappers off the forwarding +/// call, so the match sees the expression that actually flows into the call. +let rec private resolveAliases (aliases: ValMap) e = + let e = stripDebugPoints e - peel g inner mapReceiver - | e -> e, mapReceiver + match e with + | Expr.Val(vref, _, _) -> + match aliases.TryFind vref.Deref with + | Some e2 -> resolveAliases aliases e2 + | None -> e + | _ -> e // The trailing arguments of the call must be exactly the delegate's Invoke parameters, forwarded -// verbatim and in order. The remaining leading arguments (e.g. an instance receiver) are returned -// for the consumer to handle. -let private matchForwarding g invokeParams (args: Expr list) mapReceiver = +// verbatim and in order. The remaining leading arguments (e.g. an instance receiver) are resolved +// and returned for the consumer to check and emit. +let private matchForwarding g (aliases: ValMap) (invokeParams: Val list) (args: Expr list) = + let args = args |> List.map (resolveAliases aliases) + // Drop the elided unit argument when the Invoke takes no parameters. let args = match List.tryLast args with @@ -97,7 +96,7 @@ let private matchForwarding g invokeParams (args: Expr list) mapReceiver = if List.forall2 (fun (a: Expr) (tv: Val) -> - match stripDebugPoints a with + match a with | Expr.Val(avref, _, _) -> valRefEq g avref (mkLocalValRef tv) | _ -> false) forwardedArgs @@ -105,31 +104,78 @@ let private matchForwarding g invokeParams (args: Expr list) mapReceiver = then // A value-type receiver is passed to its instance method by address ('&recv'); recover the // underlying value so it can be boxed and stored as the delegate Target (the unboxing stub - // supplies the 'this' pointer on invocation). When the receiver is a side-effect-free let that - // 'peel' removed, this also re-exposes the let-bound variable so 'mapReceiver' can map it back. + // supplies the 'this' pointer on invocation), then resolve it in case the value was itself + // bound by a peeled binding. let leadingArgs = leadingArgs |> List.map (fun a -> - match stripDebugPoints a with - | Expr.Op(TOp.LValueOp(LAddrOf _, vref), _, _, m) -> exprForValRef m vref + match a with + | Expr.Op(TOp.LValueOp(LAddrOf _, vref), _, _, m) -> resolveAliases aliases (exprForValRef m vref) | _ -> a) - Some(mapReceiver leadingArgs) + Some leadingArgs else None else None -let classifyForwardingTarget g (invokeParams: Val list) expr = - let body, mapReceiver = peel g expr id +// The forwarding call may be wrapped in shapes the elaborator and BuildNewDelegateExpr produce before any +// optimizer normalization has run, in any combination: +// - effect-free let-bindings over the call: 'let unitVar = () in …' for the elided unit parameter of a +// zero-parameter Invoke (e.g. System.Action), and 'let v = recv in v.M …' evaluating the receiver of a +// non-eta delegate once; +// - an application of a let-wrapped or immediate lambda: the method-group coercion of a non-eta delegate +// over an instance method ('(let v = recv in fun x y -> v.M x y) p0 p1') and the partial-application +// shells of a curried member call. The optimizer beta-reduces these only while it is already making +// inlining decisions, which is too late for the recognizer run that must precede those decisions; +// - curried applications ('(f p0) p1'), which flatten to a single application. +// Peel them by *aliasing*: each effect-free binding (from a let or a beta-reduced lambda parameter) maps +// the bound value to the expression flowing into it, to be resolved when the arguments are matched. +// Anything not covered (an effectful binding or argument, an exotic function position) is left in place +// and fails the match, conservatively keeping the closure. The downstream bindability checks run on the +// resolved (leading) arguments, so a receiver reached through an alias is still checked before being +// hoisted. +let rec private stripToForwardingCall (exprHasEffect: Expr -> bool) g (aliases: ValMap) expr = + match stripDebugPoints expr with + | Expr.Let(TBind(v, rhs, _), inner, _, _) when not (exprHasEffect rhs) -> + stripToForwardingCall exprHasEffect g (aliases.Add v rhs) inner + | Expr.App(f, fty, tyargs, args, m) as app -> + match stripDebugPoints f with + // '(let v = e in f2) args': lift the binding off the function position + | Expr.Let(TBind(v, rhs, _), f2, _, _) when not (exprHasEffect rhs) -> + stripToForwardingCall exprHasEffect g (aliases.Add v rhs) (Expr.App(f2, fty, tyargs, args, m)) + // '(fun v -> body) arg …': beta-reduce by aliasing, one parameter at a time + | Expr.Lambda(_, None, None, [ v ], body, _, _) when List.isEmpty tyargs -> + match args with + | a :: rest when not (exprHasEffect a) -> + let aliases = aliases.Add v a - match body with - | Expr.App(Expr.Val(vref, valUseFlags, _), _, tyargs, args, _) -> - match matchForwarding g invokeParams (flattenTupledArgs vref args) mapReceiver with - | Some leadingArgs -> DirectDelegateForwardingTargetCandidate.FSharpVal(vref, valUseFlags, tyargs, leadingArgs) - | None -> DirectDelegateForwardingTargetCandidate.Other + match rest with + | [] -> stripToForwardingCall exprHasEffect g aliases body + | _ -> stripToForwardingCall exprHasEffect g aliases (Expr.App(body, tyOfExpr g body, [], rest, m)) + | _ -> app, aliases + // '(f2 args2) args': flatten the curried application + | Expr.App(f2, f2ty, tyargs2, args2, _) when List.isEmpty tyargs -> + stripToForwardingCall exprHasEffect g aliases (Expr.App(f2, f2ty, tyargs2, args2 @ args, m)) + | _ -> app, aliases + | e -> e, aliases + +let classifyForwardingTarget (exprHasEffect: Expr -> bool) g (invokeParams: Val list) expr = + let call, aliases = stripToForwardingCall exprHasEffect g ValMap.Empty expr + + match call with + | Expr.App(f, _, tyargs, args, _) -> + match stripDebugPoints f with + | Expr.Val(vref, valUseFlags, _) -> + match + tryFlattenTupledArgs vref args + |> Option.bind (matchForwarding g aliases invokeParams) + with + | Some leadingArgs -> DirectDelegateForwardingTargetCandidate.FSharpVal(vref, valUseFlags, tyargs, leadingArgs) + | None -> DirectDelegateForwardingTargetCandidate.Other + | _ -> DirectDelegateForwardingTargetCandidate.Other | Expr.Op(TOp.ILCall(isVirtual, _, isStruct, isCtor, valUseFlag, _, _, ilMethRef, enclTypeInst, methInst, _), _, args, _) -> - match matchForwarding g invokeParams args mapReceiver with + match matchForwarding g aliases invokeParams args with | Some leadingArgs -> DirectDelegateForwardingTargetCandidate.ILMethod( isVirtual, @@ -187,12 +233,12 @@ let private receiverNotByref g (leadingArgs: Expr list) = /// every Invoke; evaluating it once instead is observable unless it is side-effect free (a non-mutable /// value, a constant, a pure field read). /// - It must not reference the delegate's own Invoke parameters, which only exist inside the delegee method. -let private receiverBindable g (invokeParams: Val list) (leadingArgs: Expr list) = +let private receiverBindable (exprHasEffect: Expr -> bool) (invokeParams: Val list) (leadingArgs: Expr list) = match leadingArgs with | [ recv ] -> let recvFreeLocals = (freeInExpr CollectLocals recv).FreeLocals - not (Optimizer.ExprHasEffect g recv) + not (exprHasEffect recv) && (not (invokeParams |> List.exists (fun tv -> Zset.contains tv recvFreeLocals))) | _ -> true @@ -200,34 +246,56 @@ let private receiverBindable g (invokeParams: Val list) (leadingArgs: Expr list) /// constructor / base / self-init call, when the receiver shape is right, and when the receiver can be safely /// hoisted to the construction site. Only the witness fact is passed in (it needs the IlxGen environment); the /// newobj / super-init / self-init / instance-receiver facts are derived here from the member's call info, and -/// the base-call flag from valUseFlags. -let fsharpValDirectlyBindable g (invokeParams: Val list) (leadingArgs: Expr list) (vrefM: ValRef) (valUseFlags: ValUseFlag) hasWitnesses = - let _, _, newobj, isSuperInit, isSelfInit, takesInstanceArg, _, _ = +/// the base-call flag from valUseFlags. When directly bindable, returns the virtual-call and instance-receiver +/// facts already derived from the call info, so the caller does not re-derive them. +let fsharpValDirectlyBindable + (exprHasEffect: Expr -> bool) + g + (invokeParams: Val list) + (leadingArgs: Expr list) + (vrefM: ValRef) + (valUseFlags: ValUseFlag) + hasWitnesses + = + let _, virtualCall, newobj, isSuperInit, isSelfInit, takesInstanceArg, _, _ = GetMemberCallInfo g (vrefM, valUseFlags) - not hasWitnesses - && not newobj - && not isSuperInit - && not isSelfInit - && not valUseFlags.IsVSlotDirectCall - && receiverShapeOk leadingArgs takesInstanceArg - && receiverBindable g invokeParams leadingArgs - && staticLeadingArgIsRefType g takesInstanceArg leadingArgs - && receiverNotByref g leadingArgs + if + not hasWitnesses + && not newobj + && not isSuperInit + && not isSelfInit + && not valUseFlags.IsVSlotDirectCall + && receiverShapeOk leadingArgs takesInstanceArg + && receiverBindable exprHasEffect invokeParams leadingArgs + && staticLeadingArgIsRefType g takesInstanceArg leadingArgs + && receiverNotByref g leadingArgs + then + ValueSome(virtualCall, takesInstanceArg) + else + ValueNone /// An IL method target can be pointed at directly only when it is not a constructor / base / constrained call, /// when the receiver shape is right, and when the receiver can be safely hoisted to the construction site. A /// value-type instance receiver is boxed at the construction site (see the emit), matching the closure's /// by-value capture. The instance-receiver flag is derived here from ilMethRef and the base/constrained-call /// flags from valUseFlag. -let ilMethodDirectlyBindable g (invokeParams: Val list) (leadingArgs: Expr list) (ilMethRef: ILMethodRef) (valUseFlag: ValUseFlag) isCtor = +let ilMethodDirectlyBindable + (exprHasEffect: Expr -> bool) + g + (invokeParams: Val list) + (leadingArgs: Expr list) + (ilMethRef: ILMethodRef) + (valUseFlag: ValUseFlag) + isCtor + = let takesInstanceArg = ilMethRef.CallingConv.IsInstance not isCtor && not valUseFlag.IsVSlotDirectCall && not valUseFlag.IsPossibleConstrainedCall && receiverShapeOk leadingArgs takesInstanceArg - && receiverBindable g invokeParams leadingArgs + && receiverBindable exprHasEffect invokeParams leadingArgs && staticLeadingArgIsRefType g takesInstanceArg leadingArgs && receiverNotByref g leadingArgs @@ -235,9 +303,10 @@ let ilMethodDirectlyBindable g (invokeParams: Val list) (leadingArgs: Expr list) /// verified the delegate is built from a compatible function shape and the forwarding match pins the arity, /// so this is the residual check: /// - parameter *count* matches (essentially a sanity check). Parameter IL *types* are deliberately not -/// compared: a value-type parameter is exact by construction (a widening/boxing argument would not be a -/// verbatim Val and so would not have matched), and for reference-type parameters the CLR's delegate -/// relaxation permits contravariance, so an exact comparison would only produce false negatives. +/// compared (hence only the count is taken): a value-type parameter is exact by construction (a +/// widening/boxing argument would not be a verbatim Val and so would not have matched), and for +/// reference-type parameters the CLR's delegate relaxation permits contravariance, so an exact +/// comparison would only produce false negatives. /// - for a non-generic target, the return type matches exactly. This is the one IL mismatch the recognizer /// cannot see and the CLR will not relax: notably an F# 'unit' return compiled to 'void' versus a delegate /// whose Invoke returns 'Unit'. For a generic target the return is written in terms of type variables, so @@ -248,18 +317,18 @@ let ilMethodDirectlyBindable g (invokeParams: Val list) (leadingArgs: Expr list) /// receiver is not part of the IL signature), so it is subtracted from the target's formal-argument count. let signatureMatches numBoundLeadingFormals - (ilDelegeeParams: ILParameter list) - (ilDelegeeRet: ILReturn) + (numDelegeeParams: int) + (ilDelegeeRetTy: ILType) (ilEnclArgTys: ILType list) (ilMethArgTys: ILType list) (targetMspec: ILMethodSpec) = let arityMatches = - targetMspec.FormalArgTypes.Length - numBoundLeadingFormals = ilDelegeeParams.Length + targetMspec.FormalArgTypes.Length - numBoundLeadingFormals = numDelegeeParams let returnMatches = if List.isEmpty ilEnclArgTys && List.isEmpty ilMethArgTys then - ilDelegeeRet.Type = targetMspec.FormalReturnType + ilDelegeeRetTy = targetMspec.FormalReturnType else true diff --git a/src/Compiler/Optimize/Optimizer.fs b/src/Compiler/Optimize/Optimizer.fs index 866ddedf916..c3aad697d6f 100644 --- a/src/Compiler/Optimize/Optimizer.fs +++ b/src/Compiler/Optimize/Optimizer.fs @@ -12,6 +12,7 @@ open FSharp.Compiler open FSharp.Compiler.AbstractIL.IL open FSharp.Compiler.AttributeChecking open FSharp.Compiler.CompilerGlobalState +open FSharp.Compiler.DelegateForwarding open FSharp.Compiler.DiagnosticsLogger open FSharp.Compiler.Text.Range open FSharp.Compiler.Syntax.PrettyNaming @@ -1675,7 +1676,7 @@ and OpHasEffect g m op = | TOp.ExnFieldSet _ | TOp.Coerce | TOp.Reraise - | TOp.IntegerForLoop _ + | TOp.IntegerForLoop _ | TOp.While _ | TOp.TryWith _ (* conservative *) | TOp.TryFinally _ (* conservative *) @@ -1687,6 +1688,43 @@ and OpHasEffect g m op = | TOp.LValueOp _ (* conservative *) | TOp.ValFieldSet _ -> true +/// When a delegate construction's Invoke body is a transparent forwarding call that the ILX generator can +/// point the delegate directly at (see DelegateForwarding), prevent the optimizer from inlining the target +/// into the body: inlining would dissolve the forwarding call before code generation and force the delegate +/// back into a closure, making the emitted form depend on the target's size. Only optimizer-chosen inlining +/// is suppressed. Cross-assembly inlining of a target from a referenced assembly's optimization +/// data goes through this same inlining path, so it is suppressed here as well. +let AddDirectDelegateTargetToDontInlineSet cenv env (slotsig: SlotSig) tmvs body m = + let g = cenv.g + + if + g.langVersion.SupportsFeature Features.LanguageFeature.DirectDelegateConstruction + && cenv.optimizing + && cenv.settings.InlineLambdas + then + // Normalize the Invoke parameters exactly as IlxGen will before it runs the recognizer. + let invokeParamInfos = + List.replicate (List.concat slotsig.FormalParams).Length ValReprInfo.unnamedTopArg1 + + let tmvs, body = BindUnitVars g (tmvs, invokeParamInfos, body) + + match classifyForwardingTarget (ExprHasEffect g) g tmvs body with + | DirectDelegateForwardingTargetCandidate.FSharpVal(vref, valUseFlags, _, leadingArgs) when + // Only a value compiled as a real method can be pointed at directly (mirrors IlxGen's + // Method-storage requirement); local function values keep their inlining. Witness information + // is not computable here, so 'false' is passed - over-suppressing for the rare + // witness-requiring target only costs a missed inline in a body that stays a closure. + vref.ValReprInfo.IsSome + && (fsharpValDirectlyBindable (ExprHasEffect g) g tmvs leadingArgs vref valUseFlags false) + .IsSome + -> + match (GetInfoForVal cenv env m vref).ValExprInfo with + | StripLambdaValue(lambdaId, _, _, _, _) -> + { env with dontInline = Map.add lambdaId [] env.dontInline } + | _ -> env + | _ -> env + else + env let TryEliminateBinding cenv _env bind e2 _m = let g = cenv.g @@ -2406,11 +2444,16 @@ let rec OptimizeExpr cenv (env: IncrementalOptimizationEnv) expr = MightMakeCriticalTailcall=false Info=UnknownValue } - | Expr.Obj (_, ty, basev, createExpr, overrides, iimpls, m) -> - match expr with - | NewDelegateExpr g (lambdaId, vsl, body, _, remake) -> + | Expr.Obj (_, ty, basev, createExpr, overrides, iimpls, m) -> + match expr with + | NewDelegateExpr g (lambdaId, vsl, body, _, remake) -> + let env = + match overrides with + | [ TObjExprMethod(slotsig, _, _, _, _, mMeth) ] -> + AddDirectDelegateTargetToDontInlineSet cenv env slotsig vsl body mMeth + | _ -> env OptimizeNewDelegateExpr cenv env (lambdaId, vsl, body, remake) - | _ -> + | _ -> OptimizeObjectExpr cenv env (ty, basev, createExpr, overrides, iimpls, m) | Expr.Op (op, tyargs, args, m) -> diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs index a8ad289fc43..b0d991a9b7f 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs @@ -5,22 +5,17 @@ open System // Custom, F#-declared delegate types exercise construction with delegates defined in the *compiled* assembly // (local scope, unlike imported BCL Func/Action) and with Invoke signatures the Func/Action tests do not // cover: a multi-argument (tupled) signature, a generic delegate, and a byref parameter. (F# forbids curried -// delegate signatures — FS0950 — so every F# delegate has a single tupled Invoke parameter group.) Targets -// are [] so the optimized path genuinely emits the direct form rather than inlining the -// target away (no inline-race). +// delegate signatures — FS0950 — so every F# delegate has a single tupled Invoke parameter group.) type DTupled = delegate of int * int -> int type DGen<'T> = delegate of 'T -> 'T type DByref = delegate of byref -> unit -[] let acc (x: int) (y: int) : int = x + y -[] let ident (x: 'T) : 'T = x type C() = - [] member _.M (x: int) (y: int) : int = x * y // Tupled-signature custom delegate: Invoke(int, int). diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOff.Preview.il.bsl index ebf7fcb3ce1..c9d56b7d0a0 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOff.Preview.il.bsl @@ -129,7 +129,6 @@ .method public hidebysig instance int32 M(int32 x, int32 y) cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) .maxstack 8 @@ -141,7 +140,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledEta@30 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledEta@25 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -159,7 +158,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname instanceEta@36 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname instanceEta@31 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -170,7 +169,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/instanceEta@36::c + IL_0002: stfld class assembly/C assembly/instanceEta@31::c IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -181,7 +180,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/instanceEta@36::c + IL_0001: ldfld class assembly/C assembly/instanceEta@31::c IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance int32 assembly/C::M(int32, @@ -191,7 +190,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genEta@42 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genEta@37 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -206,7 +205,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname byrefMutate@47 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname byrefMutate@42 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -228,7 +227,6 @@ .method public static int32 acc(int32 x, int32 y) cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) .maxstack 8 @@ -240,7 +238,6 @@ .method public static !!T ident(!!T x) cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .maxstack 8 IL_0000: ldarg.0 @@ -264,7 +261,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/tupledEta@30::Invoke(int32, + IL_0001: ldftn int32 assembly/tupledEta@25::Invoke(int32, int32) IL_0007: newobj instance void assembly/DTupled::.ctor(object, native int) @@ -288,8 +285,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/instanceEta@36::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/instanceEta@36::Invoke(int32, + IL_0001: newobj instance void assembly/instanceEta@31::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/instanceEta@31::Invoke(int32, int32) IL_000c: newobj instance void assembly/DTupled::.ctor(object, native int) @@ -312,7 +309,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/genEta@42::Invoke(int32) + IL_0001: ldftn int32 assembly/genEta@37::Invoke(int32) IL_0007: newobj instance void class assembly/DGen`1::.ctor(object, native int) IL_000c: ret @@ -323,7 +320,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/byrefMutate@47::Invoke(int32&) + IL_0001: ldftn void assembly/byrefMutate@42::Invoke(int32&) IL_0007: newobj instance void assembly/DByref::.ctor(object, native int) IL_000c: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOff.il.bsl index 0441b15c935..66053083940 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOff.il.bsl @@ -129,7 +129,6 @@ .method public hidebysig instance int32 M(int32 x, int32 y) cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) .maxstack 8 @@ -141,7 +140,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledNonEta@28 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledNonEta@23 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -159,7 +158,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledEta@30 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledEta@25 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -177,7 +176,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname instanceNonEta@34 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname instanceNonEta@29 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -188,7 +187,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/instanceNonEta@34::c + IL_0002: stfld class assembly/C assembly/instanceNonEta@29::c IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -199,7 +198,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/instanceNonEta@34::c + IL_0001: ldfld class assembly/C assembly/instanceNonEta@29::c IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance int32 assembly/C::M(int32, @@ -209,7 +208,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname instanceEta@36 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname instanceEta@31 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -220,7 +219,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/instanceEta@36::c + IL_0002: stfld class assembly/C assembly/instanceEta@31::c IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -231,7 +230,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/instanceEta@36::c + IL_0001: ldfld class assembly/C assembly/instanceEta@31::c IL_0006: ldarg.1 IL_0007: ldarg.2 IL_0008: callvirt instance int32 assembly/C::M(int32, @@ -241,7 +240,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genNonEta@40 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genNonEta@35 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -256,7 +255,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genEta@42 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genEta@37 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -271,7 +270,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname byrefMutate@47 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname byrefMutate@42 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -293,7 +292,6 @@ .method public static int32 acc(int32 x, int32 y) cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) .maxstack 8 @@ -305,7 +303,6 @@ .method public static !!T ident(!!T x) cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .maxstack 8 IL_0000: ldarg.0 @@ -317,7 +314,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/tupledNonEta@28::Invoke(int32, + IL_0001: ldftn int32 assembly/tupledNonEta@23::Invoke(int32, int32) IL_0007: newobj instance void assembly/DTupled::.ctor(object, native int) @@ -329,7 +326,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/tupledEta@30::Invoke(int32, + IL_0001: ldftn int32 assembly/tupledEta@25::Invoke(int32, int32) IL_0007: newobj instance void assembly/DTupled::.ctor(object, native int) @@ -341,8 +338,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/instanceNonEta@34::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/instanceNonEta@34::Invoke(int32, + IL_0001: newobj instance void assembly/instanceNonEta@29::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/instanceNonEta@29::Invoke(int32, int32) IL_000c: newobj instance void assembly/DTupled::.ctor(object, native int) @@ -354,8 +351,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/instanceEta@36::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/instanceEta@36::Invoke(int32, + IL_0001: newobj instance void assembly/instanceEta@31::.ctor(class assembly/C) + IL_0006: ldftn instance int32 assembly/instanceEta@31::Invoke(int32, int32) IL_000c: newobj instance void assembly/DTupled::.ctor(object, native int) @@ -367,7 +364,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/genNonEta@40::Invoke(int32) + IL_0001: ldftn int32 assembly/genNonEta@35::Invoke(int32) IL_0007: newobj instance void class assembly/DGen`1::.ctor(object, native int) IL_000c: ret @@ -378,7 +375,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/genEta@42::Invoke(int32) + IL_0001: ldftn int32 assembly/genEta@37::Invoke(int32) IL_0007: newobj instance void class assembly/DGen`1::.ctor(object, native int) IL_000c: ret @@ -389,7 +386,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/byrefMutate@47::Invoke(int32&) + IL_0001: ldftn void assembly/byrefMutate@42::Invoke(int32&) IL_0007: newobj instance void assembly/DByref::.ctor(object, native int) IL_000c: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOn.Preview.il.bsl index 2b9e0be2d12..15a1a5f9f34 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOn.Preview.il.bsl @@ -129,7 +129,6 @@ .method public hidebysig instance int32 M(int32 x, int32 y) cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) .maxstack 8 @@ -141,7 +140,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname byrefMutate@47 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname byrefMutate@42 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -163,7 +162,6 @@ .method public static int32 acc(int32 x, int32 y) cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) .maxstack 8 @@ -175,7 +173,6 @@ .method public static !!T ident(!!T x) cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .maxstack 8 IL_0000: ldarg.0 @@ -257,7 +254,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/byrefMutate@47::Invoke(int32&) + IL_0001: ldftn void assembly/byrefMutate@42::Invoke(int32&) IL_0007: newobj instance void assembly/DByref::.ctor(object, native int) IL_000c: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOn.il.bsl index 0441b15c935..91f76166944 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateCustomType.fs.OptimizeOn.il.bsl @@ -129,7 +129,6 @@ .method public hidebysig instance int32 M(int32 x, int32 y) cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) .maxstack 8 @@ -141,7 +140,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledNonEta@28 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledNonEta@23 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -152,14 +151,13 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: call int32 assembly::acc(int32, - int32) - IL_0007: ret + IL_0002: add + IL_0003: ret } } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledEta@30 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname tupledEta@25 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -170,78 +168,47 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: call int32 assembly::acc(int32, - int32) - IL_0007: ret + IL_0002: add + IL_0003: ret } } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname instanceNonEta@34 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname instanceNonEta@29 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .field public class assembly/C c - .method public specialname rtspecialname instance void .ctor(class assembly/C c) cil managed + .method assembly static int32 Invoke(int32 delegateArg0, + int32 delegateArg1) cil managed { .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/instanceNonEta@34::c - IL_0007: ldarg.0 - IL_0008: call instance void [runtime]System.Object::.ctor() - IL_000d: ret - } - - .method assembly hidebysig instance int32 Invoke(int32 delegateArg0, int32 delegateArg1) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/instanceNonEta@34::c - IL_0006: ldarg.1 - IL_0007: ldarg.2 - IL_0008: callvirt instance int32 assembly/C::M(int32, - int32) - IL_000d: ret + IL_0002: mul + IL_0003: ret } } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname instanceEta@36 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname instanceEta@31 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .field public class assembly/C c - .method public specialname rtspecialname instance void .ctor(class assembly/C c) cil managed + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed { .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/instanceEta@36::c - IL_0007: ldarg.0 - IL_0008: call instance void [runtime]System.Object::.ctor() - IL_000d: ret - } - - .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/instanceEta@36::c - IL_0006: ldarg.1 - IL_0007: ldarg.2 - IL_0008: callvirt instance int32 assembly/C::M(int32, - int32) - IL_000d: ret + IL_0002: mul + IL_0003: ret } } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genNonEta@40 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genNonEta@35 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -250,13 +217,12 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: call !!0 assembly::ident(!!0) - IL_0006: ret + IL_0001: ret } } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genEta@42 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname genEta@37 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -265,13 +231,12 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: call !!0 assembly::ident(!!0) - IL_0006: ret + IL_0001: ret } } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname byrefMutate@47 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname byrefMutate@42 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -293,7 +258,6 @@ .method public static int32 acc(int32 x, int32 y) cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) .maxstack 8 @@ -305,7 +269,6 @@ .method public static !!T ident(!!T x) cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .maxstack 8 IL_0000: ldarg.0 @@ -317,7 +280,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/tupledNonEta@28::Invoke(int32, + IL_0001: ldftn int32 assembly/tupledNonEta@23::Invoke(int32, int32) IL_0007: newobj instance void assembly/DTupled::.ctor(object, native int) @@ -329,7 +292,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/tupledEta@30::Invoke(int32, + IL_0001: ldftn int32 assembly/tupledEta@25::Invoke(int32, int32) IL_0007: newobj instance void assembly/DTupled::.ctor(object, native int) @@ -340,26 +303,24 @@ { .maxstack 8 - IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/instanceNonEta@34::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/instanceNonEta@34::Invoke(int32, - int32) - IL_000c: newobj instance void assembly/DTupled::.ctor(object, + IL_0000: ldnull + IL_0001: ldftn int32 assembly/instanceNonEta@29::Invoke(int32, + int32) + IL_0007: newobj instance void assembly/DTupled::.ctor(object, native int) - IL_0011: ret + IL_000c: ret } .method public static class assembly/DTupled instanceEta(class assembly/C c) cil managed { .maxstack 8 - IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/instanceEta@36::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/instanceEta@36::Invoke(int32, - int32) - IL_000c: newobj instance void assembly/DTupled::.ctor(object, + IL_0000: ldnull + IL_0001: ldftn int32 assembly/instanceEta@31::Invoke(int32, + int32) + IL_0007: newobj instance void assembly/DTupled::.ctor(object, native int) - IL_0011: ret + IL_000c: ret } .method public static class assembly/DGen`1 genNonEta() cil managed @@ -367,7 +328,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/genNonEta@40::Invoke(int32) + IL_0001: ldftn int32 assembly/genNonEta@35::Invoke(int32) IL_0007: newobj instance void class assembly/DGen`1::.ctor(object, native int) IL_000c: ret @@ -378,7 +339,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/genEta@42::Invoke(int32) + IL_0001: ldftn int32 assembly/genEta@37::Invoke(int32) IL_0007: newobj instance void class assembly/DGen`1::.ctor(object, native int) IL_000c: ret @@ -389,7 +350,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/byrefMutate@47::Invoke(int32&) + IL_0001: ldftn void assembly/byrefMutate@42::Invoke(int32&) IL_0007: newobj instance void assembly/DByref::.ctor(object, native int) IL_000c: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs index 6a06814a03d..6d7ecdd9960 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs @@ -9,7 +9,7 @@ type Holder() = [] type HolderExtensions = - [] + [] static member Combine (h: Holder, x: int, y: int) : int = x + y // An extension member compiles to a static method whose first parameter is the receiver. Using it as a diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOff.Preview.il.bsl index 38de9585694..0e4b863938b 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOff.Preview.il.bsl @@ -60,7 +60,6 @@ int32 y) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .maxstack 8 IL_0000: ldarg.1 diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOff.il.bsl index a410776454a..940811fcfab 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOff.il.bsl @@ -60,7 +60,6 @@ int32 y) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .maxstack 8 IL_0000: ldarg.1 diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOn.Preview.il.bsl index 4ec8ad308a3..6e78d1cdc46 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOn.Preview.il.bsl @@ -60,7 +60,6 @@ int32 y) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .maxstack 8 IL_0000: ldarg.1 diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOn.il.bsl index a410776454a..8168284b0b3 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateExtensionMethod.fs.OptimizeOn.il.bsl @@ -60,7 +60,6 @@ int32 y) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .maxstack 8 IL_0000: ldarg.1 @@ -71,35 +70,19 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname extensionEta@22 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname extensionEta@22 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .field public class assembly/Holder h - .method public specialname rtspecialname instance void .ctor(class assembly/Holder h) cil managed + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed { .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/Holder assembly/extensionEta@22::h - IL_0007: ldarg.0 - IL_0008: call instance void [runtime]System.Object::.ctor() - IL_000d: ret - } - - .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldfld class assembly/Holder assembly/extensionEta@22::h - IL_0006: ldarg.1 - IL_0007: ldarg.2 - IL_0008: call int32 assembly/HolderExtensions::Combine(class assembly/Holder, - int32, - int32) - IL_000d: ret + IL_0002: add + IL_0003: ret } } @@ -108,13 +91,12 @@ { .maxstack 8 - IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/extensionEta@22::.ctor(class assembly/Holder) - IL_0006: ldftn instance int32 assembly/extensionEta@22::Invoke(int32, - int32) - IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + IL_0000: ldnull + IL_0001: ldftn int32 assembly/extensionEta@22::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) - IL_0011: ret + IL_000c: ret } } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOn.Preview.il.bsl index 74be77228f1..26e0b7e9705 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericInstanceMethod.fs.OptimizeOn.Preview.il.bsl @@ -65,41 +65,13 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case5_etaCurried@10 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static void Invoke(int32 a, - int32 b) cil managed - { - - .maxstack 8 - IL_0000: ret - } - - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case35_etaTupled@13 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static void Invoke(int32 a, - int32 b) cil managed - { - - .maxstack 8 - IL_0000: ret - } - - } - .method public static class [runtime]System.Action`2 case5_etaCurried(class assembly/C o) cil managed { .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn void assembly/case5_etaCurried@10::Invoke(int32, - int32) + IL_0000: ldarg.0 + IL_0001: ldftn instance void assembly/C::IMc(!!0, + !!0) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret @@ -109,9 +81,9 @@ { .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn void assembly/case35_etaTupled@13::Invoke(int32, - int32) + IL_0000: ldarg.0 + IL_0001: ldftn instance void assembly/C::IMt(!!0, + !!0) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOn.Preview.il.bsl index b3e611b286a..cb158381c58 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateGenericStaticMethod.fs.OptimizeOn.Preview.il.bsl @@ -56,55 +56,13 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case19_nonEta@10 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static void Invoke(int32 x, - int32 y) cil managed - { - - .maxstack 8 - IL_0000: ret - } - - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case3_etaCurried@13 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static void Invoke(int32 a, - int32 b) cil managed - { - - .maxstack 8 - IL_0000: ret - } - - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case33_etaTupled@16 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static void Invoke(int32 a, - int32 b) cil managed - { - - .maxstack 8 - IL_0000: ret - } - - } - .method public static class [runtime]System.Action`2 case19_nonEta() cil managed { .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case19_nonEta@10::Invoke(int32, - int32) + IL_0001: ldftn void class assembly/G`1::SMc(!!0, + !!0) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret @@ -115,8 +73,8 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case3_etaCurried@13::Invoke(int32, - int32) + IL_0001: ldftn void class assembly/G`1::SMc(!!0, + !!0) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret @@ -127,8 +85,8 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case33_etaTupled@16::Invoke(int32, - int32) + IL_0001: ldftn void class assembly/G`1::SMt(!!0, + !!0) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs index 5be6e249aff..d5a9ebf9fbe 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs @@ -4,9 +4,8 @@ open System open System.Text // IL (BCL) method targets are compiled as TOp.ILCall rather than an F# value application. They are made -// direct only when the eta-expanded forwarding call survives to codegen, i.e. in optimized builds; in -// unoptimized builds the eta form keeps a closure (matching the F# eta policy). See DelegateNonInlinable -// for the F#-value equivalent. +// direct only in optimized builds; in unoptimized builds the eta form keeps a closure (matching the F# +// eta policy). See DelegateKnownFunction for the F#-value equivalent. // 12. eta IL/BCL static method (System.Math.Max). let ilStaticEta () = Func(fun a b -> Math.Max(a, b)) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.OptimizeOff.Preview.il.bsl index 12ffd3cce34..5ca457d058f 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.OptimizeOff.Preview.il.bsl @@ -33,7 +33,7 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname ilStaticEta@12 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname ilStaticEta@11 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -51,7 +51,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname ilInstanceEta@16 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname ilInstanceEta@15 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -62,7 +62,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class [runtime]System.Text.StringBuilder assembly/ilInstanceEta@16::sb + IL_0002: stfld class [runtime]System.Text.StringBuilder assembly/ilInstanceEta@15::sb IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -73,7 +73,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class [runtime]System.Text.StringBuilder assembly/ilInstanceEta@16::sb + IL_0001: ldfld class [runtime]System.Text.StringBuilder assembly/ilInstanceEta@15::sb IL_0006: ldarg.1 IL_0007: callvirt instance class [runtime]System.Text.StringBuilder [runtime]System.Text.StringBuilder::Append(string) IL_000c: ret @@ -86,7 +86,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/ilStaticEta@12::Invoke(int32, + IL_0001: ldftn int32 assembly/ilStaticEta@11::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) @@ -98,8 +98,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/ilInstanceEta@16::.ctor(class [runtime]System.Text.StringBuilder) - IL_0006: ldftn instance class [runtime]System.Text.StringBuilder assembly/ilInstanceEta@16::Invoke(string) + IL_0001: newobj instance void assembly/ilInstanceEta@15::.ctor(class [runtime]System.Text.StringBuilder) + IL_0006: ldftn instance class [runtime]System.Text.StringBuilder assembly/ilInstanceEta@15::Invoke(string) IL_000c: newobj instance void class [runtime]System.Func`2::.ctor(object, native int) IL_0011: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.OptimizeOff.il.bsl index 718255efb91..98e340a1d79 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.OptimizeOff.il.bsl @@ -33,7 +33,7 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname ilStaticEta@12 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname ilStaticEta@11 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -51,7 +51,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname ilInstanceEta@16 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname ilInstanceEta@15 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -62,7 +62,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class [runtime]System.Text.StringBuilder assembly/ilInstanceEta@16::sb + IL_0002: stfld class [runtime]System.Text.StringBuilder assembly/ilInstanceEta@15::sb IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -73,7 +73,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class [runtime]System.Text.StringBuilder assembly/ilInstanceEta@16::sb + IL_0001: ldfld class [runtime]System.Text.StringBuilder assembly/ilInstanceEta@15::sb IL_0006: ldarg.1 IL_0007: callvirt instance class [runtime]System.Text.StringBuilder [runtime]System.Text.StringBuilder::Append(string) IL_000c: ret @@ -86,7 +86,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/ilStaticEta@12::Invoke(int32, + IL_0001: ldftn int32 assembly/ilStaticEta@11::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) @@ -98,8 +98,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/ilInstanceEta@16::.ctor(class [runtime]System.Text.StringBuilder) - IL_0006: ldftn instance class [runtime]System.Text.StringBuilder assembly/ilInstanceEta@16::Invoke(string) + IL_0001: newobj instance void assembly/ilInstanceEta@15::.ctor(class [runtime]System.Text.StringBuilder) + IL_0006: ldftn instance class [runtime]System.Text.StringBuilder assembly/ilInstanceEta@15::Invoke(string) IL_000c: newobj instance void class [runtime]System.Func`2::.ctor(object, native int) IL_0011: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.OptimizeOn.il.bsl index 718255efb91..98e340a1d79 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateILMethod.fs.OptimizeOn.il.bsl @@ -33,7 +33,7 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname ilStaticEta@12 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname ilStaticEta@11 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -51,7 +51,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname ilInstanceEta@16 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname ilInstanceEta@15 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -62,7 +62,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class [runtime]System.Text.StringBuilder assembly/ilInstanceEta@16::sb + IL_0002: stfld class [runtime]System.Text.StringBuilder assembly/ilInstanceEta@15::sb IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -73,7 +73,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class [runtime]System.Text.StringBuilder assembly/ilInstanceEta@16::sb + IL_0001: ldfld class [runtime]System.Text.StringBuilder assembly/ilInstanceEta@15::sb IL_0006: ldarg.1 IL_0007: callvirt instance class [runtime]System.Text.StringBuilder [runtime]System.Text.StringBuilder::Append(string) IL_000c: ret @@ -86,7 +86,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/ilStaticEta@12::Invoke(int32, + IL_0001: ldftn int32 assembly/ilStaticEta@11::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) @@ -98,8 +98,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/ilInstanceEta@16::.ctor(class [runtime]System.Text.StringBuilder) - IL_0006: ldftn instance class [runtime]System.Text.StringBuilder assembly/ilInstanceEta@16::Invoke(string) + IL_0001: newobj instance void assembly/ilInstanceEta@15::.ctor(class [runtime]System.Text.StringBuilder) + IL_0006: ldftn instance class [runtime]System.Text.StringBuilder assembly/ilInstanceEta@15::Invoke(string) IL_000c: newobj instance void class [runtime]System.Func`2::.ctor(object, native int) IL_0011: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOn.Preview.il.bsl index 8b34df3492b..13e7184f77c 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateInstanceMethod.fs.OptimizeOn.Preview.il.bsl @@ -77,55 +77,13 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case20_nonEta@12 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static void Invoke(int32 arg1, - int32 arg2) cil managed - { - - .maxstack 8 - IL_0000: ret - } - - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case4_etaCurried@15 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static void Invoke(int32 a, - int32 b) cil managed - { - - .maxstack 8 - IL_0000: ret - } - - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case34_etaTupled@18 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static void Invoke(int32 a, - int32 b) cil managed - { - - .maxstack 8 - IL_0000: ret - } - - } - .method public static class [runtime]System.Action`2 case20_nonEta(class assembly/C o) cil managed { .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn void assembly/case20_nonEta@12::Invoke(int32, - int32) + IL_0000: ldarg.0 + IL_0001: ldftn instance void assembly/C::AddC(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret @@ -135,9 +93,9 @@ { .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn void assembly/case4_etaCurried@15::Invoke(int32, - int32) + IL_0000: ldarg.0 + IL_0001: ldftn instance void assembly/C::AddC(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret @@ -147,9 +105,9 @@ { .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn void assembly/case34_etaTupled@18::Invoke(int32, - int32) + IL_0000: ldarg.0 + IL_0001: ldftn instance void assembly/C::AddT(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOn.Preview.il.bsl index 1d21f52cfe8..d881a035d3d 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateKnownFunction.fs.OptimizeOn.Preview.il.bsl @@ -33,48 +33,6 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case17_nonEta@11 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static void Invoke(int32 x, - int32 y) cil managed - { - - .maxstack 8 - IL_0000: ret - } - - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case1_etaCurried@14 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static void Invoke(int32 a, - int32 b) cil managed - { - - .maxstack 8 - IL_0000: ret - } - - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case31_etaTupled@17 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static void Invoke(int32 a, - int32 b) cil managed - { - - .maxstack 8 - IL_0000: ret - } - - } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case37_partial@20 extends [runtime]System.Object { @@ -122,8 +80,8 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case17_nonEta@11::Invoke(int32, - int32) + IL_0001: ldftn void assembly::handlerCurried(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret @@ -134,8 +92,8 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case1_etaCurried@14::Invoke(int32, - int32) + IL_0001: ldftn void assembly::handlerCurried(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret @@ -146,8 +104,8 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case31_etaTupled@17::Invoke(int32, - int32) + IL_0001: ldftn void assembly::handlerTupled(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs index 14716ed1e4c..3d00a59a5cb 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs @@ -15,7 +15,6 @@ let notDirect (k: int) = Action(fun a b -> sink (a + b + k)) let reordered (handler: int -> int -> unit) = Action(fun a b -> handler b a) type Holder() = - [] member _.TakesObj (x: obj) : int = 1 // 45. Reference-parameter contravariance: the delegate's Invoke is (string):int and the target is (object):int. @@ -27,7 +26,7 @@ let contra (h: Holder) = System.Func(fun s -> h.TakesObj s) [] type Extensions = - [] + [] static member Echo<'T> (x: 'T, y: int, z: int) : 'T = x // 54. extension member on a VALUE-TYPE receiver: an extension member compiles to a static method whose first @@ -36,3 +35,8 @@ type Extensions = // form (unlike a value-type *instance* receiver, which is reached through the method's unboxing stub), so a // closure must remain. let valueTypeExtension () = Func(fun a b -> (3).Echo(a, b)) + +// 55. over-application: 'failwith' takes only the message, and it is the *returned function* that consumes +// the delegate's (elided unit) argument. There is no saturated call to the target to point at - and binding +// 'failwith' directly would evaluate it once instead of per invocation - so a closure must remain. +let overApplied () = Action(failwith "nope") diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.Preview.il.bsl index 4320a5bf0eb..77ad669f0e0 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.Preview.il.bsl @@ -152,7 +152,6 @@ .method public hidebysig instance int32 TakesObj(object x) cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .maxstack 8 IL_0000: ldc.i4.1 @@ -161,7 +160,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname contra@26 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname contra@25 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -172,7 +171,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/Holder assembly/contra@26::h + IL_0002: stfld class assembly/Holder assembly/contra@25::h IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -183,7 +182,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/Holder assembly/contra@26::h + IL_0001: ldfld class assembly/Holder assembly/contra@25::h IL_0006: ldarg.1 IL_0007: callvirt instance int32 assembly/Holder::TakesObj(object) IL_000c: ret @@ -201,7 +200,6 @@ int32 z) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .maxstack 8 IL_0000: ldarg.0 @@ -210,7 +208,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname valueTypeExtension@38 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname valueTypeExtension@37 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -230,6 +228,36 @@ } + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname overApplied@42 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke() cil managed + { + + .maxstack 6 + .locals init (string V_0) + IL_0000: ldstr "nope" + IL_0005: stloc.0 + IL_0006: ldc.i4.0 + IL_0007: brfalse.s IL_0011 + + IL_0009: ldnull + IL_000a: unbox.any class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + IL_000f: br.s IL_0018 + + IL_0011: ldloc.0 + IL_0012: call class [runtime]System.Exception [FSharp.Core]Microsoft.FSharp.Core.Operators::Failure(string) + IL_0017: throw + + IL_0018: ldnull + IL_0019: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_001e: pop + IL_001f: ret + } + + } + .method public static class [runtime]System.Action`2 firstClass(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed { @@ -281,8 +309,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/contra@26::.ctor(class assembly/Holder) - IL_0006: ldftn instance int32 assembly/contra@26::Invoke(string) + IL_0001: newobj instance void assembly/contra@25::.ctor(class assembly/Holder) + IL_0006: ldftn instance int32 assembly/contra@25::Invoke(string) IL_000c: newobj instance void class [runtime]System.Func`2::.ctor(object, native int) IL_0011: ret @@ -293,13 +321,24 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/valueTypeExtension@38::Invoke(int32, + IL_0001: ldftn int32 assembly/valueTypeExtension@37::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) IL_000c: ret } + .method public static class [runtime]System.Action overApplied() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/overApplied@42::Invoke() + IL_0007: newobj instance void [runtime]System.Action::.ctor(object, + native int) + IL_000c: ret + } + } .class private abstract auto ansi sealed ''.$assembly diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.il.bsl index e2543d21f33..ea6c1edee84 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOff.il.bsl @@ -152,7 +152,6 @@ .method public hidebysig instance int32 TakesObj(object x) cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .maxstack 8 IL_0000: ldc.i4.1 @@ -161,7 +160,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname contra@26 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname contra@25 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -172,7 +171,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/Holder assembly/contra@26::h + IL_0002: stfld class assembly/Holder assembly/contra@25::h IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -183,7 +182,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/Holder assembly/contra@26::h + IL_0001: ldfld class assembly/Holder assembly/contra@25::h IL_0006: ldarg.1 IL_0007: callvirt instance int32 assembly/Holder::TakesObj(object) IL_000c: ret @@ -201,7 +200,6 @@ int32 z) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .maxstack 8 IL_0000: ldarg.0 @@ -210,7 +208,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname valueTypeExtension@38 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname valueTypeExtension@37 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -230,6 +228,36 @@ } + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname overApplied@42 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke() cil managed + { + + .maxstack 6 + .locals init (string V_0) + IL_0000: ldstr "nope" + IL_0005: stloc.0 + IL_0006: ldc.i4.0 + IL_0007: brfalse.s IL_0011 + + IL_0009: ldnull + IL_000a: unbox.any class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + IL_000f: br.s IL_0018 + + IL_0011: ldloc.0 + IL_0012: call class [runtime]System.Exception [FSharp.Core]Microsoft.FSharp.Core.Operators::Failure(string) + IL_0017: throw + + IL_0018: ldnull + IL_0019: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_001e: pop + IL_001f: ret + } + + } + .method public static class [runtime]System.Action`2 firstClass(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2> 'handler') cil managed { @@ -281,8 +309,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/contra@26::.ctor(class assembly/Holder) - IL_0006: ldftn instance int32 assembly/contra@26::Invoke(string) + IL_0001: newobj instance void assembly/contra@25::.ctor(class assembly/Holder) + IL_0006: ldftn instance int32 assembly/contra@25::Invoke(string) IL_000c: newobj instance void class [runtime]System.Func`2::.ctor(object, native int) IL_0011: ret @@ -293,13 +321,24 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/valueTypeExtension@38::Invoke(int32, + IL_0001: ldftn int32 assembly/valueTypeExtension@37::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) IL_000c: ret } + .method public static class [runtime]System.Action overApplied() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/overApplied@42::Invoke() + IL_0007: newobj instance void [runtime]System.Action::.ctor(object, + native int) + IL_000c: ret + } + } .class private abstract auto ansi sealed ''.$assembly diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.Preview.il.bsl index dbeaeb2ede2..cadd0be4581 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.Preview.il.bsl @@ -5,6 +5,11 @@ .assembly extern runtime { } .assembly extern FSharp.Core { } +.assembly extern netstandard +{ + .publickeytoken = (CC 7B 13 FF CD 2D DD 51 ) + .ver 2:1:0:0 +} .assembly assembly { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, @@ -132,7 +137,6 @@ .method public hidebysig instance int32 TakesObj(object x) cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .maxstack 8 IL_0000: ldc.i4.1 @@ -141,32 +145,19 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname contra@26 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname contra@25 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .field public class assembly/Holder h - .method public specialname rtspecialname instance void .ctor(class assembly/Holder h) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: stfld class assembly/Holder assembly/contra@26::h - IL_0007: ldarg.0 - IL_0008: call instance void [runtime]System.Object::.ctor() - IL_000d: ret - } - - .method assembly hidebysig instance int32 Invoke(string s) cil managed + .method assembly static int32 Invoke(string s) cil managed { - .maxstack 8 + .maxstack 5 + .locals init (object V_0) IL_0000: ldarg.0 - IL_0001: ldfld class assembly/Holder assembly/contra@26::h - IL_0006: ldarg.1 - IL_0007: callvirt instance int32 assembly/Holder::TakesObj(object) - IL_000c: ret + IL_0001: stloc.0 + IL_0002: ldc.i4.1 + IL_0003: ret } } @@ -181,7 +172,6 @@ int32 z) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .maxstack 8 IL_0000: ldarg.0 @@ -190,7 +180,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname valueTypeExtension@38 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname valueTypeExtension@37 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -200,12 +190,34 @@ .maxstack 8 IL_0000: ldc.i4.3 - IL_0001: ldarg.0 - IL_0002: ldarg.1 - IL_0003: call !!0 assembly/Extensions::Echo(!!0, - int32, - int32) - IL_0008: ret + IL_0001: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname overApplied@42 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: brfalse.s IL_000b + + IL_0003: ldnull + IL_0004: unbox.any class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + IL_0009: br.s IL_0016 + + IL_000b: ldstr "nope" + IL_0010: newobj instance void [netstandard]System.Exception::.ctor(string) + IL_0015: throw + + IL_0016: ldnull + IL_0017: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_001c: pop + IL_001d: ret } } @@ -259,12 +271,11 @@ { .maxstack 8 - IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/contra@26::.ctor(class assembly/Holder) - IL_0006: ldftn instance int32 assembly/contra@26::Invoke(string) - IL_000c: newobj instance void class [runtime]System.Func`2::.ctor(object, + IL_0000: ldnull + IL_0001: ldftn int32 assembly/contra@25::Invoke(string) + IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, native int) - IL_0011: ret + IL_000c: ret } .method public static class [runtime]System.Func`3 valueTypeExtension() cil managed @@ -272,13 +283,24 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/valueTypeExtension@38::Invoke(int32, + IL_0001: ldftn int32 assembly/valueTypeExtension@37::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) IL_000c: ret } + .method public static class [runtime]System.Action overApplied() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/overApplied@42::Invoke() + IL_0007: newobj instance void [runtime]System.Action::.ctor(object, + native int) + IL_000c: ret + } + } .class private abstract auto ansi sealed ''.$assembly diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.il.bsl index 21e52bb70f7..6f3ed2ddc14 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNegativeCases.fs.OptimizeOn.il.bsl @@ -5,6 +5,11 @@ .assembly extern runtime { } .assembly extern FSharp.Core { } +.assembly extern netstandard +{ + .publickeytoken = (CC 7B 13 FF CD 2D DD 51 ) + .ver 2:1:0:0 +} .assembly assembly { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, @@ -132,7 +137,6 @@ .method public hidebysig instance int32 TakesObj(object x) cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .maxstack 8 IL_0000: ldc.i4.1 @@ -141,32 +145,19 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname contra@26 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname contra@25 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .field public class assembly/Holder h - .method public specialname rtspecialname instance void .ctor(class assembly/Holder h) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: stfld class assembly/Holder assembly/contra@26::h - IL_0007: ldarg.0 - IL_0008: call instance void [runtime]System.Object::.ctor() - IL_000d: ret - } - - .method assembly hidebysig instance int32 Invoke(string s) cil managed + .method assembly static int32 Invoke(string s) cil managed { - .maxstack 8 + .maxstack 5 + .locals init (object V_0) IL_0000: ldarg.0 - IL_0001: ldfld class assembly/Holder assembly/contra@26::h - IL_0006: ldarg.1 - IL_0007: callvirt instance int32 assembly/Holder::TakesObj(object) - IL_000c: ret + IL_0001: stloc.0 + IL_0002: ldc.i4.1 + IL_0003: ret } } @@ -181,7 +172,6 @@ int32 z) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .maxstack 8 IL_0000: ldarg.0 @@ -190,7 +180,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname valueTypeExtension@38 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname valueTypeExtension@37 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -200,12 +190,34 @@ .maxstack 8 IL_0000: ldc.i4.3 - IL_0001: ldarg.0 - IL_0002: ldarg.1 - IL_0003: call !!0 assembly/Extensions::Echo(!!0, - int32, - int32) - IL_0008: ret + IL_0001: ret + } + + } + + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname overApplied@42 + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) + .method assembly static void Invoke() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: brfalse.s IL_000b + + IL_0003: ldnull + IL_0004: unbox.any class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + IL_0009: br.s IL_0016 + + IL_000b: ldstr "nope" + IL_0010: newobj instance void [netstandard]System.Exception::.ctor(string) + IL_0015: throw + + IL_0016: ldnull + IL_0017: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_001c: pop + IL_001d: ret } } @@ -259,12 +271,11 @@ { .maxstack 8 - IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/contra@26::.ctor(class assembly/Holder) - IL_0006: ldftn instance int32 assembly/contra@26::Invoke(string) - IL_000c: newobj instance void class [runtime]System.Func`2::.ctor(object, + IL_0000: ldnull + IL_0001: ldftn int32 assembly/contra@25::Invoke(string) + IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, native int) - IL_0011: ret + IL_000c: ret } .method public static class [runtime]System.Func`3 valueTypeExtension() cil managed @@ -272,13 +283,24 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn int32 assembly/valueTypeExtension@38::Invoke(int32, + IL_0001: ldftn int32 assembly/valueTypeExtension@37::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) IL_000c: ret } + .method public static class [runtime]System.Action overApplied() cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: ldftn void assembly/overApplied@42::Invoke() + IL_0007: newobj instance void [runtime]System.Action::.ctor(object, + native int) + IL_000c: ret + } + } .class private abstract auto ansi sealed ''.$assembly diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs deleted file mode 100644 index 0cdba8a007a..00000000000 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs +++ /dev/null @@ -1,47 +0,0 @@ -module DelegateNonInlinable - -open System - -[] -let accCurried (x: int) (y: int) : int = x + y - -[] -let accTupled (x: int, y: int) : int = x + y - -// 22. non-eta module function, non-inlinable -let niNonEta () = Func(accCurried) - -// 6. eta module function, non-inlinable (curried application) -let niEtaCurried () = Func(fun a b -> accCurried a b) - -// 36. eta module function, non-inlinable, tupled application -let niEtaTupled () = Func(fun a b -> accTupled (a, b)) - -type S = - [] - static member AccS (x: int) (y: int) : int = x + y - -// 23. non-eta static method, non-inlinable -let niStaticNonEta () = Func(S.AccS) - -// 7. eta static method, non-inlinable -let niStaticEta () = Func(fun a b -> S.AccS a b) - -type C(k: int) = - [] - member _.AccC (x: int) (y: int) : int = x + y + k - - [] - member _.GPick<'T> (x: 'T) (y: 'T) : 'T = x - -// 24. non-eta instance method, non-inlinable -let niInstanceNonEta (o: C) = Func(o.AccC) - -// 8. eta instance method, non-inlinable -let niInstanceEta (o: C) = Func(fun a b -> o.AccC a b) - -// 25. non-eta generic instance method, non-inlinable -let niGenericInstanceNonEta (o: C) = Func(o.GPick) - -// 9. eta generic instance method, non-inlinable -let niGenericInstanceEta (o: C) = Func(fun a b -> o.GPick a b) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.Preview.il.bsl deleted file mode 100644 index 8117927a131..00000000000 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.Preview.il.bsl +++ /dev/null @@ -1,374 +0,0 @@ - - - - - -.assembly extern runtime { } -.assembly extern FSharp.Core { } -.assembly assembly -{ - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, - int32, - int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) - - - - - .hash algorithm 0x00008004 - .ver 0:0:0:0 -} -.module assembly.exe - -.imagebase {value} -.file alignment 0x00000200 -.stackreserve 0x00100000 -.subsystem 0x0003 -.corflags 0x00000001 - - - - - -.class public abstract auto ansi sealed assembly - extends [runtime]System.Object -{ - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaCurried@15 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 a, - int32 b) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call int32 assembly::accCurried(int32, - int32) - IL_0007: ret - } - - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaTupled@18 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 a, - int32 b) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call int32 assembly::accTupled(int32, - int32) - IL_0007: ret - } - - } - - .class auto ansi serializable nested public S - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) - .method public static int32 AccS(int32 x, - int32 y) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: add - IL_0003: ret - } - - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticEta@28 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 a, - int32 b) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call int32 assembly/S::AccS(int32, - int32) - IL_0007: ret - } - - } - - .class auto ansi serializable nested public C - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) - .field assembly int32 k - .method public specialname rtspecialname instance void .ctor(int32 k) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: callvirt instance void [runtime]System.Object::.ctor() - IL_0006: ldarg.0 - IL_0007: pop - IL_0008: ldarg.0 - IL_0009: ldarg.1 - IL_000a: stfld int32 assembly/C::k - IL_000f: ret - } - - .method public hidebysig instance int32 AccC(int32 x, int32 y) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.1 - IL_0001: ldarg.2 - IL_0002: add - IL_0003: ldarg.0 - IL_0004: ldfld int32 assembly/C::k - IL_0009: add - IL_000a: ret - } - - .method public hidebysig instance !!T GPick(!!T x, !!T y) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.1 - IL_0001: ret - } - - } - - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceEta@41 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .field public class assembly/C o - .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niInstanceEta@41::o - IL_0007: ldarg.0 - IL_0008: call instance void [runtime]System.Object::.ctor() - IL_000d: ret - } - - .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niInstanceEta@41::o - IL_0006: ldarg.1 - IL_0007: ldarg.2 - IL_0008: tail. - IL_000a: callvirt instance int32 assembly/C::AccC(int32, - int32) - IL_000f: ret - } - - } - - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niGenericInstanceEta@47 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .field public class assembly/C o - .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niGenericInstanceEta@47::o - IL_0007: ldarg.0 - IL_0008: call instance void [runtime]System.Object::.ctor() - IL_000d: ret - } - - .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niGenericInstanceEta@47::o - IL_0006: ldarg.1 - IL_0007: ldarg.2 - IL_0008: callvirt instance !!0 assembly/C::GPick(!!0, - !!0) - IL_000d: ret - } - - } - - .method public static int32 accCurried(int32 x, - int32 y) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: add - IL_0003: ret - } - - .method public static int32 accTupled(int32 x, - int32 y) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: add - IL_0003: ret - } - - .method public static class [runtime]System.Func`3 niNonEta() cil managed - { - - .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn int32 assembly::accCurried(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - - .method public static class [runtime]System.Func`3 niEtaCurried() cil managed - { - - .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn int32 assembly/niEtaCurried@15::Invoke(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - - .method public static class [runtime]System.Func`3 niEtaTupled() cil managed - { - - .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn int32 assembly/niEtaTupled@18::Invoke(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - - .method public static class [runtime]System.Func`3 niStaticNonEta() cil managed - { - - .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn int32 assembly/S::AccS(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - - .method public static class [runtime]System.Func`3 niStaticEta() cil managed - { - - .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn int32 assembly/niStaticEta@28::Invoke(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - - .method public static class [runtime]System.Func`3 niInstanceNonEta(class assembly/C o) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldftn instance int32 assembly/C::AccC(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - - .method public static class [runtime]System.Func`3 niInstanceEta(class assembly/C o) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niInstanceEta@41::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niInstanceEta@41::Invoke(int32, - int32) - IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_0011: ret - } - - .method public static class [runtime]System.Func`3 niGenericInstanceNonEta(class assembly/C o) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldftn instance !!0 assembly/C::GPick(!!0, - !!0) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - - .method public static class [runtime]System.Func`3 niGenericInstanceEta(class assembly/C o) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niGenericInstanceEta@47::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niGenericInstanceEta@47::Invoke(int32, - int32) - IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_0011: ret - } - -} - -.class private abstract auto ansi sealed ''.$assembly - extends [runtime]System.Object -{ - .method public static void main@() cil managed - { - .entrypoint - - .maxstack 8 - IL_0000: ret - } - -} - - - - - - diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.il.bsl deleted file mode 100644 index 7a19b3b9516..00000000000 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOff.il.bsl +++ /dev/null @@ -1,477 +0,0 @@ - - - - - -.assembly extern runtime { } -.assembly extern FSharp.Core { } -.assembly assembly -{ - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, - int32, - int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) - - - - - .hash algorithm 0x00008004 - .ver 0:0:0:0 -} -.module assembly.exe - -.imagebase {value} -.file alignment 0x00000200 -.stackreserve 0x00100000 -.subsystem 0x0003 -.corflags 0x00000001 - - - - - -.class public abstract auto ansi sealed assembly - extends [runtime]System.Object -{ - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niNonEta@12 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 x, - int32 y) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call int32 assembly::accCurried(int32, - int32) - IL_0007: ret - } - - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaCurried@15 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 a, - int32 b) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call int32 assembly::accCurried(int32, - int32) - IL_0007: ret - } - - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaTupled@18 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 a, - int32 b) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call int32 assembly::accTupled(int32, - int32) - IL_0007: ret - } - - } - - .class auto ansi serializable nested public S - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) - .method public static int32 AccS(int32 x, - int32 y) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: add - IL_0003: ret - } - - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticNonEta@25 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 x, - int32 y) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call int32 assembly/S::AccS(int32, - int32) - IL_0007: ret - } - - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticEta@28 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 a, - int32 b) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call int32 assembly/S::AccS(int32, - int32) - IL_0007: ret - } - - } - - .class auto ansi serializable nested public C - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) - .field assembly int32 k - .method public specialname rtspecialname instance void .ctor(int32 k) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: callvirt instance void [runtime]System.Object::.ctor() - IL_0006: ldarg.0 - IL_0007: pop - IL_0008: ldarg.0 - IL_0009: ldarg.1 - IL_000a: stfld int32 assembly/C::k - IL_000f: ret - } - - .method public hidebysig instance int32 AccC(int32 x, int32 y) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.1 - IL_0001: ldarg.2 - IL_0002: add - IL_0003: ldarg.0 - IL_0004: ldfld int32 assembly/C::k - IL_0009: add - IL_000a: ret - } - - .method public hidebysig instance !!T GPick(!!T x, !!T y) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.1 - IL_0001: ret - } - - } - - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceNonEta@38 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .field public class assembly/C o - .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niInstanceNonEta@38::o - IL_0007: ldarg.0 - IL_0008: call instance void [runtime]System.Object::.ctor() - IL_000d: ret - } - - .method assembly hidebysig instance int32 Invoke(int32 delegateArg0, int32 delegateArg1) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niInstanceNonEta@38::o - IL_0006: ldarg.1 - IL_0007: ldarg.2 - IL_0008: tail. - IL_000a: callvirt instance int32 assembly/C::AccC(int32, - int32) - IL_000f: ret - } - - } - - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceEta@41 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .field public class assembly/C o - .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niInstanceEta@41::o - IL_0007: ldarg.0 - IL_0008: call instance void [runtime]System.Object::.ctor() - IL_000d: ret - } - - .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niInstanceEta@41::o - IL_0006: ldarg.1 - IL_0007: ldarg.2 - IL_0008: tail. - IL_000a: callvirt instance int32 assembly/C::AccC(int32, - int32) - IL_000f: ret - } - - } - - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niGenericInstanceNonEta@44 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .field public class assembly/C o - .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niGenericInstanceNonEta@44::o - IL_0007: ldarg.0 - IL_0008: call instance void [runtime]System.Object::.ctor() - IL_000d: ret - } - - .method assembly hidebysig instance int32 Invoke(int32 delegateArg0, int32 delegateArg1) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niGenericInstanceNonEta@44::o - IL_0006: ldarg.1 - IL_0007: ldarg.2 - IL_0008: callvirt instance !!0 assembly/C::GPick(!!0, - !!0) - IL_000d: ret - } - - } - - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niGenericInstanceEta@47 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .field public class assembly/C o - .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niGenericInstanceEta@47::o - IL_0007: ldarg.0 - IL_0008: call instance void [runtime]System.Object::.ctor() - IL_000d: ret - } - - .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niGenericInstanceEta@47::o - IL_0006: ldarg.1 - IL_0007: ldarg.2 - IL_0008: callvirt instance !!0 assembly/C::GPick(!!0, - !!0) - IL_000d: ret - } - - } - - .method public static int32 accCurried(int32 x, - int32 y) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: add - IL_0003: ret - } - - .method public static int32 accTupled(int32 x, - int32 y) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: add - IL_0003: ret - } - - .method public static class [runtime]System.Func`3 niNonEta() cil managed - { - - .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn int32 assembly/niNonEta@12::Invoke(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - - .method public static class [runtime]System.Func`3 niEtaCurried() cil managed - { - - .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn int32 assembly/niEtaCurried@15::Invoke(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - - .method public static class [runtime]System.Func`3 niEtaTupled() cil managed - { - - .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn int32 assembly/niEtaTupled@18::Invoke(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - - .method public static class [runtime]System.Func`3 niStaticNonEta() cil managed - { - - .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn int32 assembly/niStaticNonEta@25::Invoke(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - - .method public static class [runtime]System.Func`3 niStaticEta() cil managed - { - - .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn int32 assembly/niStaticEta@28::Invoke(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - - .method public static class [runtime]System.Func`3 niInstanceNonEta(class assembly/C o) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niInstanceNonEta@38::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niInstanceNonEta@38::Invoke(int32, - int32) - IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_0011: ret - } - - .method public static class [runtime]System.Func`3 niInstanceEta(class assembly/C o) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niInstanceEta@41::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niInstanceEta@41::Invoke(int32, - int32) - IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_0011: ret - } - - .method public static class [runtime]System.Func`3 niGenericInstanceNonEta(class assembly/C o) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niGenericInstanceNonEta@44::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niGenericInstanceNonEta@44::Invoke(int32, - int32) - IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_0011: ret - } - - .method public static class [runtime]System.Func`3 niGenericInstanceEta(class assembly/C o) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niGenericInstanceEta@47::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niGenericInstanceEta@47::Invoke(int32, - int32) - IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_0011: ret - } - -} - -.class private abstract auto ansi sealed ''.$assembly - extends [runtime]System.Object -{ - .method public static void main@() cil managed - { - .entrypoint - - .maxstack 8 - IL_0000: ret - } - -} - - - - - - diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.Preview.il.bsl deleted file mode 100644 index 110adc677fb..00000000000 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.Preview.il.bsl +++ /dev/null @@ -1,253 +0,0 @@ - - - - - -.assembly extern runtime { } -.assembly extern FSharp.Core { } -.assembly assembly -{ - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, - int32, - int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) - - - - - .hash algorithm 0x00008004 - .ver 0:0:0:0 -} -.module assembly.exe - -.imagebase {value} -.file alignment 0x00000200 -.stackreserve 0x00100000 -.subsystem 0x0003 -.corflags 0x00000001 - - - - - -.class public abstract auto ansi sealed assembly - extends [runtime]System.Object -{ - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class auto ansi serializable nested public S - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) - .method public static int32 AccS(int32 x, - int32 y) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: add - IL_0003: ret - } - - } - - .class auto ansi serializable nested public C - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) - .field assembly int32 k - .method public specialname rtspecialname instance void .ctor(int32 k) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: callvirt instance void [runtime]System.Object::.ctor() - IL_0006: ldarg.0 - IL_0007: pop - IL_0008: ldarg.0 - IL_0009: ldarg.1 - IL_000a: stfld int32 assembly/C::k - IL_000f: ret - } - - .method public hidebysig instance int32 AccC(int32 x, int32 y) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.1 - IL_0001: ldarg.2 - IL_0002: add - IL_0003: ldarg.0 - IL_0004: ldfld int32 assembly/C::k - IL_0009: add - IL_000a: ret - } - - .method public hidebysig instance !!T GPick(!!T x, !!T y) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.1 - IL_0001: ret - } - - } - - .method public static int32 accCurried(int32 x, - int32 y) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: add - IL_0003: ret - } - - .method public static int32 accTupled(int32 x, - int32 y) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: add - IL_0003: ret - } - - .method public static class [runtime]System.Func`3 niNonEta() cil managed - { - - .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn int32 assembly::accCurried(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - - .method public static class [runtime]System.Func`3 niEtaCurried() cil managed - { - - .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn int32 assembly::accCurried(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - - .method public static class [runtime]System.Func`3 niEtaTupled() cil managed - { - - .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn int32 assembly::accTupled(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - - .method public static class [runtime]System.Func`3 niStaticNonEta() cil managed - { - - .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn int32 assembly/S::AccS(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - - .method public static class [runtime]System.Func`3 niStaticEta() cil managed - { - - .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn int32 assembly/S::AccS(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - - .method public static class [runtime]System.Func`3 niInstanceNonEta(class assembly/C o) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldftn instance int32 assembly/C::AccC(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - - .method public static class [runtime]System.Func`3 niInstanceEta(class assembly/C o) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldftn instance int32 assembly/C::AccC(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - - .method public static class [runtime]System.Func`3 niGenericInstanceNonEta(class assembly/C o) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldftn instance !!0 assembly/C::GPick(!!0, - !!0) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - - .method public static class [runtime]System.Func`3 niGenericInstanceEta(class assembly/C o) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldftn instance !!0 assembly/C::GPick(!!0, - !!0) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - -} - -.class private abstract auto ansi sealed ''.$assembly - extends [runtime]System.Object -{ - .method public static void main@() cil managed - { - .entrypoint - - .maxstack 8 - IL_0000: ret - } - -} - - - - - - diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.il.bsl deleted file mode 100644 index e8bf92f5780..00000000000 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateNonInlinable.fs.OptimizeOn.il.bsl +++ /dev/null @@ -1,475 +0,0 @@ - - - - - -.assembly extern runtime { } -.assembly extern FSharp.Core { } -.assembly assembly -{ - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, - int32, - int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) - - - - - .hash algorithm 0x00008004 - .ver 0:0:0:0 -} -.module assembly.exe - -.imagebase {value} -.file alignment 0x00000200 -.stackreserve 0x00100000 -.subsystem 0x0003 -.corflags 0x00000001 - - - - - -.class public abstract auto ansi sealed assembly - extends [runtime]System.Object -{ - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niNonEta@12 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 x, - int32 y) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call int32 assembly::accCurried(int32, - int32) - IL_0007: ret - } - - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaCurried@15 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 a, - int32 b) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call int32 assembly::accCurried(int32, - int32) - IL_0007: ret - } - - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niEtaTupled@18 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 a, - int32 b) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call int32 assembly::accTupled(int32, - int32) - IL_0007: ret - } - - } - - .class auto ansi serializable nested public S - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) - .method public static int32 AccS(int32 x, - int32 y) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: add - IL_0003: ret - } - - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticNonEta@25 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 x, - int32 y) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call int32 assembly/S::AccS(int32, - int32) - IL_0007: ret - } - - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname niStaticEta@28 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static int32 Invoke(int32 a, - int32 b) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call int32 assembly/S::AccS(int32, - int32) - IL_0007: ret - } - - } - - .class auto ansi serializable nested public C - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) - .field assembly int32 k - .method public specialname rtspecialname instance void .ctor(int32 k) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: callvirt instance void [runtime]System.Object::.ctor() - IL_0006: ldarg.0 - IL_0007: pop - IL_0008: ldarg.0 - IL_0009: ldarg.1 - IL_000a: stfld int32 assembly/C::k - IL_000f: ret - } - - .method public hidebysig instance int32 AccC(int32 x, int32 y) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.1 - IL_0001: ldarg.2 - IL_0002: add - IL_0003: ldarg.0 - IL_0004: ldfld int32 assembly/C::k - IL_0009: add - IL_000a: ret - } - - .method public hidebysig instance !!T GPick(!!T x, !!T y) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.1 - IL_0001: ret - } - - } - - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceNonEta@38 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .field public class assembly/C o - .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niInstanceNonEta@38::o - IL_0007: ldarg.0 - IL_0008: call instance void [runtime]System.Object::.ctor() - IL_000d: ret - } - - .method assembly hidebysig instance int32 Invoke(int32 delegateArg0, int32 delegateArg1) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niInstanceNonEta@38::o - IL_0006: ldarg.1 - IL_0007: ldarg.2 - IL_0008: callvirt instance int32 assembly/C::AccC(int32, - int32) - IL_000d: ret - } - - } - - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niInstanceEta@41 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .field public class assembly/C o - .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niInstanceEta@41::o - IL_0007: ldarg.0 - IL_0008: call instance void [runtime]System.Object::.ctor() - IL_000d: ret - } - - .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niInstanceEta@41::o - IL_0006: ldarg.1 - IL_0007: ldarg.2 - IL_0008: callvirt instance int32 assembly/C::AccC(int32, - int32) - IL_000d: ret - } - - } - - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niGenericInstanceNonEta@44 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .field public class assembly/C o - .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niGenericInstanceNonEta@44::o - IL_0007: ldarg.0 - IL_0008: call instance void [runtime]System.Object::.ctor() - IL_000d: ret - } - - .method assembly hidebysig instance int32 Invoke(int32 delegateArg0, int32 delegateArg1) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niGenericInstanceNonEta@44::o - IL_0006: ldarg.1 - IL_0007: ldarg.2 - IL_0008: callvirt instance !!0 assembly/C::GPick(!!0, - !!0) - IL_000d: ret - } - - } - - .class auto autochar serializable sealed nested assembly beforefieldinit specialname niGenericInstanceEta@47 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .field public class assembly/C o - .method public specialname rtspecialname instance void .ctor(class assembly/C o) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/niGenericInstanceEta@47::o - IL_0007: ldarg.0 - IL_0008: call instance void [runtime]System.Object::.ctor() - IL_000d: ret - } - - .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/niGenericInstanceEta@47::o - IL_0006: ldarg.1 - IL_0007: ldarg.2 - IL_0008: callvirt instance !!0 assembly/C::GPick(!!0, - !!0) - IL_000d: ret - } - - } - - .method public static int32 accCurried(int32 x, - int32 y) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: add - IL_0003: ret - } - - .method public static int32 accTupled(int32 x, - int32 y) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: add - IL_0003: ret - } - - .method public static class [runtime]System.Func`3 niNonEta() cil managed - { - - .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn int32 assembly/niNonEta@12::Invoke(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - - .method public static class [runtime]System.Func`3 niEtaCurried() cil managed - { - - .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn int32 assembly/niEtaCurried@15::Invoke(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - - .method public static class [runtime]System.Func`3 niEtaTupled() cil managed - { - - .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn int32 assembly/niEtaTupled@18::Invoke(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - - .method public static class [runtime]System.Func`3 niStaticNonEta() cil managed - { - - .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn int32 assembly/niStaticNonEta@25::Invoke(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - - .method public static class [runtime]System.Func`3 niStaticEta() cil managed - { - - .maxstack 8 - IL_0000: ldnull - IL_0001: ldftn int32 assembly/niStaticEta@28::Invoke(int32, - int32) - IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_000c: ret - } - - .method public static class [runtime]System.Func`3 niInstanceNonEta(class assembly/C o) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niInstanceNonEta@38::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niInstanceNonEta@38::Invoke(int32, - int32) - IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_0011: ret - } - - .method public static class [runtime]System.Func`3 niInstanceEta(class assembly/C o) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niInstanceEta@41::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niInstanceEta@41::Invoke(int32, - int32) - IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_0011: ret - } - - .method public static class [runtime]System.Func`3 niGenericInstanceNonEta(class assembly/C o) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niGenericInstanceNonEta@44::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niGenericInstanceNonEta@44::Invoke(int32, - int32) - IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_0011: ret - } - - .method public static class [runtime]System.Func`3 niGenericInstanceEta(class assembly/C o) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/niGenericInstanceEta@47::.ctor(class assembly/C) - IL_0006: ldftn instance int32 assembly/niGenericInstanceEta@47::Invoke(int32, - int32) - IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, - native int) - IL_0011: ret - } - -} - -.class private abstract auto ansi sealed ''.$assembly - extends [runtime]System.Object -{ - .method public static void main@() cil managed - { - .entrypoint - - .maxstack 8 - IL_0000: ret - } - -} - - - - - - diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOn.Preview.il.bsl index 13f63f205dd..8fa5fc34989 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStaticMethod.fs.OptimizeOn.Preview.il.bsl @@ -67,48 +67,6 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case18_nonEta@12 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static void Invoke(int32 x, - int32 y) cil managed - { - - .maxstack 8 - IL_0000: ret - } - - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case2_etaCurried@15 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static void Invoke(int32 a, - int32 b) cil managed - { - - .maxstack 8 - IL_0000: ret - } - - } - - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case32_etaTupled@18 - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .method assembly static void Invoke(int32 a, - int32 b) cil managed - { - - .maxstack 8 - IL_0000: ret - } - - } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname case38_partial@21 extends [runtime]System.Object { @@ -128,8 +86,8 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case18_nonEta@12::Invoke(int32, - int32) + IL_0001: ldftn void assembly/C::AddC(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret @@ -140,8 +98,8 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case2_etaCurried@15::Invoke(int32, - int32) + IL_0001: ldftn void assembly/C::AddC(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret @@ -152,8 +110,8 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/case32_etaTupled@18::Invoke(int32, - int32) + IL_0001: ldftn void assembly/C::AddT(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs index c88a9ada21f..7bed97158ec 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs @@ -4,7 +4,6 @@ open System [] type S = - [] member _.Add (x: int) (y: int) : int = x + y // The target is an instance method on a value type. A delegate's Target is an 'object', so the receiver is diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOff.Preview.il.bsl index 29c8d30ba49..5b9ce3e8a8d 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOff.Preview.il.bsl @@ -148,7 +148,6 @@ .method public hidebysig instance int32 Add(int32 x, int32 y) cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) .maxstack 8 @@ -199,7 +198,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceEta@17 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceEta@16 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -210,7 +209,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld valuetype assembly/S assembly/structInstanceEta@17::s + IL_0002: stfld valuetype assembly/S assembly/structInstanceEta@16::s IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -222,7 +221,7 @@ .maxstack 7 .locals init (valuetype assembly/S V_0) IL_0000: ldarg.0 - IL_0001: ldfld valuetype assembly/S assembly/structInstanceEta@17::s + IL_0001: ldfld valuetype assembly/S assembly/structInstanceEta@16::s IL_0006: stloc.0 IL_0007: ldloca.s V_0 IL_0009: ldarg.1 @@ -252,8 +251,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/structInstanceEta@17::.ctor(valuetype assembly/S) - IL_0006: ldftn instance int32 assembly/structInstanceEta@17::Invoke(int32, + IL_0001: newobj instance void assembly/structInstanceEta@16::.ctor(valuetype assembly/S) + IL_0006: ldftn instance int32 assembly/structInstanceEta@16::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOff.il.bsl index 291dc96be7c..474c9e2b6ad 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOff.il.bsl @@ -148,7 +148,6 @@ .method public hidebysig instance int32 Add(int32 x, int32 y) cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) .maxstack 8 @@ -199,7 +198,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceNonEta@14 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceNonEta@13 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -210,7 +209,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld valuetype assembly/S assembly/structInstanceNonEta@14::s + IL_0002: stfld valuetype assembly/S assembly/structInstanceNonEta@13::s IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -222,7 +221,7 @@ .maxstack 7 .locals init (valuetype assembly/S V_0) IL_0000: ldarg.0 - IL_0001: ldfld valuetype assembly/S assembly/structInstanceNonEta@14::s + IL_0001: ldfld valuetype assembly/S assembly/structInstanceNonEta@13::s IL_0006: stloc.0 IL_0007: ldloca.s V_0 IL_0009: ldarg.1 @@ -234,7 +233,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceEta@17 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceEta@16 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -245,7 +244,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld valuetype assembly/S assembly/structInstanceEta@17::s + IL_0002: stfld valuetype assembly/S assembly/structInstanceEta@16::s IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -257,7 +256,7 @@ .maxstack 7 .locals init (valuetype assembly/S V_0) IL_0000: ldarg.0 - IL_0001: ldfld valuetype assembly/S assembly/structInstanceEta@17::s + IL_0001: ldfld valuetype assembly/S assembly/structInstanceEta@16::s IL_0006: stloc.0 IL_0007: ldloca.s V_0 IL_0009: ldarg.1 @@ -274,8 +273,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/structInstanceNonEta@14::.ctor(valuetype assembly/S) - IL_0006: ldftn instance int32 assembly/structInstanceNonEta@14::Invoke(int32, + IL_0001: newobj instance void assembly/structInstanceNonEta@13::.ctor(valuetype assembly/S) + IL_0006: ldftn instance int32 assembly/structInstanceNonEta@13::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) @@ -287,8 +286,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/structInstanceEta@17::.ctor(valuetype assembly/S) - IL_0006: ldftn instance int32 assembly/structInstanceEta@17::Invoke(int32, + IL_0001: newobj instance void assembly/structInstanceEta@16::.ctor(valuetype assembly/S) + IL_0006: ldftn instance int32 assembly/structInstanceEta@16::Invoke(int32, int32) IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOn.Preview.il.bsl index 05cfb2da6b4..72cbb30bc84 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOn.Preview.il.bsl @@ -131,7 +131,6 @@ .method public hidebysig instance int32 Add(int32 x, int32 y) cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) .maxstack 8 diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOn.il.bsl index f83c608dc89..c00b5018301 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateStructTarget.fs.OptimizeOn.il.bsl @@ -131,7 +131,6 @@ .method public hidebysig instance int32 Add(int32 x, int32 y) cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) .maxstack 8 @@ -172,66 +171,36 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceNonEta@14 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceNonEta@13 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .field public valuetype assembly/S s - .method public specialname rtspecialname instance void .ctor(valuetype assembly/S s) cil managed + .method assembly static int32 Invoke(int32 delegateArg0, + int32 delegateArg1) cil managed { .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld valuetype assembly/S assembly/structInstanceNonEta@14::s - IL_0007: ldarg.0 - IL_0008: call instance void [runtime]System.Object::.ctor() - IL_000d: ret - } - - .method assembly hidebysig instance int32 Invoke(int32 delegateArg0, int32 delegateArg1) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldflda valuetype assembly/S assembly/structInstanceNonEta@14::s - IL_0006: ldarg.1 - IL_0007: ldarg.2 - IL_0008: call instance int32 assembly/S::Add(int32, - int32) - IL_000d: ret + IL_0002: add + IL_0003: ret } } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceEta@17 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname structInstanceEta@16 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .field public valuetype assembly/S s - .method public specialname rtspecialname instance void .ctor(valuetype assembly/S s) cil managed + .method assembly static int32 Invoke(int32 a, + int32 b) cil managed { .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld valuetype assembly/S assembly/structInstanceEta@17::s - IL_0007: ldarg.0 - IL_0008: call instance void [runtime]System.Object::.ctor() - IL_000d: ret - } - - .method assembly hidebysig instance int32 Invoke(int32 a, int32 b) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldflda valuetype assembly/S assembly/structInstanceEta@17::s - IL_0006: ldarg.1 - IL_0007: ldarg.2 - IL_0008: call instance int32 assembly/S::Add(int32, - int32) - IL_000d: ret + IL_0002: add + IL_0003: ret } } @@ -240,26 +209,24 @@ { .maxstack 8 - IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/structInstanceNonEta@14::.ctor(valuetype assembly/S) - IL_0006: ldftn instance int32 assembly/structInstanceNonEta@14::Invoke(int32, - int32) - IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + IL_0000: ldnull + IL_0001: ldftn int32 assembly/structInstanceNonEta@13::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) - IL_0011: ret + IL_000c: ret } .method public static class [runtime]System.Func`3 structInstanceEta(valuetype assembly/S s) cil managed { .maxstack 8 - IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/structInstanceEta@17::.ctor(valuetype assembly/S) - IL_0006: ldftn instance int32 assembly/structInstanceEta@17::Invoke(int32, - int32) - IL_000c: newobj instance void class [runtime]System.Func`3::.ctor(object, + IL_0000: ldnull + IL_0001: ldftn int32 assembly/structInstanceEta@16::Invoke(int32, + int32) + IL_0007: newobj instance void class [runtime]System.Func`3::.ctor(object, native int) - IL_0011: ret + IL_000c: ret } } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs index da6b1ae9203..27c5b27b332 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs @@ -2,11 +2,9 @@ module DelegateUnitArg open System -[] let handler () : unit = () type C() = - [] member _.M () : unit = () // 46. non-eta unit-argument delegate diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOff.Preview.il.bsl index 6e416b73ea9..a6ffdf256a7 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOff.Preview.il.bsl @@ -50,7 +50,6 @@ .method public hidebysig instance void M() cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .maxstack 8 IL_0000: ret @@ -58,7 +57,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitEta@16 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitEta@14 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -73,7 +72,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitInstanceEta@22 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitInstanceEta@20 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -84,7 +83,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/caseUnitInstanceEta@22::c + IL_0002: stfld class assembly/C assembly/caseUnitInstanceEta@20::c IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -95,7 +94,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/caseUnitInstanceEta@22::c + IL_0001: ldfld class assembly/C assembly/caseUnitInstanceEta@20::c IL_0006: callvirt instance void assembly/C::M() IL_000b: nop IL_000c: ret @@ -105,7 +104,6 @@ .method public static void 'handler'() cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .maxstack 8 IL_0000: ret @@ -127,7 +125,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/caseUnitEta@16::Invoke() + IL_0001: ldftn void assembly/caseUnitEta@14::Invoke() IL_0007: newobj instance void [runtime]System.Action::.ctor(object, native int) IL_000c: ret @@ -149,8 +147,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/caseUnitInstanceEta@22::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/caseUnitInstanceEta@22::Invoke() + IL_0001: newobj instance void assembly/caseUnitInstanceEta@20::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/caseUnitInstanceEta@20::Invoke() IL_000c: newobj instance void [runtime]System.Action::.ctor(object, native int) IL_0011: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOff.il.bsl index 840fdad920e..da567add265 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOff.il.bsl @@ -50,7 +50,6 @@ .method public hidebysig instance void M() cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .maxstack 8 IL_0000: ret @@ -58,7 +57,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitNonEta@13 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitNonEta@11 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -73,7 +72,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitEta@16 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitEta@14 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -88,7 +87,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitInstanceNonEta@19 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitInstanceNonEta@17 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -99,7 +98,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/caseUnitInstanceNonEta@19::c + IL_0002: stfld class assembly/C assembly/caseUnitInstanceNonEta@17::c IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -111,7 +110,7 @@ .maxstack 5 .locals init (class assembly/C V_0) IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/caseUnitInstanceNonEta@19::c + IL_0001: ldfld class assembly/C assembly/caseUnitInstanceNonEta@17::c IL_0006: stloc.0 IL_0007: ldloc.0 IL_0008: callvirt instance void assembly/C::M() @@ -121,7 +120,7 @@ } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitInstanceEta@22 + .class auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitInstanceEta@20 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -132,7 +131,7 @@ .maxstack 8 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/caseUnitInstanceEta@22::c + IL_0002: stfld class assembly/C assembly/caseUnitInstanceEta@20::c IL_0007: ldarg.0 IL_0008: call instance void [runtime]System.Object::.ctor() IL_000d: ret @@ -143,7 +142,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/caseUnitInstanceEta@22::c + IL_0001: ldfld class assembly/C assembly/caseUnitInstanceEta@20::c IL_0006: callvirt instance void assembly/C::M() IL_000b: nop IL_000c: ret @@ -153,7 +152,6 @@ .method public static void 'handler'() cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .maxstack 8 IL_0000: ret @@ -164,7 +162,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/caseUnitNonEta@13::Invoke() + IL_0001: ldftn void assembly/caseUnitNonEta@11::Invoke() IL_0007: newobj instance void [runtime]System.Action::.ctor(object, native int) IL_000c: ret @@ -175,7 +173,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/caseUnitEta@16::Invoke() + IL_0001: ldftn void assembly/caseUnitEta@14::Invoke() IL_0007: newobj instance void [runtime]System.Action::.ctor(object, native int) IL_000c: ret @@ -186,8 +184,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/caseUnitInstanceNonEta@19::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/caseUnitInstanceNonEta@19::Invoke() + IL_0001: newobj instance void assembly/caseUnitInstanceNonEta@17::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/caseUnitInstanceNonEta@17::Invoke() IL_000c: newobj instance void [runtime]System.Action::.ctor(object, native int) IL_0011: ret @@ -198,8 +196,8 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/caseUnitInstanceEta@22::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/caseUnitInstanceEta@22::Invoke() + IL_0001: newobj instance void assembly/caseUnitInstanceEta@20::.ctor(class assembly/C) + IL_0006: ldftn instance void assembly/caseUnitInstanceEta@20::Invoke() IL_000c: newobj instance void [runtime]System.Action::.ctor(object, native int) IL_0011: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOn.Preview.il.bsl index cdbc92236f5..2c12314501a 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOn.Preview.il.bsl @@ -50,7 +50,6 @@ .method public hidebysig instance void M() cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .maxstack 8 IL_0000: ret @@ -60,7 +59,6 @@ .method public static void 'handler'() cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .maxstack 8 IL_0000: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOn.il.bsl index 5a5fcf30ef7..9746aa37757 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitArg.fs.OptimizeOn.il.bsl @@ -50,7 +50,6 @@ .method public hidebysig instance void M() cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .maxstack 8 IL_0000: ret @@ -58,7 +57,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitNonEta@13 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitNonEta@11 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -66,14 +65,12 @@ { .maxstack 8 - IL_0000: call void assembly::'handler'() - IL_0005: nop - IL_0006: ret + IL_0000: ret } } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitEta@16 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitEta@14 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -81,76 +78,39 @@ { .maxstack 8 - IL_0000: call void assembly::'handler'() - IL_0005: nop - IL_0006: ret + IL_0000: ret } } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitInstanceNonEta@19 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitInstanceNonEta@17 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .field public class assembly/C c - .method public specialname rtspecialname instance void .ctor(class assembly/C c) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/caseUnitInstanceNonEta@19::c - IL_0007: ldarg.0 - IL_0008: call instance void [runtime]System.Object::.ctor() - IL_000d: ret - } - - .method assembly hidebysig instance void Invoke() cil managed + .method assembly static void Invoke() cil managed { .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/caseUnitInstanceNonEta@19::c - IL_0006: callvirt instance void assembly/C::M() - IL_000b: nop - IL_000c: ret + IL_0000: ret } } - .class auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitInstanceEta@22 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname caseUnitInstanceEta@20 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) - .field public class assembly/C c - .method public specialname rtspecialname instance void .ctor(class assembly/C c) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: stfld class assembly/C assembly/caseUnitInstanceEta@22::c - IL_0007: ldarg.0 - IL_0008: call instance void [runtime]System.Object::.ctor() - IL_000d: ret - } - - .method assembly hidebysig instance void Invoke() cil managed + .method assembly static void Invoke() cil managed { .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldfld class assembly/C assembly/caseUnitInstanceEta@22::c - IL_0006: callvirt instance void assembly/C::M() - IL_000b: nop - IL_000c: ret + IL_0000: ret } } .method public static void 'handler'() cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .maxstack 8 IL_0000: ret @@ -161,7 +121,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/caseUnitNonEta@13::Invoke() + IL_0001: ldftn void assembly/caseUnitNonEta@11::Invoke() IL_0007: newobj instance void [runtime]System.Action::.ctor(object, native int) IL_000c: ret @@ -172,7 +132,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/caseUnitEta@16::Invoke() + IL_0001: ldftn void assembly/caseUnitEta@14::Invoke() IL_0007: newobj instance void [runtime]System.Action::.ctor(object, native int) IL_000c: ret @@ -182,24 +142,22 @@ { .maxstack 8 - IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/caseUnitInstanceNonEta@19::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/caseUnitInstanceNonEta@19::Invoke() - IL_000c: newobj instance void [runtime]System.Action::.ctor(object, + IL_0000: ldnull + IL_0001: ldftn void assembly/caseUnitInstanceNonEta@17::Invoke() + IL_0007: newobj instance void [runtime]System.Action::.ctor(object, native int) - IL_0011: ret + IL_000c: ret } .method public static class [runtime]System.Action caseUnitInstanceEta(class assembly/C c) cil managed { .maxstack 8 - IL_0000: ldarg.0 - IL_0001: newobj instance void assembly/caseUnitInstanceEta@22::.ctor(class assembly/C) - IL_0006: ldftn instance void assembly/caseUnitInstanceEta@22::Invoke() - IL_000c: newobj instance void [runtime]System.Action::.ctor(object, + IL_0000: ldnull + IL_0001: ldftn void assembly/caseUnitInstanceEta@20::Invoke() + IL_0007: newobj instance void [runtime]System.Action::.ctor(object, native int) - IL_0011: ret + IL_000c: ret } } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs index eca9f6e4b1f..ba6da87996a 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs @@ -3,7 +3,6 @@ module DelegateUnitReturn open System // Target returns unit, compiled to void; delegate (Action) returns void. -[] let returnsUnit (x: int) (y: int) : unit = () // 26. non-eta unit-returning member (compiled to void) @@ -16,7 +15,6 @@ type C = // Generic method returning its own type variable; instantiated to unit below. The compiled method // returns the type variable (System.Unit once instantiated), not void - a distinct case from the // void-returning member above. - [] static member Echo<'T>(x: 'T) : 'T = x // Generic return type variable instantiated to unit; the delegate likewise returns unit. diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOff.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOff.Preview.il.bsl index 7f4edf52dfd..2f1068b4215 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOff.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOff.Preview.il.bsl @@ -33,7 +33,7 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidEta@13 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidEta@12 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -58,7 +58,6 @@ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) .method public static !!T Echo(!!T x) cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .maxstack 8 IL_0000: ldarg.0 @@ -67,7 +66,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnEta@27 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnEta@25 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -85,7 +84,6 @@ .method public static void returnsUnit(int32 x, int32 y) cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) .maxstack 8 @@ -109,7 +107,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/voidEta@13::Invoke(int32, + IL_0001: ldftn void assembly/voidEta@12::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -132,7 +130,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnEta@27::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) + IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnEta@25::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, native int) IL_000c: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOff.il.bsl index 5fe407f3027..69a6b147055 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOff.il.bsl @@ -33,7 +33,7 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidNonEta@10 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidNonEta@9 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -52,7 +52,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidEta@13 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidEta@12 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -77,7 +77,6 @@ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) .method public static !!T Echo(!!T x) cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .maxstack 8 IL_0000: ldarg.0 @@ -86,7 +85,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnNonEta@24 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnNonEta@22 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -101,7 +100,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnEta@27 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnEta@25 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -119,7 +118,6 @@ .method public static void returnsUnit(int32 x, int32 y) cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) .maxstack 8 @@ -131,8 +129,8 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/voidNonEta@10::Invoke(int32, - int32) + IL_0001: ldftn void assembly/voidNonEta@9::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret @@ -143,7 +141,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/voidEta@13::Invoke(int32, + IL_0001: ldftn void assembly/voidEta@12::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -155,7 +153,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnNonEta@24::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) + IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnNonEta@22::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, native int) IL_000c: ret @@ -166,7 +164,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnEta@27::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) + IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnEta@25::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, native int) IL_000c: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOn.Preview.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOn.Preview.il.bsl index 2f7c62741e0..a9708f88712 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOn.Preview.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOn.Preview.il.bsl @@ -39,7 +39,6 @@ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) .method public static !!T Echo(!!T x) cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .maxstack 8 IL_0000: ldarg.0 @@ -51,7 +50,6 @@ .method public static void returnsUnit(int32 x, int32 y) cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) .maxstack 8 diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOn.il.bsl index 5fe407f3027..f57b5694074 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DelegateUnitReturn.fs.OptimizeOn.il.bsl @@ -33,7 +33,7 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidNonEta@10 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidNonEta@9 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -42,17 +42,12 @@ { .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call void assembly::returnsUnit(int32, - int32) - IL_0007: nop - IL_0008: ret + IL_0000: ret } } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidEta@13 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname voidEta@12 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -61,12 +56,7 @@ { .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: call void assembly::returnsUnit(int32, - int32) - IL_0007: nop - IL_0008: ret + IL_0000: ret } } @@ -77,7 +67,6 @@ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) .method public static !!T Echo(!!T x) cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .maxstack 8 IL_0000: ldarg.0 @@ -86,7 +75,7 @@ } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnNonEta@24 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnNonEta@22 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -95,13 +84,12 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: call !!0 assembly/C::Echo(!!0) - IL_0006: ret + IL_0001: ret } } - .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnEta@27 + .class abstract auto autochar serializable sealed nested assembly beforefieldinit specialname unitGenericReturnEta@25 extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 06 00 00 00 00 00 ) @@ -110,8 +98,7 @@ .maxstack 8 IL_0000: ldarg.0 - IL_0001: call !!0 assembly/C::Echo(!!0) - IL_0006: ret + IL_0001: ret } } @@ -119,7 +106,6 @@ .method public static void returnsUnit(int32 x, int32 y) cil managed { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.NoCompilerInliningAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) .maxstack 8 @@ -131,8 +117,8 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/voidNonEta@10::Invoke(int32, - int32) + IL_0001: ldftn void assembly/voidNonEta@9::Invoke(int32, + int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) IL_000c: ret @@ -143,7 +129,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn void assembly/voidEta@13::Invoke(int32, + IL_0001: ldftn void assembly/voidEta@12::Invoke(int32, int32) IL_0007: newobj instance void class [runtime]System.Action`2::.ctor(object, native int) @@ -155,7 +141,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnNonEta@24::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) + IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnNonEta@22::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, native int) IL_000c: ret @@ -166,7 +152,7 @@ .maxstack 8 IL_0000: ldnull - IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnEta@27::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) + IL_0001: ldftn class [FSharp.Core]Microsoft.FSharp.Core.Unit assembly/unitGenericReturnEta@25::Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit) IL_0007: newobj instance void class [runtime]System.Func`2::.ctor(object, native int) IL_000c: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs index 5417349e1f4..2dd549f4987 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs @@ -102,14 +102,6 @@ let ``DelegateNegativeCases_fs`` compilation = let ``DelegateNegativeCases_fs preview`` compilation = compilation |> getCompilation |> verifyPreviewCompilation -[] -let ``DelegateNonInlinable_fs`` compilation = - compilation |> getCompilation |> verifyCompilation - -[] -let ``DelegateNonInlinable_fs preview`` compilation = - compilation |> getCompilation |> verifyPreviewCompilation - [] let ``DelegatePartialApplication_fs`` compilation = compilation |> getCompilation |> verifyCompilation @@ -165,11 +157,9 @@ module DirectDelegateExecution open System -[] let add (x: int) (y: int) : int = x + y type G<'U> = - [] static member Pick<'T>(x: 'T) (y: 'T) : 'T = x [] @@ -212,7 +202,6 @@ module ClosureDelegateExecution open System -[] let add (x: int) (y: int) : int = x + y [] @@ -321,11 +310,9 @@ open System type DTupled = delegate of int * int -> int -[] let acc (x: int) (y: int) : int = x + y type C() = - [] member _.M (x: int) (y: int) : int = x * y [] @@ -346,7 +333,7 @@ let main _ = |> compileExeAndRun |> shouldSucceed -// Cases 31-36: a tupled application carries each tupled group as a single tuple node, exactly the shape the +// Cases 31-35: a tupled application carries each tupled group as a single tuple node, exactly the shape the // code generator de-tuples by the target's arity when it emits the call. The recognizer de-tuples the same // way, so a tupled target is as direct-able as its curried counterpart and points at the real method. [] @@ -356,7 +343,6 @@ module TupledDirect open System -[] let accT (x: int, y: int) : int = x + y [] @@ -384,7 +370,6 @@ module PartialClosure open System -[] let add3 (x: int) (y: int) (z: int) : int = x + y + z [] @@ -408,7 +393,6 @@ module PartialDirect open System -[] let prepend (prefix: string) (x: int) (y: int) : string = sprintf "%s%d%d" prefix x y [] @@ -436,11 +420,9 @@ open System let mutable ran = 0 -[] let handler () : unit = ran <- ran + 1 type C() = - [] member _.M () : unit = ran <- ran + 10 [] @@ -482,7 +464,6 @@ open System type S = val V : int new (v: int) = { V = v } - [] member this.AddV (x: int) (y: int) : int = this.V + x + y let makeAdder (s: S) = Func(s.AddV) @@ -515,7 +496,7 @@ type Holder() = class end [] type Extensions = - [] + [] static member Combine (h: Holder, x: int, y: int) : int = x + y [] @@ -545,7 +526,7 @@ open System.Runtime.CompilerServices [] type ListExtensions = - [] + [] static member CountWith<'T> (xs: 'T list, x: int, y: int) : int = List.length xs + x + y [] @@ -586,19 +567,62 @@ let main _ = |> compileExeAndRun |> shouldSucceed +// Case 55: an over-application - the target's *result* consumes the delegate argument(s) - is not a saturated +// call to the target, so it must stay a closure with per-invocation evaluation of the function position. A +// direct delegate here would be doubly wrong: it would point at the wrong method (with an incompatible IL +// return) and would stop re-evaluating the function position on each invocation. +[] +let ``Over-application stays a closure and evaluates per invocation (preview)`` () = + FSharp """ +module OverApplicationClosure + +open System + +let mutable calls = 0 + +let makeHandler (tag: string) : unit -> unit = + calls <- calls + 1 + fun () -> () + +[] +let main _ = + // 'makeHandler "h"' returns the function that consumes the Invoke argument list, so the closure must + // re-evaluate it on every invocation, not bind 'makeHandler' at construction. + let d = Action(makeHandler "h") + if calls <> 0 then failwith "over-application was evaluated at construction" + if d.Method.Name <> "Invoke" then failwithf "expected closure 'Invoke' but got '%s'" d.Method.Name + d.Invoke() + d.Invoke() + if calls <> 2 then failwithf "expected per-invocation evaluation, calls=%d" calls + + // A throwing function position likewise stays a closure and faults at invocation, not construction. + let f = Action(failwith "boom") + if f.Method.Name <> "Invoke" then failwithf "expected closure 'Invoke' but got '%s'" f.Method.Name + + try + f.Invoke() + failwith "expected the lazy 'failwith' to throw on Invoke" + with Failure "boom" -> + () + + 0 + """ + |> withLangVersionPreview + |> withOptions [ "--optimize+" ] + |> compileExeAndRun + |> shouldSucceed + // Cross-assembly targets: the recognizer has no locality guard, so a delegate over an F# function imported // from a *referenced* assembly takes the same FSharpVal direct path (StorageForValRef resolution + method-spec -// build across an assembly boundary) that the same-compiland baseline suite never reaches. The targets are -// [] so cross-assembly inlining cannot dissolve the forwarding call before codegen. +// build across an assembly boundary) that the same-compiland baseline suite never reaches. The optimizer +// preserves the forwarding call from cross-assembly inlining just as it does for local targets. let private crossAssemblyLibrary = FSharp """ module DelegateLib -[] let add (x: int) (y: int) : int = x + y type Calc(k: int) = - [] member _.Scale (x: int) (y: int) : int = (x + y) * k // A small inline function: its body is serialized into the referenced assembly and is always inlined at the @@ -637,8 +661,8 @@ let main _ = |> compileExeAndRun |> shouldSucceed -// An inline target from a referenced assembly is always inlined before the recognizer runs, so the forwarding -// call vanishes and a closure is kept even in release - the deterministic cross-assembly end of the inline-race. +// An 'inline' target from a referenced assembly is always inlined (mandatory inlining takes precedence over +// the forwarding-call preservation), so the forwarding call vanishes and a closure is kept even in release. [] let ``Cross-assembly inline target stays a closure (preview)`` () = FSharp """ @@ -675,7 +699,6 @@ module X = open Microsoft.AspNetCore.Builder open Microsoft.AspNetCore.Http - [] let add (x: int) (y: int) : int = x + y let run () = From f485b2507e673791b731a6b417448d8baaac2e8d Mon Sep 17 00:00:00 2001 From: kerams Date: Thu, 2 Jul 2026 19:13:10 +0200 Subject: [PATCH 15/16] Post merge fixes --- src/Compiler/CodeGen/IlxGen.fs | 24 ++++++++++++++++++--- src/Compiler/Optimize/DelegateForwarding.fs | 24 ++++++++++----------- src/Compiler/Optimize/Optimizer.fs | 10 ++++----- 3 files changed, 38 insertions(+), 20 deletions(-) diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index a12f4b7b823..778f66929ac 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -7589,7 +7589,7 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, // optimized builds, where debuggability is not a concern and the forwarding call survives to here. None else - match classifyForwardingTarget (Optimizer.ExprHasEffect g) g tmvs body with + match classifyForwardingTarget (Optimizer.ExprHasEffect Optimizer.EffectContext.Emit) g tmvs body with | DirectDelegateForwardingTargetCandidate.FSharpVal(vref, valUseFlags, tyargs, leadingArgs) -> match StorageForValRef m vref eenvouter with | Method(valReprInfo, vrefM, mspec, _, _, ctps, _, _, _, _, _, _) -> @@ -7598,7 +7598,16 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, let hasWitnesses = ComputeGenerateWitnesses g eenvouter && not witnessInfos.IsEmpty - match fsharpValDirectlyBindable (Optimizer.ExprHasEffect g) g tmvs leadingArgs vrefM valUseFlags hasWitnesses with + match + fsharpValDirectlyBindable + (Optimizer.ExprHasEffect Optimizer.EffectContext.Emit) + g + tmvs + leadingArgs + vrefM + valUseFlags + hasWitnesses + with | ValueSome(virtualCall, takesInstanceArg) -> let ilTyArgs = GenTypeArgs cenv m eenvouter.tyenv tyargs @@ -7652,7 +7661,16 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, enclTypeInst, methInst, leadingArgs) -> - if ilMethodDirectlyBindable (Optimizer.ExprHasEffect g) g tmvs leadingArgs ilMethRef valUseFlag isCtor then + if + ilMethodDirectlyBindable + (Optimizer.ExprHasEffect Optimizer.EffectContext.Emit) + g + tmvs + leadingArgs + ilMethRef + valUseFlag + isCtor + then let ilEnclArgTys = GenTypeArgs cenv m eenvouter.tyenv enclTypeInst let ilMethArgTys = GenTypeArgs cenv m eenvouter.tyenv methInst let boxity = if isStruct then AsValue else AsObject diff --git a/src/Compiler/Optimize/DelegateForwarding.fs b/src/Compiler/Optimize/DelegateForwarding.fs index 26ed6827151..af75fa9bd7d 100644 --- a/src/Compiler/Optimize/DelegateForwarding.fs +++ b/src/Compiler/Optimize/DelegateForwarding.fs @@ -8,8 +8,8 @@ module internal FSharp.Compiler.DelegateForwarding open Internal.Utilities.Collections -open FSharp.Compiler open FSharp.Compiler.AbstractIL.IL +open FSharp.Compiler.TcGlobals open FSharp.Compiler.TypedTree open FSharp.Compiler.TypedTreeBasics open FSharp.Compiler.TypedTreeOps @@ -135,19 +135,19 @@ let private matchForwarding g (aliases: ValMap) (invokeParams: Val list) ( // and fails the match, conservatively keeping the closure. The downstream bindability checks run on the // resolved (leading) arguments, so a receiver reached through an alias is still checked before being // hoisted. -let rec private stripToForwardingCall (exprHasEffect: Expr -> bool) g (aliases: ValMap) expr = +let rec private stripToForwardingCall exprHasEffect g (aliases: ValMap) expr = match stripDebugPoints expr with - | Expr.Let(TBind(v, rhs, _), inner, _, _) when not (exprHasEffect rhs) -> + | Expr.Let(TBind(v, rhs, _), inner, _, _) when not (exprHasEffect g rhs) -> stripToForwardingCall exprHasEffect g (aliases.Add v rhs) inner | Expr.App(f, fty, tyargs, args, m) as app -> match stripDebugPoints f with // '(let v = e in f2) args': lift the binding off the function position - | Expr.Let(TBind(v, rhs, _), f2, _, _) when not (exprHasEffect rhs) -> + | Expr.Let(TBind(v, rhs, _), f2, _, _) when not (exprHasEffect g rhs) -> stripToForwardingCall exprHasEffect g (aliases.Add v rhs) (Expr.App(f2, fty, tyargs, args, m)) // '(fun v -> body) arg …': beta-reduce by aliasing, one parameter at a time | Expr.Lambda(_, None, None, [ v ], body, _, _) when List.isEmpty tyargs -> match args with - | a :: rest when not (exprHasEffect a) -> + | a :: rest when not (exprHasEffect g a) -> let aliases = aliases.Add v a match rest with @@ -160,7 +160,7 @@ let rec private stripToForwardingCall (exprHasEffect: Expr -> bool) g (aliases: | _ -> app, aliases | e -> e, aliases -let classifyForwardingTarget (exprHasEffect: Expr -> bool) g (invokeParams: Val list) expr = +let classifyForwardingTarget exprHasEffect g (invokeParams: Val list) expr = let call, aliases = stripToForwardingCall exprHasEffect g ValMap.Empty expr match call with @@ -233,12 +233,12 @@ let private receiverNotByref g (leadingArgs: Expr list) = /// every Invoke; evaluating it once instead is observable unless it is side-effect free (a non-mutable /// value, a constant, a pure field read). /// - It must not reference the delegate's own Invoke parameters, which only exist inside the delegee method. -let private receiverBindable (exprHasEffect: Expr -> bool) (invokeParams: Val list) (leadingArgs: Expr list) = +let private receiverBindable exprHasEffect g (invokeParams: Val list) (leadingArgs: Expr list) = match leadingArgs with | [ recv ] -> let recvFreeLocals = (freeInExpr CollectLocals recv).FreeLocals - not (exprHasEffect recv) + not (exprHasEffect g recv) && (not (invokeParams |> List.exists (fun tv -> Zset.contains tv recvFreeLocals))) | _ -> true @@ -249,7 +249,7 @@ let private receiverBindable (exprHasEffect: Expr -> bool) (invokeParams: Val li /// the base-call flag from valUseFlags. When directly bindable, returns the virtual-call and instance-receiver /// facts already derived from the call info, so the caller does not re-derive them. let fsharpValDirectlyBindable - (exprHasEffect: Expr -> bool) + exprHasEffect g (invokeParams: Val list) (leadingArgs: Expr list) @@ -267,7 +267,7 @@ let fsharpValDirectlyBindable && not isSelfInit && not valUseFlags.IsVSlotDirectCall && receiverShapeOk leadingArgs takesInstanceArg - && receiverBindable exprHasEffect invokeParams leadingArgs + && receiverBindable exprHasEffect g invokeParams leadingArgs && staticLeadingArgIsRefType g takesInstanceArg leadingArgs && receiverNotByref g leadingArgs then @@ -281,7 +281,7 @@ let fsharpValDirectlyBindable /// by-value capture. The instance-receiver flag is derived here from ilMethRef and the base/constrained-call /// flags from valUseFlag. let ilMethodDirectlyBindable - (exprHasEffect: Expr -> bool) + exprHasEffect g (invokeParams: Val list) (leadingArgs: Expr list) @@ -295,7 +295,7 @@ let ilMethodDirectlyBindable && not valUseFlag.IsVSlotDirectCall && not valUseFlag.IsPossibleConstrainedCall && receiverShapeOk leadingArgs takesInstanceArg - && receiverBindable exprHasEffect invokeParams leadingArgs + && receiverBindable exprHasEffect g invokeParams leadingArgs && staticLeadingArgIsRefType g takesInstanceArg leadingArgs && receiverNotByref g leadingArgs diff --git a/src/Compiler/Optimize/Optimizer.fs b/src/Compiler/Optimize/Optimizer.fs index 965d005df74..d9d582effde 100644 --- a/src/Compiler/Optimize/Optimizer.fs +++ b/src/Compiler/Optimize/Optimizer.fs @@ -1720,6 +1720,9 @@ and OpHasEffect context g m op tyargs = | TOp.LValueOp _ (* conservative *) | TOp.ValFieldSet _ -> true +let effectContextOf (cenv: cenv) = + if cenv.optimizing then EffectContext.Emit else EffectContext.InlineBody + /// When a delegate construction's Invoke body is a transparent forwarding call that the ILX generator can /// point the delegate directly at (see DelegateForwarding), prevent the optimizer from inlining the target /// into the body: inlining would dissolve the forwarding call before code generation and force the delegate @@ -1740,14 +1743,14 @@ let AddDirectDelegateTargetToDontInlineSet cenv env (slotsig: SlotSig) tmvs body let tmvs, body = BindUnitVars g (tmvs, invokeParamInfos, body) - match classifyForwardingTarget (ExprHasEffect g) g tmvs body with + match classifyForwardingTarget (ExprHasEffect (effectContextOf cenv)) g tmvs body with | DirectDelegateForwardingTargetCandidate.FSharpVal(vref, valUseFlags, _, leadingArgs) when // Only a value compiled as a real method can be pointed at directly (mirrors IlxGen's // Method-storage requirement); local function values keep their inlining. Witness information // is not computable here, so 'false' is passed - over-suppressing for the rare // witness-requiring target only costs a missed inline in a body that stays a closure. vref.ValReprInfo.IsSome - && (fsharpValDirectlyBindable (ExprHasEffect g) g tmvs leadingArgs vref valUseFlags false) + && (fsharpValDirectlyBindable (ExprHasEffect (effectContextOf cenv)) g tmvs leadingArgs vref valUseFlags false) .IsSome -> match (GetInfoForVal cenv env m vref).ValExprInfo with @@ -1758,9 +1761,6 @@ let AddDirectDelegateTargetToDontInlineSet cenv env (slotsig: SlotSig) tmvs body else env -let effectContextOf (cenv: cenv) = - if cenv.optimizing then EffectContext.Emit else EffectContext.InlineBody - let TryEliminateBinding cenv _env bind e2 _m = let g = cenv.g From 2b9d108ceba953d5d1ab77c2fe59f7d39e682901 Mon Sep 17 00:00:00 2001 From: kerams Date: Fri, 3 Jul 2026 18:49:44 +0200 Subject: [PATCH 16/16] Comments --- src/Compiler/CodeGen/IlxGen.fs | 37 ++---- src/Compiler/Optimize/DelegateForwarding.fs | 125 +++++------------- src/Compiler/Optimize/Optimizer.fs | 34 ++--- .../DirectDelegates/DirectDelegates.fs | 67 ++++++++-- 4 files changed, 120 insertions(+), 143 deletions(-) diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index 778f66929ac..b6f488153b8 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -7571,10 +7571,8 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, let tmvs, body = BindUnitVars g (tmvs, invokeParamInfos, body) - // Direct delegate construction: when the delegate body is a saturated, transparent forwarding call to a - // known static method, module-level function, or instance method, point the delegate straight at that - // method instead of generating an intermediate closure class. Anything that does not match exactly - // falls back to the closure path below. + // Point the delegate directly at a recognized transparent-forwarding target instead of generating an + // intermediate closure; anything unmatched falls back to the closure path below. let directDelegateTarget = if not (g.langVersion.SupportsFeature LanguageFeature.DirectDelegateConstruction) then None @@ -7582,11 +7580,8 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, not cenv.options.localOptimizationsEnabled && (etaUnitDelegate || tmvs |> List.exists (fun v -> not v.IsCompilerGenerated)) then - // Eta-expanded delegate in an unoptimized build: the Invoke parameters are the user's own lambda - // variables (or, for a unit-argument eta delegate, an elided unit parameter), so keep the closure - // to preserve the user's lambda for debugging. Non-eta delegates (whose parameters are synthesized - // by BuildNewDelegateExpr) are always made direct; eta-expanded ones are made direct only in - // optimized builds, where debuggability is not a concern and the forwarding call survives to here. + // Keep eta-expanded delegates as closures in unoptimized builds so the user's lambda parameter + // names survive for debugging; non-eta parameters are synthesized, so nothing is lost there. None else match classifyForwardingTarget (Optimizer.ExprHasEffect Optimizer.EffectContext.Emit) g tmvs body with @@ -7682,13 +7677,9 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, else leadingArgs.Length - // Unlike the F# case we cannot compare parameter/return IL types here: the target's - // types come from imported metadata, whose assembly scope refs differ from the - // compiler-generated delegee types (e.g. `System.Int32, System.Runtime` vs the bare - // primary-assembly form), so structural equality reports false negatives for the very - // primitives that always match. The forwarding match already pins the arity, and the - // type checker has verified the call is well-typed, so element compatibility holds by - // construction; an arity check is the sound guard (matching the generic case). + // Imported metadata carries different assembly scope refs than the compiler-generated + // delegee types, so structural IL type comparison reports false negatives even for + // primitives; the arity check is the sound residual guard (the call is already typed). if targetMspec.FormalArgTypes.Length - numBoundLeadingFormals = numDelegeeParams then Some(targetMspec, receiverInfo leadingArgs isVirtual) else @@ -7702,23 +7693,21 @@ and GenDelegateExpr cenv cgbuf eenvouter expr (TObjExprMethod(slotsig, _attribs, | Some(targetMspec, receiverInfo) -> match receiverInfo with | None -> - // Static target: the delegate carries a null receiver. + // Static target: null Target. GenUnit cenv eenvouter m cgbuf CG.EmitInstr cgbuf (pop 0) (Push [ g.ilg.typ_IntPtr ]) (I_ldftn targetMspec) | Some(receiverExpr, isVirtual) -> - // Instance target: evaluate the receiver as the delegate's target object. + // Instance target: the receiver becomes the Target. GenExpr cenv cgbuf eenvouter receiverExpr Continue if targetMspec.DeclaringType.Boxity.IsAsValue then - // Value-type receiver: box a copy so it can be stored as the delegate's 'object' Target. The - // runtime binds the function pointer to the method's unboxing stub, which re-derives the 'this' - // pointer from the box on each invocation. This matches the closure form, which likewise - // captures the struct by value. (Struct instance methods are non-virtual, so isVirtual is - // false here and the ldftn path below is taken.) + // Box a copy as the 'object' Target; invocation reaches 'this' through the runtime's + // unboxing stub, matching the closure's by-value capture. (Struct instance methods are + // non-virtual, so the ldftn path below is taken.) CG.EmitInstr cgbuf (pop 1) (Push [ g.ilg.typ_Object ]) (I_box targetMspec.DeclaringType) if isVirtual then - // dup the receiver and bind the function pointer to its runtime type's override. + // dup the receiver so ldvirtftn can bind its runtime type's override. CG.EmitInstr cgbuf (pop 0) (Push [ targetMspec.DeclaringType ]) AI_dup CG.EmitInstr cgbuf (pop 1) (Push [ g.ilg.typ_IntPtr ]) (I_ldvirtftn targetMspec) else diff --git a/src/Compiler/Optimize/DelegateForwarding.fs b/src/Compiler/Optimize/DelegateForwarding.fs index af75fa9bd7d..c720f9bf1b5 100644 --- a/src/Compiler/Optimize/DelegateForwarding.fs +++ b/src/Compiler/Optimize/DelegateForwarding.fs @@ -36,20 +36,11 @@ let private isUnitValue e = | Expr.Const(Const.Unit, _, _) -> true | _ -> false -// The forwarding call of a *tupled* target carries each tupled argument group as a single tuple node: e.g. for -// `accTupled (x, y)` (a value of arity [2]) the call `accTupled (a, b)` is one `(a, b)` argument, exactly the -// shape BuildFSharpMethodApp produced from the value's arity. The code generator de-tuples these by the value's -// arity when it emits the call, so the compiled target takes the elements as separate IL parameters and is -// perfectly compatible with the delegate (a tupled target is as direct-able as a curried one). Mirror that -// de-tupling here so the forwarding match sees the flattened argument list: expand a tuple-construction argument -// whose size matches its arity group into the group's elements. -// -// The argument-group count must equal the target's arity *exactly*: fewer groups is a partial application of -// a group, and more is an over-application - e.g. 'Action(failwith "x")' eta-expands to '(failwith "x") ()' - -// where the extra trailing arguments are consumed by the target's *result*, not by the target itself, so -// there is no saturated call to point the delegate at. (This also rejects targets with no arity information, -// such as parameters and locals, which have no compiled method form.) A mismatch fails the match and -// conservatively keeps the closure. +// Mirror the code generator's arity-based de-tupling (a tupled argument group is one tuple node in the +// call but separate IL parameters in the compiled target) so the match sees the flattened argument list. +// The group count must equal the target's arity exactly: fewer is a partial application, more an +// over-application whose trailing arguments are consumed by the target's *result*, and a target without +// arity information has no compiled method to point at. let private tryFlattenTupledArgs (vref: ValRef) (args: Expr list) = let arities = (arityOfVal vref.Deref).AritiesOfArgs @@ -64,8 +55,6 @@ let private tryFlattenTupledArgs (vref: ValRef) (args: Expr list) = |> List.concat |> Some -/// Resolve a value reference through the aliases recorded while peeling wrappers off the forwarding -/// call, so the match sees the expression that actually flows into the call. let rec private resolveAliases (aliases: ValMap) e = let e = stripDebugPoints e @@ -76,9 +65,8 @@ let rec private resolveAliases (aliases: ValMap) e = | None -> e | _ -> e -// The trailing arguments of the call must be exactly the delegate's Invoke parameters, forwarded -// verbatim and in order. The remaining leading arguments (e.g. an instance receiver) are resolved -// and returned for the consumer to check and emit. +// Trailing arguments must be the delegate's Invoke parameters, verbatim and in order; the leading rest +// (e.g. an instance receiver) is resolved and returned for the caller to check and emit. let private matchForwarding g (aliases: ValMap) (invokeParams: Val list) (args: Expr list) = let args = args |> List.map (resolveAliases aliases) @@ -102,10 +90,8 @@ let private matchForwarding g (aliases: ValMap) (invokeParams: Val list) ( forwardedArgs invokeParams then - // A value-type receiver is passed to its instance method by address ('&recv'); recover the - // underlying value so it can be boxed and stored as the delegate Target (the unboxing stub - // supplies the 'this' pointer on invocation), then resolve it in case the value was itself - // bound by a peeled binding. + // A struct receiver arrives by address; recover the value so the emit can box it as the + // Target (invocation reaches 'this' through the runtime's unboxing stub). let leadingArgs = leadingArgs |> List.map (fun a -> @@ -119,32 +105,20 @@ let private matchForwarding g (aliases: ValMap) (invokeParams: Val list) ( else None -// The forwarding call may be wrapped in shapes the elaborator and BuildNewDelegateExpr produce before any -// optimizer normalization has run, in any combination: -// - effect-free let-bindings over the call: 'let unitVar = () in …' for the elided unit parameter of a -// zero-parameter Invoke (e.g. System.Action), and 'let v = recv in v.M …' evaluating the receiver of a -// non-eta delegate once; -// - an application of a let-wrapped or immediate lambda: the method-group coercion of a non-eta delegate -// over an instance method ('(let v = recv in fun x y -> v.M x y) p0 p1') and the partial-application -// shells of a curried member call. The optimizer beta-reduces these only while it is already making -// inlining decisions, which is too late for the recognizer run that must precede those decisions; -// - curried applications ('(f p0) p1'), which flatten to a single application. -// Peel them by *aliasing*: each effect-free binding (from a let or a beta-reduced lambda parameter) maps -// the bound value to the expression flowing into it, to be resolved when the arguments are matched. -// Anything not covered (an effectful binding or argument, an exotic function position) is left in place -// and fails the match, conservatively keeping the closure. The downstream bindability checks run on the -// resolved (leading) arguments, so a receiver reached through an alias is still checked before being -// hoisted. +// Peel the wrappers the elaborator and BuildNewDelegateExpr leave around the forwarding call: effect-free +// let-bindings, applications of let-wrapped or immediate lambdas (method-group coercions, the shells of +// curried member calls), and curried application nesting. The optimizer reduces these only while already +// making inlining decisions - too late for a recognizer that must precede them - so peel by aliasing: +// each bound value maps to the expression flowing into it, resolved when the arguments are matched. +// Anything else is left in place and fails the match, conservatively keeping the closure. let rec private stripToForwardingCall exprHasEffect g (aliases: ValMap) expr = match stripDebugPoints expr with | Expr.Let(TBind(v, rhs, _), inner, _, _) when not (exprHasEffect g rhs) -> stripToForwardingCall exprHasEffect g (aliases.Add v rhs) inner | Expr.App(f, fty, tyargs, args, m) as app -> match stripDebugPoints f with - // '(let v = e in f2) args': lift the binding off the function position | Expr.Let(TBind(v, rhs, _), f2, _, _) when not (exprHasEffect g rhs) -> stripToForwardingCall exprHasEffect g (aliases.Add v rhs) (Expr.App(f2, fty, tyargs, args, m)) - // '(fun v -> body) arg …': beta-reduce by aliasing, one parameter at a time | Expr.Lambda(_, None, None, [ v ], body, _, _) when List.isEmpty tyargs -> match args with | a :: rest when not (exprHasEffect g a) -> @@ -154,7 +128,6 @@ let rec private stripToForwardingCall exprHasEffect g (aliases: ValMap) ex | [] -> stripToForwardingCall exprHasEffect g aliases body | _ -> stripToForwardingCall exprHasEffect g aliases (Expr.App(body, tyOfExpr g body, [], rest, m)) | _ -> app, aliases - // '(f2 args2) args': flatten the curried application | Expr.App(f2, f2ty, tyargs2, args2, _) when List.isEmpty tyargs -> stripToForwardingCall exprHasEffect g aliases (Expr.App(f2, f2ty, tyargs2, args2 @ args, m)) | _ -> app, aliases @@ -190,13 +163,9 @@ let classifyForwardingTarget exprHasEffect g (invokeParams: Val list) expr = | None -> DirectDelegateForwardingTargetCandidate.Other | _ -> DirectDelegateForwardingTargetCandidate.Other -/// At most one leading argument can be hoisted to the construction site and stored as the delegate's Target: -/// - for an instance method it is the receiver (not part of the IL signature), and -/// - for a static method it is the first IL parameter, bound via the CLR's "closed over the first argument" -/// delegate mechanism (this is how an extension member's receiver, or a one-argument partial application of -/// a static method / module function, becomes direct). -/// Two or more leading arguments (e.g. a partial application that also fixes a receiver) have no closed -/// direct-delegate form, so they stay a closure. +/// At most one leading argument can become the delegate's Target: the receiver of an instance target, or +/// the first parameter of a static one via the CLR's "closed over the first argument" delegate form +/// (extension-member receivers, one-argument partial applications). More has no closed form. let private receiverShapeOk (leadingArgs: Expr list) takesInstanceArg = if takesInstanceArg then match leadingArgs with @@ -208,31 +177,23 @@ let private receiverShapeOk (leadingArgs: Expr list) takesInstanceArg = | [ _ ] -> true | _ -> false -/// A leading argument of a *static* target is stored as the delegate's Target (typed `object`) and the -/// delegate thunk passes it straight into the method's first by-value parameter with no unboxing. A value-type -/// leading argument therefore has no closed form at all, so it disqualifies the direct form. (This is unlike a -/// value-type *instance* receiver, which is boxed and reached through the method's unboxing stub - see the -/// emit - and so is supported.) Targets with no leading argument, or an instance receiver, are unaffected here. +/// The closed-delegate thunk passes the Target into a static target's first parameter with no unboxing, +/// so a value-type leading argument has no closed form (unlike an instance receiver's unboxing stub). let private staticLeadingArgIsRefType g takesInstanceArg (leadingArgs: Expr list) = match leadingArgs with | [ recv ] when not takesInstanceArg -> not (isStructTy g (tyOfExpr g recv)) | _ -> true -/// A value-type receiver is boxed at the construction site, which needs the receiver as a *value*. A struct -/// receiver is normally taken by address ('&recv'); the recognizer recovers the value from '&localVar', but any -/// other address form (e.g. '&someField') would leave a byref the box cannot consume, so disqualify it and keep -/// the closure. +/// Boxing the receiver needs it as a value: '&localVar' is recovered by the recognizer, but any other +/// address form leaves a byref the box cannot consume. let private receiverNotByref g (leadingArgs: Expr list) = match leadingArgs with | [ recv ] -> not (isByrefTy g (tyOfExpr g recv)) | _ -> true -/// The receiver is hoisted to the delegate-construction site, so a direct delegate is only sound when it can -/// be evaluated there exactly once and as the Target: -/// - A closure built from an explicit eta-lambda (e.g. `fun a -> recv.M a`) re-evaluates the receiver on -/// every Invoke; evaluating it once instead is observable unless it is side-effect free (a non-mutable -/// value, a constant, a pure field read). -/// - It must not reference the delegate's own Invoke parameters, which only exist inside the delegee method. +/// The receiver is evaluated once at the construction site rather than on every Invoke, which is only +/// unobservable when it is effect-free; and it must not reference the Invoke parameters, which exist +/// only inside the delegee. let private receiverBindable exprHasEffect g (invokeParams: Val list) (leadingArgs: Expr list) = match leadingArgs with | [ recv ] -> @@ -242,12 +203,8 @@ let private receiverBindable exprHasEffect g (invokeParams: Val list) (leadingAr && (not (invokeParams |> List.exists (fun tv -> Zset.contains tv recvFreeLocals))) | _ -> true -/// An F# value target can be pointed at directly only when the call needs no witnesses and is not a -/// constructor / base / self-init call, when the receiver shape is right, and when the receiver can be safely -/// hoisted to the construction site. Only the witness fact is passed in (it needs the IlxGen environment); the -/// newobj / super-init / self-init / instance-receiver facts are derived here from the member's call info, and -/// the base-call flag from valUseFlags. When directly bindable, returns the virtual-call and instance-receiver -/// facts already derived from the call info, so the caller does not re-derive them. +/// Returns the virtual-call and instance-receiver facts derived from the member call info when the +/// target is directly bindable. Witnesses are passed in: computing them needs the IlxGen environment. let fsharpValDirectlyBindable exprHasEffect g @@ -275,11 +232,6 @@ let fsharpValDirectlyBindable else ValueNone -/// An IL method target can be pointed at directly only when it is not a constructor / base / constrained call, -/// when the receiver shape is right, and when the receiver can be safely hoisted to the construction site. A -/// value-type instance receiver is boxed at the construction site (see the emit), matching the closure's -/// by-value capture. The instance-receiver flag is derived here from ilMethRef and the base/constrained-call -/// flags from valUseFlag. let ilMethodDirectlyBindable exprHasEffect g @@ -299,22 +251,12 @@ let ilMethodDirectlyBindable && staticLeadingArgIsRefType g takesInstanceArg leadingArgs && receiverNotByref g leadingArgs -/// Confirm the target's IL signature is compatible with the delegate's Invoke. The type checker has already -/// verified the delegate is built from a compatible function shape and the forwarding match pins the arity, -/// so this is the residual check: -/// - parameter *count* matches (essentially a sanity check). Parameter IL *types* are deliberately not -/// compared (hence only the count is taken): a value-type parameter is exact by construction (a -/// widening/boxing argument would not be a verbatim Val and so would not have matched), and for -/// reference-type parameters the CLR's delegate relaxation permits contravariance, so an exact -/// comparison would only produce false negatives. -/// - for a non-generic target, the return type matches exactly. This is the one IL mismatch the recognizer -/// cannot see and the CLR will not relax: notably an F# 'unit' return compiled to 'void' versus a delegate -/// whose Invoke returns 'Unit'. For a generic target the return is written in terms of type variables, so -/// no exact comparison is meaningful. -/// -/// 'numBoundLeadingFormals' is the number of leading IL parameters consumed by a hoisted Target (1 for a -/// static method whose first argument is bound, e.g. an extension receiver; 0 otherwise - an instance -/// receiver is not part of the IL signature), so it is subtracted from the target's formal-argument count. +/// Residual IL compatibility check; the type checker verified the call and the forwarding match pinned +/// the shape. Parameter types are deliberately not compared - value types are exact by construction and +/// reference types may use the CLR's contravariant delegate relaxation - only their count, minus any +/// leading formals consumed by a bound Target. The return type must match exactly for a non-generic +/// target (the CLR does not relax e.g. 'void' against 'Unit'); a generic target's return is written in +/// type variables, where no exact comparison is meaningful. let signatureMatches numBoundLeadingFormals (numDelegeeParams: int) @@ -334,7 +276,6 @@ let signatureMatches arityMatches && returnMatches -/// Package the receiver (if any) with the virtual-call flag for the consumer to emit. let receiverInfo (leadingArgs: Expr list) virtualCall = match leadingArgs with | [ recv ] -> Some(recv, virtualCall) diff --git a/src/Compiler/Optimize/Optimizer.fs b/src/Compiler/Optimize/Optimizer.fs index d9d582effde..1e8afe2fafd 100644 --- a/src/Compiler/Optimize/Optimizer.fs +++ b/src/Compiler/Optimize/Optimizer.fs @@ -1723,12 +1723,10 @@ and OpHasEffect context g m op tyargs = let effectContextOf (cenv: cenv) = if cenv.optimizing then EffectContext.Emit else EffectContext.InlineBody -/// When a delegate construction's Invoke body is a transparent forwarding call that the ILX generator can -/// point the delegate directly at (see DelegateForwarding), prevent the optimizer from inlining the target -/// into the body: inlining would dissolve the forwarding call before code generation and force the delegate -/// back into a closure, making the emitted form depend on the target's size. Only optimizer-chosen inlining -/// is suppressed. Cross-assembly inlining of a target from a referenced assembly's optimization -/// data goes through this same inlining path, so it is suppressed here as well. +/// Prevent the optimizer from inlining a recognized direct-delegate forwarding target into the delegate +/// body: inlining would dissolve the call before IlxGen can point the delegate at it, making the emitted +/// form depend on the target's size (locally, and through a referenced assembly's optimization data). +/// Mandatory inlining of 'inline' values takes precedence via OptimizeVal. let AddDirectDelegateTargetToDontInlineSet cenv env (slotsig: SlotSig) tmvs body m = let g = cenv.g @@ -1737,20 +1735,22 @@ let AddDirectDelegateTargetToDontInlineSet cenv env (slotsig: SlotSig) tmvs body && cenv.optimizing && cenv.settings.InlineLambdas then - // Normalize the Invoke parameters exactly as IlxGen will before it runs the recognizer. - let invokeParamInfos = - List.replicate (List.concat slotsig.FormalParams).Length ValReprInfo.unnamedTopArg1 - - let tmvs, body = BindUnitVars g (tmvs, invokeParamInfos, body) + let exprHasEffect = ExprHasEffect (effectContextOf cenv) + + // Normalize the elided unit parameter of a zero-parameter Invoke (e.g. System.Action) exactly as + // IlxGen will before it runs the recognizer + let tmvs, body = + if slotsig.FormalParams |> List.forall List.isEmpty then + BindUnitVars g (tmvs, [], body) + else + tmvs, body - match classifyForwardingTarget (ExprHasEffect (effectContextOf cenv)) g tmvs body with + match classifyForwardingTarget exprHasEffect g tmvs body with | DirectDelegateForwardingTargetCandidate.FSharpVal(vref, valUseFlags, _, leadingArgs) when - // Only a value compiled as a real method can be pointed at directly (mirrors IlxGen's - // Method-storage requirement); local function values keep their inlining. Witness information - // is not computable here, so 'false' is passed - over-suppressing for the rare - // witness-requiring target only costs a missed inline in a body that stays a closure. + // ValReprInfo.IsSome mirrors IlxGen's Method-storage requirement. Witnesses are not knowable + // here; over-suppressing a witness-requiring target only costs an inline in a closure body. vref.ValReprInfo.IsSome - && (fsharpValDirectlyBindable (ExprHasEffect (effectContextOf cenv)) g tmvs leadingArgs vref valUseFlags false) + && (fsharpValDirectlyBindable exprHasEffect g tmvs leadingArgs vref valUseFlags false) .IsSome -> match (GetInfoForVal cenv env m vref).ValExprInfo with diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs index 2dd549f4987..4b612998927 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DirectDelegates/DirectDelegates.fs @@ -612,10 +612,6 @@ let main _ = |> compileExeAndRun |> shouldSucceed -// Cross-assembly targets: the recognizer has no locality guard, so a delegate over an F# function imported -// from a *referenced* assembly takes the same FSharpVal direct path (StorageForValRef resolution + method-spec -// build across an assembly boundary) that the same-compiland baseline suite never reaches. The optimizer -// preserves the forwarding call from cross-assembly inlining just as it does for local targets. let private crossAssemblyLibrary = FSharp """ module DelegateLib @@ -684,6 +680,57 @@ let main _ = |> compileExeAndRun |> shouldSucceed +// An [] function parameter yields a direct delegate only when full inlining leaves a +// forwarding call to a named method as the delegate body: when the inlined lambda body is arbitrary code +// there is no method to point at, and when either inlining does not happen, the parameter is a first-class +// function value (case 42) - both keep a closure. +[] +let ``InlineIfLambda function parameter keeps a closure unless inlining exposes a forwarding call (preview)`` () = + FSharp """ +module InlineIfLambdaClosure + +open System + +let mutable acc = 0 + +let inline makeAction ([] f: int -> int -> unit) = Action(fun a b -> f a b) + +// Read through a mutable so no inlining step can turn the argument back into a lambda. +let mutable handler : int -> int -> unit = fun a b -> acc <- acc + a * 100 + b + +let bump (a: int) (b: int) : unit = acc <- acc + a * 1000 + b + +[] +let main _ = + // Lambda argument: 'makeAction' and the lambda both inline, leaving inlined code as the delegate body. + let k = 7 + let d = makeAction (fun a b -> acc <- acc + a * 10 + b + k) + d.Invoke(1, 2) + if acc <> 19 then failwithf "lambda: wrong result %d" acc + if d.Method.Name <> "Invoke" then failwithf "lambda: expected closure 'Invoke' but got '%s'" d.Method.Name + + // First-class argument: there is no lambda to inline, so 'f' is a function value. + acc <- 0 + let d2 = makeAction handler + d2.Invoke(1, 2) + if acc <> 102 then failwithf "value: wrong result %d" acc + if d2.Method.Name <> "Invoke" then failwithf "value: expected closure 'Invoke' but got '%s'" d2.Method.Name + + // Forwarding lambda argument: after both inline, the delegate body is a forwarding call to 'bump', + // which the recognizer binds directly. + acc <- 0 + let d3 = makeAction (fun a b -> bump a b) + d3.Invoke(1, 2) + if acc <> 1002 then failwithf "forwarding: wrong result %d" acc + if d3.Method.Name <> "bump" then failwithf "forwarding: expected direct 'bump' but got '%s'" d3.Method.Name + if not (isNull d3.Target) then failwith "forwarding: Target should be null for a static target" + 0 + """ + |> withLangVersionPreview + |> withOptions [ "--optimize+" ] + |> compileExeAndRun + |> shouldSucceed + #if NETCOREAPP [] let ``Minimal API binds a direct delegate handler by parameter name (preview)`` () = @@ -699,7 +746,7 @@ module X = open Microsoft.AspNetCore.Builder open Microsoft.AspNetCore.Http - let add (x: int) (y: int) : int = x + y + let divide (first: int) (second: int) : int = first / second let run () = let port = @@ -712,16 +759,16 @@ module X = let url = sprintf "http://127.0.0.1:%d" port let app = WebApplication.CreateBuilder().Build() - // Route parameters {x}/{y} bind to the handler's parameters by name, which requires delegate.Method to be the - // real 'add' (a direct delegate), not a synthesized closure 'Invoke'. - app.MapGet("/add/{x}/{y}", Func(fun z w -> add z w)) |> ignore + // Route parameters {second}/{first} bind to the handler's parameters by name, which requires delegate.Method to be the + // real 'divide' (a direct delegate), not a synthesized closure 'Invoke'. + app.MapGet("/divide/{second}/{first}", Func(fun z w -> divide z w)) |> ignore app.Urls.Add url app.StartAsync().GetAwaiter().GetResult() try let client = new HttpClient() - let body = client.GetStringAsync(url + "/add/2/3").GetAwaiter().GetResult() - if body.Trim() <> "5" then failwithf "minimal API returned '%s', expected '5'" body + let body = client.GetStringAsync(url + "/divide/2/6").GetAwaiter().GetResult() + if body.Trim() <> "3" then failwithf "minimal API returned '%s', expected '3'" body finally app.StopAsync().GetAwaiter().GetResult()