Monday, February 18, 2008

Update

OK. Here is my first update over the long weekend :)

I realized (and was advised) that I needed to delve deep into the working of the CLR to get a crystal clear picture, before I could start working on the front-end of the compiler. So I grokked it up a bit over the long weekend. I also bought an excellent book for understanding the CLR in depth. Its written by one of the guys who worked on the developing the CLR.

Compiling for the .NET Common Language Runtime by John Gough, Prentice Hall.
So I ve got both my reading glasses and my thinking cap on...
Here are some of the things I have been reading up about -
  • The raison d'ĂȘtre for using a virtual stack machine in the first place.

- The code reuse (implementation factorization) argument.

- Semantic factorization or bridging the semantic gap (between source and machine

language) argument.

- Portability and security argument.

  • Garbage Collector - Memory Management handled by the CLR.
  • Memoery safety and verification.

In my next post I will hopefully elaborate on the said topics in detail.

Wednesday, February 6, 2008

Compiler

It suddenly occurred to me (epiphany?) - while reading an MSDN article on building a compiler targeting the MS CLR - that this would be the best way to learn the nuts and bolts of the system (CLR included).

Having already designed a 32-bit non-pipelined processor and an assembler (coded in VHDL and implemented on Spartan-3 FPGA - under the able guidance of my colleague and mentor Yogendra Namjoshi) I can boast a clear understanding of assembly and conversion to native code.

So here I plan to go about jotting down the plans, progress as well as my thoughts during the entire project. I think the first step would be to plan how the project is going to be spread out; given the limited time available everyday after work and the weekends. A rough layout would be something like this:

· Initial literature survey ( a bit of language design fundamentals, scanners, parsers, code generators , compiler design walk through etc.) ·

- Getting the recipe right. This is the tough and perhaps the most crucial stage IMHO i.e. deciding what parts to lift off the shelf and what to custom build. Like for example, there are several parsers readily available(mostly coded in C#) while the scanners are hand-coded best. The compiler project can also be divided into two parts: the front and the back end. To reproduce the diagram given by Joel Pobar:



· Understanding the CLS which ensures that the "Ergo" language falls within the .NET frame.

· The language in which to code the scanner.
· A complex project like this would also do good to have some timelines ( I prefer the word time-lines to deadlines) to ensure completion.

· Finally I realize the necessity and inevitability of collaboration on a project like this, to churn out some thing useful.