Add mappings for ReadyToRun helpers used by llilc:
authorEugene Rozenfeld <erozen@microsoft.com>
Fri, 14 Aug 2015 06:14:09 +0000 (23:14 -0700)
committerEugene Rozenfeld <erozen@microsoft.com>
Sat, 5 Sep 2015 15:45:40 +0000 (08:45 -0700)
READYTORUN_HELPER_ThrowNullRef and READYTORUN_HELPER_ThrowDivZero.

Allow ReadyToRun tests to be run with llilc.

src/inc/readytorun.h
src/inc/readytorunhelpers.h
tests/src/readytorun/main.cs

index 0b0cce6..b0d6dd7 100644 (file)
@@ -195,6 +195,8 @@ enum ReadyToRunHelper
     READYTORUN_HELPER_Overflow                  = 0x22,
     READYTORUN_HELPER_RngChkFail                = 0x23,
     READYTORUN_HELPER_FailFast                  = 0x24,
+    READYTORUN_HELPER_ThrowNullRef              = 0x25,
+    READYTORUN_HELPER_ThrowDivZero              = 0x26,
 
     // Write barriers
     READYTORUN_HELPER_WriteBarrier              = 0x30,
index dd7275c..6e95461 100644 (file)
@@ -20,6 +20,8 @@ HELPER(READYTORUN_HELPER_Rethrow,                   CORINFO_HELP_RETHROW,
 HELPER(READYTORUN_HELPER_Overflow,                  CORINFO_HELP_OVERFLOW,                          OPTIMIZEFORSIZE)
 HELPER(READYTORUN_HELPER_RngChkFail,                CORINFO_HELP_RNGCHKFAIL,                        OPTIMIZEFORSIZE)
 HELPER(READYTORUN_HELPER_FailFast,                  CORINFO_HELP_FAIL_FAST,                         OPTIMIZEFORSIZE)
+HELPER(READYTORUN_HELPER_ThrowNullRef,              CORINFO_HELP_THROWNULLREF,                      OPTIMIZEFORSIZE)
+HELPER(READYTORUN_HELPER_ThrowDivZero,              CORINFO_HELP_THROWDIVZERO,                      OPTIMIZEFORSIZE)
 
 HELPER(READYTORUN_HELPER_WriteBarrier,              CORINFO_HELP_ASSIGN_REF,                        )
 HELPER(READYTORUN_HELPER_CheckedWriteBarrier,       CORINFO_HELP_CHECKED_ASSIGN_REF,                )
index 0a386ca..f3b3468 100644 (file)
@@ -58,25 +58,28 @@ class Program
         Assert.AreEqual(o.MovedToBaseClass(), "MovedToBaseClass");
         Assert.AreEqual(o.ChangedToVirtual(), "ChangedToVirtual");
 
-        o = null;
-
-        try
-        {
-            o.MovedToBaseClass();
-        }
-        catch (NullReferenceException)
+        if (!LLILCJitEnabled)
         {
+            o = null;
+
             try
             {
-                o.ChangedToVirtual();
+                o.MovedToBaseClass();
             }
             catch (NullReferenceException)
             {
-                return;
+                try
+                {
+                    o.ChangedToVirtual();
+                }
+                catch (NullReferenceException)
+                {
+                    return;
+                }
             }
-        }
 
-        Assert.AreEqual("NullReferenceException", "thrown");
+            Assert.AreEqual("NullReferenceException", "thrown");
+        }
     }
 
 
@@ -158,25 +161,28 @@ class Program
         Assert.AreEqual(o.MovedToBaseClass<WeakReference>(), typeof(List<WeakReference>).ToString());
         Assert.AreEqual(o.ChangedToVirtual<WeakReference>(), typeof(List<WeakReference>).ToString());
 
-        o = null;
-
-        try
-        {
-            o.MovedToBaseClass<WeakReference>();
-        }
-        catch (NullReferenceException)
+        if (!LLILCJitEnabled)
         {
+            o = null;
+
             try
             {
-                o.ChangedToVirtual<WeakReference>();
+                o.MovedToBaseClass<WeakReference>();
             }
             catch (NullReferenceException)
             {
-                return;
+                try
+                {
+                    o.ChangedToVirtual<WeakReference>();
+                }
+                catch (NullReferenceException)
+                {
+                    return;
+                }
             }
-        }
 
-        Assert.AreEqual("NullReferenceException", "thrown");
+            Assert.AreEqual("NullReferenceException", "thrown");
+        }
     }
 
     static void TestInstanceFields()
@@ -249,17 +255,19 @@ class Program
 
     static void TestMultipleLoads()
     {
-        try
-        {
-            new MyLoadContext().TestMultipleLoads();
-        }
-        catch (FileLoadException e)
-        {
-            Assert.AreEqual(e.ToString().Contains("Native image cannot be loaded multiple times"), true);
-            return;
-        }
+        if (!LLILCJitEnabled) {
+            try
+            {
+                new MyLoadContext().TestMultipleLoads();
+            }
+            catch (FileLoadException e)
+            {
+                Assert.AreEqual(e.ToString().Contains("Native image cannot be loaded multiple times"), true);
+                return;
+            }
 
-        Assert.AreEqual("FileLoadException", "thrown");
+            Assert.AreEqual("FileLoadException", "thrown");
+        }
     }
 #endif
 
@@ -310,6 +318,15 @@ class Program
 
     static int Main()
     {
+        // Code compiled by LLILC jit can't catch exceptions yet so the tests
+        // don't throw them if LLILC jit is enabled. This should be removed once
+        // exception catching is supported by LLILC jit.
+        string AltJitName = System.Environment.GetEnvironmentVariable("complus_altjitname");
+        LLILCJitEnabled =
+            ((AltJitName != null) && AltJitName.ToLower().StartsWith("llilcjit") &&
+             ((System.Environment.GetEnvironmentVariable("complus_altjit") != null) ||
+              (System.Environment.GetEnvironmentVariable("complus_altjitngen") != null)));
+
         // Run all tests 3x times to exercise both slow and fast paths work
         for (int i = 0; i < 3; i++)
            RunAllTests();
@@ -317,4 +334,6 @@ class Program
         Console.WriteLine("PASSED");
         return Assert.HasAssertFired ? 1 : 100;
     }
+
+    static bool LLILCJitEnabled;
 }