This paper presents the implementation of an efficient interpreter for a Scheme-like language using manually written asm.js code. The asm.js specification defines an optimizable subset of JavaScript which has already served well as a compilation target for web applications where performance is critical. However, its usage as a human-writable language that can be integrated into existing projects to improve performance has remained largely unexplored. We therefore apply this strategy to optimize the implementation of an interpreter. We also discuss the feasibility of this approach, as writing asm.js by hand is generally not its recommended use-case. We therefore present a macro system to solve the challenges we encounter. The resulting interpreter is compared to the original C implementation and its compiled equivalent in asm.js. This way, we evaluate whether manual integration with asm.js provides the necessary performance to bring larger applications and runtimes to the web.
[1]
Mitchell Wand,et al.
Essentials of Programming Languages, 3rd Edition
,
2008
.
[2]
de Ng Dick Bruijn,et al.
Lambda calculus notation with nameless dummies, a tool for automatic formula manipulation, with application to the Church-Rosser theorem
,
1972
.
[3]
Philip J. Fleming,et al.
How not to lie with statistics: the correct way to summarize benchmark results
,
1986,
CACM.
[4]
Alon Zakai.
Emscripten: an LLVM-to-JavaScript compiler
,
2011,
OOPSLA Companion.
[5]
Gerald J. Sussman,et al.
Structure and interpretation of computer programs
,
1985,
Proceedings of the IEEE.
[6]
Chris Lattner,et al.
LLVM: AN INFRASTRUCTURE FOR MULTI-STAGE OPTIMIZATION
,
2000
.
[7]
Mitchell Wand,et al.
Essentials of programming languages
,
2008
.
[8]
Christian Queinnec.
Lisp in small pieces
,
1994
.