Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit c73eb10

Browse files
authored
Merge pull request #7748 from janvorli/port-fix-fp-args-reflection
Port fix passing struct with four floats in registers via reflection to 1.1.0
2 parents 1602161 + 12661af commit c73eb10

File tree

3 files changed

+93
-1
lines changed

3 files changed

+93
-1
lines changed

src/vm/argdestination.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ class ArgDestination
136136
_ASSERTE(eightByteSize == 4);
137137
*(UINT32*)floatRegDest = *(UINT32*)src;
138138
}
139-
floatRegDest += 8;
139+
floatRegDest += 16;
140140
}
141141
else
142142
{
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{E55A6F8B-B9E3-45CE-88F4-22AE70F606CB}</ProjectGuid>
9+
<OutputType>Exe</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<FileAlignment>512</FileAlignment>
12+
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
13+
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
14+
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
15+
<NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
16+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
17+
<ReferenceLocalMscorlib>false</ReferenceLocalMscorlib>
18+
<CLRTestKind>BuildAndRun</CLRTestKind>
19+
<CLRTestPriority>1</CLRTestPriority>
20+
</PropertyGroup>
21+
<!-- Default configurations to help VS understand the configurations -->
22+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
23+
</PropertyGroup>
24+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25+
</PropertyGroup>
26+
<ItemGroup>
27+
<CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
28+
<Visible>False</Visible>
29+
</CodeAnalysisDependentAssemblyPaths>
30+
</ItemGroup>
31+
<ItemGroup>
32+
<!-- Add Compile Object Here -->
33+
<Compile Include="test7685.cs" />
34+
</ItemGroup>
35+
<ItemGroup>
36+
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
37+
</ItemGroup>
38+
<ItemGroup>
39+
<ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
40+
</ItemGroup>
41+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
42+
<PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
43+
</PropertyGroup>
44+
</Project>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
using System;
5+
using System.Reflection;
6+
7+
public class Test7685
8+
{
9+
static RectangleF argumentInDStuff;
10+
11+
public static int Main()
12+
{
13+
int iRetVal = 100;
14+
15+
var r = new RectangleF(1.2f, 3.4f, 5.6f, 7.8f);
16+
typeof(Test7685).GetTypeInfo().GetDeclaredMethod("DoStuff").Invoke(null, new object[] { r });
17+
18+
if (!RectangleF.Equals(ref argumentInDStuff, ref r))
19+
{
20+
TestLibrary.Logging.WriteLine($"Error: passing struct with floats via reflection. Callee received {argumentInDStuff} instead of {r}");
21+
iRetVal = 0;
22+
}
23+
24+
return iRetVal;
25+
}
26+
27+
public static void DoStuff(RectangleF r)
28+
{
29+
argumentInDStuff = r;
30+
}
31+
}
32+
33+
public struct RectangleF
34+
{
35+
private float _x, _y, _width, _height;
36+
37+
public RectangleF(float x, float y, float width, float height)
38+
{
39+
_x = x; _y = y; _width = width; _height = height;
40+
}
41+
42+
public static bool Equals(ref RectangleF r1, ref RectangleF r2)
43+
{
44+
return (r2._x == r1._x) && (r2._y == r1._y) && (r2._width == r1._width) && (r2._height == r1._height);
45+
}
46+
47+
public override string ToString() => $"[{_x}, {_y}, {_width}, {_height}]";
48+
}

0 commit comments

Comments
 (0)