Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News WebKit Now Has Full Support for WebAssembly

WebKit Now Has Full Support for WebAssembly

This item in japanese

Apple Safari has full support for WebAssembly including preparation for future integration with ECMAScript Modules and threads.

Apple has added full support for WebAssembly to WebKit, enhancing the Safari browser to be able to run code written in other languages. WebKit supports WebAssembly on  x86, x64 and ARM 64 platforms.

Since WebAssembly is accessible in the browser as a JavaScript object, WebKit is reusing existing JavaScript functionality to make it work. For example, the WebAssembly.Instance API is implemented using the ECMAScript modules already supported by the browser, preparing the way for integration with JavaScript modules when it becomes a requested feature. Also, WebKit’s implementation of WebAssembly is thread safe preparing it for when it will add support for threads, a feature that Chrome has on the roadmap too.

When a tool compiles some code to WebAssembly, it can already include various performance optimizations. But WebKit adds two more tiers of optimizations, Build Bytecode Quickly (BBQ) and the Optimized Machine-code Generator (OMG), both based on B3 JIT used by WebKit to tune up JavaScript code. BBQ is four times faster than OMG, but the resulted code is twice as slower, according to Apple engineers. BBQ is used to run code quickly, while OMG is used for hot code, performing deeper optimizations for sections of the code where speed is important.

WebAssembly is available in Safari Technology Preview Release 32. Chrome and Firefox have added full support for WebAssembly in March, while Microsoft Edge has it in preview mode for all their platforms: desktop, mobile, Xbox, and mixed reality.

Rate this Article