Skip to content

Commit

Permalink
Update Type Encoding for MulticoreJit
Browse files Browse the repository at this point in the history
  • Loading branch information
clamp03 committed Oct 20, 2020
1 parent ddb67b3 commit e26951b
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 19 deletions.
2 changes: 2 additions & 0 deletions src/coreclr/src/vm/compile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,8 @@ void CEECompileInfo::EncodeMethod(
STANDARD_VM_CONTRACT;

COOPERATIVE_TRANSITION_BEGIN();

_ASSERTE(referencingModule);
MethodDesc *pMethod = GetMethod(handle);

BOOL fSuccess;
Expand Down
8 changes: 1 addition & 7 deletions src/coreclr/src/vm/multicorejit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ HRESULT MulticoreJitRecorder::WriteOutput(IStream * pStream)
BOOL fSuccess = false;
EX_TRY
{
fSuccess = ZapSig::EncodeMethod(pMethod, NULL, &sigBuilder, (LPVOID)this, (ENCODEMODULE_CALLBACK)MulticoreJitManager::EncodeModuleHelper, (DEFINETOKEN_CALLBACK)MulticoreJitManager::TokenDefinitionHelper);
fSuccess = ZapSig::EncodeMethod(pMethod, NULL, &sigBuilder, (LPVOID)this, (ENCODEMODULE_CALLBACK)MulticoreJitManager::EncodeModuleHelper, NULL);
}
EX_CATCH
{
Expand Down Expand Up @@ -1547,12 +1547,6 @@ DWORD MulticoreJitManager::EncodeModuleHelper(void * pModuleContext, Module * pR
return ((MulticoreJitRecorder*)pModuleContext)->EncodeModule(pReferencedModule);
}

// static
void MulticoreJitManager::TokenDefinitionHelper(void* pModuleContext, Module *pReferencedModule, DWORD index, mdToken* pToken)
{
LIMITED_METHOD_CONTRACT
}

//---------------------------------------------------------------------------------------
//
// MultiCore JIT
Expand Down
5 changes: 0 additions & 5 deletions src/coreclr/src/vm/multicorejit.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,11 +304,6 @@ class MulticoreJitManager
static DWORD EncodeModuleHelper(void * pModuleContext,
Module * pReferencedModule);

static void TokenDefinitionHelper(void* pModuleContext,
Module *pReferencedModule,
DWORD index,
mdToken* pToken);

static Module * DecodeModuleFromIndex(void * pModuleContext,
DWORD ix);
};
Expand Down
6 changes: 2 additions & 4 deletions src/coreclr/src/vm/zapsig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,10 @@ BOOL ZapSig::GetSignatureForTypeHandle(TypeHandle handle,

// During IBC profiling this calls
// code:Module::TokenDefinitionHelper
// During MulticoreJit profiling this calls
// code:MulticoreJitManager::TokenDefinitionHelper
(*this->pfnTokenDefinition)(this->context.pModuleContext, pTypeHandleModule, index, &token);

// ibcExternalType tokens are actually encoded as mdtTypeDef tokens in the signature
_ASSERTE(this->context.externalTokens != ZapSig::MulticoreJitTokens && TypeFromToken(token) == ibcExternalType);
_ASSERTE(TypeFromToken(token) == ibcExternalType);
token = TokenFromRid(RidFromToken(token), mdtTypeDef);
}

Expand Down Expand Up @@ -1234,7 +1232,7 @@ BOOL ZapSig::EncodeMethod(
}

ZapSig::ExternalTokens externalTokens = ZapSig::NormalTokens;
if (pInfoModule == NULL && pfnDefineToken != NULL)
if (pInfoModule == NULL)
{
externalTokens = ZapSig::MulticoreJitTokens;
pInfoModule = pMethod->GetModule_NoLogging();
Expand Down
26 changes: 23 additions & 3 deletions src/tests/baseservices/TieredCompilation/BasicTestWithMcj.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,19 @@
using System;
using System.Runtime;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
using System.Threading;

public static class BasicTest
{
public class MCJTestClass
{
}

public struct MCJTestStruct
{
}

private static int Main()
{
const int Pass = 100;
Expand All @@ -18,10 +27,22 @@ private static int Main()
// Let multi-core JIT start jitting
Thread.Sleep(100);

PromoteToTier1(Foo, () => FooWithLoop(2), () => FooWithGeneric<int>(2));
MCJTestStruct s;
PromoteToTier1(Foo, () => FooWithLoop(2), () => FooWithGeneric<int>(3),
() => FooWithGeneric<string>("MCJ"),
() => FooWithGeneric<MCJTestClass>(null),
() => FooWithGeneric<MCJTestStruct>(s),
() => FooWithGeneric<Regex>(null),
() => FooWithGeneric(RegexOptions.IgnoreCase));

Foo();
FooWithLoop(2);
FooWithGeneric<int>(2);
FooWithGeneric<int>(3);
FooWithGeneric<string>("MCJ");
FooWithGeneric<MCJTestClass>(null);
FooWithGeneric<MCJTestStruct>(s);
FooWithGeneric<Regex>(null);
FooWithGeneric(RegexOptions.IgnoreCase);

ProfileOptimization.StartProfile(null);
return Pass;
Expand All @@ -37,7 +58,6 @@ private static void Foo2()
{
}


[MethodImpl(MethodImplOptions.NoInlining)]
private static int FooWithLoop(int n)
{
Expand Down

0 comments on commit e26951b

Please sign in to comment.