Skip to content

Commit 6523766

Browse files
dsymeKevinRansom
authored andcommitted
inline raise and others (#3239)
* inline raise and others * Update prim-types.fs * Update prim-types.fsi * update baselines
1 parent 076bd7a commit 6523766

File tree

10 files changed

+511
-813
lines changed

10 files changed

+511
-813
lines changed

src/fsharp/FSharp.Core/prim-types.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3800,7 +3800,7 @@ namespace Microsoft.FSharp.Core
38003800
| _ -> true
38013801

38023802
[<CompiledName("Raise")>]
3803-
let raise (e: exn) = (# "throw" e : 'T #)
3803+
let inline raise (e: exn) = (# "throw" e : 'T #)
38043804

38053805
let Failure message = new System.Exception(message)
38063806

@@ -3834,7 +3834,7 @@ namespace Microsoft.FSharp.Core
38343834
*)
38353835

38363836
[<CompiledName("FailWith")>]
3837-
let failwith message = raise (Failure(message))
3837+
let inline failwith message = raise (Failure(message))
38383838

38393839

38403840
[<CompiledName("InvalidArg")>]
@@ -3860,11 +3860,11 @@ namespace Microsoft.FSharp.Core
38603860

38613861
[<CompiledName("Fst")>]
38623862
[<CodeAnalysis.SuppressMessage("Microsoft.Naming","CA1704:IdentifiersShouldBeSpelledCorrectly")>]
3863-
let fst (a,_) = a
3863+
let inline fst (a,_) = a
38643864

38653865
[<CompiledName("Snd")>]
38663866
[<CodeAnalysis.SuppressMessage("Microsoft.Naming","CA1704:IdentifiersShouldBeSpelledCorrectly")>]
3867-
let snd (_,b) = b
3867+
let inline snd (_,b) = b
38683868

38693869
[<CompiledName("Ignore")>]
38703870
let inline ignore _ = ()

src/fsharp/FSharp.Core/prim-types.fsi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2065,7 +2065,7 @@ namespace Microsoft.FSharp.Core
20652065
/// <param name="exn">The exception to raise.</param>
20662066
/// <returns>The result value.</returns>
20672067
[<CompiledName("Raise")>]
2068-
val raise : exn:System.Exception -> 'T
2068+
val inline raise : exn:System.Exception -> 'T
20692069

20702070
/// <summary>Rethrows an exception. This should only be used when handling an exception</summary>
20712071
/// <returns>The result value.</returns>
@@ -2095,13 +2095,13 @@ namespace Microsoft.FSharp.Core
20952095
/// <param name="tuple">The input tuple.</param>
20962096
/// <returns>The first value.</returns>
20972097
[<CompiledName("Fst")>]
2098-
val fst : tuple:('T1 * 'T2) -> 'T1
2098+
val inline fst : tuple:('T1 * 'T2) -> 'T1
20992099

21002100
/// <summary>Return the second element of a tuple, <c>snd (a,b) = b</c>.</summary>
21012101
/// <param name="tuple">The input tuple.</param>
21022102
/// <returns>The second value.</returns>
21032103
[<CompiledName("Snd")>]
2104-
val snd : tuple:('T1 * 'T2) -> 'T2
2104+
val inline snd : tuple:('T1 * 'T2) -> 'T2
21052105

21062106
/// <summary>Generic comparison.</summary>
21072107
/// <param name="e1">The first value.</param>
@@ -2163,7 +2163,7 @@ namespace Microsoft.FSharp.Core
21632163
/// <param name="message">The exception message.</param>
21642164
/// <returns>The result value.</returns>
21652165
[<CompiledName("FailWith")>]
2166-
val failwith : message:string -> 'T
2166+
val inline failwith : message:string -> 'T
21672167

21682168
/// <summary>Throw a <c>System.ArgumentException</c> exception with
21692169
/// the given argument name and message.</summary>

tests/fsharpqa/Source/CodeGen/EmittedIL/ComputationExpressions/ComputationExpr04.il.bsl

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.81.0
2+
// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0
33
// Copyright (c) Microsoft Corporation. All rights reserved.
44

55

@@ -26,7 +26,7 @@
2626
int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 )
2727

2828
// --- The following custom attribute is added automatically, do not uncomment -------
29-
// .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 00 01 00 00 00 00 )
29+
// .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 01 01 00 00 00 00 )
3030

3131
.hash algorithm 0x00008004
3232
.ver 0:0:0:0
@@ -40,13 +40,13 @@
4040
// Offset: 0x00000218 Length: 0x0000007D
4141
}
4242
.module ComputationExpr04.exe
43-
// MVID: {5775B6C9-366A-E566-A745-0383C9B67557}
43+
// MVID: {594BFA7F-366A-E566-A745-03837FFA4B59}
4444
.imagebase 0x00400000
4545
.file alignment 0x00000200
4646
.stackreserve 0x00100000
4747
.subsystem 0x0003 // WINDOWS_CUI
4848
.corflags 0x00000001 // ILONLY
49-
// Image base: 0x00B80000
49+
// Image base: 0x00300000
5050

