Object-oriented languages often use virtual machines (VMs) that provide mechanisms such as just-in-time (JIT) compilation and garbage collection (GC). These VM components are typically implemented in a separate layer, isolating them from the application. While this approach brings the software engineering benefits of clear separation and decoupling, it introduces barriers for both understanding VM behavior and evolving the VM implementation. For example, the GC and JIT compiler are typically fixed at VM build time, limiting arbitrary adaptation at run time. Furthermore, because of this separation, the implementation of the VM cannot typically be inspected and debugged in the same way as application code, enshrining a distinction in easy-to-work-with application and hard-to-work-with VM code. These characteristics pose a barrier for application developers to understand the engine on top of which their own code runs, and fosters a knowledge gap that prevents application developers to change the VM. We propose Live Metacircular Runtimes (LMRs) to overcome this problem. LMRs are language runtime systems that seamlessly integrate the VM into the application in live programming environments. Unlike classic metacircular approaches, we propose to completely remove the separation between application and VM. By systematically applying object-oriented design to VM components, we can build live runtime systems that are small and flexible enough, where VM engineers can benefit of live programming features such as short feedback loops, and application developers with fewer VM expertise can benefit of the stronger causal connections between their programs and the VM implementation. To evaluate our proposal, we implemented Bee/LMR, a live VM for a Smalltalk-derivative environment in 22057 lines of code. We analyze case studies on tuning the garbage collector, avoiding recompilations by the just-in-time compiler, and adding support to optimize code with vector instructions to demonstrate the trade-offs of extending exploratory programming to VM development in the context of an industrial application used in production. Based on the case studies, we illustrate how our approach facilitates the daily development work of a small team of application developers. Our approach enables VM developers to gain access to live programming tools traditionally reserved for application developers, while application developers can interact with the VM and modify it using the high-level tools they use every day. Both application and VM developers can seamlessly inspect, debug, understand, and modify the different parts of the VM with shorter feedback loops and higher-level tools.
翻译:面向对象语言通常依赖虚拟机(VM)来提供即时编译(JIT)和垃圾回收(GC)等机制。这些虚拟机组件通常被实现在一个独立的层次中,与应用程序隔离。尽管这种方法带来了清晰分离与解耦的软件工程优势,但它也为理解虚拟机行为及演进虚拟机实现设置了障碍。例如,GC和JIT编译器通常于虚拟机构建时固定,限制了运行时的任意适配。此外,由于这种隔离,虚拟机的实现通常无法像应用程序代码那样被检查和调试,从而将易于处理的应用程序代码与难以处理的虚拟机代码区分开来。这些特性阻碍了应用程序开发者理解其自身代码所依托的引擎,并加剧了知识鸿沟,使应用程序开发者难以修改虚拟机。我们提出“实时元环运行时(LMR)”来解决这一问题。LMR是一种语言运行时系统,可在实时编程环境中将虚拟机无缝集成到应用程序中。与经典的元环方法不同,我们主张彻底消除应用程序与虚拟机之间的分离。通过系统地将面向对象设计应用于虚拟机组件,我们可以构建足够小巧灵活的实时运行时系统,使虚拟机工程师受益于短反馈循环等实时编程特性,同时令虚拟机专业知识较少的应用程序开发者也能受益于其程序与虚拟机实现之间更强的因果关联。为评估我们的方案,我们实现了Bee/LMR——一个用于Smalltalk衍生环境的实时虚拟机(共22057行代码)。我们通过分析垃圾回收器调优、避免即时编译器引发的重编译,以及添加对向量指令优化代码的支持等案例研究,展示了将探索式编程扩展至虚拟机开发时的权衡(以实际生产环境中使用的工业应用为背景)。基于这些案例研究,我们阐述了该方法如何促进小型应用程序开发团队的日常开发工作。我们的方法使虚拟机开发者能够使用传统上仅限于应用程序开发者的实时编程工具,同时应用程序开发者也能通过日常使用的高级工具与虚拟机交互并对其进行修改。应用程序与虚拟机开发者均可借助更短的反馈循环和更高级的工具,无缝地检查、调试、理解并修改虚拟机的不同组成部分。