Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2fb9f57

Browse files
committed
fix and tests fordotnet#122 - no .volatile emitted on stfld
1 parent742c133 commit2fb9f57

File tree

5 files changed

+267
-7
lines changed

5 files changed

+267
-7
lines changed

‎src/fsharp/ilxgen.fs‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2232,14 +2232,11 @@ and GenFieldStore isStatic cenv cgbuf eenv (rfref:RecdFieldRef,tyargs,m) sequel
22322232
if fld.IsMutable&&not(useGenuineField rfref.Tycon fld)then
22332233
letcconv=if isStaticthen ILCallingConv.Staticelse ILCallingConv.Instance
22342234
letmspec= mkILMethSpecInTy(fspec.EnclosingType, cconv,"set_"+ fld.rfield_id.idText,[fspec.FormalType],ILType.Void,[])
2235-
22362235
CG.EmitInstr cgbuf(mk_field_pops isStatic1) Push0(mkNormalCall mspec)
22372236
else
2238-
// Within assemblies we do generate some set-field operations
2239-
// for immutable fields even when resolving recursive bindings.
2240-
// However we do not generate "set" properties for these.
2241-
// Hence we just set the field directly in this case.
2242-
CG.EmitInstr cgbuf(mk_field_pops isStatic1) Push0(if isStaticthen mkNormalStsfld fspecelse mkNormalStfld fspec);
2237+
letvol=if rfref.RecdField.IsVolatilethen Volatileelse Nonvolatile
2238+
letinstr=if isStaticthen I_stsfld(vol, fspec)else I_stfld(ILAlignment.Aligned, vol, fspec)
2239+
CG.EmitInstr cgbuf(mk_field_pops isStatic1) Push0 instr;
22432240
GenUnitThenSequel cenv eenv m eenv.cloc cgbuf sequel
22442241

