Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitacd4855

Browse files
authored
RyuJIT: Don't emit cast helpers for (T)array.Clone() (#45311)
Note that Array.Clone()'s return type is the same as the type of its first operand.This allows optimization of casts on the result of calls to Clone().
1 parentf8a83c8 commitacd4855

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

‎src/coreclr/jit/gentree.cpp‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17757,6 +17757,14 @@ CORINFO_CLASS_HANDLE Compiler::gtGetClassHandle(GenTree* tree, bool* pIsExact, b
1775717757
case GT_CALL:
1775817758
{
1775917759
GenTreeCall* call = tree->AsCall();
17760+
if (call->gtFlags & CORINFO_FLG_JIT_INTRINSIC)
17761+
{
17762+
if (lookupNamedIntrinsic(call->gtCallMethHnd) == NI_System_Array_Clone)
17763+
{
17764+
objClass = gtGetClassHandle(call->gtCallThisArg->GetNode(), pIsExact, pIsNonNull);
17765+
break;
17766+
}
17767+
}
1776017768
if (call->IsInlineCandidate())
1776117769
{
1776217770
// For inline candidates, we've already cached the return

‎src/coreclr/jit/importer.cpp‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4809,6 +4809,13 @@ NamedIntrinsic Compiler::lookupNamedIntrinsic(CORINFO_METHOD_HANDLE method)
48094809
result = NI_System_GC_KeepAlive;
48104810
}
48114811
}
4812+
else if (strcmp(className, "Array") == 0)
4813+
{
4814+
if (strcmp(methodName, "Clone") == 0)
4815+
{
4816+
result = NI_System_Array_Clone;
4817+
}
4818+
}
48124819
else if (strcmp(className, "Type") == 0)
48134820
{
48144821
if (strcmp(methodName, "get_IsValueType") == 0)

‎src/coreclr/jit/namedintrinsiclist.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ enum NamedIntrinsic : unsigned short
4343
NI_System_Type_get_IsValueType,
4444
NI_System_Type_IsAssignableFrom,
4545
NI_System_Type_IsAssignableTo,
46+
NI_System_Array_Clone,
4647

4748
// These are used by HWIntrinsics but are defined more generally
4849
// to allow dead code optimization and handle the recursion case

‎src/libraries/System.Private.CoreLib/src/System/Array.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ void IList.RemoveAt(int index)
319319

320320
// Make a new array which is a shallow copy of the original array.
321321
//
322+
[Intrinsic]
322323
publicobjectClone()
323324
{
324325
returnMemberwiseClone();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp