Paul Krill
Editor at Large

WebKit upgrade improves memory usage

news
Jun 25, 20192 mins

The new bytecode format for WebKit’s JavaScriptCore browser engine is more compact and can be cached to disk

binary code matrix
Credit: Thinkstock

JavaScriptCore, the JavaScript engine for Apple’s WebKit browser engine, has been upgraded with a new bytecode format that improves memory efficiency and type safety.

The goal of the format, detailed in a June 21 bulletin, was to reduce memory consumption and allow the bytecode to be cached on disk. The WebKit team claims the new format uses 50 percent less memory on average, which translates to an overall 10 percent reduction in memory usage for JavaScript-heavy websites such as Facebook or Reddit.

Two big changes were cited as part of the new format:

  • There is no longer a separate linked encoding for execution. This means bytecode can no longer be direct threaded, since the address of the instruction could not be stored to disk, as it changes with each program invocation.
  • To make the single format suitable for both storage and execution, instructions can be encoded as narrow or wide. With a narrow instruction, the opcode and operands each take one byte. A wide instruction consists of a special single-byte opcode, op_wide, followed by a series of four-byte slots for the original opcode and its arguments.

The new bytecode also features a metadata table. When linking, a side table is initialized with all writeable data associated with a given instruction. In addition, type safety was increased through improvements to bytecode-related infrastructure. A caching API for the new bytecode is in development in the WebKit repo. Developers can contribute at bugs.webkit.org.

Developers involved with the project had sought to fix two major issues with the old bytecode format. First, it used too much memory, and second, it included an instruction stream that was writeable, which prevented memory-mapping the bytecode stream. The old bytecode format also had optimizations that were no longer beneficial, such as direct-threading.

The new bytecode format is available on the Safari 12.1 browser, which shipped with iOS 12.1 and MacOS 10.14.4, and the Safari Technology Preview. You can download the Safari Technology Preview from webkit.org.

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a “Best Technology News Coverage” award from IDG.

More from this author