Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/coreclr/inc/corinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,11 @@ enum CorInfoHelpFunc

CORINFO_HELP_BULK_WRITEBARRIER,

// Same as CORINFO_HELP_BULK_WRITEBARRIER, but it is the raw worker: it does not split the copy
// into chunks and does not poll for GC afterwards. The JIT is only allowed to use it when the
// size is a small compile-time constant, so that the copy cannot starve the GC.
CORINFO_HELP_BULK_WRITEBARRIER_SMALL,

/* Accessing fields */

CORINFO_HELP_GETFIELDADDR,
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 @@ -37,11 +37,11 @@

#include <minipal/guid.h>

constexpr GUID JITEEVersionIdentifier = { /* fbbaf45f-5b0e-4767-b962-5084c8caae77 */
0xfbbaf45f,
0x5b0e,
0x4767,
{0xb9, 0x62, 0x50, 0x84, 0xc8, 0xca, 0xae, 0x77}
constexpr GUID JITEEVersionIdentifier = { /* cb2fa75d-449d-4ee0-93ef-57011daefb8c */
0xcb2fa75d,
0x449d,
0x4ee0,
{0x93, 0xef, 0x57, 0x01, 0x1d, 0xae, 0xfb, 0x8c}
};

#endif // JIT_EE_VERSIONING_GUID_H
1 change: 1 addition & 0 deletions src/coreclr/inc/jithelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
DYNAMICJITHELPER(CORINFO_HELP_CHECKED_ASSIGN_REF, RhpCheckedAssignRef,METHOD__NIL)

DYNAMICJITHELPER(CORINFO_HELP_BULK_WRITEBARRIER, NULL, METHOD__BUFFER__MEMCOPYGC)
DYNAMICJITHELPER_NOINDIRECT(CORINFO_HELP_BULK_WRITEBARRIER_SMALL, NULL, METHOD__BUFFER__MEMCOPYGC_SMALL)
Comment thread
EgorBo marked this conversation as resolved.

// Accessing fields

Expand Down
4 changes: 3 additions & 1 deletion src/coreclr/inc/readytorun.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// If you update this, ensure you run `git grep MINIMUM_READYTORUN_MAJOR_VERSION`
// and handle pending work.
#define READYTORUN_MAJOR_VERSION 29
#define READYTORUN_MINOR_VERSION 0x0002
#define READYTORUN_MINOR_VERSION 0x0003

#define MINIMUM_READYTORUN_MAJOR_VERSION 26

Expand Down Expand Up @@ -76,6 +76,7 @@
// compiled with the GC mode transition verification scaffolding (and therefore emits
// READYTORUN_HELPER_ResumeAfterCatch at catch resumption points). Only WebAssembly emits or
// consumes the scaffolding, so the flag is only ever set on WebAssembly images.
// R2R Version 29.3 adds READYTORUN_HELPER_BulkWriteBarrierSmall.

struct READYTORUN_CORE_HEADER
{
Expand Down Expand Up @@ -387,6 +388,7 @@ enum ReadyToRunHelper
READYTORUN_HELPER_CheckedWriteBarrier = 0x31,
READYTORUN_HELPER_ByRefWriteBarrier = 0x32, // No longer supported as of READYTORUN_MAJOR_VERSION 19.0
READYTORUN_HELPER_BulkWriteBarrier = 0x33,
READYTORUN_HELPER_BulkWriteBarrierSmall = 0x34,

// Array helpers
READYTORUN_HELPER_Stelem_Ref = 0x38,
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/inc/readytorunhelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ HELPER(READYTORUN_HELPER_ThrowNotImplemented, CORINFO_HELP_THROW_NOT_IMPLE
HELPER(READYTORUN_HELPER_WriteBarrier, CORINFO_HELP_ASSIGN_REF, )
HELPER(READYTORUN_HELPER_CheckedWriteBarrier, CORINFO_HELP_CHECKED_ASSIGN_REF, )
HELPER(READYTORUN_HELPER_BulkWriteBarrier, CORINFO_HELP_BULK_WRITEBARRIER, )
HELPER(READYTORUN_HELPER_BulkWriteBarrierSmall, CORINFO_HELP_BULK_WRITEBARRIER_SMALL, )

HELPER(READYTORUN_HELPER_Stelem_Ref, CORINFO_HELP_ARRADDR_ST, )
HELPER(READYTORUN_HELPER_Ldelema_Ref, CORINFO_HELP_LDELEMA_REF, )
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/codegencommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2189,7 +2189,7 @@ void CodeGen::genGenerateCode(void** codePtr, uint32_t* nativeSizeOfCode)
//
if (genWriteBarrierUsed && JitConfig.EnableExtraSuperPmiQueries() && !m_compiler->IsAot())
{
for (int i = CORINFO_HELP_ASSIGN_REF; i <= CORINFO_HELP_BULK_WRITEBARRIER; i++)
for (int i = CORINFO_HELP_ASSIGN_REF; i <= CORINFO_HELP_BULK_WRITEBARRIER_SMALL; i++)
{
m_compiler->compGetHelperFtn((CorInfoHelpFunc)i);
}
Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/jit/codegenwasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3466,6 +3466,9 @@ void CodeGen::genEmitHelperCall(unsigned helper, int argSize, emitAttr retSize,
// RhBulkMoveWithWriteBarrier
HELPER_SIG(CORINFO_HELP_BULK_WRITEBARRIER, UNMANAGED, CORINFO_WASM_TYPE_VOID /* retval */, CORINFO_WASM_TYPE_I,
CORINFO_WASM_TYPE_I, CORINFO_WASM_TYPE_I);
// RhBulkMoveWithWriteBarrier
HELPER_SIG(CORINFO_HELP_BULK_WRITEBARRIER_SMALL, UNMANAGED, CORINFO_WASM_TYPE_VOID /* retval */,
CORINFO_WASM_TYPE_I, CORINFO_WASM_TYPE_I, CORINFO_WASM_TYPE_I);
default:
JITDUMP("Helper '%s' has no hard-coded signature\n", m_compiler->eeGetMethodFullName(params.methHnd));
unreached();
Expand Down
3 changes: 2 additions & 1 deletion src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1956,7 +1956,8 @@ bool GenTreeCall::NeedsVzeroupper(Compiler* comp)
{
// A few special cases exist that can't be found by signature alone, so we handle
// those explicitly here instead.
needsVzeroupper = IsHelperCall(CORINFO_HELP_BULK_WRITEBARRIER);
needsVzeroupper =
IsHelperCall(CORINFO_HELP_BULK_WRITEBARRIER) || IsHelperCall(CORINFO_HELP_BULK_WRITEBARRIER_SMALL);

// Most other helpers are well known to not use any floating-point or SIMD logic internally, but
// a few do exist so we need to ensure they are handled. They are identified by taking or
Expand Down
17 changes: 14 additions & 3 deletions src/coreclr/jit/lower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10352,6 +10352,9 @@ void Lowering::ContainCheckBitCast(GenTreeUnOp* node)
//
void Lowering::LowerBlockStoreAsGcBulkCopyCall(GenTreeBlk* blk)
{
// Keep direct copies small to limit GC suspension latency.
const unsigned BULK_WRITEBARRIER_SMALL_SIZE = 128;

assert(blk->OperIs(GT_STORE_BLK));
assert(blk->GetLayout()->HasGCPtr());
assert(!blk->OperIsInitBlkOp());
Expand Down Expand Up @@ -10387,16 +10390,24 @@ void Lowering::LowerBlockStoreAsGcBulkCopyCall(GenTreeBlk* blk)
}

// Size is a constant
GenTreeIntCon* size = m_compiler->gtNewIconNode((ssize_t)blk->GetLayout()->GetSize(), TYP_I_IMPL);
const unsigned blkSize = blk->GetLayout()->GetSize();
GenTreeIntCon* size = m_compiler->gtNewIconNode((ssize_t)blkSize, TYP_I_IMPL);
BlockRange().InsertBefore(data, size);

// CORINFO_HELP_BULK_WRITEBARRIER is a managed wrapper that splits the copy into chunks and polls
// for GC after each of them, so that a huge copy cannot starve the GC. When the size is a small
// compile-time constant none of that is needed and we can call the raw worker directly, saving a
// call and the size check.
const CorInfoHelpFunc helper = (blkSize <= BULK_WRITEBARRIER_SMALL_SIZE) ? CORINFO_HELP_BULK_WRITEBARRIER_SMALL
: CORINFO_HELP_BULK_WRITEBARRIER;
Comment thread
EgorBo marked this conversation as resolved.

// A hacky way to safely call fgMorphTree in Lower
GenTree* destPlaceholder = m_compiler->gtNewZeroConNode(dest->TypeGet());
GenTree* dataPlaceholder = m_compiler->gtNewZeroConNode(genActualType(data));
GenTree* sizePlaceholder = m_compiler->gtNewZeroConNode(genActualType(size));

GenTreeCall* call = m_compiler->gtNewHelperCallNode(CORINFO_HELP_BULK_WRITEBARRIER, TYP_VOID, destPlaceholder,
dataPlaceholder, sizePlaceholder);
GenTreeCall* call =
m_compiler->gtNewHelperCallNode(helper, TYP_VOID, destPlaceholder, dataPlaceholder, sizePlaceholder);
m_compiler->fgMorphArgs(call);

LIR::Range range = LIR::SeqTree(m_compiler, call);
Expand Down
8 changes: 5 additions & 3 deletions src/coreclr/jit/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1689,11 +1689,13 @@ void HelperCallProperties::init()
case CORINFO_HELP_CHECKED_ASSIGN_REF_EDI:
#endif
// GC Write barrier support
// TODO-ARM64-Bug?: Can these throw or not?
case CORINFO_HELP_ASSIGN_REF:
case CORINFO_HELP_CHECKED_ASSIGN_REF:
isNoGC = true;
FALLTHROUGH;
case CORINFO_HELP_BULK_WRITEBARRIER_SMALL:
isNoGC = true;
mutatesHeap = true;
break;

case CORINFO_HELP_BULK_WRITEBARRIER:
mutatesHeap = true;
break;
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/nativeaot/Runtime/inc/ModuleHeaders.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct ReadyToRunHeaderConstants
static const uint32_t Signature = 0x00525452; // 'RTR'

static const uint32_t CurrentMajorVersion = 29;
static const uint32_t CurrentMinorVersion = 2;
static const uint32_t CurrentMinorVersion = 3;
};

struct ReadyToRunHeader
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal struct ReadyToRunHeaderConstants
public const uint Signature = 0x00525452; // 'RTR'

public const ushort CurrentMajorVersion = 29;
public const ushort CurrentMinorVersion = 2;
public const ushort CurrentMinorVersion = 3;
}
#if READYTORUN
#pragma warning disable 0169
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ public enum ReadyToRunHelper
CheckedWriteBarrier = 0x31,
ByRefWriteBarrier = 0x32, // No longer supported as of READYTORUN_MAJOR_VERSION 19.0
BulkWriteBarrier = 0x33,
BulkWriteBarrierSmall = 0x34,

// Array helpers
Stelem_Ref = 0x38,
Expand Down
5 changes: 5 additions & 0 deletions src/coreclr/tools/Common/JitInterface/CorInfoHelpFunc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ which is the right helper to use to allocate an object of a given type. */

CORINFO_HELP_BULK_WRITEBARRIER,

// Same as CORINFO_HELP_BULK_WRITEBARRIER, but it is the raw worker: it does not split the copy
// into chunks and does not poll for GC afterwards. The JIT is only allowed to use it when the
// size is a small compile-time constant, so that the copy cannot starve the GC.
CORINFO_HELP_BULK_WRITEBARRIER_SMALL,

/* Accessing fields */

CORINFO_HELP_GETFIELDADDR,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ public static void GetEntryPoint(TypeSystemContext context, ReadyToRunHelper id,
case ReadyToRunHelper.BulkWriteBarrier:
methodDesc = context.GetCoreLibEntryPoint("System"u8, "Buffer"u8, "BulkMoveWithWriteBarrier"u8, null);
break;
case ReadyToRunHelper.BulkWriteBarrierSmall:
mangledName = "RhBulkMoveWithWriteBarrier";
break;
case ReadyToRunHelper.WriteBarrier_EAX:
mangledName = "RhpAssignRefEAX";
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,9 @@ private ISymbolNode GetHelperFtnUncached(CorInfoHelpFunc ftnNum)
case CorInfoHelpFunc.CORINFO_HELP_CHECKED_ASSIGN_REF:
id = ReadyToRunHelper.CheckedWriteBarrier;
break;
case CorInfoHelpFunc.CORINFO_HELP_BULK_WRITEBARRIER_SMALL:
id = ReadyToRunHelper.BulkWriteBarrierSmall;
break;
case CorInfoHelpFunc.CORINFO_HELP_BULK_WRITEBARRIER:
id = ReadyToRunHelper.BulkWriteBarrier;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1763,6 +1763,10 @@ private void ParseHelper(StringBuilder builder)
builder.Append("BULK_WRITE_BARRIER");
break;

case ReadyToRunHelper.BulkWriteBarrierSmall:
builder.Append("BULK_WRITE_BARRIER_SMALL");
break;

// Array helpers
case ReadyToRunHelper.Stelem_Ref:
builder.Append("STELEM_REF");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,9 @@ private ISymbolNode GetHelperFtnUncached(CorInfoHelpFunc ftnNum)
case CorInfoHelpFunc.CORINFO_HELP_CHECKED_ASSIGN_REF:
id = ReadyToRunHelper.CheckedWriteBarrier;
break;
case CorInfoHelpFunc.CORINFO_HELP_BULK_WRITEBARRIER_SMALL:
id = ReadyToRunHelper.BulkWriteBarrierSmall;
break;
case CorInfoHelpFunc.CORINFO_HELP_BULK_WRITEBARRIER:
id = ReadyToRunHelper.BulkWriteBarrier;
break;
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/vm/corelib.h
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,7 @@ DEFINE_CLASS(BUFFER, System, Buffer)
DEFINE_METHOD(BUFFER, MEMCPY_PTRBYTE_ARRBYTE, Memcpy, SM_PtrByte_Int_ArrByte_Int_Int_RetVoid)
DEFINE_METHOD(BUFFER, MEMCPY, Memcpy, SM_PtrByte_PtrByte_Int_RetVoid)
DEFINE_METHOD(BUFFER, MEMCOPYGC, BulkMoveWithWriteBarrier, SM_RefByte_RefByte_UIntPtr_RetVoid)
DEFINE_METHOD(BUFFER, MEMCOPYGC_SMALL, BulkMoveWithWriteBarrierInternal, SM_RefByte_RefByte_UIntPtr_RetVoid)

DEFINE_CLASS(STUBHELPERS, StubHelpers, StubHelpers)
#ifdef FEATURE_COMINTEROP
Expand Down
Loading