Posts

Showing posts with the label jsfuture

JavaScript gains support for SIMD

Recently , a new JavaScript feature has landed for the next Firefox Nightly: an API for SIMD (Single Instruction, Multiple Data). This blog post explains how the API works and how it fits into the JavaScript landscape. What is SIMD? SIMD is the ability of a CPU to apply an operand to vectors of values, instead of single values. For example, a CPU may be able to add two vectors v and w by adding their components, hence applying the single instruction addition to multiple data: v + w = 〈v 1 , …, v n 〉+ 〈w 1 , …, w n 〉 = 〈v 1 +w 1 , …, v n +w n 〉 SIMD brings speed-ups to many kinds of number crunching (3D computations, image processing, singal processing, etc.). John McCutchan (Google) and Peter Jensen (Intel) have proposed a JavaScript API for SIMD. That API initially grew out of the SIMD support in Dart, because Dart SIMD code needed to be compiled to JavaScript. At the moment, the API provides two data types: float32x4 (C type: __m128): four 32 bit floating point n...

ParallelJS: data parallelism for JavaScript

Updates: [2015-01-05] ParallelJS has failed . It apparently wasn’t powerful enough. Its experimental implementation will be removed from SpiderMonkey (Firefox’s JavaScript engine). [2013-12-28] A low-level JavaScript API for SIMD is another avenue for parallelization (within a single processer core). JavaScript is still a very sequential language. That is slowly changing. This blog post describes ParallelJS , an effort to bring data parallelism to JavaScript. Background Concurrency versus parallelism Parallelism: more than one task is executed at the same time. That means that the tasks run on different processors or processor cores. Concurrency: more than one task makes progress at the same time. Often, tasks depend on each other. Concurrent tasks may run in parallel, but they can also be run via time slicing (virtual parallelism, if you will). These terms are not always used precisely, but the context usually makes it clear what is meant. Kinds of ...

asm.js: closing the gap between JavaScript and native

Update 2013-12-30: New feature 32 bit floats pushes asm.js performance to 70% of native. More JavaScript engines support asm.js . The conclusion mentions LLJS as another asm.js source language. asm.js defines a subset of JavaScript that can be compiled to fast executables. It has been created at Mozilla by David Herman, Luke Wagner and Alon Zakai. According to the specification , “[asm.js] effectively describes a safe virtual machine for memory-unsafe languages like C or C++.” This blog post describes how asm.js works, it is based on the specification. Things that slow down JavaScript Current JavaScript is already quite fast, but a few mechanisms in engines limit its speed: Boxing: Floating point numbers (including integers stored as floating point numbers) are boxed , they have wrappers that allow them to co-exist with other values such as objects. Just-in-time (JIT) compilation and runtime type checks: Most JavaScript engines compile code in two stages. I...