ramnna jain wrote:How many passes are there a java compiler has?
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Stephan van Hulst wrote:I don't see why any compilers would need more than two passes though.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Stephan van Hulst wrote:I don't think that's quite right Mike. Multi-pass compilers need more memory, because for each task they perform, they add more "decorations" to the abstract syntax tree, which is always in memory. Everything needs to be in memory because optimizations may be done at a later stage.
Pass 1 would input a Cobol program from punched cards, perform a partial compilation and output intermediate code on one of the scratch tapes. Pass 2 would then input the intermediate code from tape, perform another partial compilation, and output slightly more detailed code on the other scratch tape, and so on. In this way, the compiler passes would be loaded, one at a time, from the system tape, while the compiled code would move back and forth between the scratch tapes, being gradually refined. The last pass would leave final code on a scratch tape, from which it could be loaded and executed. Since every pass performed a single scan of the original Cobol program (or the intermediate code), this scheme was known as multipass compilation. Multipass compilation made it possible to use a compiler that was much larger than the available core memory.