Concept

Asm.js

Summary
asm.js is a subset of JavaScript designed to allow computer software written in languages such as C to be run as web applications while maintaining performance characteristics considerably better than standard JavaScript, which is the typical language used for such applications. asm.js consists of a strict subset of JavaScript, to which code written in statically typed languages with manual memory management (such as C) is translated by a source-to-source compiler such as Emscripten (based on LLVM). Performance is improved by limiting language features to those amenable to ahead-of-time optimization and other performance improvements. Mozilla Firefox was the first web browser to implement asm.js-specific optimizations, starting with version 22. asm.js is superseded by WebAssembly. See below. asm.js enables significant performance improvements for web applications, but does not aim to improve the performance of hand-written JavaScript code, nor does it enable anything other than enhanced performance. It is intended to have performance characteristics closer to that of native code than standard JavaScript by limiting language features to those amenable to ahead-of-time optimization and other performance improvements. By using a subset of JavaScript, asm.js is largely supported by all major web browsers, unlike alternative approaches such as Google Native Client. asm.js is not typically written directly: instead, as an intermediate language, it is generated through the use of a compiler that takes source code in a language such as C++ and outputs asm.js. For example, given the following C code: int f(int i) { return i + 1; } Emscripten would output the following JS code: function f(i) { i = i|0; return (i + 1)|0; } Note the addition of |0 and the lack of type specifiers. In JavaScript, bitwise operators convert their operands to 32-bit signed integers and give integer results. This means that a bitwise OR with zero converts a value to an integer (a very simple "conceptual" presentation of bitwise operators may not deal with type conversion at all, but every programming language defines operators for its own convenience, as Javascript does here).
About this result
This page is automatically generated and may contain information that is not correct, complete, up-to-date, or relevant to your search query. The same applies to every other page on this website. Please make sure to verify the information with EPFL's official sources.