Skip to content

Commit

Permalink
JIT: Mark certain intrinsics as non-escaping (#113093)
Browse files Browse the repository at this point in the history
  • Loading branch information
EgorBo authored Mar 4, 2025
1 parent 1b1e94d commit 75e7800
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/coreclr/jit/objectalloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,25 @@ bool ObjectAllocator::CanLclVarEscapeViaParentStack(ArrayStack<GenTree*>* parent
canLclVarEscapeViaParentStack =
!Compiler::s_helperCallProperties.IsNoEscape(comp->eeGetHelperNum(asCall->gtCallMethHnd));
}
else if (asCall->IsSpecialIntrinsic())
{
// Some known special intrinsics don't escape. At this moment, only the ones accepting byrefs
// are supported. In order to support more intrinsics accepting objects, we need extra work
// on the VM side which is not ready for that yet.
//
switch (comp->lookupNamedIntrinsic(asCall->gtCallMethHnd))
{
case NI_System_SpanHelpers_ClearWithoutReferences:
case NI_System_SpanHelpers_Fill:
case NI_System_SpanHelpers_Memmove:
case NI_System_SpanHelpers_SequenceEqual:
canLclVarEscapeViaParentStack = false;
break;

default:
break;
}
}

// Note there is nothing special here about the parent being a call. We could move all this processing
// up to the caller and handle any sort of tree that could lead to escapes this way.
Expand Down
7 changes: 7 additions & 0 deletions src/coreclr/jit/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1669,6 +1669,13 @@ void HelperCallProperties::init()
isPure = true;
break;

case CORINFO_HELP_MEMCPY:
case CORINFO_HELP_MEMZERO:
case CORINFO_HELP_MEMSET:
case CORINFO_HELP_NATIVE_MEMSET:
isNoEscape = true;
break;

case CORINFO_HELP_LDELEMA_REF:
isPure = true;
break;
Expand Down

0 comments on commit 75e7800

Please sign in to comment.