summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Kotas <jkotas@microsoft.com>2015-08-19 22:48:01 -0700
committerJan Kotas <jkotas@microsoft.com>2015-08-19 22:48:01 -0700
commitcf3ad1e861a14aec7806cc575f19f91092309b37 (patch)
tree94cc8aaa872d222f7ce2921f83b164f9eb975165 /src
parent0152e40aec8bf3da45c111d66eb579fed686edb2 (diff)
downloadcoreclr-cf3ad1e861a14aec7806cc575f19f91092309b37.tar.gz
coreclr-cf3ad1e861a14aec7806cc575f19f91092309b37.tar.bz2
coreclr-cf3ad1e861a14aec7806cc575f19f91092309b37.zip
Complete support for atypical callsites
Diffstat (limited to 'src')
-rw-r--r--src/inc/corinfo.h3
-rw-r--r--src/zap/zapimport.cpp50
-rw-r--r--src/zap/zapimport.h2
-rw-r--r--src/zap/zapinfo.cpp34
4 files changed, 72 insertions, 17 deletions
diff --git a/src/inc/corinfo.h b/src/inc/corinfo.h
index 4c9034b4a2..27a8fc7f26 100644
--- a/src/inc/corinfo.h
+++ b/src/inc/corinfo.h
@@ -602,6 +602,8 @@ enum CorInfoHelpFunc
CORINFO_HELP_COUNT,
};
+#define CORINFO_HELP_READYTORUN_ATYPICAL_CALLSITE 0x40000000
+
//This describes the signature for a helper method.
enum CorInfoHelpSig
{
@@ -1111,6 +1113,7 @@ enum CORINFO_ACCESS_FLAGS
CORINFO_ACCESS_SET = 0x0200, // Field set (stfld)
CORINFO_ACCESS_ADDRESS = 0x0400, // Field address (ldflda)
CORINFO_ACCESS_INIT_ARRAY = 0x0800, // Field use for InitializeArray
+ CORINFO_ACCESS_ATYPICAL_CALLSITE = 0x4000, // Atypical callsite that cannot be disassembled by delay loading helper
CORINFO_ACCESS_INLINECHECK= 0x8000, // Return fieldFlags and fieldAccessor only. Used by JIT64 during inlining.
};
diff --git a/src/zap/zapimport.cpp b/src/zap/zapimport.cpp
index 1bc1568a7e..6252d524e1 100644
--- a/src/zap/zapimport.cpp
+++ b/src/zap/zapimport.cpp
@@ -1766,8 +1766,12 @@ void ZapImportSectionSignatures::PlaceDynamicHelperCell(ZapImport * pImport)
}
// Create the delay load helper
- ReadyToRunHelper helperNum = GetDelayLoadHelperForDynamicHelper(pCell->GetKind());
- ZapNode * pDelayLoadHelper = m_pImage->GetImportTable()->GetPlacedIndirectHelperThunk(helperNum, (PVOID)m_dwIndex);
+ ReadyToRunHelper helperNum = GetDelayLoadHelperForDynamicHelper(
+ (CORCOMPILE_FIXUP_BLOB_KIND)(pCell->GetKind() & ~CORINFO_HELP_READYTORUN_ATYPICAL_CALLSITE));
+
+ ZapNode * pDelayLoadHelper = m_pImage->GetImportTable()->GetPlacedIndirectHelperThunk(helperNum, (PVOID)m_dwIndex,
+ (pCell->GetKind() & CORINFO_HELP_READYTORUN_ATYPICAL_CALLSITE) ? pCell : NULL);
+
pCell->SetDelayLoadHelper(pDelayLoadHelper);
// Add entry to both the the cell and data sections
@@ -1784,7 +1788,7 @@ ZapImport * ZapImportTable::GetDynamicHelperCell(CORCOMPILE_FIXUP_BLOB_KIND kind
{
SigBuilder sigBuilder;
- sigBuilder.AppendData(kind);
+ sigBuilder.AppendData(kind & ~CORINFO_HELP_READYTORUN_ATYPICAL_CALLSITE);
GetCompileInfo()->EncodeClass(m_pImage->GetModuleHandle(), handle, &sigBuilder, NULL, NULL);
@@ -1798,7 +1802,8 @@ ZapImport * ZapImportTable::GetDynamicHelperCell(CORCOMPILE_FIXUP_BLOB_KIND kind
{
SigBuilder sigBuilder;
- EncodeMethod(kind, handle, &sigBuilder, pResolvedToken);
+ EncodeMethod((CORCOMPILE_FIXUP_BLOB_KIND)(kind & ~CORINFO_HELP_READYTORUN_ATYPICAL_CALLSITE),
+ handle, &sigBuilder, pResolvedToken);
return GetImportForSignature<ZapDynamicHelperCell, ZapNodeType_DynamicHelperCell>((void *)kind, &sigBuilder);
}
@@ -1807,7 +1812,8 @@ ZapImport * ZapImportTable::GetDynamicHelperCell(CORCOMPILE_FIXUP_BLOB_KIND kind
{
SigBuilder sigBuilder;
- EncodeField(kind, handle, &sigBuilder, pResolvedToken);
+ EncodeField((CORCOMPILE_FIXUP_BLOB_KIND)(kind & ~CORINFO_HELP_READYTORUN_ATYPICAL_CALLSITE),
+ handle, &sigBuilder, pResolvedToken);
return GetImportForSignature<ZapDynamicHelperCell, ZapNodeType_DynamicHelperCell>((void *)kind, &sigBuilder);
}
@@ -1816,7 +1822,14 @@ class ZapIndirectHelperThunk : public ZapImport
{
DWORD SaveWorker(ZapWriter * pZapWriter);
+ ZapNode * m_pCell;
+
public:
+ void SetCell(ZapNode * pCell)
+ {
+ m_pCell = pCell;
+ }
+
ReadyToRunHelper GetReadyToRunHelper()
{
return (ReadyToRunHelper)((DWORD)GetHandle() & ~READYTORUN_HELPER_FLAG_VSD);
@@ -1934,6 +1947,17 @@ DWORD ZapIndirectHelperThunk::SaveWorker(ZapWriter * pZapWriter)
#elif defined(_TARGET_AMD64_)
if (IsDelayLoadHelper())
{
+ if (m_pCell != NULL)
+ {
+ // lea rax, [pCell]
+ *p++ = 0x48;
+ *p++ = 0x8D;
+ *p++ = 0x05;
+ if (pImage != NULL)
+ pImage->WriteReloc(buffer, (int)(p - buffer), m_pCell, 0, IMAGE_REL_BASED_REL32);
+ p += 4;
+ }
+ else
if (IsVSD())
{
// mov rax, r11
@@ -2087,9 +2111,21 @@ ZapNode * ZapImportTable::GetIndirectHelperThunk(ReadyToRunHelper helperNum, PVO
return pImport;
}
-ZapNode * ZapImportTable::GetPlacedIndirectHelperThunk(ReadyToRunHelper helperNum, PVOID pArg)
+ZapNode * ZapImportTable::GetPlacedIndirectHelperThunk(ReadyToRunHelper helperNum, PVOID pArg, ZapNode * pCell)
{
- ZapNode * pImport = GetImport<ZapIndirectHelperThunk, ZapNodeType_IndirectHelperThunk>((void *)helperNum, pArg);
+ ZapNode * pImport;
+ if (pCell != NULL)
+ {
+ ZapIndirectHelperThunk * pIndirectHelperThunk = new (m_pImage->GetHeap()) ZapIndirectHelperThunk();
+ pIndirectHelperThunk->SetHandle((void *)helperNum);
+ pIndirectHelperThunk->SetHandle2(pArg);
+ pIndirectHelperThunk->SetCell(pCell);
+ pImport = pIndirectHelperThunk;
+ }
+ else
+ {
+ pImport = GetImport<ZapIndirectHelperThunk, ZapNodeType_IndirectHelperThunk>((void *)helperNum, pArg);
+ }
if (!pImport->IsPlaced())
PlaceIndirectHelperThunk(pImport);
#if defined(_TARGET_ARM_) && !defined(BINDER)
diff --git a/src/zap/zapimport.h b/src/zap/zapimport.h
index 432e373079..df4d40cd63 100644
--- a/src/zap/zapimport.h
+++ b/src/zap/zapimport.h
@@ -437,7 +437,7 @@ public:
ZapImport * GetDynamicHelperCell(CORCOMPILE_FIXUP_BLOB_KIND kind, CORINFO_FIELD_HANDLE handle, CORINFO_RESOLVED_TOKEN * pResolvedToken);
#ifdef FEATURE_READYTORUN_COMPILER
- ZapNode * GetPlacedIndirectHelperThunk(ReadyToRunHelper helperNum, PVOID pArg = NULL);
+ ZapNode * GetPlacedIndirectHelperThunk(ReadyToRunHelper helperNum, PVOID pArg = NULL, ZapNode * pCell = NULL);
ZapNode * GetIndirectHelperThunk(ReadyToRunHelper helperNum, PVOID pArg = NULL);
void PlaceIndirectHelperThunk(ZapNode * pImport);
diff --git a/src/zap/zapinfo.cpp b/src/zap/zapinfo.cpp
index dbdd26e5b9..371e0fee94 100644
--- a/src/zap/zapinfo.cpp
+++ b/src/zap/zapinfo.cpp
@@ -2981,7 +2981,10 @@ void ZapInfo::getCallInfo(CORINFO_RESOLVED_TOKEN * pResolvedToken,
#ifdef FEATURE_READYTORUN_COMPILER
if (IsReadyToRunCompilation())
{
- ZapImport * pImport = m_pImage->GetImportTable()->GetDynamicHelperCell(ENCODE_VIRTUAL_ENTRY, pResult->hMethod, pResolvedToken);
+ DWORD fAtypicalCallsite = (flags & CORINFO_CALLINFO_ATYPICAL_CALLSITE) ? CORINFO_HELP_READYTORUN_ATYPICAL_CALLSITE : 0;
+
+ ZapImport * pImport = m_pImage->GetImportTable()->GetDynamicHelperCell(
+ (CORCOMPILE_FIXUP_BLOB_KIND)(ENCODE_VIRTUAL_ENTRY | fAtypicalCallsite), pResult->hMethod, pResolvedToken);
pResult->codePointerLookup.constLookup.accessType = IAT_PVALUE;
pResult->codePointerLookup.constLookup.addr = pImport;
@@ -3618,6 +3621,8 @@ void ZapInfo::getFieldInfo (CORINFO_RESOLVED_TOKEN * pResolvedToken,
ThrowHR(E_NOTIMPL);
}
+ DWORD fAtypicalCallsite = (flags & CORINFO_ACCESS_ATYPICAL_CALLSITE) ? CORINFO_HELP_READYTORUN_ATYPICAL_CALLSITE : 0;
+
switch (pResult->fieldAccessor)
{
case CORINFO_FIELD_INSTANCE:
@@ -3722,7 +3727,8 @@ void ZapInfo::getFieldInfo (CORINFO_RESOLVED_TOKEN * pResolvedToken,
UNREACHABLE_MSG("Unexpected static helper");
}
- ZapImport * pImport = m_pImage->GetImportTable()->GetDynamicHelperCell(kind, pResolvedToken->hClass);
+ ZapImport * pImport = m_pImage->GetImportTable()->GetDynamicHelperCell(
+ (CORCOMPILE_FIXUP_BLOB_KIND)(kind | fAtypicalCallsite), pResolvedToken->hClass);
pResult->fieldLookup.accessType = IAT_PVALUE;
pResult->fieldLookup.addr = pImport;
@@ -3731,7 +3737,8 @@ void ZapInfo::getFieldInfo (CORINFO_RESOLVED_TOKEN * pResolvedToken,
}
else
{
- ZapImport * pImport = m_pImage->GetImportTable()->GetDynamicHelperCell(ENCODE_FIELD_ADDRESS, pResolvedToken->hField, pResolvedToken);
+ ZapImport * pImport = m_pImage->GetImportTable()->GetDynamicHelperCell(
+ (CORCOMPILE_FIXUP_BLOB_KIND)(ENCODE_FIELD_ADDRESS | fAtypicalCallsite), pResolvedToken->hField, pResolvedToken);
pResult->fieldLookup.accessType = IAT_PVALUE;
pResult->fieldLookup.addr = pImport;
@@ -4269,28 +4276,36 @@ void ZapInfo::getReadyToRunHelper(
ZapImport * pImport = NULL;
+ DWORD fAtypicalCallsite = (id & CORINFO_HELP_READYTORUN_ATYPICAL_CALLSITE);
+ id = (CorInfoHelpFunc)(id & ~CORINFO_HELP_READYTORUN_ATYPICAL_CALLSITE);
+
switch (id)
{
case CORINFO_HELP_READYTORUN_NEW:
- pImport = m_pImage->GetImportTable()->GetDynamicHelperCell(ENCODE_NEW_HELPER, pResolvedToken->hClass);
+ pImport = m_pImage->GetImportTable()->GetDynamicHelperCell(
+ (CORCOMPILE_FIXUP_BLOB_KIND)(ENCODE_NEW_HELPER | fAtypicalCallsite), pResolvedToken->hClass);
break;
case CORINFO_HELP_READYTORUN_NEWARR_1:
- pImport = m_pImage->GetImportTable()->GetDynamicHelperCell(ENCODE_NEW_ARRAY_HELPER, pResolvedToken->hClass);
+ pImport = m_pImage->GetImportTable()->GetDynamicHelperCell(
+ (CORCOMPILE_FIXUP_BLOB_KIND)(ENCODE_NEW_ARRAY_HELPER | fAtypicalCallsite), pResolvedToken->hClass);
break;
case CORINFO_HELP_READYTORUN_ISINSTANCEOF:
- pImport = m_pImage->GetImportTable()->GetDynamicHelperCell(ENCODE_ISINSTANCEOF_HELPER, pResolvedToken->hClass);
+ pImport = m_pImage->GetImportTable()->GetDynamicHelperCell(
+ (CORCOMPILE_FIXUP_BLOB_KIND)(ENCODE_ISINSTANCEOF_HELPER | fAtypicalCallsite), pResolvedToken->hClass);
break;
case CORINFO_HELP_READYTORUN_CHKCAST:
- pImport = m_pImage->GetImportTable()->GetDynamicHelperCell(ENCODE_CHKCAST_HELPER, pResolvedToken->hClass);
+ pImport = m_pImage->GetImportTable()->GetDynamicHelperCell(
+ (CORCOMPILE_FIXUP_BLOB_KIND)(ENCODE_CHKCAST_HELPER | fAtypicalCallsite), pResolvedToken->hClass);
break;
case CORINFO_HELP_READYTORUN_STATIC_BASE:
if (m_pImage->GetCompileInfo()->IsInCurrentVersionBubble(m_pEEJitInfo->getClassModule(pResolvedToken->hClass)))
{
- pImport = m_pImage->GetImportTable()->GetDynamicHelperCell(ENCODE_CCTOR_TRIGGER, pResolvedToken->hClass);
+ pImport = m_pImage->GetImportTable()->GetDynamicHelperCell(
+ (CORCOMPILE_FIXUP_BLOB_KIND)(ENCODE_CCTOR_TRIGGER | fAtypicalCallsite), pResolvedToken->hClass);
}
else
{
@@ -4301,7 +4316,8 @@ void ZapInfo::getReadyToRunHelper(
break;
case CORINFO_HELP_READYTORUN_DELEGATE_CTOR:
- pImport = m_pImage->GetImportTable()->GetDynamicHelperCell(ENCODE_DELEGATE_CTOR, pResolvedToken->hMethod, pResolvedToken);
+ pImport = m_pImage->GetImportTable()->GetDynamicHelperCell(
+ (CORCOMPILE_FIXUP_BLOB_KIND)(ENCODE_DELEGATE_CTOR | fAtypicalCallsite), pResolvedToken->hMethod, pResolvedToken);
break;
default: