summaryrefslogtreecommitdiff
path: root/src/zap
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/zap
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/zap')
-rw-r--r--src/zap/zapinfo.cpp10
-rw-r--r--src/zap/zapinfo.h3
2 files changed, 13 insertions, 0 deletions
diff --git a/src/zap/zapinfo.cpp b/src/zap/zapinfo.cpp
index 486cc18406..8efeedded6 100644
--- a/src/zap/zapinfo.cpp
+++ b/src/zap/zapinfo.cpp
@@ -2339,6 +2339,16 @@ void * ZapInfo::getFieldAddress(CORINFO_FIELD_HANDLE field, void **ppIndirection
return NULL;
}
+CORINFO_CLASS_HANDLE ZapInfo::getStaticFieldCurrentClass(CORINFO_FIELD_HANDLE field, bool* pIsSpeculative)
+{
+ if (pIsSpeculative != NULL)
+ {
+ *pIsSpeculative = true;
+ }
+
+ return NULL;
+}
+
DWORD ZapInfo::getFieldThreadLocalStoreID(CORINFO_FIELD_HANDLE field,
void **ppIndirection)
{
diff --git a/src/zap/zapinfo.h b/src/zap/zapinfo.h
index 70d6332790..ded4d53923 100644
--- a/src/zap/zapinfo.h
+++ b/src/zap/zapinfo.h
@@ -417,6 +417,9 @@ public:
void * getFieldAddress(CORINFO_FIELD_HANDLE field,
void **ppIndirection);
+ CORINFO_CLASS_HANDLE getStaticFieldCurrentClass(CORINFO_FIELD_HANDLE field,
+ bool* pIsSpeculative);
+
DWORD getFieldThreadLocalStoreID (CORINFO_FIELD_HANDLE field,
void **ppIndirection);
CORINFO_VARARGS_HANDLE getVarArgsHandle(CORINFO_SIG_INFO *sig,