In .net what are the possible OpCodes that can exist as the last instruction of a method.
At the moment I know that it can be
But is it possible for it to be any other opcodes? And if so what code (prefer c#) would produce them?
By "Last" I mean "the final OpCode defined in the method body"
If throw
can be the last opcode in a method, chances are that jmp
also qualifies.
Also, if we consider a recursive method whose exit condition is not located at the end, the last opcode might be a call
or tail.call
instead of a ret
.
Update: Well, no, it won't. As Marc Gravell rightfully points out in his comment, the documentation for tail.call
says:
The stack must be empty except for the arguments being transferred by the following call. The instruction following the call instruction must be a
ret
.
Update 2: Unconditional branch opcodes like br
and br.s
may also be the last instructions of a method, if its exit point occurs earlier (thanks again Marc).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With