Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RyuJIT] Intrinsify Object.MemberwiseClone() #46243

Merged
merged 1 commit into from
Dec 27, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public partial class Object
// object. This is always a shallow copy of the instance. The method is protected
// so that other object may only call this method on themselves. It is intended to
// support the ICloneable interface.
[Intrinsic]
protected unsafe object MemberwiseClone()
{
object clone = RuntimeHelpers.AllocateUninitializedClone(this);
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 @@ -17759,7 +17759,8 @@ CORINFO_CLASS_HANDLE Compiler::gtGetClassHandle(GenTree* tree, bool* pIsExact, b
GenTreeCall* call = tree->AsCall();
if (call->gtFlags & CORINFO_FLG_JIT_INTRINSIC)
{
if (lookupNamedIntrinsic(call->gtCallMethHnd) == NI_System_Array_Clone)
NamedIntrinsic ni = lookupNamedIntrinsic(call->gtCallMethHnd);
if ((ni == NI_System_Array_Clone) || (ni == NI_System_Object_MemberwiseClone))
{
objClass = gtGetClassHandle(call->gtCallThisArg->GetNode(), pIsExact, pIsNonNull);
break;
Expand Down
7 changes: 7 additions & 0 deletions src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4816,6 +4816,13 @@ NamedIntrinsic Compiler::lookupNamedIntrinsic(CORINFO_METHOD_HANDLE method)
result = NI_System_Array_Clone;
}
}
else if (strcmp(className, "Object") == 0)
{
if (strcmp(methodName, "MemberwiseClone") == 0)
{
result = NI_System_Object_MemberwiseClone;
}
}
else if (strcmp(className, "Type") == 0)
{
if (strcmp(methodName, "get_IsValueType") == 0)
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/jit/namedintrinsiclist.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ enum NamedIntrinsic : unsigned short
NI_System_Type_IsAssignableFrom,
NI_System_Type_IsAssignableTo,
NI_System_Array_Clone,
NI_System_Object_MemberwiseClone,

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