Skip to content

Commit

Permalink
Merge branch 'dotnet:main' into AOT_delegates
Browse files Browse the repository at this point in the history
  • Loading branch information
LeVladIonescu authored May 15, 2023
2 parents 3144e6e + 9dd59af commit 175dae9
Show file tree
Hide file tree
Showing 51 changed files with 644 additions and 282 deletions.
1 change: 1 addition & 0 deletions docs/workflow/debugging/coreclr/debugging-runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ If for some reason `System.Private.CoreLib.dll` is missing, you can rebuild it w

Visual Studio's capabilities as a full IDE provide a lot of help making the runtime debugging more amiable.

0. Run `.\build.cmd clr.nativeprereqs -a <architecture> -c <configuration>`. This will build some of the tools requiremented for the native build. This step only needs to be run once as long you don't clean the `artifacts` directory.
1. Open the CoreCLR solution _(coreclr.sln)_ in Visual Studio.
* _Method 1_: Use the build scripts to open the solution:
1. Run `.\build.cmd -vs coreclr.sln -a <architecture> -c <configuration>`. This will create and launch the CoreCLR solution in VS for the specified architecture and configuration. By default, this will be `x64 Debug`.
Expand Down
6 changes: 4 additions & 2 deletions eng/native/configureplatform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -461,10 +461,12 @@ if(CLR_CMAKE_TARGET_UNIX)
else()
clr_unknown_arch()
endif()
else()
set(CLR_CMAKE_TARGET_WIN32 1)
endif(CLR_CMAKE_TARGET_UNIX)

if(CLR_CMAKE_TARGET_OS STREQUAL windows)
set(CLR_CMAKE_TARGET_WIN32 1)
endif()

# check if host & target os/arch combination are valid
if (NOT (CLR_CMAKE_TARGET_OS STREQUAL CLR_CMAKE_HOST_OS) AND NOT CLR_CMAKE_TARGET_WASI)
if(NOT (CLR_CMAKE_HOST_OS STREQUAL windows))
Expand Down
8 changes: 6 additions & 2 deletions src/coreclr/inc/corinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ enum CorInfoHelpFunc
CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_NOCTOR,
CORINFO_HELP_GETSHARED_GCTHREADSTATIC_BASE_DYNAMICCLASS,
CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_DYNAMICCLASS,
CORINFO_HELP_GETSHARED_GCTHREADSTATIC_BASE_NOCTOR_OPTIMIZED,
CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_NOCTOR_OPTIMIZED,

/* Debugger */
Expand Down Expand Up @@ -1731,6 +1732,7 @@ struct CORINFO_THREAD_STATIC_BLOCKS_INFO
uint32_t offsetOfThreadLocalStoragePointer;
uint32_t offsetOfMaxThreadStaticBlocks;
uint32_t offsetOfThreadStaticBlocks;
uint32_t offsetOfGCDataPointer;
};

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -2733,11 +2735,13 @@ class ICorStaticInfo
CORINFO_FIELD_INFO *pResult
) = 0;

// Returns the index against which the field's thread static block in stored in TLS.
virtual uint32_t getThreadLocalFieldInfo (
CORINFO_FIELD_HANDLE field) = 0;
CORINFO_FIELD_HANDLE field, bool isGCType) = 0;

// Returns the thread static block information like offsets, etc. from current TLS.
virtual void getThreadLocalStaticBlocksInfo (
CORINFO_THREAD_STATIC_BLOCKS_INFO* pInfo) = 0;
CORINFO_THREAD_STATIC_BLOCKS_INFO* pInfo, bool isGCType) = 0;

// Returns true iff "fldHnd" represents a static field.
virtual bool isFieldStatic(CORINFO_FIELD_HANDLE fldHnd) = 0;
Expand Down
6 changes: 4 additions & 2 deletions src/coreclr/inc/icorjitinfoimpl_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -411,10 +411,12 @@ void getFieldInfo(
CORINFO_FIELD_INFO* pResult) override;

uint32_t getThreadLocalFieldInfo(
CORINFO_FIELD_HANDLE field) override;
CORINFO_FIELD_HANDLE field,
bool isGCtype) override;

void getThreadLocalStaticBlocksInfo(
CORINFO_THREAD_STATIC_BLOCKS_INFO* pInfo) override;
CORINFO_THREAD_STATIC_BLOCKS_INFO* pInfo,
bool isGCType) override;

