Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into build-wasm-aot-helix
Browse files Browse the repository at this point in the history
  • Loading branch information
radical committed Apr 14, 2021
2 parents a1cd01c + 209a9b1 commit a741040
Show file tree
Hide file tree
Showing 77 changed files with 3,149 additions and 3,091 deletions.
2 changes: 1 addition & 1 deletion Build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<!-- Upfront restore hooks -->
<Import Project="$(RepositoryEngineeringDir)restore\docs.targets" Condition="'$(DotNetBuildFromSource)' != 'true'" />
<Import Project="$(RepositoryEngineeringDir)restore\optimizationData.targets" Condition="'$(DotNetBuildFromSource)' != 'true' and '$(EnableNgenOptimization)' == 'true'" />
<Import Project="$(RepositoryEngineeringDir)restore\optimizationData.targets" Condition="'$(DotNetBuildFromSource)' != 'true'" />

<Target Name="BuildLocalTasks"
BeforeTargets="Build">
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@

<!--Feature switches -->
<PropertyGroup>
<EnableNgenOptimization Condition="'$(EnableNgenOptimization)' == '' and '$(Configuration)' == 'Release'">true</EnableNgenOptimization>
<EnableNgenOptimization Condition="'$(EnableNgenOptimization)' == '' and ('$(Configuration)' == 'Release' or '$(Configuration)' == 'Checked')">true</EnableNgenOptimization>
<!-- Enable NuGet static graph evaluation to optimize incremental restore -->
<RestoreUseStaticGraphEvaluation>true</RestoreUseStaticGraphEvaluation>
<!-- Turn off end of life target framework checks as we intentionally build older .NETCoreApp configurations. -->
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/ToolBox/superpmi/superpmi-shared/lwmlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ LWM(GetJustMyCodeHandle, DWORDLONG, DLDL)
LWM(GetLazyStringLiteralHelper, DWORDLONG, DWORD)
LWM(GetLikelyClass, Agnostic_GetLikelyClass, Agnostic_GetLikelyClassResult)
LWM(GetLocationOfThisType, DWORDLONG, Agnostic_CORINFO_LOOKUP_KIND)
LWM(IsJitIntrinsic, DWORDLONG, DWORD)
LWM(GetMethodAttribs, DWORDLONG, DWORD)
LWM(GetClassModule, DWORDLONG, DWORDLONG)
LWM(GetModuleAssembly, DWORDLONG, DWORDLONG)
Expand Down
22 changes: 22 additions & 0 deletions src/coreclr/ToolBox/superpmi/superpmi-shared/methodcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,28 @@ DWORD MethodContext::repGetClassAttribs(CORINFO_CLASS_HANDLE classHandle)
return value;
}

void MethodContext::recIsJitIntrinsic(CORINFO_METHOD_HANDLE ftn, bool result)
{
if (IsJitIntrinsic == nullptr)
IsJitIntrinsic = new LightWeightMap<DWORDLONG, DWORD>();

IsJitIntrinsic->Add(CastHandle(ftn), (DWORD)result);
DEBUG_REC(dmpIsJitIntrinsic(CastHandle(ftn), (DWORD)result));
}
void MethodContext::dmpIsJitIntrinsic(DWORDLONG key, DWORD value)
{
printf("IsJitIntrinsic key ftn-%016llX, value res-%u", key, value);
}
bool MethodContext::repIsJitIntrinsic(CORINFO_METHOD_HANDLE ftn)
{
AssertCodeMsg((IsJitIntrinsic != nullptr) && (IsJitIntrinsic->GetIndex(CastHandle(ftn)) != -1), EXCEPTIONCODE_MC,
"Didn't find %016llX", CastHandle(ftn));

bool result = (BOOL)IsJitIntrinsic->Get(CastHandle(ftn));
DEBUG_REP(dmpIsJitIntrinsic(CastHandle(ftn), (DWORD)result));
return result;
}

