GNU Emacs 를 네이티브 코드로 가져오기
Bringing GNU Emacs to Native Code
Bringing GNU Emacs to Native Code
@misc{corallo2020bringing,
title = {Bringing GNU Emacs to Native Code},
author = {Andrea Corallo and Luca Nassi and Nicola Manca},
year = {2020},
eprint = {2004.02504},
archivePrefix = {arXiv},
primaryClass = {cs.PL},
url = {https://arxiv.org/abs/2004.02504}
}
Corallo, A., Nassi, L., & Manca, N. (2020). Bringing GNU Emacs to Native Code [Preprint]. arXiv. https://doi.org/10.48550/arXiv.2004.02504
CORALLO A, NASSI L, MANCA N. Bringing GNU Emacs to Native Code[EB/OL]. (2020-04-06)[2026-11-30]. https://arxiv.org/abs/2004.02504.
초록
Emacs Lisp (Elisp) 은 Emacs 텍스트 편집기 계열이 사용하는 Lisp 방언이다. 현재 GNU Emacs 는 컴파일된 바이트코드로 변환된 후 해석 또는 바이트 해석 방식으로 Elisp 코드를 실행할 수 있다. 본 논문에서는 Elisp 를 대상으로 네이티브 코드를 타겟으로 하는 최적화 컴파일러 접근법의 구현을 논의한다. 네이티브 컴파일러는 바이트 컴파일러의 내부 표현을 입력으로 활용하며, libgccjit 을 이용하여 GNU 컴파일러 컬렉션 (GCC) 인프라스트럭처를 통해 코드 생성을 달성한다. 생성된 실행 파일은 이진 파일로 저장되며 동적으로 로드 및 언로드될 수 있다. 컴파일러의 대부분 기능은 Elisp 자체로 작성되었으며, GNU Emacs 코어와 libgccjit 과 인터페이스하기 위한 C 백엔드를 포함하여 여러 최적화 패스가 포함된다. 아직 진행 중인 작업임에도 불구하고, 우리의 구현은 기능적인 Emacs 를 부트스트랩할 수 있으며, 전체 GNU Emacs Lisp 패키지 아카이브 (ELPA) 를 포함한 모든 문맥적 범위 (lexical scope) 가 있는 Elisp 파일을 컴파일할 수 있다. 측정된 소규모 벤치마크에 따르면, 네이티브 컴파일된 Elisp 는 동등한 바이트코드에 비해 성능이 2.3 배에서 42 배까지 향상됨을 보여준다.
Emacs Lisp (Elisp) is the Lisp dialect used by the Emacs text editor family. GNU Emacs can currently execute Elisp code either interpreted or byte-interpreted after it has been compiled to byte-code. In this work we discuss the implementation of an optimizing compiler approach for Elisp targeting native code. The native compiler employs the byte-compiler's internal representation as input and exploits libgccjit to achieve code generation using the GNU Compiler Collection (GCC) infrastructure. Generated executables are stored as binary files and can be loaded and unloaded dynamically. Most of the functionality of the compiler is written in Elisp itself, including several optimization passes, paired with a C back-end to interface with the GNU Emacs core and libgccjit. Though still a work in progress, our implementation is able to bootstrap a functional Emacs and compile all lexically scoped Elisp files, including the whole GNU Emacs Lisp Package Archive (ELPA). Native-compiled Elisp shows an increase of performance ranging from 2.3x up to 42x with respect to the equivalent byte-code, measured over a set of small benchmarks.