5151

5252
// =============== CLASS MEMBERS DECLARATION ===================
@@ -77,33 +77,45 @@
7777
.method public strict virtual instance class [ComputationExprLibrary]Library.Eventually`1<int32>
7878
Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit unitVar) cil managed
7979
{
80-
// Code size 55 (0x37)
80+
// Code size 69 (0x45)
8181
.maxstack 6
82-
.locals init ([0] int32 x)
82+
.locals init ([0] int32 x,
83+
[1] string V_1)
8384
.language '{AB4F38C9-B6E6-43BA-BE3B-58080B2CCCE3}', '{994B45C4-E6E9-11D2-903F-00C04FA302A1}', '{5A869D0B-6611-11D3-BD2A-0000F80849BD}'
8485
.line 7,7 : 13,54 'C:\\GitHub\\dsyme\\visualfsharp\\tests\\fsharpqa\\Source\\CodeGen\\EmittedIL\\ComputationExpressions\\ComputationExpr04.fs'
8586
IL_0000: nop
8687
IL_0001: nop
87-
.line 7,7 : 22,37
88+
.line 7,7 : 22,37 ''
8889
IL_0002: ldstr "hello"
8990
IL_0007: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5<class [FSharp.Core]Microsoft.FSharp.Core.Unit,class [mscorlib]System.IO.TextWriter,class [FSharp.Core]Microsoft.FSharp.Core.Unit,class [FSharp.Core]Microsoft.FSharp.Core.Unit,class [FSharp.Core]Microsoft.FSharp.Core.Unit>::.ctor(string)
9091
IL_000c: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatLine<class [FSharp.Core]Microsoft.FSharp.Core.Unit>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4<!!0,class [mscorlib]System.IO.TextWriter,class [FSharp.Core]Microsoft.FSharp.Core.Unit,class [FSharp.Core]Microsoft.FSharp.Core.Unit>)
9192
IL_0011: pop
92-
.line 7,7 : 39,53
93+
.line 7,7 : 39,53 ''
9394
IL_0012: ldstr "hello"
9495
IL_0017: callvirt instance int32 [mscorlib]System.String::get_Length()
9596
IL_001c: stloc.0
96-
.line 8,8 : 13,28
97+
.line 8,8 : 13,28 ''
9798
IL_001d: ldstr "fail"
98-
IL_0022: call !!0 [FSharp.Core]Microsoft.FSharp.Core.Operators::FailWith<class [FSharp.Core]Microsoft.FSharp.Core.Unit>(string)
99-
IL_0027: pop
100-
.line 9,9 : 13,21
101-
IL_0028: ldarg.0
102-
IL_0029: ldfld class [ComputationExprLibrary]Library.EventuallyBuilder ComputationExpr04/'res4@7-1'::builder@
103-
IL_002e: ldloc.0
104-
IL_002f: tail.
105-
IL_0031: callvirt instance class [ComputationExprLibrary]Library.Eventually`1<!!0> [ComputationExprLibrary]Library.EventuallyBuilder::Return<int32>(!!0)
106-
IL_0036: ret
99+
IL_0022: stloc.1
100+
IL_0023: ldc.i4.0
101+
IL_0024: brfalse.s IL_002e
102+
103+
IL_0026: ldnull
104+
IL_0027: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit
105+
IL_002c: br.s IL_0035
106+
107+
IL_002e: ldloc.1
108+
IL_002f: call class [mscorlib]System.Exception [FSharp.Core]Microsoft.FSharp.Core.Operators::Failure(string)
109+
IL_0034: throw
110+
111+
IL_0035: pop
112+
.line 9,9 : 13,21 ''
113+
IL_0036: ldarg.0
114+
IL_0037: ldfld class [ComputationExprLibrary]Library.EventuallyBuilder ComputationExpr04/'res4@7-1'::builder@
115+
IL_003c: ldloc.0
116+
IL_003d: tail.
117+
IL_003f: callvirt instance class [ComputationExprLibrary]Library.Eventually`1<!!0> [ComputationExprLibrary]Library.EventuallyBuilder::Return<int32>(!!0)
118+
IL_0044: ret
107119
} // end of method 'res4@7-1'::Invoke
108120

109121
} // end of class 'res4@7-1'
@@ -134,22 +146,22 @@
134146
.maxstack 6
135147
.locals init ([0] class [mscorlib]System.Exception V_0,
136148
[1] int32 x)
137-
.line 6,12 : 9,21
149+
.line 6,12 : 9,21 ''
138150
IL_0000: nop
139151
IL_0001: ldarg.1
140152
IL_0002: stloc.0
141-
.line 11,11 : 13,54
153+
.line 11,11 : 13,54 ''
142154
IL_0003: nop
143-
.line 11,11 : 22,37
155+
.line 11,11 : 22,37 ''
144156
IL_0004: ldstr "hello"
145157
IL_0009: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5<class [FSharp.Core]Microsoft.FSharp.Core.Unit,class [mscorlib]System.IO.TextWriter,class [FSharp.Core]Microsoft.FSharp.Core.Unit,class [FSharp.Core]Microsoft.FSharp.Core.Unit,class [FSharp.Core]Microsoft.FSharp.Core.Unit>::.ctor(string)
146158
IL_000e: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatLine<class [FSharp.Core]Microsoft.FSharp.Core.Unit>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4<!!0,class [mscorlib]System.IO.TextWriter,class [FSharp.Core]Microsoft.FSharp.Core.Unit,class [FSharp.Core]Microsoft.FSharp.Core.Unit>)
147159
IL_0013: pop
148-
.line 11,11 : 39,53
160+
.line 11,11 : 39,53 ''
149161
IL_0014: ldstr "hello"
150162
IL_0019: callvirt instance int32 [mscorlib]System.String::get_Length()
151163
IL_001e: stloc.1
152-
.line 12,12 : 13,21
164+
.line 12,12 : 13,21 ''
153165
IL_001f: ldarg.0
154166
IL_0020: ldfld class [ComputationExprLibrary]Library.EventuallyBuilder ComputationExpr04/'res4@6-2'::builder@
155167
IL_0025: ldloc.1
@@ -184,7 +196,7 @@
184196
{
185197
// Code size 48 (0x30)
186198
.maxstack 8
187-
.line 6,6 : 9,12
199+
.line 6,6 : 9,12 ''
188200
IL_0000: nop
189201
IL_0001: ldarg.0
190202
IL_0002: ldfld class [ComputationExprLibrary]Library.EventuallyBuilder ComputationExpr04/res4@6::builder@
@@ -238,7 +250,7 @@
238250
.maxstack 4
239251
.locals init ([0] class [ComputationExprLibrary]Library.Eventually`1<int32> res4,
240252
[1] class [ComputationExprLibrary]Library.EventuallyBuilder builder@)
241-
.line 14,14 : 1,25
253+
.line 14,14 : 1,25 ''
242254
IL_0000: call class [ComputationExprLibrary]Library.EventuallyBuilder [ComputationExprLibrary]Library.TheEventuallyBuilder::get_eventually()
243255
IL_0005: stloc.1
244256
IL_0006: ldloc.1

0 commit comments

Comments
 (0)