Compiling by partial evaluation

John R Levine <johnl@taugh.com>
Tue, 19 Nov 2024 14:48:00 -0500

          From comp.compilers

Related articles
Compiling by partial evaluation johnl@taugh.com (John R Levine) (2024-11-19)
| List of all articles for this month |
From: John R Levine <johnl@taugh.com>
Newsgroups: comp.compilers
Date: Tue, 19 Nov 2024 14:48:00 -0500
Organization: Compilers Central
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="88977"; mail-complaints-to="abuse@iecc.com"
Keywords: code, interpreter
Posted-Date: 19 Nov 2024 14:48:49 EST

In this paper the authors take an interpreter and a program it's
interpreting and use partial evaluation to turn it into code. It seems
too good to be true but they say it works well on some examples they've
tried, turining Javascript and Lua programs into WebAssembly.


https://arxiv.org/abs/2411.10559


Partial Evaluation, Whole-Program Compilation


Chris Fallin, Maxwell Bernstein


There is a tension in dynamic language runtime design between speed and
correctness: state-of-the-art JIT compilation, the result of enormous
industrial investment and significant research, achieves heroic speedups
at the cost of complexity that can result in serious correctness bugs.
Much of this complexity comes from the existence of multiple tiers and the
need to maintain correspondence between these separate definitions of the
language's semantics; also, from the indirect nature of the semantics
implicitly encoded in a compiler backend. One way to address this
complexity is to automatically derive, as much as possible, the compiled
code from a single source-of-truth; for example, the interpreter tier. In
this work, we introduce a partial evaluator that can derive compiled code
``for free'' by specializing an interpreter with its bytecode. This
transform operates on the interpreter body at a basic-block IR level and
is applicable to almost unmodified existing interpreters in systems
languages such as C or C++. We show the effectiveness of this new tool by
applying it to the interpreter tier of an existing industrial JavaScript
engine, SpiderMonkey, yielding 2.17× speedups, and the PUC-Rio Lua
interpreter, yielding 1.84× speedups with only three hours' effort.
Finally, we outline an approach to carry this work further, deriving more
of the capabilities of a JIT backend from first principles while retaining
semantics-preserving correctness.






Regards,
John Levine, johnl@taugh.com, Taughannock Networks, Trumansburg NY
Please consider the environment before reading this e-mail. https://jl.ly


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.