What are the possible OpCodes for the latest method statement?

In .net, what possible OpCodes may exist as the last instruction of a method.

At the moment, I know it could be

But is it possible to be any other opcode? And if so, what code (preferably C #) will produce them?

By "last" I mean "final OpCode defined in the method body"

+6
source share
1 answer

If throw may be the last opcode in a method, most likely jmp .

In addition, if we consider a recursive method whose exit condition is not at the end, the last operation code may be call or tail.call instead of ret .

Update: Well, no, it won’t. As Mark Gravell rightly points out in his comment, the documentation for tail.call says:

The stack must be empty, with the exception of the arguments passed to the next call. The statement following the call statement must be ret .

Update 2: Unconditional branch codes such as br and br.s may also be the last instructions of a method if its exit point occurs earlier (thanks again Marc).

+2
source

Source: https://habr.com/ru/post/921550/


All Articles