bool isFieldStatic(
CORINFO_FIELD_HANDLE fldHnd) 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 = { /* 50246073-be42-4227-b9e1-edc585672820 */
0x50246073,
0xbe42,
0x4227,
{0xb9, 0xe1, 0xed, 0xc5, 0x85, 0x67, 0x28, 0x20}
constexpr GUID JITEEVersionIdentifier = { /* f63c2964-bae9-448f-baaf-9c9f2d4292f2 */
0xf63c2964,
0xbae9,
0x448f,
{0xba, 0xaf, 0x9c, 0x9f, 0x2d, 0x42, 0x92, 0xf2}
};

//////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
3 changes: 2 additions & 1 deletion src/coreclr/inc/jithelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,9 @@
JITHELPER(CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE, JIT_GetSharedNonGCThreadStaticBase, CORINFO_HELP_SIG_REG_ONLY)
JITHELPER(CORINFO_HELP_GETSHARED_GCTHREADSTATIC_BASE_NOCTOR, JIT_GetSharedGCThreadStaticBase, CORINFO_HELP_SIG_REG_ONLY)
JITHELPER(CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_NOCTOR, JIT_GetSharedNonGCThreadStaticBase, CORINFO_HELP_SIG_REG_ONLY)
JITHELPER(CORINFO_HELP_GETSHARED_GCTHREADSTATIC_BASE_DYNAMICCLASS, JIT_GetSharedGCThreadStaticBaseDynamicClass, CORINFO_HELP_SIG_REG_ONLY)
JITHELPER(CORINFO_HELP_GETSHARED_GCTHREADSTATIC_BASE_DYNAMICCLASS, JIT_GetSharedGCThreadStaticBaseDynamicClass, CORINFO_HELP_SIG_REG_ONLY)
JITHELPER(CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_DYNAMICCLASS, JIT_GetSharedNonGCThreadStaticBaseDynamicClass, CORINFO_HELP_SIG_REG_ONLY)
JITHELPER(CORINFO_HELP_GETSHARED_GCTHREADSTATIC_BASE_NOCTOR_OPTIMIZED, JIT_GetSharedGCThreadStaticBaseOptimized, CORINFO_HELP_SIG_REG_ONLY)
JITHELPER(CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_NOCTOR_OPTIMIZED, JIT_GetSharedNonGCThreadStaticBaseOptimized, CORINFO_HELP_SIG_REG_ONLY)

// Debugger
Expand Down
10 changes: 6 additions & 4 deletions src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -972,19 +972,21 @@ void WrapICorJitInfo::getFieldInfo(
}

uint32_t WrapICorJitInfo::getThreadLocalFieldInfo(
CORINFO_FIELD_HANDLE field)
CORINFO_FIELD_HANDLE field,
bool isGCtype)
{
API_ENTER(getThreadLocalFieldInfo);
uint32_t temp = wrapHnd->getThreadLocalFieldInfo(field);
uint32_t temp = wrapHnd->getThreadLocalFieldInfo(field, isGCtype);
API_LEAVE(getThreadLocalFieldInfo);
return temp;
}

void WrapICorJitInfo::getThreadLocalStaticBlocksInfo(
CORINFO_THREAD_STATIC_BLOCKS_INFO* pInfo)
CORINFO_THREAD_STATIC_BLOCKS_INFO* pInfo,
bool isGCType)
{
API_ENTER(getThreadLocalStaticBlocksInfo);
wrapHnd->getThreadLocalStaticBlocksInfo(pInfo);
wrapHnd->getThreadLocalStaticBlocksInfo(pInfo, isGCType);
API_LEAVE(getThreadLocalStaticBlocksInfo);
}

Expand Down
17 changes: 12 additions & 5 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -7818,7 +7818,6 @@ class Compiler
void eeGetFieldInfo(CORINFO_RESOLVED_TOKEN* pResolvedToken,
CORINFO_ACCESS_FLAGS flags,
CORINFO_FIELD_INFO* pResult);
uint32_t eeGetThreadLocalFieldInfo(CORINFO_FIELD_HANDLE field);

// Get the flags

Expand Down Expand Up @@ -9394,11 +9393,19 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
return IsInstrumented() && jitFlags->IsSet(JitFlags::JIT_FLAG_BBOPT);
}

