Some Domain Knowledge


Compiler

This FIGURE illustrates the fundamental role of a compiler in software development, translating source code into machine code while identifying and reporting errors. An effective compiler must accurately distinguish between legal and illegal programs, generate correct machine-readable code, and efficiently manage variable storage and code organization.

<aside> <img src="/icons/photo-landscape_gray.svg" alt="/icons/photo-landscape_gray.svg" width="40px" />

FIGURE

Image courtesy of Prof. 游, Introduction to Compiler Design, NYCU, Fall 2023

Image courtesy of Prof. 游, Introduction to Compiler Design, NYCU, Fall 2023

</aside>

The compiler structure FIGURE depicted includes a Front End and a Back End, connected via an Intermediate Representation (IR). The Front End efficiently translates legal source code into IR, typically operating with a time complexity of $O(n)$ or $O(n \log{n})$. The back end converts IR into machine code and involves NP-complete problems, thus making it computationally complex. This modular approach allows multiple Front Ends for various programming languages and numerous optimization passes, resulting in more efficient generated machine code.

<aside> <img src="/icons/photo-landscape_gray.svg" alt="/icons/photo-landscape_gray.svg" width="40px" />

FIGURE

Image courtesy of Prof. 游, Introduction to Compiler Design, NYCU, Fall 2023

Image courtesy of Prof. 游, Introduction to Compiler Design, NYCU, Fall 2023

</aside>

<aside> <img src="/icons/photo-landscape_gray.svg" alt="/icons/photo-landscape_gray.svg" width="40px" />

FIGURE

Image courtesy of Prof. 游, Introduction to Compiler Design, NYCU, Fall 2023

Image courtesy of Prof. 游, Introduction to Compiler Design, NYCU, Fall 2023

</aside>

<aside> <img src="/icons/photo-landscape_gray.svg" alt="/icons/photo-landscape_gray.svg" width="40px" />

FIGURE

Image courtesy of Prof. 游, Introduction to Compiler Design, NYCU, Fall 2023

Image courtesy of Prof. 游, Introduction to Compiler Design, NYCU, Fall 2023

</aside>

Runtime

Runtime refers to the entire period during which a program is executing—from the moment it starts until it finishes. During this time, the program interacts with the operating system and hardware resources, executes instructions, and processes data.

The Role of Runtime

Memory Management

Allocating and releasing memory needed during program execution to ensure efficient resource usage.


Error Handling

Monitoring and handling errors or exceptions during execution to maintain program stability.