《Engineering a Compiler, Second Edition》的笔记-第45页
- 章节名：Ch1:Overview of Compilation
- 页码：第45页 2014-10-08 18:37:55
COMPILER CONSTRUCTION IS ENGINEERING A typical compiler has a series of passes that, together, translate code from some source language into some target language. Along the way, the compiler uses dozens of algorithms and data structures. The compiler writer must select, for each step in the process, an appropriate solution. A successful compiler executes an unimaginable number of times. Con-sider the total number of times that GCC compiler has run. Over GCC's lifetime, even small inefficiencies add up to a significant amount of time. The savings from good design and implementation accumulate over time. Thus, the compiler writer must pay attention to compile time costs, such as the asymptotic complexity of algorithms, the actual running time of the implementation, and the space used by data structures. The compiler writer should have in mind a budget for how much time the compiler will spend on its various tasks. For example, scanning and parsing are two problems for which efficient algorithms abound. Scanners recognize and classify words in time pro-portional to the number of characters in the input program. For a typical programming language, a parser can build derivations in time proportional to the length of the derivation. (The restricted structure of programming languages makes efficient parsing possible.) Because efficient and effec-tive techniques exist for scanning and parsing, the compiler writer should expect to spend just a small fraction of compile time on these tasks. By contrast, optimization and code generation contain several problems that require more time. Many of the algorithms that we will examine for program analysis and optimization will have complexities greater than O(n). Thus, algorithm choice in the optimizer and code generator has a larger impact on compile time than it does in the compiler's front end. The compiler writer may need to trade precision of analysis and effectiveness of optimization against increases in compile time. He or she should make such decisions consciously and carefully.
qtum对本书的所有笔记 · · · · · ·
说明 · · · · · ·