Questions tagged [intermediate-language]

An intermediate language, in compiler design, is a low-level language that typically resembles an idealized assembly language, often a textual representation of bytecode for a virtual machine. For .NET's CIL, use the [cil] tag.

An intermediate language, in compiler design, is a translation stage after the syntax tree and before the machine code. The term is usually used for final stages of the translation, after high-level optimizations have been performed, but at a stage when the translation is still independent of the target machine.

In particular, “intermediate language” often means a low-level, assembly-like language for a virtual machine such as the JVM, .NET, Prolog's WAM, etc.

For example, the .NET Common Intermediate Language is the assembly language for the virtual machine that is the target of and other compilers.

133 questions
46
votes
4 answers

Understanding STG

The design of GHC is based on something called STG, which stands for "spineless, tagless G-machine". Now G-machine is apparently short for "graph reduction machine", which defines how laziness is implemented. Unevaluated thunks are stored as an…
MathematicalOrchid
  • 58,942
  • 16
  • 110
  • 206
30
votes
0 answers

Pragmatics of typed intermediate languages

One trend in the compilation is to use typed intermediate languages. Haskell's ghc with its core intermediate language, a variant of System F-omega, is an example of this architecture [ 1 ]. Another is LLVM, which has a typed intermediate language…
26
votes
7 answers

What does Backpatching mean?

What does backpatching mean ? Please illustrate with a simple example.
25
votes
3 answers

How does the .NET IL .maxstack directive work?

I'd like to know how does .maxstack really work. I know it doesn't have to do with the actual size of the types you are declaring but with the number of them. My questions are: does this apply just for the function, or to all the functions that we…
devoured elysium
  • 90,453
  • 117
  • 313
  • 521
17
votes
4 answers

Why is it so easy to decompile .NET IL code?

Why is it so easy to decompile .NET IL-code into source code, compared to decompiling native x86 binaries? (Reflector produces quite good source code most of the time, while decompiling the output of a C++ compiler is almost impossible.) Is it…
compie
  • 9,449
  • 15
  • 51
  • 73
14
votes
2 answers

Is there a binary kind of SVG?

It just seems to me that when writing code for dynamic data visualization, I end up doing the same things over and over in different languages/platforms. Now if I had a cross platform language(which I do) and something like a binary version of SVG,…
user81993
  • 5,209
  • 3
  • 26
  • 51
13
votes
5 answers

Difference between interface as type constraint and interface as parameter?

If I wanted to create a method that takes an instance of IList as a parameter (or any other interface, but let's use IList as an example), I could create a generic method with a type constraint, e.g.: public static void Foo1(T list) where T :…
Donut
  • 96,420
  • 18
  • 123
  • 140
13
votes
5 answers

C# 6 Auto Initialization Property and the use of backing fields

Prior to C# 6, the initialization of properties did not use backing fields to initialize default values. In C#6, it uses the backing fields to initialize with new Auto initialization properties. I'm curious why prior to C#6 IL uses the property…
Spock
  • 6,821
  • 1
  • 36
  • 58
12
votes
3 answers

How to turn a list of string into one string in scheme?

For example I have (list "a" "1" "b" "2" "c" "3"). Now I want to turn this list into one "a1b2c3". How do I do that? Thank you.
user2444642
  • 121
  • 1
  • 1
  • 3
12
votes
2 answers

What are some obvious optimizations for a virtual machine implementing a functional language?

I'm working on an intermediate language and a virtual machine to run a functional language with a couple of "problematic" properties: Lexical namespaces (closures) Dynamically growing call stack A slow integer type (bignums) The intermediate…
11
votes
2 answers

Is the c# compiler smarter than the VB.NET compiler?

If I look at the IL that is created in Linqpad for the two following code snippets, I wonder what happens here. In c# int i = 42; results in the following IL code IL_0000: ret whereas in VB Dim i As Integer = 42 it is IL_0000: ldc.i4.s 2A…
Olaf
  • 9,471
  • 8
  • 34
  • 54
11
votes
1 answer

Static constructor on a .NET interface is not run

You can define a static constructor on an interface in .NET in IL. However, if you do so, the static constructor is not run when you run a method on the interface: .method public static void Main() { .entrypoint .locals init ( class…
thecoop
  • 42,842
  • 15
  • 122
  • 181
9
votes
1 answer

Does F# Interpreter (fsi.exe) also produces Intermediate Language-Code as F# Compiler (fsc.exe) does?

Currently I'm doing a recherche for university about F#. I have a question about the F# interactive Console and the F# compiler. The F# compiler produces Microsoft Intermediate Language (MSIL) code when its compiling F#-source. This is then…
martin
  • 2,797
  • 3
  • 23
  • 42
9
votes
2 answers

Can Mono.Cecil modify code already loaded in the AppDomain?

I want to add some behavior to a certain class at runtime. I know how to subclass at runtime using Reflection.Emit but that's not enough. Depending on some external configuration I need to inject opcodes in a method on a type T so all classes that…
Thiago de Arruda
  • 4,360
  • 5
  • 37
  • 66
8
votes
2 answers

What is the meaning of -2 in this IL instruction?

I was discovering the IL code of a simple program: long x = 0; for(long i = 0;i< int.MaxValue * 2L; i++) { x = i; } Console.WriteLine(x); I build this code in Release mode and this IL code is generated: .method private hidebysig static void …
Selman Genç
  • 94,267
  • 13
  • 106
  • 172
1
2 3
8 9