What's the purpose of the CIL nop opcode?

前端 未结 19 1301
被撕碎了的回忆
被撕碎了的回忆 2020-12-07 10:42

I\'m going through MSIL and noticing there are a lot of nop instructions in the MSIL.

The MSDN article says they take no action and are used to fill space if the opc

19条回答
  •  隐瞒了意图╮
    2020-12-07 10:45

    NOPs serve several purposes:

    • They allow the debugger to place a breakpoint on a line even if it is combined with others in the generated code.
    • It allows the loader to patch a jump with a different-sized target offset.
    • It allows a block of code to be aligned at a particular boundary, which can be good for caching.
    • It allows for incremental linking to overwrite chunks of code with a call to a new section without having to worry about the overall function changing size.

提交回复
热议问题