bool CanBeInstrumentedOrIsOptimized() const
bool DoEarlyBlockMerging() const
{
return IsInstrumented() || (jitFlags->IsSet(JitFlags::JIT_FLAG_TIER0) &&
jitFlags->IsSet(JitFlags::JIT_FLAG_BBINSTR_IF_LOOPS)) ||
jitFlags->IsSet(JitFlags::JIT_FLAG_BBOPT);
if (jitFlags->IsSet(JitFlags::JIT_FLAG_DEBUG_EnC) || jitFlags->IsSet(JitFlags::JIT_FLAG_DEBUG_CODE))
{
return false;
}

if (jitFlags->IsSet(JitFlags::JIT_FLAG_MIN_OPT) && !jitFlags->IsSet(JitFlags::JIT_FLAG_TIER0))
{
return false;
}

return true;
}

// true if we should use the PINVOKE_{BEGIN,END} helpers instead of generating
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/jit/compiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3518,6 +3518,7 @@ inline bool Compiler::IsSharedStaticHelper(GenTree* tree)
helper == CORINFO_HELP_GETSHARED_GCTHREADSTATIC_BASE ||
helper == CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE ||
helper == CORINFO_HELP_GETSHARED_GCTHREADSTATIC_BASE_NOCTOR ||
helper == CORINFO_HELP_GETSHARED_GCTHREADSTATIC_BASE_NOCTOR_OPTIMIZED ||
helper == CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_NOCTOR ||
helper == CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_NOCTOR_OPTIMIZED ||
helper == CORINFO_HELP_GETSHARED_GCTHREADSTATIC_BASE_DYNAMICCLASS ||
Expand Down
6 changes: 0 additions & 6 deletions src/coreclr/jit/ee_il_dll.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,6 @@ void Compiler::eeGetFieldInfo(CORINFO_RESOLVED_TOKEN* pResolvedToken,
info.compCompHnd->getFieldInfo(pResolvedToken, info.compMethodHnd, accessFlags, pResult);
}

FORCEINLINE
uint32_t Compiler::eeGetThreadLocalFieldInfo(CORINFO_FIELD_HANDLE field)
{
return info.compCompHnd->getThreadLocalFieldInfo(field);
}

