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
- Ret http://msdn.microsoft.com/en-us/library/system.reflection.emit.opcodes.ret.aspx
- Throw http://msdn.microsoft.com/en-us/library/system.reflection.emit.opcodes.throw.aspx
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
throwcan be the last opcode in a method, chances are thatjmpalso qualifies.Also, if we consider a recursive method whose exit condition is not located at the end,
the last opcode might be acallortail.callinstead of aret.Update: Well, no, it won’t. As Marc Gravell rightfully points out in his comment, the documentation for
tail.callsays:Update 2: Unconditional branch opcodes like
brandbr.smay also be the last instructions of a method, if its exit point occurs earlier (thanks again Marc).