Compiling Dynamic Languages



AbstractThe purpose of this thesis is to examine if ahead-of-time compilation is a viable solution for executing programs written in Dynamic Languages when compared to interpretation and just-in-time compilation, and to find out how such a solution can be made.
We achieve this by first describing and classifying Dynamic Languages in terms of their type systems and programming concepts. Specifically we will show how the Dynamic Languages differ from Statically Typed Languages.
We then build an ahead-of-time compiler, called the project compiler, for a subset of JavaScript. The subset is large enough to constitute a Dynamic Language and large enough to run an industry standard benchmark. The ahead-of-time compiler can also do optimizations. Furthermore, we benchmark this compiler implementation and compare it to the benchmark results for two contemporary JavaScript implementations: Rhino which is a JavaScript interpreter and compiler, and V8 which is a JavaScript just-in-time compiler. We also profile the implementation to measure the effect of the implemented optimizations.
Based on these results we find that the performance of the project compiler is better than that of the interpreter, but the performance is worse than that of the two other compilers. The performance of the project compiler is influenced negatively by its implementation of JavaScript values in memory. We also find that the implemented optimizations give significant performance benefits for simple examples, but do not improve the performance significantly when running more complex benchmarks.
We conclude that ahead-of-time compilation is a viable alternative to interpretation of dynamic languages, but based on the collected results we are unable to make any generalizations with regards to ahead-of-time compilation compared to just-in-time compilation.
TypeBachelor thesis [Academic thesis]
Year2013
PublisherTechnical University of Denmark, Department of Applied Mathematics and Computer Science / DTU Co
AddressMatematiktorvet, Building 303B, DK-2800 Kgs. Lyngby, Denmark, compute@compute.dtu.dk
SeriesB.Sc.-2013-15
NoteDTU supervisors: Christian Probst, cwpr@dtu.dk, and Sven Karlsson, svea@dtu.dk, DTU Compute
Electronic version(s)[pdf]
Publication linkhttp://www.compute.dtu.dk/English.aspx
BibTeX data [bibtex]
IMM Group(s)Computer Science & Engineering