Skip to content

Commit 37284fc

Browse files
authored
Revert "Inject IJW Copy Constructor calls in the JIT instead of in the IL stu…" (#106420)
This reverts commit ec067c8.
1 parent b1968e7 commit 37284fc

42 files changed

Lines changed: 755 additions & 1197 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.CoreCLR.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -344,12 +344,6 @@ internal static int EnumCompareTo<T>(T x, T y) where T : struct, Enum
344344
return x.CompareTo(y);
345345
}
346346

347-
348-
// The body of this function will be created by the EE for the specific type.
349-
// See getILIntrinsicImplementation for how this happens.
350-
[Intrinsic]
351-
internal static extern unsafe void CopyConstruct<T>(T* dest, T* src) where T : unmanaged;
352-
353347
internal static ref byte GetRawData(this object obj) =>
354348
ref Unsafe.As<RawData>(obj).Data;
355349

src/coreclr/System.Private.CoreLib/src/System/StubHelpers.cs

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,6 +1315,75 @@ public IntPtr AddRef()
13151315
}
13161316
} // class CleanupWorkListElement
13171317

1318+
internal unsafe struct CopyConstructorCookie
1319+
{
1320+
private void* m_source;
1321+
1322+
private nuint m_destinationOffset;
1323+
1324+
public delegate*<void*, void*, void> m_copyConstructor;
1325+
1326+
public delegate*<void*, void> m_destructor;
1327+
1328+
public CopyConstructorCookie* m_next;
1329+
1330+
[StackTraceHidden]
1331+
public void ExecuteCopy(void* destinationBase)
1332+
{
1333+
if (m_copyConstructor != null)
1334+
{
1335+
m_copyConstructor((byte*)destinationBase + m_destinationOffset, m_source);
1336+
}
1337+
1338+
if (m_destructor != null)
1339+
{
1340+
m_destructor(m_source);
1341+
}
1342+
}
1343+
}
1344+
1345+
internal unsafe struct CopyConstructorChain
1346+
{
1347+
public void* m_realTarget;
1348+
public CopyConstructorCookie* m_head;
1349+
1350+
public void Add(CopyConstructorCookie* cookie)
1351+
{
1352+
cookie->m_next = m_head;
1353+
m_head = cookie;
1354+
}
1355+
1356+
[ThreadStatic]
1357+
private static CopyConstructorChain s_copyConstructorChain;
1358+
1359+
public void Install(void* realTarget)
1360+
{
1361+
m_realTarget = realTarget;
1362+
s_copyConstructorChain = this;
1363+
}
1364+
1365+
[StackTraceHidden]
1366+
private void ExecuteCopies(void* destinationBase)
1367+
{
1368+
for (CopyConstructorCookie* current = m_head; current != null; current = current->m_next)
1369+
{
1370+
current->ExecuteCopy(destinationBase);
1371+
}
1372+
}
1373+
1374+
[UnmanagedCallersOnly]
1375+
[StackTraceHidden]
1376+
public static void* ExecuteCurrentCopiesAndGetTarget(void* destinationBase)
1377+
{
1378+
void* target = s_copyConstructorChain.m_realTarget;
1379+
s_copyConstructorChain.ExecuteCopies(destinationBase);
1380+
// Reset this instance to ensure we don't accidentally execute the copies again.
1381+
// All of the pointers point to the stack, so we don't need to free any memory.
1382+
s_copyConstructorChain = default;
1383+
return target;
1384+
}
1385+
}
1386+
13181387
internal static partial class StubHelpers
13191388
{
13201389
[MethodImpl(MethodImplOptions.InternalCall)]

src/coreclr/inc/corinfo.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,6 @@ enum CorInfoTypeWithMod
644644
{
645645
CORINFO_TYPE_MASK = 0x3F, // lower 6 bits are type mask
646646
CORINFO_TYPE_MOD_PINNED = 0x40, // can be applied to CLASS, or BYREF to indicate pinned
647-
CORINFO_TYPE_MOD_COPY_WITH_HELPER = 0x80 // can be applied to VALUECLASS to indicate 'needs helper to copy'
648647
};
649648

650649
inline CorInfoType strip(CorInfoTypeWithMod val) {
@@ -3326,8 +3325,6 @@ class ICorDynamicInfo : public ICorStaticInfo
33263325
// but for tailcalls, the contract is that JIT leaves the indirection cell in
33273326
// a register during tailcall.
33283327
virtual void updateEntryPointForTailCall(CORINFO_CONST_LOOKUP* entryPoint) = 0;
3329-
3330-
virtual CORINFO_METHOD_HANDLE getSpecialCopyHelper(CORINFO_CLASS_HANDLE type) = 0;
33313328
};
33323329

33333330
/**********************************************************************************/

src/coreclr/inc/icorjitinfoimpl_generated.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -742,9 +742,6 @@ uint32_t getJitFlags(
742742
CORJIT_FLAGS* flags,
743743
uint32_t sizeInBytes) override;
744744

745-
CORINFO_METHOD_HANDLE getSpecialCopyHelper(
746-
CORINFO_CLASS_HANDLE type) override;
747-
748745
/**********************************************************************************/
749746
// clang-format on
750747
/**********************************************************************************/

src/coreclr/inc/jiteeversionguid.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ typedef const GUID *LPCGUID;
4343
#define GUID_DEFINED
4444
#endif // !GUID_DEFINED
4545

46-
constexpr GUID JITEEVersionIdentifier = { /* 62865a69-7c84-4ba5-8636-a7dec55c05a7 */
47-
0x62865a69,
48-
0x7c84,
49-
0x4ba5,
50-
{0x86, 0x36, 0xa7, 0xde, 0xc5, 0x5c, 0x05, 0xa7}
46+
constexpr GUID JITEEVersionIdentifier = { /* f43f9022-8795-4791-ba55-c450d76cfeb9 */
47+
0xf43f9022,
48+
0x8795,
49+
0x4791,
50+
{0xba, 0x55, 0xc4, 0x50, 0xd7, 0x6c, 0xfe, 0xb9}
5151
};
5252

5353
//////////////////////////////////////////////////////////////////////////////////////////////////////////

src/coreclr/jit/ICorJitInfo_names_generated.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,5 @@ DEF_CLR_API(recordRelocation)
180180
DEF_CLR_API(getRelocTypeHint)
181181
DEF_CLR_API(getExpectedTargetArchitecture)
182182
DEF_CLR_API(getJitFlags)
183-
DEF_CLR_API(getSpecialCopyHelper)
184183

185184
#undef DEF_CLR_API

src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,15 +1742,6 @@ uint32_t WrapICorJitInfo::getJitFlags(
17421742
return temp;
17431743
}
17441744

1745-
CORINFO_METHOD_HANDLE WrapICorJitInfo::getSpecialCopyHelper(
1746-
CORINFO_CLASS_HANDLE type)
1747-
{
1748-
API_ENTER(getSpecialCopyHelper);
1749-
CORINFO_METHOD_HANDLE temp = wrapHnd->getSpecialCopyHelper(type);
1750-
API_LEAVE(getSpecialCopyHelper);
1751-
return temp;
1752-
}
1753-
17541745
/**********************************************************************************/
17551746
// clang-format on
17561747
/**********************************************************************************/

src/coreclr/jit/compiler.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1989,10 +1989,6 @@ void Compiler::compInit(ArenaAllocator* pAlloc,
19891989
m_fpStructLoweringCache = nullptr;
19901990
#endif
19911991

1992-
#if defined(TARGET_X86) && defined(FEATURE_IJW)
1993-
m_specialCopyArgs = nullptr;
1994-
#endif
1995-
19961992
// check that HelperCallProperties are initialized
19971993

19981994
assert(s_helperCallProperties.IsPure(CORINFO_HELP_GET_GCSTATIC_BASE));

src/coreclr/jit/compiler.h

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5703,36 +5703,6 @@ class Compiler
57035703
const CORINFO_SWIFT_LOWERING* GetSwiftLowering(CORINFO_CLASS_HANDLE clsHnd);
57045704
#endif
57055705

5706-
#if defined(TARGET_X86) && defined(FEATURE_IJW)
5707-
bool* m_specialCopyArgs;
5708-
bool recordArgRequiresSpecialCopy(unsigned argNum)
5709-
{
5710-
if (argNum >= info.compArgsCount)
5711-
{
5712-
return false;
5713-
}
5714-
5715-
if (m_specialCopyArgs == nullptr)
5716-
{
5717-
m_specialCopyArgs = new (getAllocator()) bool[info.compArgsCount];
5718-
memset(m_specialCopyArgs, 0, info.compArgsCount * sizeof(bool));
5719-
}
5720-
5721-
m_specialCopyArgs[argNum] = true;
5722-
return true;
5723-
}
5724-
5725-
bool argRequiresSpecialCopy(unsigned argNum)
5726-
{
5727-
return argNum < info.compArgsCount && m_specialCopyArgs != nullptr && m_specialCopyArgs[argNum];
5728-
}
5729-
5730-
bool compHasSpecialCopyArgs()
5731-
{
5732-
return m_specialCopyArgs != nullptr;
5733-
}
5734-
#endif
5735-
57365706
void optRecordLoopMemoryDependence(GenTree* tree, BasicBlock* block, ValueNum memoryVN);
57375707
void optCopyLoopMemoryDependence(GenTree* fromTree, GenTree* toTree);
57385708

src/coreclr/jit/gentree.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16599,7 +16599,6 @@ GenTree* Compiler::gtNewTempStore(
1659916599
valTyp = lvaGetRealType(val->AsLclVar()->GetLclNum());
1660016600
val->gtType = valTyp;
1660116601
}
16602-
1660316602
var_types dstTyp = varDsc->TypeGet();
1660416603

1660516604
/* If the variable's lvType is not yet set then set it here */

0 commit comments

Comments
 (0)