-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Add support for emitting finally regions in ILEmitter #27109
Conversation
In #26418 I added the same capability to the C++ versions of these classes and there I modeled the design after System.Reflection.Emit: The only difference seems to be that it keeps track of the try-catch in a stack inside the code stream. Just some food for thought. |
Oh, cool. Didn't realize that was there too! I did it the awkward way (where one needs to hold on to the exception region builder) because I though it might be useful to be able to have regions/handlers spanning multiple ILCodeStreams. That might be of dubious value (I certainly don't need it now). |
Ironically I think this would be needed to switch the current PInvoke stubs generated in the runtime to use the more general mechanism instead of its own custom thrown together thing, so maybe I should be using your design 😄 |
This will be needed to properly do cleanups in marshalling stubs. The usage goes like (I couldn't come up with anything better): ``` var b = codeStream.BeginTry(); //... codeStream.EndTry(b); codeStream.BeginHandler(b); // ... codeStream.EndHandler(b); emit.NewFinallyRegion(b); ```
485e301
to
f37db36
Compare
Cc @dotnet/crossgen-contrib |
This is used to create MethodIL for the interop stubs. I introduced this field in dotnet#27109 but forgot to make a copy here.
This is used to create MethodIL for the interop stubs. I introduced this field in #27109 but forgot to make a copy here.
This will be needed to properly do cleanups in marshalling stubs.
The usage goes like (I couldn't come up with anything better):