为什么 C#

编程入门 行业动态 更新时间:2024-10-12 03:19:35
本文介绍了为什么 C# ->CIL 在每条指令上都有标签吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在编译的 C# 程序上使用 ILDASM.exe 时,它​​显示方法中的每条指令都有一个标签.

When using ILDASM.exe on a compiled C# program, it shows that there is a label for every instruction within methods.

例如:

IL_0001: ldc.i4.4 IL_0002: stloc.0 IL_0003: ldc.r8 12.34 IL_000c: stloc.1 IL_000d: ldc.r8 3.1415926535897931 IL_0016: stloc.2 IL_0017: ldstr "Ehsan" IL_001c: stloc.3 IL_001d: ret

这是为什么?这样做是不是效率低下,还是 CIL 编译器会自己优化这些标签?

Why is this? Is it not inefficient to do this or does the CIL compiler optimize these labels itself?

推荐答案

标签不存在于编译的 CIL 中.为方便起见,它们显示在反汇编代码中.

Labels are not present in the compiled CIL. They are displayed for your convenience in the dissassembled code.

这些特定的标签对应于指令偏移量,而手工代码没有这种限制(标签可以是任意字符串).

These particular labels correspond to instruction offsets, while there is no such restriction on hand-made code (labels could be arbitrary strings).

更多推荐

为什么 C#

本文发布于:2023-11-13 06:30:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1583702.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!