Forum > Pas2JS

Asm.js optimizations

(1/1)

lainz:
Asm.js
https://en.wikipedia.org/wiki/Asm.js

Is the pas2js output javascript code optimized like is described in that wiki article, for example:


--- Code: C  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---int f(int i) {  return i + 1;}
That in Pascal is something like:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function f(i: integer): integer;begin  Result := i + 1;end;
And translated to Asm.js


--- Code: Javascript  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function f(i) {  i = i|0;  return (i + 1)|0;}
The extra "|0" converts the variables to int32 acording to the article, so it doesn't use floating point math.

mattias:
No, but it would be possible to add an option to do so.
I did not take a look what other conversions are needed, so I can't estimate how much work it is.

lainz:
Hi thanks for the quick response.

Ok it will be great and another reason to choose pas2js instead of emscriptem.

Navigation

[0] Message Index

Go to full version