summaryrefslogtreecommitdiff
path: root/src/dlls
diff options
context:
space:
mode:
authorAndy Ayers <andya@microsoft.com>2018-11-12 10:58:03 -0800
committerGitHub <noreply@github.com>2018-11-12 10:58:03 -0800
commitc2abe892b227740c4b8baa51f5433dfc1101a52f (patch)
tree994c07557800a0db391bfad7b0df8c9097b783bf /src/dlls
parenta49296e266ae9aa0bee760f2fcf51d3497ba818d (diff)
downloadcoreclr-c2abe892b227740c4b8baa51f5433dfc1101a52f.tar.gz
coreclr-c2abe892b227740c4b8baa51f5433dfc1101a52f.tar.bz2
coreclr-c2abe892b227740c4b8baa51f5433dfc1101a52f.zip
Allow jit to examine type of initonly static ref typed fields (#20886)
The jit incorporates the value of integer and float typed initonly static fields into its codegen, if the class initializer has already run. The jit can't incorporate the values of ref typed initonly static fields, but the types of those values can't change, and the jit can use this knowledge to enable type based optimizations like devirtualization. In particular for static fields initialized by complex class factory logic the jit can now see the end result of that logic instead of having to try and deduce the type of object that will initialize or did initialize the field. Examples of this factory pattern in include `EqualityComparer<T>.Default` and `Comparer<T>.Default`. The former is already optimized in some cases by via special-purpose modelling in the framework, jit, and runtime (see #14125) but the latter is not. With this change calls through `Comparer<T>.Default` may now also devirtualize (though won't yet inline as the devirtualization happens late). Also update the reflection code to throw an exception instead of changing the value of a fully initialized static readonly field. Closes #4108.
Diffstat (limited to 'src/dlls')
-rw-r--r--src/dlls/mscorrc/mscorrc.rc2
-rw-r--r--src/dlls/mscorrc/resource.h2
2 files changed, 4 insertions, 0 deletions
diff --git a/src/dlls/mscorrc/mscorrc.rc b/src/dlls/mscorrc/mscorrc.rc
index 0e35c29061..bb39c9ac6f 100644
--- a/src/dlls/mscorrc/mscorrc.rc
+++ b/src/dlls/mscorrc/mscorrc.rc
@@ -961,6 +961,8 @@ BEGIN
IDS_E_TYPEACCESS "Attempt by method '%1' to access type '%2' failed.%3"
IDS_INVOKE_NULLREF_RETURNED "The target method returned a null reference."
+
+ IDS_EE_CANNOT_SET_INITONLY_STATIC_FIELD "Cannot set initonly static field '%1%' after type '%2' is initialized."
END
// These strings are used for Event Log Entry
diff --git a/src/dlls/mscorrc/resource.h b/src/dlls/mscorrc/resource.h
index 512b22e7de..8c315e1abe 100644
--- a/src/dlls/mscorrc/resource.h
+++ b/src/dlls/mscorrc/resource.h
@@ -716,3 +716,5 @@
#define IDS_EE_ERROR_COM 0x2641
#define IDS_INVOKE_NULLREF_RETURNED 0x2642
+
+#define IDS_EE_CANNOT_SET_INITONLY_STATIC_FIELD 0x2643