void MethodContext::recGetMethodAttribs(CORINFO_METHOD_HANDLE methodHandle, DWORD attribs)
{
if (GetMethodAttribs == nullptr)
Expand Down
7 changes: 6 additions & 1 deletion src/coreclr/ToolBox/superpmi/superpmi-shared/methodcontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ class MethodContext
void dmpGetClassAttribs(DWORDLONG key, DWORD value);
DWORD repGetClassAttribs(CORINFO_CLASS_HANDLE classHandle);

void recIsJitIntrinsic(CORINFO_METHOD_HANDLE ftn, bool result);
void dmpIsJitIntrinsic(DWORDLONG key, DWORD value);
bool repIsJitIntrinsic(CORINFO_METHOD_HANDLE ftn);

void recGetMethodAttribs(CORINFO_METHOD_HANDLE methodHandle, DWORD attribs);
void dmpGetMethodAttribs(DWORDLONG key, DWORD value);
DWORD repGetMethodAttribs(CORINFO_METHOD_HANDLE methodHandle);
Expand Down Expand Up @@ -898,7 +902,7 @@ class MethodContext
};

// ********************* Please keep this up-to-date to ease adding more ***************
// Highest packet number: 191
// Highest packet number: 192
// *************************************************************************************
enum mcPackets
{
Expand Down Expand Up @@ -1000,6 +1004,7 @@ enum mcPackets
Packet_GetJustMyCodeHandle = 68,
Packet_GetLikelyClass = 182, // Added 9/27/2020
Packet_GetLocationOfThisType = 69,
Packet_IsJitIntrinsic = 192,
Packet_GetMethodAttribs = 70,
Packet_GetMethodClass = 71,
Packet_GetMethodModule = 181, // Added 11/20/2020
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@
// ICorMethodInfo
//
/**********************************************************************************/

// Quick check whether the method is a jit intrinsic. Returns the same value as getMethodAttribs(ftn) &
// CORINFO_FLG_JIT_INTRINSIC, except faster.
bool interceptor_ICJI::isJitIntrinsic(CORINFO_METHOD_HANDLE ftn)
{
mc->cr->AddCall("isJitIntrinsic");
bool temp = original_ICorJitInfo->isJitIntrinsic(ftn);
mc->recIsJitIntrinsic(ftn, temp);
return temp;
}

// return flags (defined above, CORINFO_FLG_PUBLIC ...)
uint32_t interceptor_ICJI::getMethodAttribs(CORINFO_METHOD_HANDLE ftn /* IN */)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
#include "spmiutil.h"


bool interceptor_ICJI::isJitIntrinsic(
CORINFO_METHOD_HANDLE ftn)
{
mcs->AddCall("isJitIntrinsic");
return original_ICorJitInfo->isJitIntrinsic(ftn);
}

uint32_t interceptor_ICJI::getMethodAttribs(
CORINFO_METHOD_HANDLE ftn)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
#include "spmiutil.h"


bool interceptor_ICJI::isJitIntrinsic(
CORINFO_METHOD_HANDLE ftn)
{
return original_ICorJitInfo->isJitIntrinsic(ftn);
}

uint32_t interceptor_ICJI::getMethodAttribs(
CORINFO_METHOD_HANDLE ftn)
{
Expand Down
8 changes: 8 additions & 0 deletions src/coreclr/ToolBox/superpmi/superpmi/icorjitinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ ICorJitInfo* InitICorJitInfo(JitInstance* jitInstance)
//
/**********************************************************************************/

// Quick check whether the method is a jit intrinsic. Returns the same value as getMethodAttribs(ftn) &
// CORINFO_FLG_JIT_INTRINSIC, except faster.
bool MyICJI::isJitIntrinsic(CORINFO_METHOD_HANDLE ftn)
{
jitInstance->mc->cr->AddCall("isJitIntrinsic");
return jitInstance->mc->repIsJitIntrinsic(ftn);
}

// return flags (defined above, CORINFO_FLG_PUBLIC ...)
uint32_t MyICJI::getMethodAttribs(CORINFO_METHOD_HANDLE ftn /* IN */)
{
Expand Down
31 changes: 23 additions & 8 deletions src/coreclr/crossgen-corelib.proj
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
<CrossGen2DllFiles Condition="'$(CrossDir)' != ''" Include="$(BinDir)/$(CrossDir)/crossgen2/*" />
</ItemGroup>

<ItemGroup>
<OptimizationMibcFiles Include="$(MibcOptimizationDataDir)/$(TargetOS)/$(TargetArchitecture)/**/*.mibc" />
</ItemGroup>

<PropertyGroup>
<CoreLibAssemblyName>System.Private.CoreLib</CoreLibAssemblyName>
<CoreLibInputPath>$([MSBuild]::NormalizePath('$(BinDir)', 'IL', '$(CoreLibAssemblyName).dll'))</CoreLibInputPath>
Expand All @@ -53,12 +57,28 @@
<CoreLibPerfMapPath></CoreLibPerfMapPath>
<CoreLibNiPdbPath Condition="$(BuildPdb)">$([MSBuild]::NormalizePath('$(BinDir)', 'PDB', '$(CoreLibAssemblyName).ni.pdb'))</CoreLibNiPdbPath>
<CoreLibPerfMapPath Condition="$(BuildPerfMap)">$([MSBuild]::NormalizePath('$(BinDir)', '$(CoreLibAssemblyName).perf.map'))</CoreLibPerfMapPath>
<MergedMibcPath>$([MSBuild]::NormalizePath('$(BinDir)', 'StandardOptimizationData.mibc'))</MergedMibcPath>
</PropertyGroup>
</Target>

<Target Name="InvokeCrossgen"
<Target Name="CreateMergedMibcFile"
DependsOnTargets="PrepareForCrossgen"
Inputs="$(CoreLibInputPath);@(CrossGen2DllFiles)"
Inputs="@(OptimizationMibcFiles)"
Outputs="$(MergedMibcPath)">

<PropertyGroup>
<DotNetPgoCmd>$(DotNetCli) $([MSBuild]::NormalizePath('$(BinDir)', 'dotnet-pgo', 'dotnet-pgo.dll')) merge</DotNetPgoCmd>
<DotNetPgoCmd>$(DotNetPgoCmd) -o:$(MergedMibcPath)</DotNetPgoCmd>
<DotNetPgoCmd>$(DotNetPgoCmd) @(OptimizationMibcFiles->'-i:%(Identity)', ' ')</DotNetPgoCmd>
</PropertyGroup>

<Message Condition="'$(DotNetBuildFromSource)' != 'true'" Importance="High" Text="$(DotNetPgoCmd)"/>
<Exec Condition="'$(DotNetBuildFromSource)' != 'true'" Command="$(DotNetPgoCmd)" />
</Target>

<Target Name="InvokeCrossgen"
DependsOnTargets="PrepareForCrossgen;CreateMergedMibcFile"
Inputs="$(CoreLibInputPath);@(CrossGen2DllFiles);$(MergedMibcPath)"
Outputs="$(CoreLibOutputPath);$(CoreLibNiPdbPath);$(CoreLibPerfMapPath)"
AfterTargets="Build">

Expand All @@ -75,17 +95,12 @@
<Message Importance="High"
Text="Generating native image of System.Private.CoreLib for $(OSPlatformConfig). Logging to $(CrossGenCoreLibLog)" />

<ItemGroup>
<OptimizationMibcFiles Include="$(MibcOptimizationDataDir)/$(TargetOS)/$(TargetArchitecture)/**/*.mibc" />
</ItemGroup>

<PropertyGroup>
<CrossGenDllCmd>$(DotNetCli) $([MSBuild]::NormalizePath('$(BinDir)', '$(CrossDir)', 'crossgen2', 'crossgen2.dll'))</CrossGenDllCmd>
<CrossGenDllCmd>$(CrossGenDllCmd) -o:$(CoreLibOutputPath)</CrossGenDllCmd>
<CrossGenDllCmd>$(CrossGenDllCmd) -r:$([MSBuild]::NormalizePath('$(BinDir)', 'IL', '*.dll'))</CrossGenDllCmd>
<CrossGenDllCmd>$(CrossGenDllCmd) --targetarch:$(TargetArchitecture)</CrossGenDllCmd>
<MibcArgs>@(OptimizationMibcFiles->'-m:%(Identity)', ' ')</MibcArgs>
<CrossGenDllCmd Condition="'$(UsingToolIbcOptimization)' != 'true' and '$(Configuration)' == 'Release'">$(CrossGenDllCmd) $(MibcArgs) --embed-pgo-data</CrossGenDllCmd>
<CrossGenDllCmd Condition="'$(UsingToolIbcOptimization)' != 'true' and '$(EnableNgenOptimization)' == 'true'">$(CrossGenDllCmd) -m:$(MergedMibcPath) --embed-pgo-data</CrossGenDllCmd>
<CrossGenDllCmd>$(CrossGenDllCmd) -O</CrossGenDllCmd>
<CrossGenDllCmd>$(CrossGenDllCmd) $(CoreLibInputPath)</CrossGenDllCmd>
</PropertyGroup>
Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/inc/corinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -1953,6 +1953,9 @@ class ICorStaticInfo
//
/**********************************************************************************/

// Quick check whether the method is a jit intrinsic. Returns the same value as getMethodAttribs(ftn) & CORINFO_FLG_JIT_INTRINSIC, except faster.
virtual bool isJitIntrinsic(CORINFO_METHOD_HANDLE ftn) = 0;

// return flags (a bitfield of CorInfoFlags values)
virtual uint32_t getMethodAttribs (
CORINFO_METHOD_HANDLE ftn /* IN */
Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/inc/icorjitinfoimpl_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

public:

bool isJitIntrinsic(
CORINFO_METHOD_HANDLE ftn) override;

uint32_t getMethodAttribs(
CORINFO_METHOD_HANDLE ftn) override;

Expand Down
10 changes: 5 additions & 5 deletions src/coreclr/inc/jiteeversionguid.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ typedef const GUID *LPCGUID;
#define GUID_DEFINED
#endif // !GUID_DEFINED

constexpr GUID JITEEVersionIdentifier = { /* 1776ab48-edfa-49be-a11f-ec216b28174c */
0x1776ab48,
0xedfa,
0x49be,
{0xa1, 0x1f, 0xec, 0x21, 0x6b, 0x28, 0x17, 0x4c}
constexpr GUID JITEEVersionIdentifier = { /* a33f2f79-dd8d-49dd-b4c3-ac86f34f6a87 */
0xa33f2f79,
0xdd8d,
0x49dd,
{0xb4, 0xc3, 0xac, 0x86, 0xf3, 0x4f, 0x6a, 0x87}
};

//////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/jit/ICorJitInfo_API_names.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// DO NOT EDIT THIS FILE! IT IS AUTOGENERATED
// To regenerate run the gen script in src/coreclr/tools/Common/JitInterface/ThunkGenerator
// and follow the instructions in docs/project/updating-jitinterface.md
DEF_CLR_API(isJitIntrinsic)
DEF_CLR_API(getMethodAttribs)
DEF_CLR_API(setMethodAttribs)
DEF_CLR_API(getMethodSig)
Expand Down
9 changes: 9 additions & 0 deletions src/coreclr/jit/ICorJitInfo_API_wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@
// clang-format off
/**********************************************************************************/

bool WrapICorJitInfo::isJitIntrinsic(
CORINFO_METHOD_HANDLE ftn)
{
API_ENTER(isJitIntrinsic);
bool temp = wrapHnd->isJitIntrinsic(ftn);
API_LEAVE(isJitIntrinsic);
return temp;
}

uint32_t WrapICorJitInfo::getMethodAttribs(
CORINFO_METHOD_HANDLE ftn)
{
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -7542,6 +7542,7 @@ class Compiler
// Get the flags

bool eeIsValueClass(CORINFO_CLASS_HANDLE clsHnd);
bool eeIsJitIntrinsic(CORINFO_METHOD_HANDLE ftn);

#if defined(DEBUG) || defined(FEATURE_JIT_METHOD_PERF) || defined(FEATURE_SIMD) || defined(TRACK_LSRA_STATS)

Expand Down
6 changes: 6 additions & 0 deletions src/coreclr/jit/ee_il_dll.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ bool Compiler::eeIsValueClass(CORINFO_CLASS_HANDLE clsHnd)
return info.compCompHnd->isValueClass(clsHnd);
}

FORCEINLINE
bool Compiler::eeIsJitIntrinsic(CORINFO_METHOD_HANDLE ftn)
{
return info.compCompHnd->isJitIntrinsic(ftn);
}

FORCEINLINE
void Compiler::eeGetSig(unsigned sigTok,
CORINFO_MODULE_HANDLE scope,
Expand Down
59 changes: 17 additions & 42 deletions src/coreclr/jit/fgbasic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -893,8 +893,6 @@ void Compiler::fgFindJumpTargets(const BYTE* codeAddr, IL_OFFSET codeSize, Fixed
}

CORINFO_RESOLVED_TOKEN resolvedToken;
CORINFO_RESOLVED_TOKEN constrainedResolvedToken;
CORINFO_CALL_INFO callInfo;

while (codeAddr < codeEndp)
{
Expand Down Expand Up @@ -958,54 +956,35 @@ void Compiler::fgFindJumpTargets(const BYTE* codeAddr, IL_OFFSET codeSize, Fixed
break;
}

CORINFO_METHOD_HANDLE methodHnd = nullptr;
unsigned methodFlags = 0;
bool mustExpand = false;
CorInfoIntrinsics intrinsicID = CORINFO_INTRINSIC_Illegal;
NamedIntrinsic ni = NI_Illegal;
CORINFO_METHOD_HANDLE methodHnd = nullptr;
bool isJitIntrinsic = false;
bool mustExpand = false;
NamedIntrinsic ni = NI_Illegal;

if (resolveTokens)
{
impResolveToken(codeAddr, &resolvedToken, CORINFO_TOKENKIND_Method);
eeGetCallInfo(&resolvedToken,
(prefixFlags & PREFIX_CONSTRAINED) ? &constrainedResolvedToken : nullptr,
combine(combine(CORINFO_CALLINFO_KINDONLY, CORINFO_CALLINFO_ALLOWINSTPARAM),
(opcode == CEE_CALLVIRT) ? CORINFO_CALLINFO_CALLVIRT : CORINFO_CALLINFO_NONE),
&callInfo);

methodHnd = callInfo.hMethod;
methodFlags = callInfo.methodFlags;
methodHnd = resolvedToken.hMethod;
isJitIntrinsic = eeIsJitIntrinsic(methodHnd);
}

if ((methodFlags & (CORINFO_FLG_INTRINSIC | CORINFO_FLG_JIT_INTRINSIC)) != 0)
if (isJitIntrinsic)
{
intrinsicCalls++;
ni = lookupNamedIntrinsic(methodHnd);

if ((methodFlags & CORINFO_FLG_INTRINSIC) != 0)
switch (ni)
{
intrinsicID = info.compCompHnd->getIntrinsicID(methodHnd, &mustExpand);
}
case NI_IsSupported_True:
case NI_IsSupported_False:
{
pushedStack.PushConstant();
break;
}

if ((methodFlags & CORINFO_FLG_JIT_INTRINSIC) != 0)
{
if (intrinsicID == CORINFO_INTRINSIC_Illegal)
default:
{
ni = lookupNamedIntrinsic(methodHnd);

switch (ni)
{
case NI_IsSupported_True:
case NI_IsSupported_False:
{
pushedStack.PushConstant();
break;
}

default:
{
break;
}
}
break;
}
}
}
Expand Down Expand Up @@ -1162,10 +1141,6 @@ void Compiler::fgFindJumpTargets(const BYTE* codeAddr, IL_OFFSET codeSize, Fixed
noway_assert(sz == sizeof(unsigned));
prefixFlags |= PREFIX_CONSTRAINED;

if (resolveTokens)
{
impResolveToken(codeAddr, &constrainedResolvedToken, CORINFO_TOKENKIND_Constrained);
}
codeAddr += sizeof(unsigned);

{
Expand Down
14 changes: 14 additions & 0 deletions src/coreclr/jit/fgopt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1996,6 +1996,20 @@ void Compiler::fgUpdateLoopsAfterCompacting(BasicBlock* block, BasicBlock* bNext
{
optLoopTable[loopNum].lpEntry = block;
}

/* Check the loop's first block */

if (optLoopTable[loopNum].lpFirst == bNext)
{
optLoopTable[loopNum].lpFirst = block;
}

/* Check the loop top */

if (optLoopTable[loopNum].lpTop == bNext)
{
optLoopTable[loopNum].lpTop = block;
}
}
}

Expand Down
Loading

0 comments on commit a741040

Please sign in to comment.