blob: 8d763d7c32cacafd6643735861b7b4266a2871cd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 )
.ver 4:0:0:0
}
.assembly extern System.Private.CoreLib
{
.publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A )
.ver 4:0:0:0
}
.assembly ILHelpers { }
.class public ILHelpers.ILHelpersTest
{
.method public static void EatArgs(string, object)
{
ret
}
.method public static void EatArg(object)
{
ret
}
//this is copied from the test case for https://github.com/dotnet/coreclr/issues/14784
//its been adapted to remove the requirement for Console.WriteLine because thats not supported in WASM
//it can be removed once we have support for Console.WriteLine and can run the CoreCLR tests
.method public static int32 InlineAssignByte()
{
.locals init (
int8 local,
object b
)
ldstr "InlineAssignByte"
ldc.i4 300
dup
stloc.0
box int32
stloc.1
ldloc.1
call void ILHelpers.ILHelpersTest::EatArgs(string, object)
ldstr "InlineAssignByte"
ldloc.0
box int32
call void ILHelpers.ILHelpersTest::EatArgs(string, object)
ldloc.1
//after the unboxing and truncation on the way in ensure that we can subtract 200 and end up with the expected 100 return value
unbox.any int32
ldc.i4 200
sub
ret
}
.method public static int32 DupTest(int32&)
{
.locals init (
int32 local,
int32 local2
)
ldarg.0
//push a bunch of entries onto the stack using dup, we will consume them through the rest of this method
dup
dup
dup
dup
dup
//first off lets ensure the passed parameter was pointing to an int of less than 10 (it should be 9)
ldind.i4
ldc.i4 10
clt
brtrue target
//this is just trying to mess with the stack accross basic block boundries
//it should actually leave the evaluation stack unchanged in the end
pop
dup
//make sure we can deref one of our duplicate int refs and box it without any trouble
target: ldind.i4
box int32
call void ILHelpers.ILHelpersTest::EatArg(object)
//deref one of our duplicates and add 1 to it, this should not write back to the parameter it should only be stored in the local
ldind.i4
ldc.i4 1
add
stloc.0
//load one of our duplicates and add 200 to it, we're eventually going to return this value and test for it in the caller
ldind.i4
ldc.i4 200
add
//this should write back into the parameter
stind.i4
ldloc.0
dup
add
dup
stloc.1
ldloc.0
ceq
//if the added value equals the source value we've got something writing to its original StackEntry instead of a dup
brtrue failure
ldind.i4
ret
failure:
pop
ldc.i4 0
ret
}
}
|