利用内部构建系统构建跨模块可扩展的混合增量编译器
Constructing Hybrid Incremental Compilers for Cross-Module Extensibility with an Internal Build System
摘要:
上下文:编译时间是软件项目适应性的一个重要因素。快速重新编译可以对项目的更改进行廉价的实验,因为这些更改可以快速测试。长期以来,单独和增量编译一直是人们感兴趣的主题,以促进快速重新编译。Inquiry:尽管增量编译器有很多好处,但这种编译器通常不是默认的。这是因为增量化需要横切的、复杂的和容易出错的技术,比如依赖跟踪、缓存、缓存失效和更改检测。特别是在具有跨模块定义和集成的语言的编译器中,正确有效地实现增量编译器可能是一个挑战。在编译器中改进增量就更难了。我们解决这个问题,通过开发一个编译器的设计方法,重用现有的非增量编译器的部分,以降低构建增量编译器的成本。它还提供了一种通过分期编译难以增量化的语言功能的直观方法。方法:我们使用本文中提出的编译器设计方法来开发一个增量编译器的Replego项重写语言。这种语言有一组乍一看与增量编译不兼容的特性。因此,我们把Cubergo作为我们的关键案例来演示这种方法。我们展示了这种方法是如何分解原始编译器的,并有一个增量编译Cubergo的解决方案。我们构建增量编译器的关键思想是在内部使用增量构建系统将我们从原始编译器中提取的组件连接在一起。知识:生成的编译器已经在使用中,作为原来的全程序编译器的替代品。我们发现编译器内部的增量构建系统是我们方法的重要组成部分。这允许编译器编写者考虑编译的多个步骤,并几乎毫不费力地将其组合到增量编译器中。通常情况下,C语言中的独立编译由外部构建系统来促进,程序员负责管理文件之间的依赖关系。我们重用现有的健全和最佳的增量构建系统,并将其依赖跟踪到编译器。基础:本文提供了一个Artifact产品,可以使用增量式编译器。我们评估了一个大型的Adjugo项目,以测试其性能。基准测试从版本控制中重放对Approgo项目的编辑。这些基准测试是人工制品的一部分,打包为虚拟机映像以便于再现。重要性:虽然我们在Tumego程序设计语言上演示了我们的设计方法,但我们也在本文中对其进行了一般性描述。许多当前使用的程序设计语言的编译器比必要的要慢得多。我们的设计提供了一种方法来改变这一点,通过重用现有的编译器,并使其在合理的时间内增量。
英文摘要:
Context: Compilation time is an important factor in the adaptability of a software project. Fast recompilation enables cheap experimentation with changes to a project, as those changes can be tested quickly. Separate and incremental compilation has been a topic of interest for a long time to facilitate fast recompilation. Inquiry: Despite the benefits of an incremental compiler, such compilers are usually not the default. This is because incrementalization requires cross-cutting, complicated, and error-prone techniques such as dependency tracking, caching, cache invalidation, and change detection. Especially in compilers for languages with cross-module definitions and integration, correctly and efficiently implementing an incremental compiler can be a challenge. Retrofitting incrementality into a compiler is even harder. We address this problem by developing a compiler design approach that reuses parts of an existing non-incremental compiler to lower the cost of building an incremental compiler. It also gives an intuition into compiling difficult-to-incrementalize language features through staging. Approach: We use the compiler design approach presented in this paper to develop an incremental compiler for the Stratego term-rewriting language. This language has a set of features that at first glance look incompatible with incremental compilation. Therefore, we treat Stratego as our critical case to demonstrate the approach on. We show how this approach decomposes the original compiler and has a solution to compile Stratego incrementally. The key idea on which we build our incremental compiler is to internally use an incremental build system to wire together the components we extract from the original compiler. Knowledge: The resulting compiler is already in use as a replacement of the original whole-program compiler. We find that the incremental build system inside the compiler is a crucial component of our approach. This allows a compiler writer to think in multiple steps of compilation, and combine that into a incremental compiler almost effortlessly. Normally, separate compilation à la C is facilitated by an external build system, where the programmer is responsible for managing dependencies between files. We reuse an existing sound and optimal incremental build system, and integrate its dependency tracking into the compiler. Grounding: The incremental compiler for Stratego is available as an artefact along with this article. We evaluate it on a large Stratego project to test its performance. The benchmark replays edits to the Stratego project from version control. These benchmarks are part of the artefact, packaged as a virtual machine image for easy reproducibility. Importance: Although we demonstrate our design approach on the Stratego programming language, we also describe it generally throughout this paper. Many currently used programming languages have a compiler that is much slower than necessary. Our design provides an approach to change this, by reusing an existing compiler and making it incremental within a reasonable amount of time.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。