22452242
//--------------------------------------------------------------------------
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// #Regression #NoMono #NoMT #CodeGen #EmittedIL
2+
typeC()=
3+
[<VolatileFieldAttribute>]
4+
let mutablex=1
5+
6+
memberthis.Xwith get()= xandset v= x<- v
7+
8+
9+
typeStaticC()=
10+
[<VolatileFieldAttribute>]
11+
static let mutablex=1
12+
13+
static memberXwith get()= xandset v= x<- v
Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
2+
// Microsoft (R) .NET Framework IL Disassembler. Version 4.0.30319.33440
3+
// Copyright (c) Microsoft Corporation. All rights reserved.
4+
5+
6+
7+
// Metadata version: v4.0.30319
8+
.assembly extern mscorlib
9+
{
10+
.publickeytoken= (B7 7A 5C561934 E089 )// .z\V.4..
11+
.ver4:0:0:0
12+
}
13+
.assembly extern FSharp.Core
14+
{
15+
.publickeytoken= (B0 3F 5F 7F11 D5 0A 3A )// .?_....:
16+
.ver4:4:0:9055
17+
}
18+
.assembly Mutation05
19+
{
20+
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32,
21+
int32,
22+
int32)= (01000200000000000000000000000000 )
23+
24+
// --- The following custom attribute is added automatically, do not uncomment -------
25+
// .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 01 01 00 00 00 00 )
26+
27+
.hash algorithm 0x00008004
28+
.ver0:0:0:0
29+
}
30+
.mresource public FSharpSignatureData.Mutation05
31+
{
32+
// Offset: 0x00000000 Length: 0x000004C6
33+
}
34+
.mresource public FSharpOptimizationData.Mutation05
35+
{
36+
// Offset: 0x000004D0 Length: 0x00000127
37+
}
38+
.module Mutation05.exe
39+
// MVID: {54C7CE57-8C6A-2E22-A745-038357CEC754}
40+
.imagebase 0x00400000
41+
.file alignment 0x00000200
42+
.stackreserve 0x00100000
43+
.subsystem 0x0003// WINDOWS_CUI
44+
.corflags 0x00000001// ILONLY
45+
// Image base: 0x001E0000
46+
47+
48+
// =============== CLASS MEMBERS DECLARATION ===================
49+
50+
.class public abstract auto ansi sealed Mutation05
51+
extends [mscorlib]System.Object
52+
{
53+
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags)= (0100070000000000 )
54+
.class auto ansi serializable nested public C
55+
extends [mscorlib]System.Object
56+
{
57+
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags)= (0100030000000000 )
58+
.field assembly int32 x
59+
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.VolatileFieldAttribute::.ctor()= (01000000 )
60+
.method public specialname rtspecialname
61+
instance void .ctor() cil managed
62+
{
63+
// Code size 19 (0x13)
64+
.maxstack8
65+
.language '{AB4F38C9-B6E6-43BA-BE3B-58080B2CCCE3}', '{994B45C4-E6E9-11D2-903F-00C04FA302A1}', '{5A869D0B-6611-11D3-BD2A-0000F80849BD}'
66+
.line4,4 :5,22 'C:\\GitHub\\dsyme\\visualfsharp\\tests\\fsharpqa\\Source\\CodeGen\\EmittedIL\\Mutation\\Mutation05.fs'
67+
IL_0000: ldarg.0
68+
IL_0001: callvirt instance void [mscorlib]System.Object::.ctor()
69+
IL_0006: ldarg.0
70+
IL_0007: pop
71+
IL_0008: nop
72+
IL_0009: ldarg.0
73+
IL_000a: ldc.i4.1
74+
IL_000b: volatile.
75+
IL_000d: stfld int32 Mutation05/C::x
76+
.line2,2 :6,7 ''
77+
IL_0012: ret
78+
}// end of method C::.ctor
79+
80+
.method public hidebysig specialname
81+
instance int32 get_X() cil managed
82+
{
83+
// Code size 10 (0xa)
84+
.maxstack8
85+
.line6,6 :32,33 ''
86+
IL_0000: nop
87+
IL_0001: ldarg.0
88+
IL_0002: volatile.
89+
IL_0004: ldfld int32 Mutation05/C::x
90+
IL_0009: ret
91+
}// end of method C::get_X
92+
93+
.method public hidebysig specialname
94+
instance void set_X(int32 v) cil managed
95+
{
96+
// Code size 11 (0xb)
97+
.maxstack8
98+
.line6,6 :46,52 ''
99+
IL_0000: nop
100+
IL_0001: ldarg.0
101+
IL_0002: ldarg.1
102+
IL_0003: volatile.
103+
IL_0005: stfld int32 Mutation05/C::x
104+
IL_000a: ret
105+
}// end of method C::set_X
106+
107+
.property instance int32 X()
108+
{
109+
.set instance void Mutation05/C::set_X(int32)
110+
.get instance int32 Mutation05/C::get_X()
111+
}// end of property C::X
112+
}// end of class C
113+
114+
.class auto ansi serializable nested public StaticC
115+
extends [mscorlib]System.Object
116+
{
117+
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags)= (0100030000000000 )
118+
.field static assembly int32 x
119+
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.VolatileFieldAttribute::.ctor()= (01000000 )
120+
.field static assembly int32 init@9
121+
.method public specialname rtspecialname
122+
instance void .ctor() cil managed
123+
{
124+
// Code size 10 (0xa)
125+
.maxstack8
126+
.line9,9 :6,13 ''
127+
IL_0000: ldarg.0
128+
IL_0001: callvirt instance void [mscorlib]System.Object::.ctor()
129+
IL_0006: ldarg.0
130+
IL_0007: pop
131+
IL_0008: nop
132+
IL_0009: ret
133+
}// end of method StaticC::.ctor
134+
135+
.method public specialname static int32
136+
get_X() cil managed
137+
{
138+
// Code size 33 (0x21)
139+
.maxstack8
140+
.line13,13 :34,35 ''
141+
IL_0000: volatile.
142+
IL_0002: ldsfld int32 Mutation05/StaticC::init@9
143+
IL_0007: ldc.i4.1
144+
IL_0008: bge.s IL_000c
145+
146+
IL_000a: br.s IL_000e
147+
148+
IL_000c: br.s IL_0017
149+
150+
.line100001,100001 :0,0 ''
151+
IL_000e: call void [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives/IntrinsicFunctions::FailStaticInit()
152+
IL_0013: nop
153+
.line100001,100001 :0,0 ''
154+
IL_0014: nop
155+
IL_0015: br.s IL_0018
156+
157+
.line100001,100001 :0,0 ''
158+
.line100001,100001 :0,0 ''
159+
IL_0017: nop
160+
IL_0018: nop
161+
IL_0019: volatile.
162+
IL_001b: ldsfld int32 Mutation05/StaticC::x
163+
IL_0020: ret
164+
}// end of method StaticC::get_X
165+
166+
.method public specialname static void
167+
set_X(int32 v) cil managed
168+
{
169+
// Code size 34 (0x22)
170+
.maxstack8
171+
.line13,13 :48,54 ''
172+
IL_0000: volatile.
173+
IL_0002: ldsfld int32 Mutation05/StaticC::init@9
174+
IL_0007: ldc.i4.1
175+
IL_0008: bge.s IL_000c
176+
177+
IL_000a: br.s IL_000e
178+
179+
IL_000c: br.s IL_0017
180+
181+
.line100001,100001 :0,0 ''
182+
IL_000e: call void [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives/IntrinsicFunctions::FailStaticInit()
183+
IL_0013: nop
184+
.line100001,100001 :0,0 ''
185+
IL_0014: nop
186+
IL_0015: br.s IL_0018
187+
188+
.line100001,100001 :0,0 ''
189+
.line100001,100001 :0,0 ''
190+
IL_0017: nop
191+
IL_0018: nop
192+
IL_0019: ldarg.0
193+
IL_001a: volatile.
194+
IL_001c: stsfld int32 Mutation05/StaticC::x
195+
IL_0021: ret
196+
}// end of method StaticC::set_X
197+
198+
.method private specialname rtspecialname static
199+
void .cctor() cil managed
200+
{
201+
// Code size 13 (0xd)
202+
.maxstack8
203+
.line100001,100001 :0,0 ''
204+
IL_0000: ldc.i4.0
205+
IL_0001: stsfld int32 '<StartupCode$Mutation05>'.$Mutation05::init@
206+
IL_0006: ldsfld int32 '<StartupCode$Mutation05>'.$Mutation05::init@
207+
IL_000b: pop
208+
IL_000c: ret
209+
}// end of method StaticC::.cctor
210+
211+
.property int32 X()
212+
{
213+
.set void Mutation05/StaticC::set_X(int32)
214+
.get int32 Mutation05/StaticC::get_X()
215+
}// end of property StaticC::X
216+
}// end of class StaticC
217+
218+
}// end of class Mutation05
219+
220+
.class private abstract auto ansi sealed '<StartupCode$Mutation05>'.$Mutation05
221+
extends [mscorlib]System.Object
222+
{
223+
.field static assembly int32 init@
224+
.custom instance void [mscorlib]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggerBrowsableState)= (0100000000000000 )
225+
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor()= (01000000 )
226+
.custom instance void [mscorlib]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor()= (01000000 )
227+
.method public static void main@() cil managed
228+
{
229+
.entrypoint
230+
// Code size 18 (0x12)
231+
.maxstack8
232+
.line11,11 :12,29 ''
233+
IL_0000: nop
234+
IL_0001: ldc.i4.1
235+
IL_0002: volatile.
236+
IL_0004: stsfld int32 Mutation05/StaticC::x
237+
IL_0009: ldc.i4.1
238+
IL_000a: volatile.
239+
IL_000c: stsfld int32 Mutation05/StaticC::init@9
240+
.line9,9 :6,13 ''
241+
IL_0011: ret
242+
}// end of method $Mutation05::main@
243+
244+
}// end of class '<StartupCode$Mutation05>'.$Mutation05
245+
246+
247+
// =============================================================
248+
249+
// *********** DISASSEMBLY COMPLETE ***********************

