A Surprisingly Simple Lua Compiler

被引:1
|
作者
Gualandi, Hugo Musso [1 ]
Ierusalimschy, Roberto [1 ]
机构
[1] Pontificia Univ Catolica Rio de Janeiro, Rio de Janeiro, Brazil
关键词
dynamic languages; interpreters; partial evaluation; compilers; just-in-time compilers;
D O I
10.1145/3475061.3475077
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
Dynamically-typed programming languages are often implemented using interpreters, which offer several advantages in terms of portability and flexibility of the implementation. However, as a language matures and its programs get bigger, programmers may seek compilers, to avoid the interpretation overhead. In this study, we present LuaAOT, a simple ahead-of-time compiler for Lua. The compiler is derived from the Lua interpreter and it exemplifies an old idea of using partial evaluation to produce a compiler based on an existing interpreter. Our contribution is to apply this idea to a well-established programming language. We show that with a quite modest effort it is possible to implement an efficient compiler that covers the entirety of Lua, including coroutines and tail calls. The whole implementation required less than 500 lines of new code. For this effort, we reduced the running time of our benchmarks from 20% to 60%.
引用
收藏
页码:1 / 8
页数:8
相关论文
共 50 条
  • [1] A surprisingly simple Lua compiler-Extended version
    Gualandi, Hugo Musso
    Ierusalimschy, Roberto
    JOURNAL OF COMPUTER LANGUAGES, 2022, 72
  • [2] Generating declarations needed by LuaJIT compiler for binding Lua and C
    Vukobrat, Violeta
    Rankov, Branislav
    Jovanovic, Petar
    Popovic, Miroslav
    2015 23RD TELECOMMUNICATIONS FORUM TELFOR (TELFOR), 2015, : 847 - 850
  • [3] Surprisingly simple spectra
    Vincent De Comarmond
    Robert de Mello Koch
    Katherine Jefferies
    Journal of High Energy Physics, 2011
  • [4] Surprisingly simple spectra
    De Comarmond, Vincent
    Koch, Robert de Mello
    Jefferies, Katherine
    JOURNAL OF HIGH ENERGY PHYSICS, 2011, (02):
  • [5] A surprisingly simple determinant
    Nijenhuis, A
    AMERICAN MATHEMATICAL MONTHLY, 2003, 110 (05): : 439 - 440
  • [6] Α simple compiler-compiler for microcomputer
    Mössenböck, H.
    IT - Information Technology, 1984, 26 (1-6): : 186 - 194
  • [7] Five surprisingly simple complexities
    Strehl, V
    Wilf, HS
    JOURNAL OF SYMBOLIC COMPUTATION, 1995, 20 (5-6) : 725 - 729
  • [8] A surprisingly simple summation solution
    Andersen, ES
    Larsen, ME
    Honold, T
    Knuth, DE
    AMERICAN MATHEMATICAL MONTHLY, 1997, 104 (05): : 466 - 467
  • [9] SIMPLE ADC IS SURPRISINGLY ACCURATE
    WSALNE, M
    EDN, 1994, 39 (12) : 154 - 154
  • [10] An Optimization Problem with a Surprisingly Simple Solution
    Drinen, D.
    Kennedy, K. G.
    Priestley, W. M.
    AMERICAN MATHEMATICAL MONTHLY, 2009, 116 (04): : 328 - 341