[Paper Review] Compiling Language Definitions: The ASF+SDF Compiler
This paper presents the ASF+SDF compiler, which translates high-level language definitions written in the ASF+SDF meta-language into highly optimized C code. By leveraging maximal subterm sharing (hash-consing) and direct C code generation, the compiler achieves superior performance—matching or exceeding that of functional and rewrite language compilers—enabling efficient execution of large-scale language definitions with up to 10,000 rules and 1 million+ nodes.
The ASF+SDF Meta-Environment is an interactive language development environment whose main application areas are definition of domain-specific languages, generation of program analysis and transformation tools, production of software renovation tools, and general specification and prototyping. It uses conditional rewrite rules to define the dynamic semantics and other tool-oriented aspects of languages, so the effectiveness of the generated tools is critically dependent on the quality of the rewrite rule implementation. The ASF+SDF rewrite rule compiler generates C code, thus taking advantage of C's portability and the sophisticated optimization capabilities of current C compilers as well as avoiding potential abstract machine interface bottlenecks. It can handle large (10 000+ rule) language definitions and uses an efficient run-time storage scheme capable of handling large (1 000 000+ node) terms. Term storage uses maximal subterm sharing (hash-consing), which turns out to be more effective in the case of ASF+SDF than in Lisp or SML. Extensive benchmarking has shown the time and space performance of the generated code to be as good as or better than that of the best current rewrite rule and functional language compilers.
Motivation & Objective
- To develop a high-performance compiler for ASF+SDF language definitions that supports complex program analysis, transformation, and software renovation tasks.
- To address the performance bottleneck of interpretive execution in term rewriting systems by generating efficient, portable C code.
- To enable scalable handling of large language definitions (up to 10,000 rules) and massive term structures (over 1 million nodes).
- To improve runtime efficiency through maximal subterm sharing, reducing memory usage and accelerating term equality checks.
Proposed method
- Direct compilation of ASF+SDF language definitions into portable, optimized C code to leverage C compiler optimizations and avoid virtual machine overhead.
- Employment of a run-time storage scheme based on maximal subterm sharing (hash-consing) to minimize memory allocation and accelerate term comparison.
- Use of conditional rewrite rules, associative lists, and default rules to express complex semantics and control flow in language definitions.
- Integration of the ATerm library for efficient term representation and manipulation, supporting both strict and lazy evaluation patterns.
- Application of benchmarking with memory- and time-intensive workloads (e.g., evalexp, evaltree) to evaluate performance under stress.
- Self-compilation of the ASF+SDF compiler to validate the toolchain and measure performance on real-world, large-scale definitions.
Experimental results
Research questions
- RQ1Can a direct compilation approach from a high-level language definition language to C achieve performance comparable to or better than existing functional and rewrite language compilers?
- RQ2How effective is maximal subterm sharing in reducing memory usage and improving term equality performance in large-scale term rewriting systems?
- RQ3To what extent can the generated C code handle large language definitions (e.g., 10,000+ rules) and massive term structures (e.g., 1 million+ nodes) without performance degradation?
- RQ4Does the combination of direct C code generation and efficient term storage enable better performance than interpretive or virtual machine-based execution?
- RQ5Can the compiler scale effectively under memory-intensive workloads, such as those requiring lazy evaluation and high term reuse?
Key findings
- The ASF+SDF compiler generates C code that performs as well as or better than the best current functional and rewrite language compilers in both time and space efficiency.
- Maximal subterm sharing significantly reduces memory usage—by up to 90%—and improves performance, especially in memory-intensive benchmarks like evaltree.
- The compiler successfully handles large-scale definitions: the ASF+SDF compiler self-compiles in 216 seconds with sharing, compared to 661 seconds without, and uses only 16 MB memory versus 117 MB.
- The Risla expander compiles in 9 seconds with sharing (18 seconds without), using only 8 MB memory, demonstrating scalability for domain-specific language processing.
- In the evaltree benchmark, only ASF+SDF with maximal subterm sharing scales beyond n=20, maintaining acceptable memory usage where other systems fail.
- Execution time comparisons show that only Clean (lazy) outperforms ASF+SDF in some benchmarks, but differences are small, confirming ASF+SDF’s strong competitive performance.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.