‎tests/fsharpqa/Source/CodeGen/EmittedIL/Mutation/env.lst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
SOURCE=Mutation02.fs ISCFLAGS="-g --test:EmitFeeFeeAs100001 --optimize-" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd Mutation02.exe"# Mutation02.fs
44
SOURCE=Mutation03.fs ISCFLAGS="-g --test:EmitFeeFeeAs100001 --optimize-" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd Mutation03.exe"# Mutation03.fs
55
SOURCE=Mutation04.fs ISCFLAGS="-g --test:EmitFeeFeeAs100001 --optimize-" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd Mutation04.exe"# Mutation04.fs
6+
SOURCE=Mutation05.fs ISCFLAGS="-g --test:EmitFeeFeeAs100001 --optimize-" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd Mutation05.exe"# Mutation05.fs
67

‎tests/fsharpqa/Source/test.lst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ CodeGen01,NoMTCodeGen\EmittedIL\InequalityComparison
1717
CodeGen01,NoMTCodeGen\EmittedIL\ListExpressionStepping
1818
CodeGen01,NoMTCodeGen\EmittedIL\MethodImplAttribute
1919
CodeGen01,NoMTCodeGen\EmittedIL\Misc
20-
CodeGen01,NoMTCodeGen\EmittedIL\Mutation
20+
CodeGen01,CodeGenMutation,NoMTCodeGen\EmittedIL\Mutation
2121
CodeGen01,NoMTCodeGen\EmittedIL\Operators
2222
CodeGen01,NoMTCodeGen\EmittedIL\QueryExpressionStepping
2323
CodeGen01,NoMTCodeGen\EmittedIL\SeqExpressionStepping

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp