Repository navigation
[mono] Optimize thread state transition - #58992
Closed
filipnavara wants to merge 11 commits into
Closed
filipnavara wants to merge 11 commits into
filipnavara wants to merge 11 commits into
Conversation
|
Tagging subscribers to this area: Issue DetailsIgnore, just want to see the CI.
|
…py_stack to a buffer
filipnavara
force-pushed
the
mono_faster_pinvoke
branch
from
September 12, 2021 04:33
ac50e0c to
0ba4346
Compare
|
Draft Pull Request was automatically closed for inactivity. Please let us know if you'd like to reopen it. |
This pull request was closed.
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Ignore for reviews, just want to see the CI.
This revamps the logic in how transitions from managed to native code happen with regards to GC. The core idea is to ensure that every possible reference is spilled to the stack before the transition to icall or P/Invoke.
The wrappers for P/Invoke (w/o
SuppressGCTransition) ensure the spilling in the following way:MonoLMFstructure on the stackThe wrappers for P/Invoke with
SuppressGCTransitiondon't get any special treatment since GC safe mode is not entered.The wrappers for icalls don't enter GC safe mode themselves. In that regard they behave like P/Invoke with
SuppressGCTransitionand skip the explicit argument spilling. This should be safe if the icalls useHANDLESlogic which should ensure proper tracking by GC if the icall eventually enters the GC safe mode.Additionally, the following changes are present:
thread_state_initcaptures only stack boundaries in the contextcopy_stackis no longer necessary and it's removed; since all the references are spilled to the stack before the GC safe transition they stay on the stack for the duration of the native callTODO:
save_lmf, add emiting ofllvm.eh.unwind.initintrinsic to spill the callee saved registersmono_threads_enter_gc_safe_regionare safe