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

[mono][wasm] Allow methods with finally clauses to be AOTed. #63065

Merged
merged 2 commits into from
Jan 3, 2022

Conversation

vargaz
Copy link
Contributor

@vargaz vargaz commented Dec 22, 2021

This is implemented by running the finally clause with the interpreter.
Methods with clauses have additional code generated, which:

  • Saves the IL state (pc+arguments+locals) into a MonoMethodILState
    structure.
  • Pushes an LMF frame on the LMF stack of type MONO_LMFEXT_IL_STATE.
    The LMF frame points to the il state.

During EH, if such an LMF frame is found, and the IL pc in the
il state points inside a clause, then an interpreted version
of the method is created, and the finally clause is ran using
the interpreter using the il state as the starting state.

@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@ghost ghost assigned vargaz Dec 22, 2021
@vargaz
Copy link
Contributor Author

vargaz commented Dec 22, 2021

/azp run runtime-manual

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@EgorBo
Copy link
Member

EgorBo commented Dec 22, 2021

Not sure if this is related, but in CoreCLR we try to clone "finally" block for the exception-free case:
image

so I guess it can help to avoid falling back to interpreter in most cases

@vargaz
Copy link
Contributor Author

vargaz commented Dec 22, 2021

This PR only runs finally blocks with the interpreter during exception handling, the normal case runs them using AOT.

@vargaz
Copy link
Contributor Author

vargaz commented Dec 26, 2021

/azp run runtime-manual

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vargaz
Copy link
Contributor Author

vargaz commented Dec 26, 2021

The remaining WASM failures all look like an OOM while AOTing Microsoft.CodeAnalysis.CSharp.dll.

@vargaz
Copy link
Contributor Author

vargaz commented Dec 28, 2021

/azp run runtime-manual

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vargaz
Copy link
Contributor Author

vargaz commented Jan 1, 2022

/azp run runtime-manual

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vargaz vargaz force-pushed the deopt2 branch 2 times, most recently from b537b76 to bfc524b Compare January 1, 2022 16:44
This is implemented by running the finally clause with the interpreter.
Methods with clauses have additional code generated, which:
* Saves the IL state (pc+arguments+locals) into a MonoMethodILState
structure.
* Pushes an LMF frame on the LMF stack of type MONO_LMFEXT_IL_STATE.
  The LMF frame points to the il state.

During EH, if such an LMF frame is found, and the IL pc in the
il state points inside a clause, then an interpreted version
of the method is created, and the finally clause is ran using
the interpreter using the il state as the starting state.
@vargaz
Copy link
Contributor Author

vargaz commented Jan 2, 2022

/azp run runtime-manual

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vargaz
Copy link
Contributor Author

vargaz commented Jan 2, 2022

Failures are unrelated.

@vargaz vargaz merged commit c7ec82a into dotnet:main Jan 3, 2022
@vargaz vargaz deleted the deopt2 branch January 3, 2022 11:44
@ghost ghost locked as resolved and limited conversation to collaborators Feb 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants