How to understand these paragraphs in EMCA 335 regarding `.locals init`?

半世苍凉 提交于 2019-12-01 13:32:54
  1. This just says that any memory established for storing integral types including Byte, Short, Int, Long, UInt, etc should have that memory cleared and the value set to 0, and Float, Double, etc should be 0.0. In .Net, this is the expected default value for the local variables for value types.

  2. Ensuring that object references on the heap start off with an address pointing to null may require a different setup than forcing actual values in a memory address on the stack to have a zero value for the value types. So while objects are always null, value types are only zeroed out if the .locals init is set.

  3. Value types do not have a constructor. The memory is allocated when you dimension the variable, but no default initialization call takes place for value types in CLI.

  4. It sounds like verified code is a notch above the basic level provided directly by the CLI, and among other things requires value type initialization. But I'm just guessing on that one. Sort of like declaring it "unsafe" vs. "managed" or whatever.

  5. It sounds like when zeroing values CLI makes a judgement call as it is zeroing values to decide if it actually needs to do so or not. But it sounds like this option is not always possible, depending on the native platform, or else depending on the memory size or something.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!