Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
ldtoken shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
jkotas committed Oct 16, 2019
1 parent 0430c3a commit 485a405
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12337,7 +12337,7 @@ GenTree* Compiler::gtFoldTypeCompare(GenTree* tree)
}

// We can't answer the equality comparison definitively at jit
// time, but can still simplify the comparison.
// time, but can still simplfy the comparison.
//
// Find out how we can compare the two handles.
// NOTE: We're potentially passing NO_CLASS_HANDLE, but the runtime knows what to do with it here.
Expand Down
3 changes: 3 additions & 0 deletions src/vm/jithelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4103,6 +4103,9 @@ NOINLINE HCIMPL1(Object*, JIT_GetRuntimeType_Framed, CORINFO_CLASS_HANDLE type)
if (refType == NULL)
{
HELPER_METHOD_FRAME_BEGIN_RET_1(refType);
// Compensate for CORINFO_TOKENKIND_Ldtoken optimization done by CEEInfo::embedGenericHandle
if (!typeHandle.IsTypeDesc() && typeHandle.AsMethodTable()->IsArray())
typeHandle = ArrayBase::GetTypeHandle(typeHandle.AsMethodTable());
refType = typeHandle.GetManagedClassObject();
HELPER_METHOD_FRAME_END();
}
Expand Down
7 changes: 6 additions & 1 deletion src/vm/jitinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2625,7 +2625,12 @@ void CEEInfo::embedGenericHandle(

pResult->handleType = CORINFO_HANDLETYPE_CLASS;

if (pResolvedToken->tokenType == CORINFO_TOKENKIND_Newarr)
if (pResolvedToken->tokenType == CORINFO_TOKENKIND_Newarr
#ifndef FEATURE_READYTORUN_COMPILER
// This enables use of MethodTable fast-path through JIT_GetRuntimeTypeHandle helper
|| (pResolvedToken->tokenType == CORINFO_TOKENKIND_Ldtoken && th.IsArray())
#endif
)
{
pResult->compileTimeHandle = (CORINFO_GENERIC_HANDLE)th.AsArray()->GetTemplateMethodTable();
}
Expand Down

0 comments on commit 485a405

Please sign in to comment.