summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/vm/genericdict.cpp4
-rw-r--r--tests/src/readytorun/genericsload/app.config39
-rw-r--r--tests/src/readytorun/genericsload/callgenericctor.cs35
-rw-r--r--tests/src/readytorun/genericsload/callgenericctor.csproj58
-rw-r--r--tests/src/readytorun/genericsload/genericslib.il58
-rw-r--r--tests/src/readytorun/genericsload/genericslib.ilproj41
-rw-r--r--tests/src/readytorun/genericsload/project.json44
-rw-r--r--tests/src/readytorun/genericsload/usegenericfield.cs39
-rw-r--r--tests/src/readytorun/genericsload/usegenericfield.csproj58
9 files changed, 376 insertions, 0 deletions
diff --git a/src/vm/genericdict.cpp b/src/vm/genericdict.cpp
index 04e2550e1e..65638d1402 100644
--- a/src/vm/genericdict.cpp
+++ b/src/vm/genericdict.cpp
@@ -682,6 +682,8 @@ Dictionary::PopulateEntry(
th = th.GetMethodTable()->GetMethodTableMatchingParentClass(declaringType.AsMethodTable());
}
+ th.GetMethodTable()->EnsureInstanceActive();
+
result = (CORINFO_GENERIC_HANDLE)th.AsPtr();
break;
}
@@ -915,6 +917,8 @@ Dictionary::PopulateEntry(
DWORD fieldIndex;
IfFailThrow(ptr.GetData(&fieldIndex));
+ th.AsMethodTable()->EnsureInstanceActive();
+
result = (CORINFO_GENERIC_HANDLE)th.AsMethodTable()->GetFieldDescByIndex(fieldIndex);
break;
}
diff --git a/tests/src/readytorun/genericsload/app.config b/tests/src/readytorun/genericsload/app.config
new file mode 100644
index 0000000000..7f13fbce41
--- /dev/null
+++ b/tests/src/readytorun/genericsload/app.config
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="System.Collections" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Runtime.Extensions" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration> \ No newline at end of file
diff --git a/tests/src/readytorun/genericsload/callgenericctor.cs b/tests/src/readytorun/genericsload/callgenericctor.cs
new file mode 100644
index 0000000000..05e16afb3b
--- /dev/null
+++ b/tests/src/readytorun/genericsload/callgenericctor.cs
@@ -0,0 +1,35 @@
+// 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.
+//
+
+using System;
+using System.Runtime.CompilerServices;
+
+class Foo<T>
+{
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ internal void M()
+ {
+ new GenClass<T>();
+ }
+}
+
+class Program
+{
+ static int Main()
+ {
+ try
+ {
+ new Foo<string>().M();
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("FAIL");
+ return 101;
+ }
+
+ Console.WriteLine("PASS");
+ return 100;
+ }
+}
diff --git a/tests/src/readytorun/genericsload/callgenericctor.csproj b/tests/src/readytorun/genericsload/callgenericctor.csproj
new file mode 100644
index 0000000000..f3b7648707
--- /dev/null
+++ b/tests/src/readytorun/genericsload/callgenericctor.csproj
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{7DECC55A-B584-4456-83BA-6C42A5B3B3CB}</ProjectGuid>
+ <OutputType>exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <CLRTestKind>BuildAndRun</CLRTestKind>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <DefineConstants>$(DefineConstants);STATIC;CORECLR</DefineConstants>
+ <ZapRequire>1</ZapRequire>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="genericslib.ilproj">
+ <Project>{F74F55A1-DFCF-4C7C-B462-E96E1D0BB667}</Project>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="callgenericctor.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="project.json" />
+ <None Include="app.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <PropertyGroup>
+ <CLRTestBatchPreCommands><![CDATA[
+$(CLRTestBatchPreCommands)
+%Core_Root%\crossgen /readytorun /platform_assemblies_paths %Core_Root%%3B%25CD% /out genericslib.ni.dll genericslib.dll
+%Core_Root%\crossgen /readytorun /platform_assemblies_paths %Core_Root%%3B%25CD% /out callgenericctor.ni.exe callgenericctor.exe
+]]></CLRTestBatchPreCommands>
+ <BashCLRTestPreCommands><![CDATA[
+$(BashCLRTestPreCommands)
+$CORE_ROOT/crossgen -readytorun -platform_assemblies_paths $CORE_ROOT:`pwd` -out genericslib.ni.dll genericslib.dll
+$CORE_ROOT/crossgen -readytorun -platform_assemblies_paths $CORE_ROOT:`pwd` -out callgenericctor.ni.exe callgenericctor.exe
+]]></BashCLRTestPreCommands>
+ </PropertyGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/tests/src/readytorun/genericsload/genericslib.il b/tests/src/readytorun/genericsload/genericslib.il
new file mode 100644
index 0000000000..fdc2f408a3
--- /dev/null
+++ b/tests/src/readytorun/genericsload/genericslib.il
@@ -0,0 +1,58 @@
+// 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 genericslib { }
+.module genericslib.dll
+
+.assembly extern mscorlib { }
+
+// A module constructor that sets GenClass`1<string>::StaticField to true.
+.method assembly specialname rtspecialname static
+ void .cctor() cil managed
+{
+ ldc.i4.1
+ stsfld bool class GenClass`1<string>::StaticField
+ ret
+}
+
+.class public auto ansi beforefieldinit GenClass`1<T>
+ extends [mscorlib]System.Object
+{
+ .field static public bool StaticField
+
+ /*
+ public GenClass()
+ {
+ if (!StaticField)
+ throw new System.Exception();
+ }
+ */
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ ldarg.0
+ call instance void [mscorlib]System.Object::.ctor()
+
+ ldsfld bool class GenClass`1<!T>::StaticField
+ brtrue.s OK
+
+ newobj instance void [mscorlib]System.Exception::.ctor()
+ throw
+
+ OK: ret
+ }
+
+ /*
+ public static bool StaticMethod()
+ {
+ return StaticField;
+ }
+ */
+ .method public hidebysig static bool StaticMethod() cil managed
+ {
+ ldsfld bool class GenClass`1<!T>::StaticField
+ ret
+ }
+}
diff --git a/tests/src/readytorun/genericsload/genericslib.ilproj b/tests/src/readytorun/genericsload/genericslib.ilproj
new file mode 100644
index 0000000000..d68af8b867
--- /dev/null
+++ b/tests/src/readytorun/genericsload/genericslib.ilproj
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <AssemblyName>$(MSBuildProjectName)</AssemblyName>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <CLRTestKind>SharedLibrary</CLRTestKind>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <PropertyGroup>
+
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="genericslib.il" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+ </PropertyGroup>
+</Project>
diff --git a/tests/src/readytorun/genericsload/project.json b/tests/src/readytorun/genericsload/project.json
new file mode 100644
index 0000000000..da49daf7aa
--- /dev/null
+++ b/tests/src/readytorun/genericsload/project.json
@@ -0,0 +1,44 @@
+{
+ "dependencies": {
+ "Microsoft.NETCore.Platforms": "1.0.1-rc3-24117-00",
+ "System.Collections": "4.0.10",
+ "System.Collections.NonGeneric": "4.0.1-rc3-24117-00",
+ "System.Collections.Specialized": "4.0.1-rc3-24117-00",
+ "System.ComponentModel": "4.0.1-rc3-24117-00",
+ "System.Console": "4.0.0-rc3-24117-00",
+ "System.Diagnostics.Process": "4.1.0-rc3-24117-00",
+ "System.Globalization": "4.0.10",
+ "System.Globalization.Calendars": "4.0.0",
+ "System.IO": "4.0.10",
+ "System.IO.FileSystem": "4.0.1-rc3-24117-00",
+ "System.IO.FileSystem.Primitives": "4.0.0",
+ "System.Linq": "4.1.0-rc3-24117-00",
+ "System.Linq.Queryable": "4.0.1-rc3-24117-00",
+ "System.Reflection": "4.1.0-rc3-24117-00",
+ "System.Reflection.Primitives": "4.0.0",
+ "System.Runtime": "4.1.0-rc3-24117-00",
+ "System.Runtime.Extensions": "4.0.10",
+ "System.Runtime.Handles": "4.0.0",
+ "System.Runtime.InteropServices": "4.1.0-rc3-24117-00",
+ "System.Runtime.InteropServices.RuntimeInformation": "4.0.0-rc3-24117-00",
+ "System.Runtime.Loader": "4.0.0-rc3-24117-00",
+ "System.Text.Encoding": "4.0.10",
+ "System.Threading": "4.0.10",
+ "System.Xml.ReaderWriter": "4.0.11-rc3-24117-00",
+ "System.Xml.XDocument": "4.0.11-rc3-24117-00",
+ "System.Xml.XmlDocument": "4.0.1-rc3-24117-00",
+ "System.Xml.XmlSerializer": "4.0.11-rc3-24117-00"
+ },
+ "frameworks": {
+ "dnxcore50": {}
+ },
+ "runtimes": {
+ "win7-x86": {},
+ "win7-x64": {},
+ "ubuntu.14.04-x64": {},
+ "osx.10.10-x64": {},
+ "centos.7-x64": {},
+ "rhel.7-x64": {},
+ "debian.8-x64": {}
+ }
+}
diff --git a/tests/src/readytorun/genericsload/usegenericfield.cs b/tests/src/readytorun/genericsload/usegenericfield.cs
new file mode 100644
index 0000000000..770334c6cf
--- /dev/null
+++ b/tests/src/readytorun/genericsload/usegenericfield.cs
@@ -0,0 +1,39 @@
+// 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.
+//
+
+using System;
+using System.Runtime.CompilerServices;
+
+class Foo<T>
+{
+ [MethodImplAttribute(MethodImplOptions.NoInlining)]
+ internal bool M()
+ {
+ return GenClass<T>.StaticField;
+ }
+}
+
+class Program
+{
+ static int Main()
+ {
+ try
+ {
+ if (!new Foo<string>().M())
+ {
+ Console.WriteLine("FAIL - bad result");
+ return 102;
+ }
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("FAIL - exception caught");
+ return 101;
+ }
+
+ Console.WriteLine("PASS");
+ return 100;
+ }
+}
diff --git a/tests/src/readytorun/genericsload/usegenericfield.csproj b/tests/src/readytorun/genericsload/usegenericfield.csproj
new file mode 100644
index 0000000000..ae24a27d6b
--- /dev/null
+++ b/tests/src/readytorun/genericsload/usegenericfield.csproj
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{7DECC55A-B584-4456-83BA-6C42A5B3B3CB}</ProjectGuid>
+ <OutputType>exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <CLRTestKind>BuildAndRun</CLRTestKind>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <DefineConstants>$(DefineConstants);STATIC;CORECLR</DefineConstants>
+ <ZapRequire>1</ZapRequire>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="genericslib.ilproj">
+ <Project>{F74F55A1-DFCF-4C7C-B462-E96E1D0BB667}</Project>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="usegenericfield.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="project.json" />
+ <None Include="app.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <PropertyGroup>
+ <CLRTestBatchPreCommands><![CDATA[
+$(CLRTestBatchPreCommands)
+%Core_Root%\crossgen /readytorun /platform_assemblies_paths %Core_Root%%3B%25CD% /out genericslib.ni.dll genericslib.dll
+%Core_Root%\crossgen /readytorun /platform_assemblies_paths %Core_Root%%3B%25CD% /out usegenericfield.ni.exe usegenericfield.exe
+]]></CLRTestBatchPreCommands>
+ <BashCLRTestPreCommands><![CDATA[
+$(BashCLRTestPreCommands)
+$CORE_ROOT/crossgen -readytorun -platform_assemblies_paths $CORE_ROOT:`pwd` -out genericslib.ni.dll genericslib.dll
+$CORE_ROOT/crossgen -readytorun -platform_assemblies_paths $CORE_ROOT:`pwd` -out usegenericfield.ni.exe usegenericfield.exe
+]]></BashCLRTestPreCommands>
+ </PropertyGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>