Skip to content

Commit

Permalink
[JIT] Add support to inline the field access of primitive types marke…
Browse files Browse the repository at this point in the history
…d with TLS (dotnet#82973)

* Add CORINFO_THREAD_LOCAL_FIELD_INFO and getThreadLocalFieldInfo()

* Implementation of getThreadLocalFieldInfo()

* Change the field types from CORINFO_CONST_LOOKUP to uint32_t

* Introduce CORINFO_FIELD_STATIC_TLS_MANAGED

* Introduce GTF_FLD_TLS_MANAGED

* Introduce eeGetThreadLocalFieldInfo()

* Fix the offsetOfThreadStaticBlocks, hardcode threadStaticBlockIndex for now

* Add impThreadLocalFieldAccess()

* Switch to GS segment register with a TODO

* Add reverse map `g_threadStaticBlockTypeIDMap` for type -> ID

* Fix GS segment register encoding

* Add comment for g_threadStaticBlockTypeIDMap

* Add extra parameter for typeIndex in JIT_GetSharedNonGCThreadStaticBase

* Update JIT_GetSharedNonGCThreadStaticBase to add logic for storing typeIndex in t_threadStaticBlocks

* Fix encoding of gs:[0x58]

* fix some bugs in importer to change size from 4 to 8

* add some printf in jithelpers

* To revert

* Update the helper to skip making re-entry for staticBlock

* Add impThreadLocalFieldWrite() for store

* Fix a issue for helper

* Use JITDUMP

* Just enable the optimization for primitive types

* Update the JITEE guid

* Fix an assert for volatile variables

* Mark helper block as cold block

* wip

* Fix the size of maxThreadStaticBlock

* fix a bug to insert the entry in cache

* Add #ifdef for HOST_WINDOWS / TARGET_WINDOWS

* Dynamic memory allocation for static block array

* Call InitTypeMap only if host == windows

* Add CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_NOCTOR_OPTIMIZED

* Expand the TLS field access in late phase

* Move rarely ran block to the end

* wip

* Fix the bug to access the value from fastPath

* Remove code from importer

* Cleanup the code

* Moved CreateBlockFromTree to fgbasic.cpp

* Move fgExpandThreadLocalAccess() to flowgraph.cpp

* Add getThreadLocalStaticBlocksInfo() method

* Consume getThreadLocalStaticBlocksInfo() method

* Updated definition of getThreadLocalFieldInfo()

* Rename CORINFO_THREAD_LOCAL_FIELD_INFO to CORINFO_THREAD_STATIC_BLOCKS_INFO

* Add TARGET_WINDOWS

* Make TARGET_WINDOWS at some definitions

* Add dummy definition for unix

* jit format

* remote unnecessary code from morph

* Fix an issue on linux, add assert for tls_index != 0

* Convert from TARGET_WINDOWS to HOST_WINDOWS

* jit format

* fix the if-check

* fix gcc build error

* Added MethodHaveTlsFieldAccess()

* Handle the case for '_tls_index == 0'

* fix a typo

* Fix windows/arm64 issue

* fix encoding of teb loading for arm64

* Fix the condition in jitinterface to select correct helper

* fix the condition for other helper too

* fix the windows/x86 case

* jit format

* Use CORINFO_CONST_LOOKUP for _tls_index

* Move typeIdMap to BaseDomain class

* Introduce useFatPointerDispatch parameter for GetTypeID()

* jit format

* Do not pass classID and moduleID to the new helper

* fix build for non-windows

* fix superpmi methods

* review feedback

* fix linux build errors

* review feedback

* fix weight inherit

* inline JIT_GetNonGCThreadStaticBase_Helper to fix the contract error

* Remove dead code from helper

* Add GTF_CALL_M_EXP_TLS_ACCESS to check if we do not revisit the already expanded call node

* address feedback

* regenerate the files

* Introduce fgExpandHelper and fgExpandHelperForBlock and reuse it for various helper expansion

* fix the typo

* update the assert for runtimelookup

* check if we should skip rarely run blocks

* review feedback

* Remove GTF_IND_INVARIANT from `typeIndex` access because it produces nullptr 1st time and valid value 2nd time onwards
  • Loading branch information
kunalspathak authored Apr 11, 2023
1 parent b68f669 commit 563408a
Show file tree
Hide file tree
Showing 48 changed files with 1,821 additions and 895 deletions.
19 changes: 19 additions & 0 deletions src/coreclr/inc/corinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ enum CorInfoHelpFunc
CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_NOCTOR,
CORINFO_HELP_GETSHARED_GCTHREADSTATIC_BASE_DYNAMICCLASS,
CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_DYNAMICCLASS,
CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_NOCTOR_OPTIMIZED,

/* Debugger */

Expand Down Expand Up @@ -1686,6 +1687,7 @@ enum CORINFO_FIELD_ACCESSOR
CORINFO_FIELD_STATIC_GENERICS_STATIC_HELPER, // static field access using the "generic static" helper (argument is MethodTable *)
CORINFO_FIELD_STATIC_ADDR_HELPER, // static field accessed using address-of helper (argument is FieldDesc *)
CORINFO_FIELD_STATIC_TLS, // unmanaged TLS access
CORINFO_FIELD_STATIC_TLS_MANAGED, // managed TLS access
CORINFO_FIELD_STATIC_READYTORUN_HELPER, // static field access using a runtime lookup helper
CORINFO_FIELD_STATIC_RELOCATABLE, // static field access using relocation (used in AOT)
CORINFO_FIELD_INTRINSIC_ZERO, // intrinsic zero (IntPtr.Zero, UIntPtr.Zero)
Expand Down Expand Up @@ -1725,6 +1727,17 @@ struct CORINFO_FIELD_INFO
CORINFO_CONST_LOOKUP fieldLookup; // Used by Ready-to-Run
};

