Skip to content

inline raise and others #3239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/fsharp/FSharp.Core/prim-types.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3800,7 +3800,7 @@ namespace Microsoft.FSharp.Core
| _ -> true

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

let Failure message = new System.Exception(message)

Expand Down Expand Up @@ -3834,7 +3834,7 @@ namespace Microsoft.FSharp.Core
*)

[<CompiledName("FailWith")>]
let failwith message = raise (Failure(message))
let inline failwith message = raise (Failure(message))


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

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

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

[<CompiledName("Ignore")>]
let inline ignore _ = ()
Expand Down
8 changes: 4 additions & 4 deletions src/fsharp/FSharp.Core/prim-types.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -2065,7 +2065,7 @@ namespace Microsoft.FSharp.Core
/// <param name="exn">The exception to raise.</param>
/// <returns>The result value.</returns>
[<CompiledName("Raise")>]
val raise : exn:System.Exception -> 'T
val inline raise : exn:System.Exception -> 'T

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

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

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

/// <summary>Throw a <c>System.ArgumentException</c> exception with
/// the given argument name and message.</summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.81.0
// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0
// Copyright (c) Microsoft Corporation. All rights reserved.


Expand All @@ -26,7 +26,7 @@
int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 )

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

.hash algorithm 0x00008004
.ver 0:0:0:0
Expand All @@ -40,13 +40,13 @@
// Offset: 0x00000218 Length: 0x0000007D
}
.module ComputationExpr04.exe
// MVID: {5775B6C9-366A-E566-A745-0383C9B67557}
// MVID: {594BFA7F-366A-E566-A745-03837FFA4B59}
.imagebase 0x00400000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY
// Image base: 0x00B80000
// Image base: 0x00300000


// =============== CLASS MEMBERS DECLARATION ===================
Expand Down Expand Up @@ -77,33 +77,45 @@
.method public strict virtual instance class [ComputationExprLibrary]Library.Eventually`1<int32>
Invoke(class [FSharp.Core]Microsoft.FSharp.Core.Unit unitVar) cil managed
{
// Code size 55 (0x37)
// Code size 69 (0x45)
.maxstack 6
.locals init ([0] int32 x)
.locals init ([0] int32 x,
[1] string V_1)
.language '{AB4F38C9-B6E6-43BA-BE3B-58080B2CCCE3}', '{994B45C4-E6E9-11D2-903F-00C04FA302A1}', '{5A869D0B-6611-11D3-BD2A-0000F80849BD}'
.line 7,7 : 13,54 'C:\\GitHub\\dsyme\\visualfsharp\\tests\\fsharpqa\\Source\\CodeGen\\EmittedIL\\ComputationExpressions\\ComputationExpr04.fs'
IL_0000: nop
IL_0001: nop
.line 7,7 : 22,37
.line 7,7 : 22,37 ''
IL_0002: ldstr "hello"
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)
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>)
IL_0011: pop
.line 7,7 : 39,53
.line 7,7 : 39,53 ''
IL_0012: ldstr "hello"
IL_0017: callvirt instance int32 [mscorlib]System.String::get_Length()
IL_001c: stloc.0
.line 8,8 : 13,28
.line 8,8 : 13,28 ''
IL_001d: ldstr "fail"
IL_0022: call !!0 [FSharp.Core]Microsoft.FSharp.Core.Operators::FailWith<class [FSharp.Core]Microsoft.FSharp.Core.Unit>(string)
IL_0027: pop
.line 9,9 : 13,21
IL_0028: ldarg.0
IL_0029: ldfld class [ComputationExprLibrary]Library.EventuallyBuilder ComputationExpr04/'res4@7-1'::builder@
IL_002e: ldloc.0
IL_002f: tail.
IL_0031: callvirt instance class [ComputationExprLibrary]Library.Eventually`1<!!0> [ComputationExprLibrary]Library.EventuallyBuilder::Return<int32>(!!0)
IL_0036: ret
IL_0022: stloc.1
IL_0023: ldc.i4.0
IL_0024: brfalse.s IL_002e

IL_0026: ldnull
IL_0027: unbox.any [FSharp.Core]Microsoft.FSharp.Core.Unit
IL_002c: br.s IL_0035

IL_002e: ldloc.1
IL_002f: call class [mscorlib]System.Exception [FSharp.Core]Microsoft.FSharp.Core.Operators::Failure(string)
IL_0034: throw

IL_0035: pop
.line 9,9 : 13,21 ''
IL_0036: ldarg.0
IL_0037: ldfld class [ComputationExprLibrary]Library.EventuallyBuilder ComputationExpr04/'res4@7-1'::builder@
IL_003c: ldloc.0
IL_003d: tail.
IL_003f: callvirt instance class [ComputationExprLibrary]Library.Eventually`1<!!0> [ComputationExprLibrary]Library.EventuallyBuilder::Return<int32>(!!0)
IL_0044: ret
} // end of method 'res4@7-1'::Invoke

} // end of class 'res4@7-1'
Expand Down Expand Up @@ -134,22 +146,22 @@
.maxstack 6
.locals init ([0] class [mscorlib]System.Exception V_0,
[1] int32 x)
.line 6,12 : 9,21
.line 6,12 : 9,21 ''
IL_0000: nop
IL_0001: ldarg.1
IL_0002: stloc.0
.line 11,11 : 13,54
.line 11,11 : 13,54 ''
IL_0003: nop
.line 11,11 : 22,37
.line 11,11 : 22,37 ''
IL_0004: ldstr "hello"
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)
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>)
IL_0013: pop
.line 11,11 : 39,53
.line 11,11 : 39,53 ''
IL_0014: ldstr "hello"
IL_0019: callvirt instance int32 [mscorlib]System.String::get_Length()
IL_001e: stloc.1
.line 12,12 : 13,21
.line 12,12 : 13,21 ''
IL_001f: ldarg.0
IL_0020: ldfld class [ComputationExprLibrary]Library.EventuallyBuilder ComputationExpr04/'res4@6-2'::builder@
IL_0025: ldloc.1
Expand Down Expand Up @@ -184,7 +196,7 @@
{
// Code size 48 (0x30)
.maxstack 8
.line 6,6 : 9,12
.line 6,6 : 9,12 ''
IL_0000: nop
IL_0001: ldarg.0
IL_0002: ldfld class [ComputationExprLibrary]Library.EventuallyBuilder ComputationExpr04/res4@6::builder@
Expand Down Expand Up @@ -238,7 +250,7 @@
.maxstack 4
.locals init ([0] class [ComputationExprLibrary]Library.Eventually`1<int32> res4,
[1] class [ComputationExprLibrary]Library.EventuallyBuilder builder@)
.line 14,14 : 1,25
.line 14,14 : 1,25 ''
IL_0000: call class [ComputationExprLibrary]Library.EventuallyBuilder [ComputationExprLibrary]Library.TheEventuallyBuilder::get_eventually()
IL_0005: stloc.1
IL_0006: ldloc.1
Expand Down
Loading