cil

Java's Virtual Machine and CLR

∥☆過路亽.° 提交于 2019-11-27 09:57:58
As a sort of follow up to the question called Differences between MSIL and Java bytecode? , what is the (major) differences or similarity in how the Java Virtual Machine works versus how the .NET Framework Common Language Runtime (CLR) works? Also, is the .NET framework CLR a "virtual machine" or does it not have the attributes of a virtual machine? benjismith There are a lot of similarities between both implementations (and in my opinion: yes, they're both "virtual machines"). For one thing, they're both stack-based VM's, with no notion of "registers" like we're used to seeing in a modern CPU

What can you do in MSIL that you cannot do in C# or VB.NET? [closed]

江枫思渺然 提交于 2019-11-27 08:55:13
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . All code written in .NET languages compiles to MSIL, but are there specific tasks / operations that you can do only using MSIL

Why is !0 a type in Microsoft Intermediate Language (MSIL)?

纵然是瞬间 提交于 2019-11-27 03:43:27
问题 In many MSIL listings, I have observed the following: System.Nullable`1<!0> etc ... or class !0 etc ... What's the meaning of !0 in these circumstances? 回答1: This is quirk of the decompiler you use to look at a .NET assembly. It is the behavior of ildasm.exe, other ones like Reflector or ILSpy get this right. The Microsoft programmer who wrote it took a shortcut, he generates a string from the IL that just displays the type argument the way it is encoded, without writing the extra code to

Is there a way to see the native code produced by theJITter for given C# / CIL?

安稳与你 提交于 2019-11-27 01:20:21
问题 In a comment on this answer (which suggests using bit-shift operators over integer multiplication / division, for performance), I queried whether this would actually be faster. In the back of my mind is an idea that at some level, something will be clever enough to work out that >> 1 and / 2 are the same operation. However, I'm now wondering if this is in fact true, and if it is, at what level it occurs. A test program produces the following comparative CIL (with optimize on) for two methods

Making a CLR/.NET Language Debuggable

懵懂的女人 提交于 2019-11-27 01:13:24
问题 What are some resources for making a CLR/.NET language debuggable? I'm developing an ActionScript 3 to IL compiler, which uses DLR CallSites and CallSiteBinders to handle the dynamic aspects of the otherwise static programming language. I'm looking for any information on making the emitted IL map back to the source code, and I'd also like to know how I can make the dynamic call sites map back as well. So this is ultimately two questions: How can I make the IL debuggable? How can I make the

Modifying Existing .NET Assemblies

无人久伴 提交于 2019-11-27 01:02:35
问题 Is there a way to modify existing .NET assemblies without resorting to 3rd party tools? I know that PostSharp makes this possible but I find it incredibly wasteful that the developler of PostSharp basically had to rewrite the functionality of the whole System.Reflection namespace in order to make existing assemblies modifiable. System.Reflection.Emit only allows the creation of new, dynamic assemblies. However, all the builder classes used here inherit from the basic reflection classes (e.g.

What is the purpose of hidebysig in a MSIL method?

江枫思渺然 提交于 2019-11-26 23:57:21
问题 Using ildasm and a C# program e.g. static void Main(string[] args) { } gives: .method private hidebysig static void Main(string[] args) cil managed { .entrypoint // Code size 2 (0x2) .maxstack 8 IL_0000: nop IL_0001: ret } // end of method Program::Main What does the hidebysig construct do? 回答1: From ECMA 335, section 8.10.4 of partition 1: The CTS provides independent control over both the names that are visible from a base type (hiding) and the sharing of layout slots in the derived class

Why does this (null || !TryParse) conditional result in “use of unassigned local variable”?

岁酱吖の 提交于 2019-11-26 23:54:11
问题 The following code results in use of unassigned local variable "numberOfGroups" : int numberOfGroups; if(options.NumberOfGroups == null || !int.TryParse(options.NumberOfGroups, out numberOfGroups)) { numberOfGroups = 10; } However, this code works fine (though, ReSharper says the = 10 is redundant): int numberOfGroups = 10; if(options.NumberOfGroups == null || !int.TryParse(options.NumberOfGroups, out numberOfGroups)) { numberOfGroups = 10; } Am I missing something, or is the compiler not

Generate tail call opcode

这一生的挚爱 提交于 2019-11-26 22:27:40
Out of curiosity I was trying to generate a tail call opcode using C#. Fibinacci is an easy one, so my c# example looks like this: private static void Main(string[] args) { Console.WriteLine(Fib(int.MaxValue, 0)); } public static int Fib(int i, int acc) { if (i == 0) { return acc; } return Fib(i - 1, acc + i); } If I build it in release and run it without debugging I do not get a stack overflow. Debugging or running it without optimizations and I do get a stack overflow, implying that tail call is working when in release with optimizations on (which is what I expected). The MSIL for this looks

Call and Callvirt

别来无恙 提交于 2019-11-26 21:55:16
What is the difference between the CIL instructions "Call" and "Callvirt"? call is for calling non-virtual, static, or superclass methods, i.e., the target of the call is not subject to overriding. callvirt is for calling virtual methods (so that if this is a subclass that overrides the method, the subclass version is called instead). Drew Noakes When the runtime executes a call instruction it's making a call to an exact piece of code (method). There's no question about where it exists. Once the IL has been JITted, the resulting machine code at the call site is an unconditional jmp instruction