//----------------------------------------------------------------------------
// getThreadLocalStaticBlocksInfo and CORINFO_THREAD_STATIC_BLOCKS_INFO: The EE instructs the JIT about how to access a thread local field

struct CORINFO_THREAD_STATIC_BLOCKS_INFO
{
CORINFO_CONST_LOOKUP tlsIndex;
uint32_t offsetOfThreadLocalStoragePointer;
uint32_t offsetOfMaxThreadStaticBlocks;
uint32_t offsetOfThreadStaticBlocks;
};

//----------------------------------------------------------------------------
// Exception handling

Expand Down Expand Up @@ -2743,6 +2756,12 @@ class ICorStaticInfo
CORINFO_FIELD_INFO *pResult
) = 0;

virtual uint32_t getThreadLocalFieldInfo (
CORINFO_FIELD_HANDLE field) = 0;

virtual void getThreadLocalStaticBlocksInfo (
CORINFO_THREAD_STATIC_BLOCKS_INFO* pInfo) = 0;

// Returns true iff "fldHnd" represents a static field.
virtual bool isFieldStatic(CORINFO_FIELD_HANDLE fldHnd) = 0;

Expand Down
6 changes: 6 additions & 0 deletions src/coreclr/inc/icorjitinfoimpl_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,12 @@ void getFieldInfo(
CORINFO_ACCESS_FLAGS flags,
CORINFO_FIELD_INFO* pResult) override;

uint32_t getThreadLocalFieldInfo(
CORINFO_FIELD_HANDLE field) override;

void getThreadLocalStaticBlocksInfo(
CORINFO_THREAD_STATIC_BLOCKS_INFO* pInfo) 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 = { /* 3054e9ba-bcfe-417c-9043-92ccc8738b80 */
0x3054e9ba,
0xbcfe,
0x417c,
{0x90, 0x43, 0x92, 0xcc, 0xc8, 0x73, 0x8b, 0x80}
constexpr GUID JITEEVersionIdentifier = { /* 236d7997-3d71-45f9-b7d7-5241ad89a56f */
0x236d7997,
0x3d71,
0x45f9,
{ 0xb7, 0xd7, 0x52, 0x41, 0xad, 0x89, 0xa5, 0x6f }
};

//////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/inc/jithelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@
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_NONGCTHREADSTATIC_BASE_DYNAMICCLASS, JIT_GetSharedNonGCThreadStaticBaseDynamicClass, CORINFO_HELP_SIG_REG_ONLY)
JITHELPER(CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_NOCTOR_OPTIMIZED, JIT_GetSharedNonGCThreadStaticBaseOptimized, CORINFO_HELP_SIG_REG_ONLY)

