[Mono-devel-list] suggestion for optimizing MCS
He HongFu
hfhe at stryon.com
Tue Nov 4 08:38:48 EST 2003
Hi all:
There is just a suggestion about optimizing the MCS.
AFAIK, now the working flow of the current MCS as following: firstly use CSharpParser to parse all source file,building type tree, member token table, parsing all statement and expression then resolving the type tree, finally defining the types, emiting IL codes. Maybe I'm wrong about that.
And I get the working flow of CSC(Microsoft) when I parsing it. The flow as following:
CSC compiles all files with four phases:
Phase 1. Handle preprocessor directives, build type tree for all files, and parse these type's member lexically and syntactically. I think the work of this phase is building a symbol table.
Phase 2. Semantically parse the members of all defined type, including type resolving. We can get type information from the symbol table built above
Phase 3. Semantically parse the members of all defined type, such as method overload, Main entry defined, etc.
Phase 4. Lexicallly, syntactically, Semantically parse the member body such as method, property, sevolve statements
expressions, I don't know whether .
If errors occur in the one of the file in some phase, all file will do util the same phase work was finished.
I have thought about the implementation of CSC for long time. Why it did as that? As well known, the author of the CSC is Anders Hejlsberg which is one of the best excellent programmer of compiler. I just get some tiny reasons. I think the primary advantage is that compiling multiple file and error handling. First, the work flow of CSC can save obvious memory usage When compiling multiple files. Second, if we have error in a file in some phase, we can stop the following phase work after parsing all files in the phase, and exit the compiler. And preprocessor directive can be proprocessing without any overloads.
Of course, the changes of MCS makes more overloads, and the structure of CSC maybe not as many advantages as I thought. I
hope Mono hacker can cosider it carefully. Or if want to optimize MCS, we can make a branch just for experiment.
Regardings!
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡He HongFu
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡hfhe at stryon.com
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡2003-11-04
More information about the Mono-devel-list
mailing list