https://de.wikipedia.org/w/api.php?action=feedcontributions&feedformat=atom&user=MultWikiWikipedia - Benutzerbeiträge [de]2025-05-02T06:26:00ZBenutzerbeiträgeMediaWiki 1.44.0-wmf.27https://de.wikipedia.org/w/index.php?title=Benutzer:MultWiki&diff=158258987Benutzer:MultWiki2016-09-27T07:55:41Z<p>MultWiki: </p>
<hr />
<div>#WEITERLEITUNG [[en:User:MultWiki]]<br />
[[Benutzer:MultWiki|MultWiki]] ([[Benutzer Diskussion:MultWiki|Diskussion]]) 09:55, 27. Sep. 2016 (CEST)</div>MultWikihttps://de.wikipedia.org/w/index.php?title=Asm.js&diff=157821943Asm.js2016-06-16T20:22:40Z<p>MultWiki: /* Emulators */ Fixed DOSBox caps</p>
<hr />
<div>{{Lowercase}}<br />
{{Infobox programming language<br />
|influenced by = [[JavaScript]]<br />
|operating system = [[Platform independent]]<br />
|released = {{Start date and age|2013|3|21|df=yes}}<ref>{{cite web|url=https://blog.mozilla.org/luke/2013/03/21/asm-js-in-firefox-nightly/|title=asm.js in Firefox Nightly|accessdate=13 Nov 2014|date=21 Mar 2013|website=Luke Wagner's blog}}</ref><br />
|name = asm.js<br />
|designer = [[Mozilla]]<br />
|website = {{URL|asmjs.org}}<br />
}}<br />
<br />
'''asm.js''' is an [[intermediate programming language]] designed to allow [[computer software]] written in languages such as [[C programming language|C]] to be run as [[web application]]s while maintaining performance characteristics considerably better than standard [[JavaScript]], the typical language used for such applications.<br />
<br />
asm.js consists of a strict subset of JavaScript, into 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]]).<ref name="github.com"/> Performance is improved by limiting language features to those amenable to [[ahead-of-time optimization]] and other performance improvements.<br />
<br />
[[Mozilla Firefox]] was the first web browser to implement asm.js-specific optimizations, starting with Firefox 22.<ref name=languages>{{cite web |url=https://www.mozilla.org/en-US/firefox/22.0/releasenotes/ |title=Firefox 22.0 release notes |publisher=Mozilla |accessdate=July 4, 2013}}</ref><br />
<br />
== Design ==<br />
<br />
asm.js consists of a strict subset of the [[JavaScript]] language. It enables significant performance improvements for [[web application]]s that are written in statically-typed languages with manual memory management (such as [[C programming language|C]]) and then translated to JavaScript by a [[source-to-source compiler]]. Asm.js does not aim to improve the performance of hand-written JavaScript code, nor does it enable anything other than enhanced performance.<br />
<br />
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.<ref>{{cite web|url=http://asmjs.org/spec/latest/ |title=Asm.js |publisher=Asm.js |date= |accessdate=2015-03-05}}</ref> By using a subset of JavaScript, asm.js is largely supported by all major [[web browser]]s,<ref>{{cite web |url=http://asmjs.org/faq.html |title=asm.js&nbsp;— frequently asked questions|publisher=Asmjs.org |date=July 26, 2014}}</ref> unlike alternative approaches such as [[Google Native Client]].<br />
<br />
== Code generation ==<br />
{{unreferenced section|date=March 2015}}<br />
<br />
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.<br />
<br />
For example, given the following C code:<br />
<br />
<syntaxhighlight lang="c"><br />
int f(int i) {<br />
return i + 1;<br />
}<br />
<br />
</syntaxhighlight><br />
<br />
Emscripten would output the following JS code:<br />
<syntaxhighlight lang="ecmascript"><br />
function f(i) {<br />
i = i|0;<br />
return (i + 1)|0;<br />
}<br />
</syntaxhighlight><br />
<br />
Note the addition of <code>|0</code> 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, an otherwise useless operation, converts a value to an integer. By doing this for each parameter, this ensures that if the function is called from outside code, the value will be converted to the correct type. This is also used on the return value, in this case to ensure that the result of adding 1 to i will be an integer (as otherwise it could become too large), and to mark the return type of the function. These conversions are required by asm.js, so that an optimising compiler can produce highly efficient native code ahead-of-time. In such an optimising compiler, no conversions are performed when asm.js code calls other asm.js code, as the required type specifiers mean it is guaranteed that values will already have the correct type. Furthermore, rather than performing a floating-point addition and converting to an integer, it can simply do a native integer operation. Together, this leads to significant performance benefits.<br />
<br />
Here is another example to calculate the length of a string:<br />
<br />
<source lang="c"><br />
size_t strlen(char *ptr) {<br />
char *curr = ptr;<br />
while (*curr != 0) {<br />
curr++;<br />
}<br />
return (curr − ptr);<br />
}<br />
</source><br />
<br />
This would result in the following asm.js code:<br />
<br />
<source lang="ecmascript"><br />
function strlen(ptr) { // calculate length of C string<br />
ptr = ptr|0;<br />
var curr = 0;<br />
curr = ptr;<br />
while (MEM8[curr]|0 != 0) {<br />
curr = (curr + 1)|0;<br />
}<br />
return (curr − ptr)|0;<br />
}<br />
</source><br />
<br />
In the generated code, the variable MEM8 is actually a byte-by-byte "view" of a typed buffer, which serves as the "heap" of the asm.js code.<br />
<br />
== Performance ==<br />
<br />
Since asm.js runs in a browser, the performance heavily depends on both the browser and hardware. Preliminary benchmarks of C programs compiled to asm.js are usually within a factor of 2 slowdown over native compilation with [[Clang]].<ref>{{cite web|title=asm.js|url=http://asmjs.org/faq.html|publisher=Asm.js|accessdate=2015-03-05}}</ref><br />
<br />
Much of this performance gain over normal JavaScript is due to 100% [[type (computer programming)|type]] consistency and virtually no [[Garbage collection (computer science)|garbage collection]] (memory is manually managed in a large typed array). This simpler model with no dynamic behavior, no memory allocation or deallocation, just a narrow set of well-defined integer and floating point operations enables much greater performance and potential for [[optimization (computer science)|optimization]].{{Citation needed|date=October 2014}}<br />
<br />
Mozilla's benchmark from December 2013 showed significant improvements: "Firefox with [[float32]] optimizations can run all those benchmarks at around 1.5× slower than native, or better."<ref name="float32">{{cite web|title=Gap between asm.js and native performance gets even narrower with float32 optimizations|url=https://hacks.mozilla.org/2013/12/gap-between-asm-js-and-native-performance-gets-even-narrower-with-float32-optimizations/|accessdate=11 April 2014|author=Alon Zakai|author2=Robert Nyman|date=20 December 2013}}</ref> Mozilla points out that the performance of natively compiled code is not a single measure but rather a range, with different native compilers (in this case [[Clang]] and [[GNU Compiler Collection|GCC]]) delivering code of differing performance. "In fact, on some benchmarks, like [[Box2D]], [[FASTA]] and copy, asm.js is as close or closer to Clang than Clang is to GCC. In one case, asm.js even beats Clang by a slight amount on Box2D."<ref name="float32"/><br />
<br />
== Implementations ==<br />
The [[Emscripten]] project provides tools that can be used to compile C and C++ codebases (or any other languages that can be converted to [[LLVM]]) into asm.js.<ref name="github.com">{{cite web|author= |url=https://github.com/kripken/emscripten |title=kripken/emscripten · GitHub |publisher=Github.com |date= |accessdate=2015-03-05}}</ref><br />
<br />
All browsers with support for [[ES6|the newest edition of JavaScript]] should be able to run asm.js code, as it is a subset of that specification. However, since features were added in that edition to enable full asm.js support, older browsers lacking those features may encounter problems.<br />
<br />
Some browser implementations are especially optimised for asm.js:<br />
<br />
* [[Mozilla Firefox]] was the first web browser to implement asm.js-specific optimizations, starting with Firefox 22.<ref name="languages"/> [[OdinMonkey]], Mozilla's asm.js ahead-of-time compiler used in Firefox, is a component of [[IonMonkey]], the JIT compiler of [[SpiderMonkey]].<br />
* Microsoft is implementing support for asm.js in [[Chakra (JavaScript engine)|Chakra]], the JavaScript engine used by [[Microsoft Edge]], performing validation to produce highly optimised JIT code.<ref name=edge>{{cite web|url=https://blogs.windows.com/msedgedev/2015/05/07/bringing-asm-js-to-chakra-microsoft-edge/|title=Bringing Asm.js to Chakra and Microsoft Edge|publisher=Microsoft|accessdate=May 7, 2015|date=May 7, 2015}}</ref><br />
* The optimizations of [[Google Chrome]]'s [[V8 (JavaScript engine)|V8 JavaScript engine]] in Chrome 28 made asm.js benchmarks more than twice as fast as prior versions of Chrome,<ref name=chromiumblog>{{cite web |url=http://blog.chromium.org/2013/05/chrome-28-beta-more-immersive-web.html |title=Chrome 28 Beta: A more immersive web, everywhere |publisher=Google |accessdate=2013-07-06}}</ref> although Chrome's V8 does not use ahead-of-time compilation.<br />
<br />
== Adoption ==<br />
{{Primary sources|section|date=March 2015}}<br />
<br />
Almost all of the current applications based on asm.js are C/C++ applications compiled to asm.js using [[Emscripten]] or Mandreel. With that in mind, the kind of applications that are going to target asm.js in the near future are those that will benefit from the portability of running in a browser but which have a level of complexity for which a direct port to JavaScript would be infeasible.<br />
<br />
So far, a number of [[programming language]]s, [[application framework]]s, [[Program (computing)|programs]], [[Library (computing)|libraries]], [[Computer game|games]], [[game engine]]s and other software have already been [[Porting|ported]].<ref>{{cite web|title=Home&nbsp;— Demos&nbsp;— Games and Game Engines|url=https://github.com/kripken/emscripten/wiki#games-and-game-engines}}</ref> Some of them are given below.<br />
<br />
=== Programming languages ===<br />
* [[C/C++]]: [[Clang]] and [[LLVM]]<br />
* [[Lua (programming language)|Lua]] VM: Lua [[virtual machine]]<ref>{{cite web|title=Lua REPL|url=http://kripken.github.io/lua.vm.js/repl.html|publisher=Kripken.github.io|accessdate=2015-03-05}}</ref><br />
* [[Perl]]: port of (micro)perl-5.16.3<ref>{{cite web|title=plu|url=http://themucker.github.io/plu/|publisher=Themucker.github.io|accessdate=2015-03-05}}</ref><br />
* [[Python (programming language)|Python]] – port of [[CPython]]<ref>{{cite web|title=repl.it&nbsp;— Python|url=http://repl.it/languages/Python|publisher=Repl.it|accessdate=2015-03-05}}</ref><br />
* [[Ruby (programming language)|Ruby]] – port of Ruby<ref>{{cite web|title=repl.it&nbsp;— Ruby|url=http://repl.it/languages/Ruby|publisher=Repl.it|accessdate=2015-03-05}}</ref><br />
<br />
=== Application frameworks ===<br />
* pepper.js: Ports of miscellaneous [[PNaCl]] apps (earth, voronoi, bullet, etc.)<ref>{{cite web|title=pepper.js Examples|url=http://trypepperjs.appspot.com/examples.html|publisher=Trypepperjs.appspot.com|accessdate=2015-03-05}}</ref><br />
* [[Qt Software|Qt]]: ports of various Qt demos, plus KDE apps, such as [[Kate (text editor)|Kate]]<ref>{{cite web|title=emscripten-qt&nbsp;— Demos|url=http://vps2.etotheipiplusone.com:30176/redmine/projects/emscripten-qt/wiki/Demos|publisher=Vps.etotheipiplusone.com|accessdate=2015-03-05}}</ref><br />
<br />
=== Programs and libraries ===<br />
* [[OpenGL]], [[Simple DirectMedia Layer|SDL]], and [[Simple DirectMedia Layer|SDL2]]<ref>{{cite web|title=About Emscripten|url=https://kripken.github.io/emscripten-site/docs/introducing_emscripten/about_emscripten.html#porting-code-to-use-emscripten}}</ref><br />
* [[Vim (text editor)|Vim]] (Vi IMproved)<ref>{{cite web|title=Vim.js&nbsp;— JavaScript port of Vim|url=http://coolwanglu.github.io/vim.js/web/vim.html|publisher=Coolwanglu.github.io|accessdate=2015-03-05}}</ref><br />
* [[FreeType]]: [[TrueType]] [[font rendering]] in JavaScript, using FreeType<ref>{{cite web|title=TrueType Fonts in JavaScript|url=http://www.syntensity.com/static/freetype.html|archiveurl=https://web.archive.org/web/20121012061814/http://www.syntensity.com/static/freetype.html|archivedate=2012-10-12 <!-- 061814 --> }}</ref><br />
* [[SQLite]]<ref>{{cite web|title=Port of SQLite to Javascript|url=https://github.com/kripken/sql.js|publisher=Github.com|accessdate=2015-03-05}}</ref><br />
* [[GNU Privacy Guard]]<ref>{{cite web|title=GnuPG.js|url=http://manuels.github.io/unix-toolbox.js-gnupg/|publisher=Manuuels.github.io|accessdate=2015-03-05}}</ref><br />
* [[ctags]]<ref>{{cite web|title=ctags in the browser|url=https://github.com/larsxschneider/ctags.js|publisher=Github.com|accessdate=2015-03-05}}</ref><br />
* [[gnuplot]]<ref>{{cite web|title=Gnuplot online|url=http://gnuplot.respawned.com/|publisher=Gnuplot.respawned.com|accessdate=2015-03-05}}</ref><br />
* [[Graphviz]]<ref>{{cite web|title=A hack to put GraphViz on the web.|url=https://github.com/mdaines/viz.js|publisher=Github.com|accessdate=2015-03-05}}</ref><br />
* [[zlib]]<ref>{{cite web|title=JavaScript port of ZLib DEFLATE for the browser|url=https://github.com/richardassar/zpipe|publisher=Github.com|accessdate=2015-03-05}}</ref><br />
<br />
=== Game engines ===<br />
* [[Unreal Engine 3]]: was ported in 4 days<ref>{{cite press release|title=Epic Games Releases ‘Epic Citadel’ on the Web|url=https://www.unrealengine.com/news/epic-games-releases-epic-citadel-on-the-web|website=UnrealEngine.com|date=May 2, 2013}}</ref><ref>{{cite web|title=Unreal Engine 3 ported to JavaScript and WebGL, works in any modern browser|url=http://www.extremetech.com/gaming/151900-unreal-engine-3-ported-to-javascript-and-webgl-works-in-any-modern-browser|work=[[ExtremeTech]]|publisher=[[Ziff Davis]]|accessdate=2015-03-05}}</ref><br />
* [[Unreal Engine 4]]<br />
* [[Unity (game engine)|Unity]]<ref>{{cite web|url=http://blogs.unity3d.com/2014/04/29/on-the-future-of-web-publishing-in-unity/|title=On the future of Web publishing in Unity|publisher=Blogs.unity3d.com|date=April 29, 2014}}</ref><br />
* [[ScummVM]], which supports numerous classic adventure games<ref>{{cite web|url=http://clb.demon.fi/html5scummvm/ |title=HTML5 |publisher=Clb.demon.fi |date= |accessdate=2015-03-05}}</ref><br />
<br />
=== Games ===<br />
* ''[[Doom (video game)|Doom]]'': the open source [[Freedoom]] game assets running on [[PrBoom]], which is based on the open source Doom code<ref>{{cite web|url=http://kripken.github.io/boon/boon.html |title=Emscripten-Generated Code |publisher=Kripken.github.io |date= |accessdate=2015-03-05}}</ref><br />
* ''[[SuperTux]]''<ref>{{cite web|url=http://forandom.github.io/WebSupertux/ |title=Emscripten-Generated Code |publisher=Forandom.github.io |date= |accessdate=2015-03-05}}</ref><br />
* ''[[Dune II]]'' via OpenDune<ref>{{cite web|author = Guryanov Aleksander|url = http://epicport.com/en/dune2|title = Dune 2 - Online (browser version)|publisher = Epicport|date = |accessdate = 2015-03-05}}</ref><br />
* ''[[BananaBread]]'' based on [[Cube 2: Sauerbraten|Cube 2]]<ref>{{cite web|title=Mozilla Banana Bread Demo|url=https://developer.mozilla.org/en-US/demos/detail/bananabread/|publisher=Developer.mozilla.org|accessdate=2015-03-05}}</ref><br />
* Every game in the [[Humble Bundle|Humble Mozilla Bundle]]<ref>{{cite web|title=Humble Mozilla Bundle pushes WebGL-powered browser gaming|publisher=Ars Technica|date=15 Oct 2014|accessdate=15 Oct 2014|url=http://arstechnica.com/gaming/2014/10/humble-mozilla-bundle-pushes-webgl-powered-browser-gaming/}}</ref> (''[[Super Hexagon]]'', ''[[AaaaaAAaaaAAAaaAAAAaAAAAA!!!&nbsp;– A Reckless Disregard for Gravity|Aaaaa! for the awesome]]'', ''[[Osmos]]'', ''[[Zen Bound 2]]'', ''[[Dustforce DX]]'', ''[[Voxatron]]'', ''[[FTL: Advanced Edition]]'' and ''[[Democracy 3]]'')<br />
<br />
=== Emulators ===<br />
* [[DOSBox]]<ref>{{cite web|url=https://github.com/dreamlayers/em-dosbox |title=EM-Dosbox on Github |accessdate=2015-04-09}}</ref><br />
* [[Start9.io]]: a web emulation platform targeting multiple gaming architectures<br />
* JSMESS: a port of the [[Multi Emulator Super System|MESS]] emulator for many game consoles and computer systems<ref>{{cite web|url=http://jsmess.textfiles.com/ |title=Page Redirection |publisher=Jsmess.textfiles.com |date= |accessdate=2015-03-05}}</ref><br />
<br />
=== Mathematics ===<br />
* HTML5 Fractal Playground<ref>{{cite web|url=http://danielsadventure.info/html5fractal|title=HTML5 Fractal Playground|publisher=Danielsadvernture.info|accessdate=2015-03-05}}</ref> – draws iterating-function generated fractals, such as the [[Mandelbrot fractal]].<br />
<br />
== See also ==<br />
{{Portal|Free software}}<br />
* [[WebAssembly]] – an in-development bytecode for browsers, intended to be faster to parse than asm.js<br />
* [[RPython]]<br />
* [[CrossBridge]]<br />
<br />
== References ==<br />
{{reflist|30em}}<br />
<br />
== External links ==<br />
* {{official website}}<br />
* {{Github|dherman/asm.js}}<br />
* [http://ejohn.org/blog/asmjs-javascript-compile-target Asm.js: The JavaScript Compile Target]<br />
* [https://github.com/wbraswell/rperl#rperl RPerl]<br />
* [https://www.chromestatus.com/metrics/feature/popularity#UseAsm Asm.js usage per Google Chrome statistics]<br />
<br />
{{JavaScript}}<br />
{{ECMAScript}}<br />
{{Mozilla}}<br />
<br />
[[Category:JavaScript]]<br />
[[Category:Mozilla]]<br />
[[Category:Web programming]]</div>MultWikihttps://de.wikipedia.org/w/index.php?title=Benutzer_Diskussion:MultWiki&diff=154025958Benutzer Diskussion:MultWiki2016-05-02T08:53:16Z<p>MultWiki: AZ: Weiterleitung nach en:User talk:MultWiki erstellt</p>
<hr />
<div>#WEITERLEITUNG [[en:User talk:MultWiki]]</div>MultWikihttps://de.wikipedia.org/w/index.php?title=Benutzer:MultWiki&diff=154025711Benutzer:MultWiki2016-05-02T08:43:38Z<p>MultWiki: AZ: Weiterleitung nach en:User:MultWiki erstellt</p>
<hr />
<div>#WEITERLEITUNG [[en:User:MultWiki]]</div>MultWikihttps://de.wikipedia.org/w/index.php?title=Benutzer:MultWiki&diff=88798681Benutzer:MultWiki2011-05-13T17:22:05Z<p>MultWiki: AZ: Die Seite wurde neu angelegt: Minepedia-Link!!! [http://de.minecraftwiki.net/wiki/Benutzer:MultMiWi Hier.]</p>
<hr />
<div>Minepedia-Link!!! [http://de.minecraftwiki.net/wiki/Benutzer:MultMiWi Hier.]</div>MultWiki