Skip to content

Commit

Permalink
fix and tests for #122 - no .volatile emitted on stfld
Browse files Browse the repository at this point in the history
fixes #122
closes #144

commit f138b61
Author: Don Syme <dsyme@microsoft.com>
Date:   Thu Jan 29 12:19:37 2015 +0000

    enable codegen as smoke tests

commit 20b1e81
Author: Don Syme <dsyme@microsoft.com>
Date:   Thu Jan 29 12:18:26 2015 +0000

    update baselines for tests

commit b43c327
Merge: 4a83340 d17d429
Author: Don Syme <dsyme@microsoft.com>
Date:   Thu Jan 29 11:59:17 2015 +0000

    Merge branch 'fsharp4' of http://github.com/Microsoft/visualfsharp into fix-122

commit 4a83340
Author: Don Syme <dsyme@microsoft.com>
Date:   Thu Jan 29 10:17:43 2015 +0000

    NOP commit to run appveyor

commit 2fb9f57
Author: Don Syme <dsyme@microsoft.com>
Date:   Tue Jan 27 17:44:49 2015 +0000

    fix and tests for #122 - no .volatile emitted on stfld
  • Loading branch information
dsyme authored and latkin committed Jan 30, 2015
1 parent 22fc2c7 commit 7b1d896
Show file tree
Hide file tree
Showing 8 changed files with 336 additions and 72 deletions.
9 changes: 3 additions & 6 deletions src/fsharp/ilxgen.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2232,14 +2232,11 @@ and GenFieldStore isStatic cenv cgbuf eenv (rfref:RecdFieldRef,tyargs,m) sequel
if fld.IsMutable && not (useGenuineField rfref.Tycon fld) then
let cconv = if isStatic then ILCallingConv.Static else ILCallingConv.Instance
let mspec = mkILMethSpecInTy (fspec.EnclosingType, cconv, "set_" + fld.rfield_id.idText, [fspec.FormalType],ILType.Void,[])

CG.EmitInstr cgbuf (mk_field_pops isStatic 1) Push0 (mkNormalCall mspec)
else
// Within assemblies we do generate some set-field operations
// for immutable fields even when resolving recursive bindings.
// However we do not generate "set" properties for these.
// Hence we just set the field directly in this case.
CG.EmitInstr cgbuf (mk_field_pops isStatic 1) Push0 (if isStatic then mkNormalStsfld fspec else mkNormalStfld fspec);
let vol = if rfref.RecdField.IsVolatile then Volatile else Nonvolatile
let instr = if isStatic then I_stsfld (vol, fspec) else I_stfld (ILAlignment.Aligned, vol, fspec)
CG.EmitInstr cgbuf (mk_field_pops isStatic 1) Push0 instr;
GenUnitThenSequel cenv eenv m eenv.cloc cgbuf sequel

//--------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

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


Expand All @@ -13,7 +13,7 @@
.assembly extern FSharp.Core
{
.publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) // .?_....:
.ver 4:0:0:0
.ver 4:4:0:9055
}
.assembly GenericTypeStaticField01
{
Expand All @@ -29,20 +29,20 @@
}
.mresource public FSharpSignatureData.GenericTypeStaticField01
{
// Offset: 0x00000000 Length: 0x0000062C
// Offset: 0x00000000 Length: 0x00000608
}
.mresource public FSharpOptimizationData.GenericTypeStaticField01
{
// Offset: 0x00000630 Length: 0x000001F9
// Offset: 0x00000610 Length: 0x000001E7
}
.module GenericTypeStaticField01.exe
// MVID: {4DAC0E02-1E75-7E6B-A745-0383020EAC4D}
// MVID: {54CA24D1-1E75-7E6B-A745-0383D124CA54}
.imagebase 0x00400000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY
// Image base: 0x0000000000550000
// Image base: 0x00460000


// =============== CLASS MEMBERS DECLARATION ===================
Expand All @@ -63,7 +63,7 @@
// Code size 10 (0xa)
.maxstack 8
.language '{AB4F38C9-B6E6-43BA-BE3B-58080B2CCCE3}', '{994B45C4-E6E9-11D2-903F-00C04FA302A1}', '{5A869D0B-6611-11D3-BD2A-0000F80849BD}'
.line 2,2 : 6,9
.line 2,2 : 6,9 'C:\\GitHub\\dsyme\\visualfsharp\\tests\\fsharpqa\\Source\\CodeGen\\EmittedIL\\Misc\\GenericTypeStaticField01.fs'
IL_0000: ldarg.0
IL_0001: callvirt instance void [mscorlib]System.Object::.ctor()
IL_0006: ldarg.0
Expand All @@ -75,24 +75,25 @@
.method private specialname rtspecialname static
void .cctor() cil managed
{
// Code size 18 (0x12)
// Code size 20 (0x14)
.maxstack 8
.line 3,3 : 10,41
.line 3,3 : 10,41 ''
IL_0000: nop
IL_0001: newobj instance void class GenericTypeStaticField01/Foo`1<!a>::.ctor()
IL_0006: stsfld class GenericTypeStaticField01/Foo`1<!0> class GenericTypeStaticField01/Foo`1<!a>::theInstance
IL_000b: ldc.i4.1
IL_000c: stsfld int32 class GenericTypeStaticField01/Foo`1<!a>::init@2
.line 2,2 : 6,9
IL_0011: ret
IL_000c: volatile.
IL_000e: stsfld int32 class GenericTypeStaticField01/Foo`1<!a>::init@2
.line 2,2 : 6,9 ''
IL_0013: ret
} // end of method Foo`1::.cctor

.method public specialname static class GenericTypeStaticField01/Foo`1<!a>
get_Instance() cil managed
{
// Code size 27 (0x1b)
.maxstack 8
.line 4,4 : 28,39
.line 4,4 : 28,39 ''
IL_0000: volatile.
IL_0002: ldsfld int32 class GenericTypeStaticField01/Foo`1<!a>::init@2
IL_0007: ldc.i4.1
Expand Down Expand Up @@ -127,7 +128,7 @@
{
// Code size 10 (0xa)
.maxstack 8
.line 6,6 : 6,9
.line 6,6 : 6,9 ''
IL_0000: ldarg.0
IL_0001: callvirt instance void [mscorlib]System.Object::.ctor()
IL_0006: ldarg.0
Expand All @@ -139,24 +140,25 @@
.method private specialname rtspecialname static
void .cctor() cil managed
{
// Code size 18 (0x12)
// Code size 20 (0x14)
.maxstack 8
.line 7,7 : 10,44
.line 7,7 : 10,44 ''
IL_0000: nop
IL_0001: newobj instance void class GenericTypeStaticField01/Bar`2<!a,!b>::.ctor()
IL_0006: stsfld class GenericTypeStaticField01/Bar`2<!0,!1> class GenericTypeStaticField01/Bar`2<!a,!b>::theInstance
IL_000b: ldc.i4.1
IL_000c: stsfld int32 class GenericTypeStaticField01/Bar`2<!a,!b>::'init@6-1'
.line 6,6 : 6,9
IL_0011: ret
IL_000c: volatile.
IL_000e: stsfld int32 class GenericTypeStaticField01/Bar`2<!a,!b>::'init@6-1'
.line 6,6 : 6,9 ''
IL_0013: ret
} // end of method Bar`2::.cctor

.method public specialname static class GenericTypeStaticField01/Bar`2<!a,!b>
get_Instance() cil managed
{
// Code size 27 (0x1b)
.maxstack 8
.line 8,8 : 28,39
.line 8,8 : 28,39 ''
IL_0000: volatile.
IL_0002: ldsfld int32 class GenericTypeStaticField01/Bar`2<!a,!b>::'init@6-1'
IL_0007: ldc.i4.1
Expand Down
13 changes: 13 additions & 0 deletions tests/fsharpqa/Source/CodeGen/EmittedIL/Mutation/Mutation05.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// #Regression #NoMono #NoMT #CodeGen #EmittedIL
type C() =
[<VolatileFieldAttribute>]
let mutable x = 1

member this.X with get() = x and set v = x <- v


type StaticC() =
[<VolatileFieldAttribute>]
static let mutable x = 1

static member X with get() = x and set v = x <- v
Loading

0 comments on commit 7b1d896

Please sign in to comment.