Abstract

Web applications (apps) programmed using HTML, CSS, and JavaScript have advantages in portability and productivity, compared to Android or IOS apps. However, web apps are involved with some performance issue, due to JavaScript with its dynamic typing and prototypes which are difficult to execute efficiently. One popular way of accelerating JavaScript is using the just-in-time compilation (JITC), which translates the JavaScript source code to the machine code at runtime. Unfortunately, JavaScript JITC for web apps suffers from the parsing and compilation overhead seriously, which offsets the performance gain of executing the compiled code. In this paper, we propose ahead-of-time compilation (AOTC) of JavaScript at the client device. We save the code generated by the JITC at the first run of the web app, so that we can reuse the code in the next runs to remove the parsing and the compilation overhead. For the JavaScriptCore (JSC) engine of the WebKit, we developed three AOTCs. Bytecode-AOTC saves the bytecode, so we can omit the parsing overhead. Native-AOTC saves the machine code, so we can omit the compilation as well as the parsing overhead, yet with a higher space overhead. We also developed a selective-AOTC which selects between the two AOTC depending on the performance benefit and the space overhead of a target JavaScript function. We experimented with four web apps on a commercial smart TV. For the JavaScript portion of the app loading time, bytecode-AOTC and native- AOTC achieve 33.5% and 62.1% performance benefit, with a space overhead of 2.3 times and 15.4 times of the original JavaScript source code size, respectively. Selective-AOTC achieves a trade-off of 45.9% performance benefit and a space overhead of 4.7 times. Our evaluation on JavaScript benchmarks also shows a tangible performance gain, although it is lower than web apps. Finally, we compare to the AOTC for V8 engine and discuss some issues.

Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call