// Debugger
JITHELPER(CORINFO_HELP_DBG_IS_JUST_MY_CODE, JIT_DbgIsJustMyCode,CORINFO_HELP_SIG_REG_ONLY)
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ set( JIT_SOURCES
hwintrinsic.cpp
hostallocator.cpp
ifconversion.cpp
runtimelookup.cpp
helperexpansion.cpp
indirectcalltransformer.cpp
importercalls.cpp
importer.cpp
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/jit/ICorJitInfo_names_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ DEF_CLR_API(getFieldClass)
DEF_CLR_API(getFieldType)
DEF_CLR_API(getFieldOffset)
DEF_CLR_API(getFieldInfo)
DEF_CLR_API(getThreadLocalFieldInfo)
DEF_CLR_API(getThreadLocalStaticBlocksInfo)
DEF_CLR_API(isFieldStatic)
DEF_CLR_API(getArrayOrStringLength)
DEF_CLR_API(getBoundaries)
Expand Down
17 changes: 17 additions & 0 deletions src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,23 @@ void WrapICorJitInfo::getFieldInfo(
API_LEAVE(getFieldInfo);
}

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

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

bool WrapICorJitInfo::isFieldStatic(
CORINFO_FIELD_HANDLE fldHnd)
{
Expand Down
5 changes: 5 additions & 0 deletions src/coreclr/jit/codegenxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5420,8 +5420,13 @@ void CodeGen::genCodeForIndir(GenTreeIndir* tree)
if (addr->IsIconHandle(GTF_ICON_TLS_HDL))
{
noway_assert(EA_ATTR(genTypeSize(targetType)) == EA_PTRSIZE);
#if TARGET_64BIT
emit->emitIns_R_C(ins_Load(TYP_I_IMPL), EA_PTRSIZE, tree->GetRegNum(), FLD_GLOBAL_GS,
(int)addr->AsIntCon()->gtIconVal);
#else
emit->emitIns_R_C(ins_Load(TYP_I_IMPL), EA_PTRSIZE, tree->GetRegNum(), FLD_GLOBAL_FS,
(int)addr->AsIntCon()->gtIconVal);
#endif
}
else
{
Expand Down
6 changes: 6 additions & 0 deletions src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5044,6 +5044,12 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl
// Partially inline static initializations
DoPhase(this, PHASE_EXPAND_STATIC_INIT, &Compiler::fgExpandStaticInit);

if (TargetOS::IsWindows)
{
// Currently this is only applicable for Windows
DoPhase(this, PHASE_EXPAND_TLS, &Compiler::fgExpandThreadLocalAccess);
}

// Insert GC Polls
DoPhase(this, PHASE_INSERT_GC_POLLS, &Compiler::fgInsertGCPolls);

Expand Down
28 changes: 25 additions & 3 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -4834,7 +4834,7 @@ class Compiler

GenTree* fgInitThisClass();

GenTreeCall* fgGetStaticsCCtorHelper(CORINFO_CLASS_HANDLE cls, CorInfoHelpFunc helper);
GenTreeCall* fgGetStaticsCCtorHelper(CORINFO_CLASS_HANDLE cls, CorInfoHelpFunc helper, uint32_t typeIndex = 0);

GenTreeCall* fgGetSharedCCtor(CORINFO_CLASS_HANDLE cls);

Expand Down Expand Up @@ -5287,11 +5287,21 @@ class Compiler
PhaseStatus StressSplitTree();
void SplitTreesRandomly();
void SplitTreesRemoveCommas();

template <bool (Compiler::*ExpansionFunction)(BasicBlock*, Statement*, GenTreeCall*)>
PhaseStatus fgExpandHelper(bool skipRarelyRunBlocks);

template <bool (Compiler::*ExpansionFunction)(BasicBlock*, Statement*, GenTreeCall*)>
bool fgExpandHelperForBlock(BasicBlock* block);

PhaseStatus fgExpandRuntimeLookups();
bool fgExpandRuntimeLookupsForCall(BasicBlock* block, Statement* stmt, GenTreeCall* call);

PhaseStatus fgExpandThreadLocalAccess();
bool fgExpandThreadLocalAccessForCall(BasicBlock* block, Statement* stmt, GenTreeCall* call);

bool fgExpandStaticInitForBlock(BasicBlock* block);
bool fgExpandStaticInitForCall(BasicBlock* block, Statement* stmt, GenTreeCall* call);
PhaseStatus fgExpandStaticInit();
bool fgExpandStaticInitForCall(BasicBlock* block, Statement* stmt, GenTreeCall* call);

PhaseStatus fgInsertGCPolls();
BasicBlock* fgCreateGCPoll(GCPollType pollType, BasicBlock* block);
Expand Down Expand Up @@ -7018,6 +7028,7 @@ class Compiler
#define OMF_HAS_MDNEWARRAY 0x00002000 // Method contains 'new' of an MD array
#define OMF_HAS_MDARRAYREF 0x00004000 // Method contains multi-dimensional intrinsic array element loads or stores.
#define OMF_HAS_STATIC_INIT 0x00008000 // Method has static initializations we might want to partially inline
#define OMF_HAS_TLS_FIELD 0x00010000 // Method contains TLS field access

// clang-format on

Expand Down Expand Up @@ -7068,6 +7079,16 @@ class Compiler
optMethodFlags |= OMF_HAS_GUARDEDDEVIRT;
}

bool doesMethodHasTlsFieldAccess()
{
return (optMethodFlags & OMF_HAS_TLS_FIELD) != 0;
}

void setMethodHasTlsFieldAccess()
{
optMethodFlags |= OMF_HAS_TLS_FIELD;
}

void pickGDV(GenTreeCall* call,
IL_OFFSET ilOffset,
bool isInterface,
Expand Down Expand Up @@ -7769,6 +7790,7 @@ 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
5 changes: 3 additions & 2 deletions src/coreclr/jit/compiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3677,6 +3677,7 @@ inline bool Compiler::IsSharedStaticHelper(GenTree* tree)
helper == CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE ||
helper == CORINFO_HELP_GETSHARED_GCTHREADSTATIC_BASE_NOCTOR ||
helper == CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_NOCTOR ||
helper == CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_NOCTOR_OPTIMIZED ||
helper == CORINFO_HELP_GETSHARED_GCTHREADSTATIC_BASE_DYNAMICCLASS ||
helper == CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_DYNAMICCLASS ||
#ifdef FEATURE_READYTORUN
Expand Down Expand Up @@ -3726,12 +3727,12 @@ inline bool Compiler::IsGcSafePoint(GenTreeCall* call)
// Note that we want to have two special FIELD_HANDLES that will both
// be considered non-Data Offset handles
//
// The special values that we use are FLD_GLOBAL_DS and FLD_GLOBAL_FS
// The special values that we use are FLD_GLOBAL_DS, FLD_GLOBAL_FS or FLD_GLOBAL_GS.
//

inline bool jitStaticFldIsGlobAddr(CORINFO_FIELD_HANDLE fldHnd)
{
return (fldHnd == FLD_GLOBAL_DS || fldHnd == FLD_GLOBAL_FS);
return (fldHnd == FLD_GLOBAL_DS || fldHnd == FLD_GLOBAL_FS || fldHnd == FLD_GLOBAL_GS);
}

/*
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/jit/compphases.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ CompPhaseNameMacro(PHASE_COMPUTE_EDGE_WEIGHTS2, "Compute edge weights (2, f
CompPhaseNameMacro(PHASE_STRESS_SPLIT_TREE, "Stress gtSplitTree", false, -1, false)
CompPhaseNameMacro(PHASE_EXPAND_RTLOOKUPS, "Expand runtime lookups", false, -1, true)
CompPhaseNameMacro(PHASE_EXPAND_STATIC_INIT, "Expand static init", false, -1, true)
CompPhaseNameMacro(PHASE_EXPAND_TLS, "Expand TLS access", false, -1, true)
CompPhaseNameMacro(PHASE_INSERT_GC_POLLS, "Insert GC Polls", false, -1, true)
CompPhaseNameMacro(PHASE_DETERMINE_FIRST_COLD_BLOCK, "Determine first cold block", false, -1, true)
CompPhaseNameMacro(PHASE_RATIONALIZE, "Rationalize IR", false, -1, false)
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 @@ -44,6 +44,12 @@ 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
7 changes: 6 additions & 1 deletion src/coreclr/jit/emitarm64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13804,7 +13804,7 @@ void emitter::emitInsLoadStoreOp(instruction ins, emitAttr attr, regNumber dataR

if (addr->isContained())
{
assert(addr->OperIs(GT_CLS_VAR_ADDR, GT_LCL_ADDR, GT_LEA));
assert(addr->OperIs(GT_CLS_VAR_ADDR, GT_LCL_ADDR, GT_LEA) || (addr->IsIconHandle(GTF_ICON_TLS_HDL)));

int offset = 0;
DWORD lsl = 0;
Expand Down Expand Up @@ -13927,6 +13927,11 @@ void emitter::emitInsLoadStoreOp(instruction ins, emitAttr attr, regNumber dataR
emitIns_R_S(ins, attr, dataReg, lclNum, offset);
}
}
else if (addr->IsIconHandle(GTF_ICON_TLS_HDL))
{
// On Arm64, TEB is in r18, so load from the r18 as base.
emitIns_R_R_I(ins, attr, dataReg, REG_R18, addr->AsIntCon()->IconValue());
}
else if (emitIns_valid_imm_for_ldst_offset(offset, emitTypeSize(indir->TypeGet())))
{
// Then load/store dataReg from/to [memBase + offset]
Expand Down
52 changes: 43 additions & 9 deletions src/coreclr/jit/emitxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7281,6 +7281,10 @@ void emitter::emitIns_R_C(instruction ins, emitAttr attr, regNumber reg, CORINFO
{
sz += 1;
}
else if (fldHnd == FLD_GLOBAL_GS)
{
sz += 2; // Needs SIB byte as well.
}
}

id->idCodeSize(sz);
Expand Down Expand Up @@ -7349,7 +7353,7 @@ void emitter::emitIns_C_R(instruction ins, emitAttr attr, CORINFO_FIELD_HANDLE f
}

// Special case: mov reg, fs:[ddd]
if (fldHnd == FLD_GLOBAL_FS)
if ((fldHnd == FLD_GLOBAL_FS) || (fldHnd == FLD_GLOBAL_GS))
{
sz += 1;
}
Expand Down Expand Up @@ -10026,6 +10030,12 @@ void emitter::emitDispClsVar(CORINFO_FIELD_HANDLE fldHnd, ssize_t offs, bool rel
return;
}

if (fldHnd == FLD_GLOBAL_GS)
{
printf("GS:[0x%04X]", (unsigned)offs);
return;
}

if (fldHnd == FLD_GLOBAL_DS)
{
printf("[0x%04X]", (unsigned)offs);
Expand Down Expand Up @@ -13370,11 +13380,16 @@ BYTE* emitter::emitOutputCV(BYTE* dst, instrDesc* id, code_t code, CnsVal* addc)
fldh = id->idAddr()->iiaFieldHnd;
offs = emitGetInsDsp(id);

// Special case: mov reg, fs:[ddd]
if (fldh == FLD_GLOBAL_FS)
{
// Special case: mov reg, fs:[ddd]
dst += emitOutputByte(dst, 0x64);
}
else if (fldh == FLD_GLOBAL_GS)
{
// Special case: mov reg, gs:[ddd]
dst += emitOutputByte(dst, 0x65);
}

// Compute VEX/EVEX prefix
// Some of its callers already add EVEX/VEX prefix and then call this routine.
Expand Down Expand Up @@ -13584,6 +13599,11 @@ BYTE* emitter::emitOutputCV(BYTE* dst, instrDesc* id, code_t code, CnsVal* addc)
}
}

if (fldh == FLD_GLOBAL_GS)
{
dst += emitOutputByte(dst, 0x25);
}

// Do we have a constant or a static data member?
doff = Compiler::eeGetJitDataOffs(fldh);
if (doff >= 0)
Expand Down Expand Up @@ -13663,12 +13683,18 @@ BYTE* emitter::emitOutputCV(BYTE* dst, instrDesc* id, code_t code, CnsVal* addc)
#endif // TARGET_AMD64

#ifdef TARGET_AMD64
// All static field and data section constant accesses should be marked as relocatable
noway_assert(id->idIsDspReloc());
dst += emitOutputLong(dst, 0);
#else // TARGET_X86
if (id->idIsDspReloc())
{
// All static field and data section constant accesses should be marked as relocatable
dst += emitOutputLong(dst, 0);
}
else
{
dst += emitOutputLong(dst, (ssize_t)target);
}
#else
dst += emitOutputLong(dst, (int)(ssize_t)target);
#endif // TARGET_X86
#endif // TARGET_AMD64

if (id->idIsDspReloc())
{
Expand Down Expand Up @@ -16481,8 +16507,16 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp)
code = insEncodeReg3456(id, id->idReg1(), size, code);
}

regcode = (insEncodeReg345(id, id->idReg1(), size, &code) << 8);
dst = emitOutputCV(dst, id, code | regcode | 0x0500);
regcode = (insEncodeReg345(id, id->idReg1(), size, &code) << 8);
CORINFO_FIELD_HANDLE fldh = id->idAddr()->iiaFieldHnd;
if (fldh == FLD_GLOBAL_GS)
{
dst = emitOutputCV(dst, id, code | regcode | 0x0400);
}
else
{
dst = emitOutputCV(dst, id, code | regcode | 0x0500);
}
}

sz = emitSizeOfInsDsc(id);
Expand Down
Loading

0 comments on commit 563408a

Please sign in to comment.