Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
EgorBo committed Feb 24, 2024
1 parent ec82a4d commit f3c0141
Show file tree
Hide file tree
Showing 11 changed files with 154 additions and 284 deletions.
1 change: 1 addition & 0 deletions src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10346,6 +10346,7 @@ void Compiler::impImportBlockCode(BasicBlock* block)
GenTreeCall* call;
if (opcode == CEE_INITBLK)
{
// value is zero -> memzero, otherwise -> memset
if (op2->IsIntegralConst(0))
{
call = gtNewHelperCallNode(CORINFO_HELP_MEMZERO, TYP_VOID, op1, op3);
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/vm/appdomain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1378,7 +1378,6 @@ void SystemDomain::LoadBaseSystemClasses()
g_pWeakReferenceOfTClass = CoreLibBinder::GetClass(CLASS__WEAKREFERENCEGENERIC);

g_pCastHelpers = CoreLibBinder::GetClass(CLASS__CASTHELPERS);
g_pRuntimeHelpers = CoreLibBinder::GetClass(CLASS__RUNTIME_HELPERS);

#ifdef FEATURE_COMINTEROP
if (g_pConfig->IsBuiltInCOMSupported())
Expand Down
3 changes: 1 addition & 2 deletions src/coreclr/vm/callcounting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,8 +662,7 @@ bool CallCountingManager::SetCodeEntryPoint(

// Let's tier up all cast and runtime helpers faster than other methods. This is because we want to import them as
// direct calls in codegen and they need to be promoted earlier than their callers.
PTR_MethodTable mt = methodDesc->GetMethodTable();
if (mt == g_pCastHelpers || mt == g_pRuntimeHelpers)
if (methodDesc->GetMethodTable() == g_pCastHelpers)
{
callCountThreshold = max(1, (CallCount)(callCountThreshold / 2));
}
Expand Down
8 changes: 5 additions & 3 deletions src/coreclr/vm/corelib.h
Original file line number Diff line number Diff line change
Expand Up @@ -632,9 +632,11 @@ DEFINE_METHOD(RUNTIME_HELPERS, ENUM_COMPARE_TO, EnumCompareTo, NoSig
DEFINE_METHOD(RUNTIME_HELPERS, ALLOC_TAILCALL_ARG_BUFFER, AllocTailCallArgBuffer, SM_Int_IntPtr_RetIntPtr)
DEFINE_METHOD(RUNTIME_HELPERS, GET_TAILCALL_INFO, GetTailCallInfo, NoSig)
DEFINE_METHOD(RUNTIME_HELPERS, DISPATCH_TAILCALLS, DispatchTailCalls, NoSig)
DEFINE_METHOD(RUNTIME_HELPERS, MEMSET, MemSet, SM_RefByte_Byte_UIntPtr_RetVoid)
DEFINE_METHOD(RUNTIME_HELPERS, MEMZERO, MemZero, SM_RefByte_UIntPtr_RetVoid)
DEFINE_METHOD(RUNTIME_HELPERS, MEMCOPY, MemCopy, SM_RefByte_RefByte_UIntPtr_RetVoid)

DEFINE_CLASS(SPAN_HELPERS, System, SpanHelpers)
DEFINE_METHOD(SPAN_HELPERS, MEMSET, Fill, SM_RefByte_Byte_UIntPtr_RetVoid)
DEFINE_METHOD(SPAN_HELPERS, MEMZERO, ClearWithoutReferences, SM_RefByte_UIntPtr_RetVoid)
DEFINE_METHOD(SPAN_HELPERS, MEMCOPY, Memmove, SM_RefByte_RefByte_UIntPtr_RetVoid)

DEFINE_CLASS(UNSAFE, CompilerServices, Unsafe)
DEFINE_METHOD(UNSAFE, AS_POINTER, AsPointer, NoSig)
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/vm/ecall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,15 @@ void ECall::PopulateManagedHelpers()
pDest = pMD->GetMultiCallableAddrOfCode();
SetJitHelperFunction(CORINFO_HELP_LDELEMA_REF, pDest);

pMD = CoreLibBinder::GetMethod((BinderMethodID)(METHOD__RUNTIME_HELPERS__MEMSET));
pMD = CoreLibBinder::GetMethod((BinderMethodID)(METHOD__SPAN_HELPERS__MEMSET));
pDest = pMD->GetMultiCallableAddrOfCode();
SetJitHelperFunction(CORINFO_HELP_MEMSET, pDest);

pMD = CoreLibBinder::GetMethod((BinderMethodID)(METHOD__RUNTIME_HELPERS__MEMZERO));
pMD = CoreLibBinder::GetMethod((BinderMethodID)(METHOD__SPAN_HELPERS__MEMZERO));
pDest = pMD->GetMultiCallableAddrOfCode();
SetJitHelperFunction(CORINFO_HELP_MEMZERO, pDest);

pMD = CoreLibBinder::GetMethod((BinderMethodID)(METHOD__RUNTIME_HELPERS__MEMCOPY));
pMD = CoreLibBinder::GetMethod((BinderMethodID)(METHOD__SPAN_HELPERS__MEMCOPY));
pDest = pMD->GetMultiCallableAddrOfCode();
SetJitHelperFunction(CORINFO_HELP_MEMCPY, pDest);
}
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/vm/vars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ GVAL_IMPL_INIT(DWORD, g_debuggerWordTLSIndex, TLS_OUT_OF_INDEXES);
GVAL_IMPL_INIT(DWORD, g_TlsIndex, TLS_OUT_OF_INDEXES);

MethodTable* g_pCastHelpers;
MethodTable* g_pRuntimeHelpers;
#ifdef FEATURE_EH_FUNCLETS
GPTR_IMPL(MethodTable, g_pEHClass);
GPTR_IMPL(MethodTable, g_pExceptionServicesInternalCallsClass);
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/vm/vars.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,6 @@ EXTERN OBJECTHANDLE g_pPreallocatedExecutionEngineException;
EXTERN OBJECTHANDLE g_pPreallocatedSentinelObject;

EXTERN MethodTable* g_pCastHelpers;
EXTERN MethodTable* g_pRuntimeHelpers;

GPTR_DECL(Thread,g_pFinalizerThread);
GPTR_DECL(Thread,g_pSuspensionThread);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,38 +126,5 @@ internal static bool IsPrimitiveType(this CorElementType et)
[Intrinsic]
internal static bool IsKnownConstant(char t) => false;
#pragma warning restore IDE0060

#if NATIVEAOT
[System.Runtime.RuntimeExport("RhRuntimeHelpers_MemCopy")]
#endif
private static void MemCopy(ref byte dest, ref byte src, nuint size)
{
if (size > 0)
{
// Implicit nullchecks
SpanHelpers.Memmove(ref dest, ref src, size);
}
}

#if NATIVEAOT
[System.Runtime.RuntimeExport("RhRuntimeHelpers_MemZero")]
#endif
private static void MemZero(ref byte dest, nuint size)
{
if (size > 0)
{
// Implicit nullcheck
_ = Unsafe.ReadUnaligned<byte>(ref dest);
SpanHelpers.ClearWithoutReferences(ref dest, size);
}
}

#if NATIVEAOT
[System.Runtime.RuntimeExport("RhRuntimeHelpers_MemSet")]
#endif
private static void MemSet(ref byte dest, byte value, nuint size)
{
SpanHelpers.Fill(ref dest, size, value);
}
}
}
Loading

0 comments on commit f3c0141

Please sign in to comment.