summaryrefslogtreecommitdiff
path: root/src/vm/zapsig.cpp
diff options
context:
space:
mode:
authorFadi Hanna <fadim@microsoft.com>2016-08-03 18:00:49 -0700
committerGitHub <noreply@github.com>2016-08-03 18:00:49 -0700
commit693fff99049bc7d63459b2c444237ca532036b47 (patch)
treeb6c9b7fdc517276f1480f6a9deb23c506ffc8fdd /src/vm/zapsig.cpp
parentd18ddfda61efdfe4521d2dce816fa01021bf26a8 (diff)
downloadcoreclr-693fff99049bc7d63459b2c444237ca532036b47.tar.gz
coreclr-693fff99049bc7d63459b2c444237ca532036b47.tar.bz2
coreclr-693fff99049bc7d63459b2c444237ca532036b47.zip
Adding Support for FieldDescSlot generic dictionary entries for R2R generic code. (#6200)
This enables generic code with ldtoken instructions for fields on generic types to be compiled into R2R. This change makes newer versions of the runtime compatible with older version R2R images, but not vice-versa. Therefore, the major version is increased to 2 with this change. This change adds more encodings to a R2R image without changing the format of any previously encoded entity, and is backwards compatible.
Diffstat (limited to 'src/vm/zapsig.cpp')
-rw-r--r--src/vm/zapsig.cpp48
1 files changed, 34 insertions, 14 deletions
diff --git a/src/vm/zapsig.cpp b/src/vm/zapsig.cpp
index 93b34db31e..c619610f42 100644
--- a/src/vm/zapsig.cpp
+++ b/src/vm/zapsig.cpp
@@ -836,7 +836,7 @@ MethodDesc *ZapSig::DecodeMethod(Module *pReferencingModule,
Module *pInfoModule,
PCCOR_SIGNATURE pBuffer,
SigTypeContext *pContext,
- TypeHandle * ppTH, /*=NULL*/
+ TypeHandle *ppTH, /*=NULL*/
PCCOR_SIGNATURE *ppOwnerTypeSpecWithVars, /*=NULL*/
PCCOR_SIGNATURE *ppMethodSpecWithVars /*=NULL*/)
{
@@ -1013,7 +1013,20 @@ MethodDesc *ZapSig::DecodeMethod(Module *pReferencingModule,
FieldDesc * ZapSig::DecodeField(Module *pReferencingModule,
Module *pInfoModule,
PCCOR_SIGNATURE pBuffer,
- TypeHandle * ppTH /*=NULL*/)
+ TypeHandle *ppTH /*=NULL*/)
+{
+ STANDARD_VM_CONTRACT;
+
+ SigTypeContext typeContext; // empty context is OK: encoding should not contain type variables.
+
+ return DecodeField(pReferencingModule, pInfoModule, pBuffer, &typeContext, ppTH);
+}
+
+FieldDesc * ZapSig::DecodeField(Module *pReferencingModule,
+ Module *pInfoModule,
+ PCCOR_SIGNATURE pBuffer,
+ SigTypeContext *pContext,
+ TypeHandle *ppTH /*=NULL*/)
{
CONTRACTL
{
@@ -1037,10 +1050,8 @@ FieldDesc * ZapSig::DecodeField(Module *pReferencingModule,
ZapSig::Context zapSigContext(pInfoModule, pReferencingModule);
ZapSig::Context * pZapSigContext = &zapSigContext;
- SigTypeContext typeContext; // empty context is OK: encoding should not contain type variables.
-
pOwnerMT = sig.GetTypeHandleThrowing(pInfoModule,
- &typeContext,
+ pContext,
ClassLoader::LoadTypes,
CLASS_LOADED,
FALSE,
@@ -1371,7 +1382,8 @@ void ZapSig::EncodeField(
SigBuilder *pSigBuilder,
LPVOID pEncodeModuleContext,
ENCODEMODULE_CALLBACK pfnEncodeModule,
- CORINFO_RESOLVED_TOKEN * pResolvedToken)
+ CORINFO_RESOLVED_TOKEN *pResolvedToken,
+ BOOL fEncodeUsingResolvedTokenSpecStreams)
{
CONTRACTL
{
@@ -1452,15 +1464,23 @@ void ZapSig::EncodeField(
if (fieldFlags & ENCODE_FIELD_SIG_OwnerType)
{
- ZapSig zapSig(pInfoModule, pEncodeModuleContext, ZapSig::NormalTokens,
- (EncodeModuleCallback) pfnEncodeModule, NULL);
+ if (fEncodeUsingResolvedTokenSpecStreams && pResolvedToken != NULL && pResolvedToken->pTypeSpec != NULL)
+ {
+ _ASSERTE(pResolvedToken->cbTypeSpec > 0);
+ pSigBuilder->AppendBlob((PVOID)pResolvedToken->pTypeSpec, pResolvedToken->cbTypeSpec);
+ }
+ else
+ {
+ ZapSig zapSig(pInfoModule, pEncodeModuleContext, ZapSig::NormalTokens,
+ (EncodeModuleCallback)pfnEncodeModule, NULL);
- //
- // Write class
- //
- BOOL fSuccess;
- fSuccess = zapSig.GetSignatureForTypeHandle(pMT, pSigBuilder);
- _ASSERTE(fSuccess);
+ //
+ // Write class
+ //
+ BOOL fSuccess;
+ fSuccess = zapSig.GetSignatureForTypeHandle(pMT, pSigBuilder);
+ _ASSERTE(fSuccess);
+ }
}
if ((fieldFlags & ENCODE_FIELD_SIG_IndexInsteadOfToken) == 0)