On implementing multiple pluggable dynamic language frontends on the JVM, using the Nashorn runtime

University essay from KTH/Skolan för datavetenskap och kommunikation (CSC)

Abstract: Nashorn is a JavaScript engine that compiles JavaScript source code to Java bytecode and executes it on a Java Virtual Machine. The new bytecode in-struction invokedynamic that was introduced in Java 7 to make it easier for dynamic languages to handle linking at runtime is used frequently by Nashorn. Nashorn also has a type system that optimizes the code by using primitive bytecode instructions where possible. They are known to be the fastest imple-mentations for particular operations. Either types are proved statically or a method called optimistic type guess-ing is used. That means that expressions are assumed to have an int value, the narrowest and fastest possible type, until that assumption proves to be wrong. When that happens, the code is deoptimized to use types that can hold the current value. In this thesis a new architecture for Nashorn is presented that makes Nashorn’s type system reusable to other dynamic language implementations. The solution is an intermediate representation very similar to bytecode but with untyped instructions. It is referred to as Nashorn bytecode in this thesis. A TypeScript front-end has been implemented on top of Nashorn’s cur-rent architecture. TypeScript is a language that is very similar to JavaScript with the main difference being that it has type annotations. Performance mea-surements which show that the type annotations can be used to improve the performance of the type system are also presented in this thesis. The results show that it indeed has an impact but that it is not as big as anticipated.

  AT THIS PAGE YOU CAN DOWNLOAD THE WHOLE ESSAY. (follow the link to the next page)