
What are the Different Compiler Engineering Techniques?Irrespective of whatever programming language you use, your computer will only understand machine code. Then how is your application running? That is with the help of translators. Translator converts your programming language into machine code called object code which your computer can understand.
There are
two types of translators: Compilers and Interpreters. Compilers convert
your programming language into an intermediary representation and this
intermediary representation is then converted into object code. Interpreters
work in a different way. They do not have an intermediary representation.
They read each line of code from your language and convert it directly
to object code. Then they read next line of your code and so on. If the
language you use can be easily convertible to object code then interpreters
can be used. Understanding
Key Terms: The language
which you use i.e. the input language is called Source Language. Compiler
which you use will be implemented using a particular language. That is
termed as Implementation Language. Compiler will output object code in
a different language, which is termed as Target Language. Following diagram
pictorially represents these three key languages: Compiler
Engineering Techniques: Based on
the source language, target language and other requirements (like Performance,
Efficiency) Compiler can be developed with a particular implementation
language. For compiler development and implementation, different compiler
engineering techniques are proposed. This article will focus on the following
most commonly used and famous compiler engineering techniques: Assembly
Language as Implementation Language and Target Language Overview
of each of these techniques is given below: Assembly
Language as Implementation Language and Target Language: This is a direct
solution. In general, developing a compiler involves more complications.
Using assembly language as implementation language will require complex
programming as well as debugging activities. This will be expensive. Hence
bootstrapping technique was introduced. Bootstrapping:
In bootstrapping, compiler will compile the source program in the language
used for developing source program. i.e., source language and implementation
language will be the same. Assume that there is a compiler KC: A?B, where
language A is a higher language when compared to assembly language. Implement
a compiler with definition KA: L?B. Apply KC over KA and process the source
program. Compiler mapping will now have the definition KC =KC (KA): L?B.
This means that KC has bootstrapped KA. Bootstrapping
is also termed as self-hosting. Few sample languages that have bootstrapped
compiler are Basic, Pascal, C, Modula-2 and much more. First language
to be bootstrapped was LISP and it happened in the year 1962. Cross
Compiler Technology: Cross Compilers are used to generate target object
code in a non-resident platform for the compiler. If you have to use multiple
platforms to perform different computing functions while converting to
target language, you can use cross-compilers. Virtual
Machines: Virtual machines are alternatives to cross compilers. They
are also portable and support multiple platforms, multiple operating systems.
When you have more than one target platforms, how will you translate the
source program to each of the target object code? As per this technique,
source program will be converted into an intermediate byte code using
compilers. First virtual
machine was developed for Pascal in 1970s. JVM (Java Virtual Machine)
is a best example for virtual machines. Just-In-Time
Compilation: This compilation technique is also termed as dynamic
compilation. It highly concentrates on increasing run time performance
of your program. Using this technique, object code is generated directly
in the memory and not stored anywhere. Hence there is an improvisation
in performance. Sometimes,
just-in-time compilers work together with virtual machine interpreters.
Intermediate byte code is initially processed by virtual machine interpreters.
If the time taken by this interpreter for a particular block of code is
high and it affects performance, then just-in-time compilers will come
into action and do the translation into target object code. In this case,
just-in-time compilers can do the complete translation of intermediate
representation into object code or perform translation for a particular
file or function which consumes more time when tried with virtual machine
interpreter. First just-in-time
compiler was developed for Smalltalk in 1980s. Many implementations of
Java Virtual Machine use this technique. .NET Applications are also using
Just-In-Time Compilers for effective and efficient compilation.
_______________________________________________________________________
FREE
Subscription
Subscribe
to our mailing list and receive new articles Note
: We never rent, trade, or sell my email lists to Visit
.NET Programming Tutorial Homepage ______________________________________________________ |