/*****************************************************************************
*
* VOS info, method sigs, etc
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/jit/fgbasic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1840,7 +1840,7 @@ void Compiler::fgFindJumpTargets(const BYTE* codeAddr, IL_OFFSET codeSize, Fixed

if ((jmpDist == 0) &&
(opcode == CEE_LEAVE || opcode == CEE_LEAVE_S || opcode == CEE_BR || opcode == CEE_BR_S) &&
opts.CanBeInstrumentedOrIsOptimized())
opts.DoEarlyBlockMerging())
{
break; /* NOP */
}
Expand Down Expand Up @@ -2989,7 +2989,7 @@ unsigned Compiler::fgMakeBasicBlocks(const BYTE* codeAddr, IL_OFFSET codeSize, F

jmpDist = (sz == 1) ? getI1LittleEndian(codeAddr) : getI4LittleEndian(codeAddr);

if ((jmpDist == 0) && (opcode == CEE_BR || opcode == CEE_BR_S) && opts.CanBeInstrumentedOrIsOptimized())
if ((jmpDist == 0) && (opcode == CEE_BR || opcode == CEE_BR_S) && opts.DoEarlyBlockMerging())
{
continue; /* NOP */
}
Expand Down
7 changes: 5 additions & 2 deletions src/coreclr/jit/flowgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,8 @@ bool Compiler::fgIsCommaThrow(GenTree* tree, bool forFolding /* = false */)
// cls - The class handle
// helper - The helper function
// typeIndex - The static block type index. Used only for
// CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_NOCTOR_OPTIMIZED to cache
// CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_NOCTOR_OPTIMIZED or
// CORINFO_HELP_GETSHARED_GCTHREADSTATIC_BASE_NOCTOR_OPTIMIZED to cache
// the static block in an array at index typeIndex.
//
// Return Value:
Expand All @@ -715,6 +716,7 @@ GenTreeCall* Compiler::fgGetStaticsCCtorHelper(CORINFO_CLASS_HANDLE cls, CorInfo
switch (helper)
{
case CORINFO_HELP_GETSHARED_GCSTATIC_BASE_NOCTOR:
case CORINFO_HELP_GETSHARED_GCTHREADSTATIC_BASE_NOCTOR_OPTIMIZED:
bNeedClassID = false;
FALLTHROUGH;

Expand Down Expand Up @@ -795,7 +797,8 @@ GenTreeCall* Compiler::fgGetStaticsCCtorHelper(CORINFO_CLASS_HANDLE cls, CorInfo

result = gtNewHelperCallNode(helper, type, opModuleIDArg, opClassIDArg);
}
else if (helper == CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_NOCTOR_OPTIMIZED)
else if ((helper == CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_NOCTOR_OPTIMIZED) ||
(helper == CORINFO_HELP_GETSHARED_GCTHREADSTATIC_BASE_NOCTOR_OPTIMIZED))
{
result = gtNewHelperCallNode(helper, type, gtNewIconNode(typeIndex));
result->SetExpTLSFieldAccess();
Expand Down
54 changes: 38 additions & 16 deletions src/coreclr/jit/helperexpansion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,8 @@ bool Compiler::fgExpandRuntimeLookupsForCall(BasicBlock** pBlock, Statement* stm

//------------------------------------------------------------------------------
// fgExpandThreadLocalAccess: Inline the CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_NOCTOR_OPTIMIZED
// helper. See fgExpandThreadLocalAccessForCall for details.
// or CORINFO_HELP_GETSHARED_GCTHREADSTATIC_BASE_NOCTOR_OPTIMIZED helper. See
// fgExpandThreadLocalAccessForCall for details.
//
// Returns:
// PhaseStatus indicating what, if anything, was changed.
Expand Down Expand Up @@ -446,7 +447,7 @@ PhaseStatus Compiler::fgExpandThreadLocalAccess()

//------------------------------------------------------------------------------
// fgExpandThreadLocalAccessForCall : Expand the CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_NOCTOR_OPTIMIZED
// that access fields marked with [ThreadLocal].
// or CORINFO_HELP_GETSHARED_GCTHREADSTATIC_BASE_NOCTOR_OPTIMIZED, that access fields marked with [ThreadLocal].
//
// Arguments:
// pBlock - Block containing the helper call to expand. If expansion is performed,
Expand Down Expand Up @@ -483,20 +484,31 @@ bool Compiler::fgExpandThreadLocalAccessForCall(BasicBlock** pBlock, Statement*
assert(!"Unsupported scenario of optimizing TLS access on Arm32");
#endif

JITDUMP("Expanding thread static local access for [%06d] in " FMT_BB ":\n", dspTreeID(call), block->bbNum);
DISPTREE(call);
JITDUMP("\n");
bool isGCThreadStatic =
eeGetHelperNum(call->gtCallMethHnd) == CORINFO_HELP_GETSHARED_GCTHREADSTATIC_BASE_NOCTOR_OPTIMIZED;

CORINFO_THREAD_STATIC_BLOCKS_INFO threadStaticBlocksInfo;
info.compCompHnd->getThreadLocalStaticBlocksInfo(&threadStaticBlocksInfo);
JITDUMP("getThreadLocalStaticBlocksInfo\n:");
info.compCompHnd->getThreadLocalStaticBlocksInfo(&threadStaticBlocksInfo, isGCThreadStatic);

uint32_t offsetOfMaxThreadStaticBlocksVal = 0;
uint32_t offsetOfThreadStaticBlocksVal = 0;

JITDUMP("getThreadLocalStaticBlocksInfo (%s)\n:", isGCThreadStatic ? "GC" : "Non-GC");
offsetOfMaxThreadStaticBlocksVal = threadStaticBlocksInfo.offsetOfMaxThreadStaticBlocks;
offsetOfThreadStaticBlocksVal = threadStaticBlocksInfo.offsetOfThreadStaticBlocks;

JITDUMP("tlsIndex= %u\n", (ssize_t)threadStaticBlocksInfo.tlsIndex.addr);
JITDUMP("offsetOfMaxThreadStaticBlocks= %u\n", threadStaticBlocksInfo.offsetOfMaxThreadStaticBlocks);
JITDUMP("offsetOfThreadLocalStoragePointer= %u\n", threadStaticBlocksInfo.offsetOfThreadLocalStoragePointer);
JITDUMP("offsetOfThreadStaticBlocks= %u\n", threadStaticBlocksInfo.offsetOfThreadStaticBlocks);
JITDUMP("offsetOfMaxThreadStaticBlocks= %u\n", offsetOfMaxThreadStaticBlocksVal);
JITDUMP("offsetOfThreadStaticBlocks= %u\n", offsetOfThreadStaticBlocksVal);
JITDUMP("offsetOfGCDataPointer= %u\n", threadStaticBlocksInfo.offsetOfGCDataPointer);

assert(threadStaticBlocksInfo.tlsIndex.accessType == IAT_VALUE);
assert(eeGetHelperNum(call->gtCallMethHnd) == CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_NOCTOR_OPTIMIZED);

JITDUMP("Expanding thread static local access for [%06d] in " FMT_BB ":\n", dspTreeID(call), block->bbNum);
DISPTREE(call);
JITDUMP("\n");
assert((eeGetHelperNum(call->gtCallMethHnd) == CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_NOCTOR_OPTIMIZED) ||
(eeGetHelperNum(call->gtCallMethHnd) == CORINFO_HELP_GETSHARED_GCTHREADSTATIC_BASE_NOCTOR_OPTIMIZED));

call->ClearExpTLSFieldAccess();
assert(call->gtArgs.CountArgs() == 1);
Expand All @@ -508,6 +520,7 @@ bool Compiler::fgExpandThreadLocalAccessForCall(BasicBlock** pBlock, Statement*
DebugInfo debugInfo = stmt->GetDebugInfo();
block = fgSplitBlockBeforeTree(block, stmt, call, &newFirstStmt, &callUse);
*pBlock = block;
var_types callType = call->TypeGet();
assert(prevBb != nullptr && block != nullptr);

// Block ops inserted by the split need to be morphed here since we are after morph.
Expand All @@ -523,8 +536,8 @@ bool Compiler::fgExpandThreadLocalAccessForCall(BasicBlock** pBlock, Statement*

// Grab a temp to store result (it's assigned from either fastPathBb or fallbackBb)
unsigned threadStaticBlockLclNum = lvaGrabTemp(true DEBUGARG("TLS field access"));
lvaTable[threadStaticBlockLclNum].lvType = TYP_I_IMPL;
threadStaticBlockLcl = gtNewLclvNode(threadStaticBlockLclNum, call->TypeGet());
lvaTable[threadStaticBlockLclNum].lvType = callType;
threadStaticBlockLcl = gtNewLclvNode(threadStaticBlockLclNum, callType);

*callUse = gtClone(threadStaticBlockLcl);

Expand Down Expand Up @@ -564,8 +577,7 @@ bool Compiler::fgExpandThreadLocalAccessForCall(BasicBlock** pBlock, Statement*
GenTree* tlsLclValueUse = gtNewLclVarNode(tlsLclNum);

// Create tree for "maxThreadStaticBlocks = tls[offsetOfMaxThreadStaticBlocks]"
GenTree* offsetOfMaxThreadStaticBlocks =
gtNewIconNode(threadStaticBlocksInfo.offsetOfMaxThreadStaticBlocks, TYP_I_IMPL);
GenTree* offsetOfMaxThreadStaticBlocks = gtNewIconNode(offsetOfMaxThreadStaticBlocksVal, TYP_I_IMPL);
GenTree* maxThreadStaticBlocksRef =
gtNewOperNode(GT_ADD, TYP_I_IMPL, gtCloneExpr(tlsLclValueUse), offsetOfMaxThreadStaticBlocks);
GenTree* maxThreadStaticBlocksValue =
Expand All @@ -577,7 +589,7 @@ bool Compiler::fgExpandThreadLocalAccessForCall(BasicBlock** pBlock, Statement*
maxThreadStaticBlocksCond = gtNewOperNode(GT_JTRUE, TYP_VOID, maxThreadStaticBlocksCond);

// Create tree for "threadStaticBlockBase = tls[offsetOfThreadStaticBlocks]"
GenTree* offsetOfThreadStaticBlocks = gtNewIconNode(threadStaticBlocksInfo.offsetOfThreadStaticBlocks, TYP_I_IMPL);
GenTree* offsetOfThreadStaticBlocks = gtNewIconNode(offsetOfThreadStaticBlocksVal, TYP_I_IMPL);
GenTree* threadStaticBlocksRef =
gtNewOperNode(GT_ADD, TYP_I_IMPL, gtCloneExpr(tlsLclValueUse), offsetOfThreadStaticBlocks);
GenTree* threadStaticBlocksValue =
Expand Down Expand Up @@ -642,6 +654,16 @@ bool Compiler::fgExpandThreadLocalAccessForCall(BasicBlock** pBlock, Statement*
fgNewBBFromTreeAfter(BBJ_ALWAYS, threadStaticBlockNullCondBB, fallbackValueDef, debugInfo, true);

// fastPathBb
if (isGCThreadStatic)
{
// Need to add extra indirection to access the data pointer.

threadStaticBlockBaseLclValueUse = gtNewIndir(callType, threadStaticBlockBaseLclValueUse, GTF_IND_NONFAULTING);
threadStaticBlockBaseLclValueUse =
gtNewOperNode(GT_ADD, callType, threadStaticBlockBaseLclValueUse,
gtNewIconNode(threadStaticBlocksInfo.offsetOfGCDataPointer, TYP_I_IMPL));
}

GenTree* fastPathValueDef =
gtNewStoreLclVarNode(threadStaticBlockLclNum, gtCloneExpr(threadStaticBlockBaseLclValueUse));
BasicBlock* fastPathBb = fgNewBBFromTreeAfter(BBJ_ALWAYS, fallbackBb, fastPathValueDef, debugInfo, true);
Expand Down
12 changes: 10 additions & 2 deletions src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3963,7 +3963,15 @@ GenTree* Compiler::impImportStaticFieldAccess(CORINFO_RESOLVED_TOKEN* pResolvedT

case CORINFO_FIELD_STATIC_TLS_MANAGED:

typeIndex = info.compCompHnd->getThreadLocalFieldInfo(pResolvedToken->hField);
if (pFieldInfo->helper == CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_NOCTOR_OPTIMIZED)
{
typeIndex = info.compCompHnd->getThreadLocalFieldInfo(pResolvedToken->hField, false);
}
else
{
assert(pFieldInfo->helper == CORINFO_HELP_GETSHARED_GCTHREADSTATIC_BASE_NOCTOR_OPTIMIZED);
typeIndex = info.compCompHnd->getThreadLocalFieldInfo(pResolvedToken->hField, true);
}

FALLTHROUGH;
case CORINFO_FIELD_STATIC_SHARED_STATIC_HELPER:
Expand Down Expand Up @@ -7412,7 +7420,7 @@ void Compiler::impImportBlockCode(BasicBlock* block)
case CEE_BR_S:
jmpDist = (sz == 1) ? getI1LittleEndian(codeAddr) : getI4LittleEndian(codeAddr);

if ((jmpDist == 0) && opts.CanBeInstrumentedOrIsOptimized())
if ((jmpDist == 0) && opts.DoEarlyBlockMerging())
{
break; /* NOP */
}
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/jit/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1476,6 +1476,7 @@ void HelperCallProperties::init()
case CORINFO_HELP_GETSHARED_GCSTATIC_BASE_NOCTOR:
case CORINFO_HELP_GETSHARED_NONGCSTATIC_BASE_NOCTOR:
case CORINFO_HELP_GETSHARED_GCTHREADSTATIC_BASE_NOCTOR:
case CORINFO_HELP_GETSHARED_GCTHREADSTATIC_BASE_NOCTOR_OPTIMIZED:
case CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_NOCTOR:
case CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_NOCTOR_OPTIMIZED:

Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/jit/valuenum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12228,6 +12228,9 @@ VNFunc Compiler::fgValueNumberJitHelperMethodVNFunc(CorInfoHelpFunc helpFunc)
case CORINFO_HELP_GETSHARED_GCTHREADSTATIC_BASE_NOCTOR:
vnf = VNF_GetsharedGcthreadstaticBaseNoctor;
break;
case CORINFO_HELP_GETSHARED_GCTHREADSTATIC_BASE_NOCTOR_OPTIMIZED:
vnf = VNF_GetsharedGcthreadstaticBaseNoctorOptimized;
break;
case CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_NOCTOR:
vnf = VNF_GetsharedNongcthreadstaticBaseNoctor;
break;
Expand Down
Loading

0 comments on commit 175dae9

Please sign in to comment.