void* CEEInfo::getFieldAddress(CORINFO_FIELD_HANDLE fieldHnd,
void **ppIndirection)
{
- LIMITED_METHOD_CONTRACT;
- _ASSERTE(isVerifyOnly());
+ CONTRACTL{
+ SO_TOLERANT;
+ THROWS;
+ GC_TRIGGERS;
+ MODE_PREEMPTIVE;
+ } CONTRACTL_END;
+
+ void *result = NULL;
+
if (ppIndirection != NULL)
*ppIndirection = NULL;
- return (void *)0x10;
+
+ // Do not bother with initialization if we are only verifying the method.
+ if (isVerifyOnly())
+ {
+ return (void *)0x10;
+ }
+
+ JIT_TO_EE_TRANSITION();
+
+ FieldDesc* field = (FieldDesc*)fieldHnd;
+
+ _ASSERTE(field->IsRVA());
+
+ result = field->GetStaticAddressHandle(NULL);
+
+ EE_TO_JIT_TRANSITION();
+
+ return result;
}
CORINFO_CLASS_HANDLE CEEInfo::getStaticFieldCurrentClass(CORINFO_FIELD_HANDLE fieldHnd,
case corInfoHelpFunc: flags return readyToRunHelper;
#include "readytorunhelpers.h"
+ case CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPEHANDLE:
+ return READYTORUN_HELPER_GetRuntimeTypeHandle;
+
case CORINFO_HELP_STRCNS_CURRENT_MODULE:
*pfOptimizeForSize = true;
return READYTORUN_HELPER_GetString;
void * ZapInfo::getFieldAddress(CORINFO_FIELD_HANDLE field, void **ppIndirection)
{
+ if (IsReadyToRunCompilation())
+ {
+ void * pAddress = m_pEEJitInfo->getFieldAddress(field, ppIndirection);
+
+ return m_pImage->m_pILMetaData->GetRVAField(pAddress);
+ }
+
_ASSERTE(ppIndirection != NULL);
CORINFO_CLASS_HANDLE hClass = m_pEEJitInfo->getFieldClass(field);
}
break;
- case CORINFO_FIELD_STATIC_ADDRESS: // field at given address
case CORINFO_FIELD_STATIC_RVA_ADDRESS: // RVA field at given address
+ if (m_pEEJitInfo->getClassModule(pResolvedToken->hClass) != m_pImage->m_hModule)
+ {
+ m_zapper->Warning(W("ReadyToRun: Cross-module RVA static fields not supported\n"));
+ ThrowHR(E_NOTIMPL);
+ }
+ break;
+
+ case CORINFO_FIELD_STATIC_ADDRESS: // field at given address
case CORINFO_FIELD_STATIC_ADDR_HELPER: // static field accessed using address-of helper (argument is FieldDesc *)
case CORINFO_FIELD_STATIC_TLS:
m_zapper->Warning(W("ReadyToRun: Rare kinds of static fields not supported\n"));
}
}
+ static void RVAFieldTest()
+ {
+ ReadOnlySpan<byte> value = new byte[] { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
+ for (byte i = 0; i < value.Length; i++)
+ Assert.AreEqual(value[i], (byte)(9 - i));
+ }
+
static void RunAllTests()
{
TestVirtualMethodCalls();
TestOpenClosedDelegate();
GenericLdtokenFieldsTest();
+
+ RVAFieldTest();
}
static int Main()