-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Scaffolding for CoreCLR interpreter intrinsics #116769
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
0c10cbc
Checkpoint
kg 475e617
Debugger.Break is only an intrinsic in mono, not coreclr
kg 0c46ef8
No special handling needed for Unsafe methods
kg 760b864
InterpMode release build fixes
kg 92baf4f
Cleanup & address PR feedback
kg b9c8f38
Remove outdated comment and unnecessary writeline
kg 1db3566
Update src/coreclr/interpreter/intrinsics.cpp
kg 79a7be1
Update src/coreclr/interpreter/intrinsics.cpp
kg 4a672ea
This test causes crashes on arm64 for some reason and isn't very useful
kg 8b30e4b
Fix build
kg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| #include "interpreter.h" | ||
| #include "intrinsics.h" | ||
|
|
||
| #define HAS_PREFIX(haystack, needle) \ | ||
| (strncmp(haystack, needle, strlen(needle)) == 0) | ||
|
|
||
| NamedIntrinsic GetNamedIntrinsic(COMP_HANDLE compHnd, CORINFO_METHOD_HANDLE compMethod, CORINFO_METHOD_HANDLE method) | ||
| { | ||
| const char* className = NULL; | ||
| const char* namespaceName = NULL; | ||
| const char* methodName = compHnd->getMethodNameFromMetadata(method, &className, &namespaceName, NULL, 0); | ||
|
|
||
| // Array methods don't have metadata | ||
| if (!namespaceName) | ||
| return NI_Illegal; | ||
|
|
||
| if (!HAS_PREFIX(namespaceName, "System")) | ||
| return NI_Illegal; | ||
|
|
||
| if (!strcmp(namespaceName, "System")) | ||
| { | ||
| if (!strcmp(className, "Double") || !strcmp(className, "Single")) | ||
kg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| if (!strcmp(methodName, "ConvertToIntegerNative")) | ||
| return NI_PRIMITIVE_ConvertToIntegerNative; | ||
| else if (!strcmp(methodName, "MultiplyAddEstimate")) | ||
| return NI_System_Math_MultiplyAddEstimate; | ||
| } | ||
| else if (!strcmp(className, "Math") || !strcmp(className, "MathF")) | ||
| { | ||
| if (!strcmp(methodName, "ReciprocalEstimate")) | ||
| return NI_System_Math_ReciprocalEstimate; | ||
jkotas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| else if (!strcmp(methodName, "ReciprocalSqrtEstimate")) | ||
| return NI_System_Math_ReciprocalSqrtEstimate; | ||
| } | ||
| } | ||
| else if (!strcmp(namespaceName, "System.Numerics")) | ||
| { | ||
| if (!strcmp(className, "Vector") && !strcmp(methodName, "get_IsHardwareAccelerated")) | ||
| return NI_IsSupported_False; | ||
|
|
||
| // Fall back to managed implementation for everything else. | ||
| return NI_Illegal; | ||
| } | ||
| else if (!strcmp(namespaceName, "System.Runtime.Intrinsics")) | ||
| { | ||
| // Vector128<T> etc | ||
| if (HAS_PREFIX(className, "Vector") && !strcmp(methodName, "get_IsHardwareAccelerated")) | ||
| return NI_IsSupported_False; | ||
|
|
||
| // Fall back to managed implementation for everything else. | ||
| return NI_Illegal; | ||
| } | ||
| else if (HAS_PREFIX(namespaceName, "System.Runtime.Intrinsics")) | ||
| { | ||
| // Architecture-specific intrinsics. | ||
| if (!strcmp(methodName, "get_IsSupported")) | ||
| return NI_IsSupported_False; | ||
|
|
||
| // Every intrinsic except IsSupported is PNSE in interpreted-only mode. | ||
| return NI_Throw_PlatformNotSupportedException; | ||
| } | ||
| else if (HAS_PREFIX(namespaceName, "System.Runtime")) | ||
| { | ||
| if (!strcmp(namespaceName, "System.Runtime.CompilerServices")) | ||
| { | ||
| if (!strcmp(className, "StaticsHelpers")) | ||
| { | ||
| if (!strcmp(methodName, "VolatileReadAsByref")) | ||
| return NI_System_Runtime_CompilerServices_StaticsHelpers_VolatileReadAsByref; | ||
| } | ||
| else if (!strcmp(className, "RuntimeHelpers")) | ||
| { | ||
| if (!strcmp(methodName, "IsReferenceOrContainsReferences")) | ||
| return NI_System_Runtime_CompilerServices_RuntimeHelpers_IsReferenceOrContainsReferences; | ||
| } | ||
| } | ||
| else if (!strcmp(namespaceName, "System.Runtime.InteropServices")) | ||
| { | ||
| if (!strcmp(className, "MemoryMarshal")) | ||
| { | ||
| if (!strcmp(methodName, "GetArrayDataReference`1")) | ||
kg marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return NI_System_Runtime_InteropService_MemoryMarshal_GetArrayDataReference; | ||
| } | ||
| } | ||
| } | ||
| else if (!strcmp(namespaceName, "System.Threading")) | ||
| { | ||
| if (!strcmp(className, "Interlocked")) | ||
| { | ||
| if (!strcmp(methodName, "CompareExchange")) | ||
| return NI_System_Threading_Interlocked_CompareExchange; | ||
| else if (!strcmp(methodName, "MemoryBarrier")) | ||
| return NI_System_Threading_Interlocked_MemoryBarrier; | ||
| } | ||
| else if (!strcmp(className, "Thread")) | ||
| { | ||
| if (!strcmp(methodName, "FastPollGC")) | ||
| return NI_System_Threading_Thread_FastPollGC; | ||
| } | ||
| else if (!strcmp(className, "Volatile")) | ||
| { | ||
| if (!strcmp(methodName, "ReadBarrier")) | ||
| return NI_System_Threading_Volatile_ReadBarrier; | ||
| else if (!strcmp(methodName, "WriteBarrier")) | ||
| return NI_System_Threading_Volatile_WriteBarrier; | ||
| } | ||
| } | ||
|
|
||
| return NI_Illegal; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| #ifndef __INTERPRETER_INTRINSICS_H__ | ||
| #define __INTERPRETER_INTRINSICS_H__ | ||
|
|
||
| #include "../jit/namedintrinsiclist.h" | ||
|
|
||
| NamedIntrinsic GetNamedIntrinsic(COMP_HANDLE compHnd, CORINFO_METHOD_HANDLE compMethod, CORINFO_METHOD_HANDLE method); | ||
|
|
||
| #endif // __INTERPRETER_INTRINSICS_H__ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.