Preview

Proceedings of the Institute for System Programming of the RAS (Proceedings of ISP RAS)

Advanced search

Аhead of time optimization for JavaScript programs

https://doi.org/10.15514/ISPRAS-2015-27(6)-5

Abstract

Modern JavaScript engines use just-in-time (JIT) compilation to produce binary code. JIT compilers are limited in a complexity of optimizations they can perform at a runtime without delaying an execution. Static ahead-of-time (AOT) compilers do not have such limitations, but they are not well suited for compiling dynamic languages such as JavaScript. In the paper, we discuss methods for augmenting multi-tiered JIT compiler with a capability for AOT compilation, and implement some of ahead-of-time compilation ideas in two JavaScript engines - JavaScriptCore and V8. In JavaScriptCore (JSC), which is a part of open-source WebKit library, we have developed and implemented a framework, which allows saving of JavaScript programs as a binary package containing bytecode and a native code. The framework consists of two components: command-line compiler, which compiles source JavaScript program into compressed binary package, consisting of JSC internal representation called bytecode and native code produced by JSC’s non-optimized JIT compiler. The second component is patched JSC engine with a capability for loading and executing binary packages produced by the compiler. In addition, we have implemented saving of optimized internal representation in another JavaScript engine, which is called V8 and is used in Chrome and many other browsers. When running the same JavaScript program, cached internal representation can be loaded to reduce JIT-compilation time and decrease percentage of running unoptimized code before it became hot.

About the Authors

Roman Zhuykov
ISP RAS
Russian Federation


Eugene Sharygin
CMC MSU
Russian Federation


References

1. JavaScriptCore webpage on WebKit website. http://trac.webkit.org/wiki/JavaScriptCore

2. WebKit Browser Engine website. http://www.webkit.org

3. V8 Browser Engine webpage. https://code.google.com/p/v8/

4. S. Hong, J. Kim, J. W. Shin, S. Moon, H. Oh, J. Lee, H. Choi “Java client ahead-of-time compiler for embedded systems”, Proceedings of the 2007 ACM SIGPLAN/SIGBED conference on Languages, compilers, and tools for embedded systems, 2007, pp. 63-72

5. S. Hong, S. Moon “Client-Ahead-Of-Time Compilation for Digital TV Software Platform” 3rd workshop on Dynamic Compilation Everywhere preprint, 2013. http://sites.google.com/site/dynamiccompilationeverywhere/home/dce-2014/DCE-2014-Sunghyun-Hong-article.pdf

6. R. Zhuykov, D. Melnik, R. Buchatskiy, V. Vardanyan, V. Ivanishin, E. Sharygin. Metody dinamicheskoj i predvaritel'noj optimizacii programm na jazyke JavaScript [Dynamic and ahead of time optimization for JavaScript programs]. Trudy ISP RАN [The Proceedings of ISP RAS], 2014, vol. 26, no. 1, pp. 297-314. DOI: 10.15514/ISPRAS-2014-26(1)-10 (in Russian)

7. ECMA-262 Standard description.

8. http://www.ecma-international.org/publications/standards/Ecma-262.htm

9. Asm.js language website. http://asmjs.org/

10. “Are we fast yet?” website. https://arewefastyet.com/

11. Tramp3d testing webpage. http://gcc.opensuse.org/c++bench/tramp3d/


Review

For citations:


Zhuykov R., Sharygin E. Аhead of time optimization for JavaScript programs. Proceedings of the Institute for System Programming of the RAS (Proceedings of ISP RAS). 2015;27(6):67-86. (In Russ.) https://doi.org/10.15514/ISPRAS-2015-27(6)-5



Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 License.


ISSN 2079-8156 (Print)
ISSN 2220-6426 (Online)