You've already forked linux-packaging-mono
Imported Upstream version 5.10.0.69
Former-commit-id: fc39669a0b707dd3c063977486506b6793da2890
This commit is contained in:
parent
d8f8abd549
commit
e2950ec768
@@ -1,5 +1,8 @@
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
rem Enable Server GC for this test
|
||||
set RH_UseServerGC=1
|
||||
"%1\%2"
|
||||
set ErrorCode=%ERRORLEVEL%
|
||||
IF "%ErrorCode%"=="100" (
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Compile Include="*.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Enable Server GC for this test
|
||||
export RH_UseServerGC=1
|
||||
$1/$2
|
||||
if [ $? == 100 ]; then
|
||||
echo pass
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<Project ToolsVersion="14.0" DefaultTargets="BuildAllFrameworkLibraries" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project DefaultTargets="BuildAllFrameworkLibraries" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
|
||||
<Import Project="..\..\..\..\src\BuildIntegration\BuildFrameworkNativeObjects.proj" />
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Compile Include="*.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Compile Include="*.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -30,6 +30,7 @@ class Program
|
||||
TestGvmDelegates.Run();
|
||||
TestGvmDependencies.Run();
|
||||
TestFieldAccess.Run();
|
||||
TestNativeLayoutGeneration.Run();
|
||||
|
||||
return 100;
|
||||
}
|
||||
@@ -716,6 +717,9 @@ class Program
|
||||
|
||||
public virtual string IFaceMethod1(T t) { return "BaseClass.IFaceMethod1"; }
|
||||
public virtual string IFaceGVMethod1<U>(T t, U u) { return "BaseClass.IFaceGVMethod1"; }
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public virtual string VirtualButNotUsedVirtuallyMethod(T t) { return "BaseClass.VirtualButNotUsedVirtuallyMethod"; }
|
||||
}
|
||||
|
||||
public class DerivedClass1<T> : BaseClass<T>, IFace<T>
|
||||
@@ -728,6 +732,12 @@ class Program
|
||||
public new virtual string GVMethod3<U>(T t, U u) { return "DerivedClass1.GVMethod3"; }
|
||||
|
||||
public override string IFaceMethod1(T t) { return "DerivedClass1.IFaceMethod1"; }
|
||||
|
||||
public string UseVirtualButNotUsedVirtuallyMethod(T t)
|
||||
{
|
||||
// Calling through base produces a `call` instead of `callvirt` instruction.
|
||||
return base.VirtualButNotUsedVirtuallyMethod(t);
|
||||
}
|
||||
}
|
||||
|
||||
public class DerivedClass2<T> : DerivedClass1<T>, IFace<T>
|
||||
@@ -801,6 +811,7 @@ class Program
|
||||
new DerivedClass1<string>().GVMethod2<string>("string", "string2");
|
||||
new DerivedClass1<string>().GVMethod3<string>("string", "string2");
|
||||
new DerivedClass1<string>().GVMethod4<string>("string", "string2");
|
||||
new DerivedClass1<string>().UseVirtualButNotUsedVirtuallyMethod("string");
|
||||
new DerivedClass2<string>().Method1("string");
|
||||
new DerivedClass2<string>().Method2("string");
|
||||
new DerivedClass2<string>().Method3("string");
|
||||
@@ -809,13 +820,15 @@ class Program
|
||||
new DerivedClass2<string>().GVMethod2<string>("string", "string2");
|
||||
new DerivedClass2<string>().GVMethod3<string>("string", "string2");
|
||||
new DerivedClass2<string>().GVMethod4<string>("string", "string2");
|
||||
((IFace<string>)new BaseClass<string>()).IFaceMethod1("string");
|
||||
Func<IFace<string>> f = () => new BaseClass<string>(); // Hack to prevent devirtualization
|
||||
f().IFaceMethod1("string");
|
||||
((IFace<string>)new BaseClass<string>()).IFaceGVMethod1<string>("string1", "string2");
|
||||
|
||||
MethodInfo m1 = typeof(BaseClass<string>).GetTypeInfo().GetDeclaredMethod("Method1");
|
||||
MethodInfo m2 = typeof(BaseClass<string>).GetTypeInfo().GetDeclaredMethod("Method2");
|
||||
MethodInfo m3 = typeof(BaseClass<string>).GetTypeInfo().GetDeclaredMethod("Method3");
|
||||
MethodInfo m4 = typeof(BaseClass<string>).GetTypeInfo().GetDeclaredMethod("Method4");
|
||||
MethodInfo unusedMethod = typeof(BaseClass<string>).GetTypeInfo().GetDeclaredMethod("VirtualButNotUsedVirtuallyMethod");
|
||||
MethodInfo gvm1 = typeof(BaseClass<string>).GetTypeInfo().GetDeclaredMethod("GVMethod1").MakeGenericMethod(typeof(string));
|
||||
MethodInfo gvm2 = typeof(BaseClass<string>).GetTypeInfo().GetDeclaredMethod("GVMethod2").MakeGenericMethod(typeof(string));
|
||||
MethodInfo gvm3 = typeof(BaseClass<string>).GetTypeInfo().GetDeclaredMethod("GVMethod3").MakeGenericMethod(typeof(string));
|
||||
@@ -824,6 +837,7 @@ class Program
|
||||
Verify("BaseClass.Method2", m2.Invoke(new BaseClass<string>(), new[] { "" }));
|
||||
Verify("BaseClass.Method3", m3.Invoke(new BaseClass<string>(), new[] { "" }));
|
||||
Verify("BaseClass.Method4", m4.Invoke(new BaseClass<string>(), new[] { "" }));
|
||||
Verify("BaseClass.VirtualButNotUsedVirtuallyMethod", unusedMethod.Invoke(new BaseClass<string>(), new[] { "" }));
|
||||
Verify("DerivedClass1.Method1", m1.Invoke(new DerivedClass1<string>(), new[] { "" }));
|
||||
Verify("DerivedClass1.Method2", m2.Invoke(new DerivedClass1<string>(), new[] { "" }));
|
||||
Verify("BaseClass.Method3", m3.Invoke(new DerivedClass1<string>(), new[] { "" }));
|
||||
@@ -963,36 +977,50 @@ class Program
|
||||
|
||||
class TestConstrainedMethodCalls
|
||||
{
|
||||
class Atom1 { }
|
||||
class Atom2 { }
|
||||
|
||||
interface IFoo<T>
|
||||
{
|
||||
void Frob();
|
||||
bool Frob(object o);
|
||||
}
|
||||
|
||||
struct Foo<T> : IFoo<T>
|
||||
{
|
||||
public int FrobbedValue;
|
||||
|
||||
public void Frob()
|
||||
public bool Frob(object o)
|
||||
{
|
||||
FrobbedValue = 12345;
|
||||
return o is T[,,];
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
static void DoFrob<T, U>(ref T t) where T : IFoo<U>
|
||||
static bool DoFrob<T, U>(ref T t, object o) where T : IFoo<U>
|
||||
{
|
||||
// Perform a constrained interface call from shared code.
|
||||
// This should have been resolved to a direct call at compile time.
|
||||
t.Frob();
|
||||
return t.Frob(o);
|
||||
}
|
||||
|
||||
public static void Run()
|
||||
{
|
||||
var foo = new Foo<object>();
|
||||
DoFrob<Foo<object>, object>(ref foo);
|
||||
var foo1 = new Foo<Atom1>();
|
||||
bool result = DoFrob<Foo<Atom1>, Atom1>(ref foo1, new Atom1[0,0,0]);
|
||||
|
||||
// If the FrobbedValue doesn't change when we frob, we must have done box+interface call.
|
||||
if (foo.FrobbedValue != 12345)
|
||||
if (foo1.FrobbedValue != 12345)
|
||||
throw new Exception();
|
||||
|
||||
// Also check we passed the right generic context to Foo.Frob
|
||||
if (!result)
|
||||
throw new Exception();
|
||||
|
||||
// Also check dependency analysis:
|
||||
// EEType for Atom2[,,] that we'll check for was never allocated.
|
||||
var foo2 = new Foo<Atom2>();
|
||||
if (DoFrob<Foo<Atom2>, Atom2>(ref foo2, new object()))
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
@@ -1128,6 +1156,21 @@ class Program
|
||||
string IMethod1<T>(T t1, T t2);
|
||||
}
|
||||
|
||||
interface ICovariant<out T>
|
||||
{
|
||||
string ICovariantGVM<U>();
|
||||
}
|
||||
|
||||
public interface IBar<T>
|
||||
{
|
||||
U IBarGVMethod<U>(Func<T, U> arg);
|
||||
}
|
||||
|
||||
public interface IFace<T>
|
||||
{
|
||||
string IFaceGVMethod1<U>(T t, U u);
|
||||
}
|
||||
|
||||
class Base : IFoo<string>, IFoo<int>
|
||||
{
|
||||
public virtual string GMethod1<T>(T t1, T t2) { return "Base.GMethod1<" + typeof(T) + ">(" + t1 + "," + t2 + ")"; }
|
||||
@@ -1175,6 +1218,36 @@ class Program
|
||||
public string IMethod1<T>(T t1, T t2) { return "MyStruct3.IMethod1<" + typeof(T) + ">(" + t1 + "," + t2 + ")"; }
|
||||
}
|
||||
|
||||
public class AnotherBaseClass<T>
|
||||
{
|
||||
public virtual string IFaceMethod1(T t) { return "AnotherBaseClass.IFaceMethod1"; }
|
||||
public virtual string IFaceGVMethod1<U>(T t, U u) { return "AnotherBaseClass.IFaceGVMethod1"; }
|
||||
}
|
||||
|
||||
public class AnotherDerivedClass<T> : AnotherBaseClass<T>, IFace<T>
|
||||
{
|
||||
}
|
||||
|
||||
public class BarImplementor : IBar<int>
|
||||
{
|
||||
public virtual U IBarGVMethod<U>(Func<int, U> arg) { return arg(123); }
|
||||
}
|
||||
|
||||
public class Yahoo<T>
|
||||
{
|
||||
public virtual U YahooGVM<U>(Func<T, U> arg) { return default(U); }
|
||||
}
|
||||
|
||||
public class YahooDerived : Yahoo<int>
|
||||
{
|
||||
public override U YahooGVM<U>(Func<int, U> arg) { return arg(456); }
|
||||
}
|
||||
|
||||
public class Covariant<T> : ICovariant<T>
|
||||
{
|
||||
public string ICovariantGVM<U>() { return String.Format("Covariant<{0}>.ICovariantGVM<{1}>", typeof(T).Name, typeof(U).Name); }
|
||||
}
|
||||
|
||||
static string s_GMethod1;
|
||||
static string s_IFooString;
|
||||
static string s_IFooObject;
|
||||
@@ -1328,6 +1401,20 @@ class Program
|
||||
Console.WriteLine("====================");
|
||||
}
|
||||
|
||||
{
|
||||
string res = ((IFace<string>)new AnotherDerivedClass<string>()).IFaceGVMethod1<string>("string1", "string2");
|
||||
WriteLineWithVerification("AnotherBaseClass.IFaceGVMethod1", res);
|
||||
|
||||
res = ((IBar<int>)new BarImplementor()).IBarGVMethod<string>((i) => "BarImplementor:" + i.ToString());
|
||||
WriteLineWithVerification("BarImplementor:123", res);
|
||||
|
||||
Yahoo<int> y = new YahooDerived();
|
||||
WriteLineWithVerification("YahooDerived:456", y.YahooGVM<string>((i) => "YahooDerived:" + i.ToString()));
|
||||
|
||||
ICovariant<object> cov = new Covariant<string>();
|
||||
WriteLineWithVerification("Covariant<String>.ICovariantGVM<Exception>", cov.ICovariantGVM<Exception>());
|
||||
}
|
||||
|
||||
if (s_NumErrors != 0)
|
||||
throw new Exception();
|
||||
}
|
||||
@@ -1952,4 +2039,53 @@ class Program
|
||||
throw new Exception(s_NumErrors + " errors!");
|
||||
}
|
||||
}
|
||||
|
||||
// Regression test for https://github.com/dotnet/corert/issues/3659
|
||||
class TestNativeLayoutGeneration
|
||||
{
|
||||
#pragma warning disable 649 // s_ref was never assigned
|
||||
private static object s_ref;
|
||||
#pragma warning restore 649
|
||||
|
||||
class Used
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public virtual string DoStuff()
|
||||
{
|
||||
return "Used";
|
||||
}
|
||||
}
|
||||
|
||||
class Unused<T> : Used
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public override string DoStuff()
|
||||
{
|
||||
return "Unused " + typeof(T).ToString();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
public void Blagh()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public static void Run()
|
||||
{
|
||||
new Used().DoStuff();
|
||||
|
||||
try
|
||||
{
|
||||
// Call an instance method on something we never allocated, but overrides a used virtual.
|
||||
// This asserted the compiler when trying to build a template for Unused<__Canon>.
|
||||
((Unused<object>)s_ref).Blagh();
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Compile Include="*.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Compile Include="*.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
34
external/corert/tests/src/Simple/HelloWasm/CpObj.il
vendored
Normal file
34
external/corert/tests/src/Simple/HelloWasm/CpObj.il
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
// 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 CpObj { }
|
||||
|
||||
.class public CpObj.CpObjTest
|
||||
{
|
||||
.method public hidebysig static void CpObj(valuetype CpObj.TestValue& dest, valuetype CpObj.TestValue& src) cil managed
|
||||
{
|
||||
.maxstack 8
|
||||
ldarg.0
|
||||
ldarg.1
|
||||
cpobj CpObj.TestValue
|
||||
ret
|
||||
}
|
||||
}
|
||||
|
||||
.class public value sealed CpObj.TestValue
|
||||
{
|
||||
.field public int32 Field;
|
||||
}
|
||||
20
external/corert/tests/src/Simple/HelloWasm/CpObj.ilproj
vendored
Normal file
20
external/corert/tests/src/Simple/HelloWasm/CpObj.ilproj
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<OutputType>Library</OutputType>
|
||||
<DebugType>portable</DebugType>
|
||||
<OutputPath>$(MSBuildProjectDirectory)\bin\$(Configuration)\$(Platform)\</OutputPath>
|
||||
<IntermediateOutputPath>$(MSBuildProjectDirectory)\obj\$(Configuration)\$(Platform)\</IntermediateOutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="CpObj.il" />
|
||||
<PackageReference Include="Microsoft.NETCore.App">
|
||||
<Version>$(MicrosoftNETCoreAppPackageVersion)</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
|
||||
</Project>
|
||||
15
external/corert/tests/src/Simple/HelloWasm/HelloWasm.cmd
vendored
Normal file
15
external/corert/tests/src/Simple/HelloWasm/HelloWasm.cmd
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
@echo off
|
||||
setlocal
|
||||
set ErrorCode=100
|
||||
for /f "usebackq delims=;" %%F in (`"%1\%2" world`) do (
|
||||
if "%%F"=="Hello world" set ErrorCode=0
|
||||
)
|
||||
IF "%ErrorCode%"=="0" (
|
||||
echo %~n0: pass
|
||||
EXIT /b 0
|
||||
) ELSE (
|
||||
echo %~n0: fail - %ErrorCode%
|
||||
EXIT /b 1
|
||||
)
|
||||
endlocal
|
||||
|
||||
10
external/corert/tests/src/Simple/HelloWasm/HelloWasm.csproj
vendored
Normal file
10
external/corert/tests/src/Simple/HelloWasm/HelloWasm.csproj
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Compile Include="*.cs" />
|
||||
|
||||
<ProjectReference Include="CpObj.ilproj" />
|
||||
<IlcArg Include="-r:$(IntermediateOutputPath)\CpObj.dll" />
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), SimpleTest.targets))\SimpleTest.targets" />
|
||||
</Project>
|
||||
11
external/corert/tests/src/Simple/HelloWasm/HelloWasm.sh
vendored
Normal file
11
external/corert/tests/src/Simple/HelloWasm/HelloWasm.sh
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
dir=$1
|
||||
file=$2
|
||||
cmp=`$dir/$file world | tr '\n' ';'`
|
||||
if [[ $cmp = "Hello world;" ]]; then
|
||||
echo pass
|
||||
exit 0
|
||||
else
|
||||
echo fail
|
||||
exit 1
|
||||
fi
|
||||
252
external/corert/tests/src/Simple/HelloWasm/Program.cs
vendored
Normal file
252
external/corert/tests/src/Simple/HelloWasm/Program.cs
vendored
Normal file
@@ -0,0 +1,252 @@
|
||||
// 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.InteropServices;
|
||||
using CpObj;
|
||||
|
||||
internal static class Program
|
||||
{
|
||||
private static int staticInt;
|
||||
[ThreadStatic]
|
||||
private static int threadStaticInt;
|
||||
private static unsafe void Main(string[] args)
|
||||
{
|
||||
Add(1, 2);
|
||||
int tempInt = 0;
|
||||
(*(&tempInt)) = 9;
|
||||
if(tempInt == 9)
|
||||
{
|
||||
PrintLine("Hello from C#!");
|
||||
}
|
||||
|
||||
TestClass tempObj = new TestDerivedClass(1337);
|
||||
tempObj.TestMethod("Hello");
|
||||
tempObj.TestVirtualMethod("Hello");
|
||||
tempObj.TestVirtualMethod2("Hello");
|
||||
|
||||
TwoByteStr str = new TwoByteStr() { first = 1, second = 2 };
|
||||
TwoByteStr str2 = new TwoByteStr() { first = 3, second = 4 };
|
||||
*(&str) = str2;
|
||||
str2 = *(&str);
|
||||
|
||||
if (str2.second == 4)
|
||||
{
|
||||
PrintLine("value type int field test: Ok.");
|
||||
}
|
||||
|
||||
staticInt = 5;
|
||||
if (staticInt == 5)
|
||||
{
|
||||
PrintLine("static int field test: Ok.");
|
||||
}
|
||||
|
||||
if(threadStaticInt == 0)
|
||||
{
|
||||
PrintLine("thread static int initial value field test: Ok.");
|
||||
}
|
||||
|
||||
threadStaticInt = 9;
|
||||
if(threadStaticInt == 9)
|
||||
{
|
||||
PrintLine("thread static int field test: Ok.");
|
||||
}
|
||||
|
||||
var boxedInt = (object)tempInt;
|
||||
if(((int)boxedInt) == 9)
|
||||
{
|
||||
PrintLine("box test: Ok.");
|
||||
}
|
||||
|
||||
var boxedStruct = (object)new BoxStubTest { Value = "Boxed Stub Test: Ok." };
|
||||
PrintLine(boxedStruct.ToString());
|
||||
|
||||
var not = Not(0xFFFFFFFF) == 0x00000000;
|
||||
if (not)
|
||||
{
|
||||
PrintLine("not test: Ok.");
|
||||
}
|
||||
|
||||
var negInt = Neg(42) == -42;
|
||||
if (negInt)
|
||||
{
|
||||
PrintLine("negInt test: Ok.");
|
||||
}
|
||||
|
||||
var shiftLeft = ShiftLeft(1, 2) == 4;
|
||||
if (shiftLeft)
|
||||
{
|
||||
PrintLine("shiftLeft test: Ok.");
|
||||
}
|
||||
|
||||
var shiftRight = ShiftRight(4, 2) == 1;
|
||||
if (shiftRight)
|
||||
{
|
||||
PrintLine("shiftRight test: Ok.");
|
||||
}
|
||||
|
||||
var unsignedShift = UnsignedShift(0xFFFFFFFFu, 4) == 0x0FFFFFFFu;
|
||||
if (unsignedShift)
|
||||
{
|
||||
PrintLine("unsignedShift test: Ok.");
|
||||
}
|
||||
|
||||
var switchTest0 = SwitchOp(5, 5, 0);
|
||||
if (switchTest0 == 10)
|
||||
{
|
||||
PrintLine("SwitchOp0 test: Ok.");
|
||||
}
|
||||
|
||||
var switchTest1 = SwitchOp(5, 5, 1);
|
||||
if (switchTest1 == 25)
|
||||
{
|
||||
PrintLine("SwitchOp1 test: Ok.");
|
||||
}
|
||||
|
||||
var switchTestDefault = SwitchOp(5, 5, 20);
|
||||
if (switchTestDefault == 0)
|
||||
{
|
||||
PrintLine("SwitchOpDefault test: Ok.");
|
||||
}
|
||||
|
||||
var cpObjTestA = new TestValue { Field = 1234 };
|
||||
var cpObjTestB = new TestValue { Field = 5678 };
|
||||
CpObjTest.CpObj(ref cpObjTestB, ref cpObjTestA);
|
||||
if (cpObjTestB.Field == 1234)
|
||||
{
|
||||
PrintLine("CpObj test: Ok.");
|
||||
}
|
||||
}
|
||||
|
||||
private static unsafe void PrintString(string s)
|
||||
{
|
||||
int length = s.Length;
|
||||
fixed (char* curChar = s)
|
||||
{
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
TwoByteStr curCharStr = new TwoByteStr();
|
||||
curCharStr.first = (byte)(*(curChar + i));
|
||||
printf((byte*)&curCharStr, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void PrintLine(string s)
|
||||
{
|
||||
PrintString(s);
|
||||
PrintString("\n");
|
||||
}
|
||||
|
||||
private static int Add(int a, int b)
|
||||
{
|
||||
return a + b;
|
||||
}
|
||||
|
||||
private static uint Not(uint a)
|
||||
{
|
||||
return ~a;
|
||||
}
|
||||
|
||||
private static int Neg(int a)
|
||||
{
|
||||
return -a;
|
||||
}
|
||||
|
||||
private static int ShiftLeft(int a, int b)
|
||||
{
|
||||
return a << b;
|
||||
}
|
||||
|
||||
private static int ShiftRight(int a, int b)
|
||||
{
|
||||
return a >> b;
|
||||
}
|
||||
|
||||
private static uint UnsignedShift(uint a, int b)
|
||||
{
|
||||
return a >> b;
|
||||
}
|
||||
|
||||
private static int SwitchOp(int a, int b, int mode)
|
||||
{
|
||||
switch(mode)
|
||||
{
|
||||
case 0:
|
||||
return a + b;
|
||||
case 1:
|
||||
return a * b;
|
||||
case 2:
|
||||
return a / b;
|
||||
case 3:
|
||||
return a - b;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("*")]
|
||||
private static unsafe extern int printf(byte* str, byte* unused);
|
||||
}
|
||||
|
||||
public struct TwoByteStr
|
||||
{
|
||||
public byte first;
|
||||
public byte second;
|
||||
}
|
||||
|
||||
public struct BoxStubTest
|
||||
{
|
||||
public string Value;
|
||||
public override string ToString()
|
||||
{
|
||||
return Value;
|
||||
}
|
||||
}
|
||||
|
||||
public class TestClass
|
||||
{
|
||||
public string TestString {get; set;}
|
||||
|
||||
public TestClass(int number)
|
||||
{
|
||||
if(number != 1337)
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
public void TestMethod(string str)
|
||||
{
|
||||
TestString = str;
|
||||
if (TestString == str)
|
||||
Program.PrintLine("Instance method call test: Ok.");
|
||||
}
|
||||
public virtual void TestVirtualMethod(string str)
|
||||
{
|
||||
Program.PrintLine("Virtual Slot Test: Ok If second");
|
||||
}
|
||||
|
||||
public virtual void TestVirtualMethod2(string str)
|
||||
{
|
||||
Program.PrintLine("Virtual Slot Test 2: Ok");
|
||||
}
|
||||
}
|
||||
|
||||
public class TestDerivedClass : TestClass
|
||||
{
|
||||
public TestDerivedClass(int number) : base(number)
|
||||
{
|
||||
|
||||
}
|
||||
public override void TestVirtualMethod(string str)
|
||||
{
|
||||
Program.PrintLine("Virtual Slot Test: Ok");
|
||||
base.TestVirtualMethod(str);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
|
||||
0
external/corert/tests/src/Simple/HelloWasm/no_cpp
vendored
Normal file
0
external/corert/tests/src/Simple/HelloWasm/no_cpp
vendored
Normal file
0
external/corert/tests/src/Simple/HelloWasm/no_ryujit
vendored
Normal file
0
external/corert/tests/src/Simple/HelloWasm/no_ryujit
vendored
Normal file
1
external/corert/tests/src/Simple/HelloWasm/no_unix
vendored
Normal file
1
external/corert/tests/src/Simple/HelloWasm/no_unix
vendored
Normal file
@@ -0,0 +1 @@
|
||||
Doesn't work on OSX.
|
||||
0
external/corert/tests/src/Simple/HelloWasm/wasm
vendored
Normal file
0
external/corert/tests/src/Simple/HelloWasm/wasm
vendored
Normal file
@@ -5,6 +5,7 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
public class BringUpTest
|
||||
{
|
||||
@@ -28,6 +29,9 @@ public class BringUpTest
|
||||
if (TestSpecialArrayInterfaces() == Fail)
|
||||
return Fail;
|
||||
|
||||
if (TestIterfaceCallOptimization() == Fail)
|
||||
return Fail;
|
||||
|
||||
return Pass;
|
||||
}
|
||||
|
||||
@@ -359,4 +363,34 @@ public class BringUpTest
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Interface call optimization tests
|
||||
|
||||
public interface ISomeInterface
|
||||
{
|
||||
int SomeValue { get; }
|
||||
}
|
||||
|
||||
public abstract class SomeAbstractBaseClass : ISomeInterface
|
||||
{
|
||||
public abstract int SomeValue { get; }
|
||||
}
|
||||
|
||||
public class SomeClass : SomeAbstractBaseClass
|
||||
{
|
||||
public override int SomeValue
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
get { return 14; }
|
||||
}
|
||||
}
|
||||
|
||||
private static int TestIterfaceCallOptimization()
|
||||
{
|
||||
ISomeInterface test = new SomeClass();
|
||||
int v = test.SomeValue;
|
||||
return (v == 14) ? Pass : Fail;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user