Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I was thinking of int types, SIMD, shared memory with an explicit model, and arbitrary jumps. It's nice that some of those are getting fixed.

I would also like to see a bytecode with structures (and alignment control), nice code generation and execution and some form of virtual memory for resources.

What I don't understand is why Mozilla didn't define a bytecode and a to-JS compiler for it. Browsers without support would have been just as slow, but there would have been much more room for evolution.

I'm almost expecting Mozilla to pull a Trojan any day now: define a bytecode that compiles to asm.js and declare asm.js deprecated.



> What I don't understand is why Mozilla didn't define a bytecode and a to-JS compiler for it

If nothing else, Mozilla does not have nearly as much money as Google, and really cannot afford a "tear down everything and rebuild it" approach like PNaCl. An advantage of OdinMonkey is that it is able to reuse a huge chunk of the SpiderMonkey infrastructure. If you look at the diagram in the article with the red arrow, the "Ion-compile" step is the same size as the others, but in reality is a huge number of line of code, representing multiple engineer-years of ongoing work.

Much of the work the article describes, such as parallel Ion compilation, was carried out mostly for the benefit of non-asm.js compilation, but because OdinMonkey shares the infrastructure, it was able to benefit from it without having to create a new implementation from scratch.

Beyond the engineering of the implementation itself, asm.js itself is a natural evolution of Emscripten-style JS, which had already successfully demonstrated that it can be used for large applications, and that other non-Mozilla browsers are interested in it enough to have done optimization work for it. This reduces the risk that the design itself is technically broken in some way that wouldn't be apparent until people try to run large production-ready applications, as well as the risk that only Firefox will ever be able to run asm.js code at a decent speed.


> If nothing else, Mozilla does not have nearly as much money as Google, and really cannot afford a "tear down everything and rebuild it" approach like PNaCl

The rest of your post is spot-on, but this part isn't really true. The barriers to "tear down everything and rebuild it" are much more systemic and less monetary (just look at the small JS engine teams that got us where we are today).

Meanwhile, Mozilla Research certainly continues to grow, and Rust is a perfect example of a "tear down everything and rebuild it" project now run by them, albeit in a different domain than JS.


The domain differs for Rust from JS or PNaCl. The latter are on the web. Rust is AOT compiled and for systems programming. It's competing with C++, not JS -- and not for safe C++ on the Web (not yet, anyway; Rust2JS and Rust on the GPU are of course on radars due to LLVM and eholk & co. at IU, respectively).

Even with Rust, we don't tear down Unix or DWARF, to pick two examples -- we use 'em for maximum leverage.


int types are in JS and have been since 1995, due to the bitwise logical and shift ops.

arbitrary jumps are a deoptimizer and verifier hazard (Java's verifier had O(n^4) complexity DoS attack demo'd by Michael Franz and his group at UCI). Do not want.

SIMD is coming and wanted in hand-coded JS too, not a bytecode issue per se.

> What I don't understand is why Mozilla didn't define a bytecode and a to-JS compiler for it. Browsers without support would have been just as slow, but there would have been much more room for evolution.

You mix speed ("just as slow" -- wait, we're fast at asm.js input, faster on startup than PNaCl -- did you read the post?) with "room for evolution". I just argued above that having two syntaxes hurts evolution. Please separate speed from evolution and address my argument.

Mozilla is in no position, philosophically or market-share-wise, to "pull a Trojan". Also, my argument stands no matter who is making it. No ad hominem fallacies, please!


> int types are in JS and have been since 1995, due to the bitwise logical and shift ops.

That's like saying int64 is a subset of float64 because you can use two floats to encode it.

> arbitrary jumps are a deoptimizer and verifier hazard

True, this would be one of the decisions to be made when designing a bytecode format.

> You mix speed ("just as slow" -- wait, we're fast at asm.js input, faster on startup than PNaCl -- did you read the post?)

You misunderstood. Asm.js running on a browser that doesn't have support for it is just as slow as output from bytecode-to-JS compiler would be. And for browsers that do have support, both asm.js and a hypothetical bytecode would behave the same.

The major differences with a bytecode would be requiring two "executables" and a better semantic model.

Also, I'm not necessarily defending PNaCl itself, nor did I even bring it up.

> No ad hominem fallacies, please!

I'm not sure where you got that, the Trojan comment was meant positively.

I think it would be nice if Mozilla introduced a bytecode (superset of asm.js semantics), once asm.js itself was accepted.


> That's like saying int64 is a subset of float64 because you can use two floats to encode it.

No. (x>>>0) is uint32(x), (x|0) is int32(x). Please read http://asmjs.org/spec/latest/.

> True, this would be one of the decisions to be made when designing a bytecode format.

Indeed, no clean-slate design, we have learned from the past. Dropping goto leaves less to change in asm.js. You need to produce the missing semantics or else we're just arguing syntax.

> Asm.js running on a browser that doesn't have support for it is just as slow as output from bytecode-to-JS compiler would be.

No, asm.js on browsers that do not use AOT compilation is already faster than non-asm.js for the workloads of interest (compiled from C/C++, etc.).

Anyway, speed was not the issue. => evolution is harder with two syntaxes.

Trojan is usually pejorative -- beware Greeks bearing gifts and all that ;-). No worries, but really, it does not make sense to do a second syntax for asm.js, at least not yet. Maybe in the farther future when JS has reached some fixed point.

/be


> No, asm.js on browsers that do not use AOT compilation is already faster than non-asm.js for the workloads of interest (compiled from C/C++, etc.).

That would be a bytecode-to-asm.js compiler. Hence, no difference besides distribution.

I was not aware so many features are getting added to JS for the sake of asm.js. Other than structure/array abstractions (like LLVM's), which largely only improve debugging, I can't think of important missing features that can't be fixed with compilers or extra APIs.

The only major objection remains lack of elegance (which is indeed largely a syntax/decoding argument). I guess browsers environments are doomed to be ugly and quirky.


> That would be a bytecode-to-asm.js compiler. Hence, no difference besides distribution.

Your "That" referred to something in my sentence "No, asm.js on browsers that do not use AOT compilation is already faster than non-asm.js for the workloads of interest (compiled from C/C++, etc.)" -- but I have no idea what. Please use a noun. What "That" did you mean?

I was not talking about a bytecode-to-asm.js compiler. I said asm.js code (output of Emscripten, hand-coded -- whatever typechecks) runs faster in other browsers such as Chrome than non-asm functionally equivalent code, even without AOT compilation. But as the blog post shows, AOT in Firefox is even faster at startup (and see the link on "throughput" for other wins).

Missing features are not being added to JS for the sake of asm.js. I clearly wrote we are adding SIMD, int64, etc. for hand-coded JS users. Ecma TC39 is not only concerned with "compile to JS" use-cases, we look at apps, libraries, and compilers.

For some reason, at least twice now, when I've written X, you've read Y or !X. Not sure why, but I hope this message is clear, at least!

/be


> Please use a noun. What "That" did you mean?

If a hypothetical bytecode were designed, a compiler from this bytecode to asm.js would be just as fast in browsers without support for this bytecode (or for that matter asm.js) as asm.js is currently.

One would compile C/C++ to this bytecode and either ship it directly (to browsers that support it) or compile to asm.js and ship that (to browsers that don't support it).

This process I described is precisely how Dart works and while I don't particularly like Dart itself, I think its compilation/distribution mechanism is nice.

It's possible to do this later, after (and if) asm.js becomes popular. And it would even possible to eventually compile JS itself to this bytecode.

> But as the blog post shows, AOT in Firefox is even faster at startup (and see the link on "throughput" for other wins).

I am not immediately concerned with the merits of asm.js as implemented in Firefox at the moment.

> Missing features are not being added to JS for the sake of asm.js. I clearly wrote we are adding SIMD, int64, etc. for hand-coded JS users. Ecma TC39 is not only concerned with "compile to JS" use-cases, we look at apps, libraries, and compilers.

Sure, I guess. These features just seemed to me more important for asm.js than generic application JS (as opposed to, say, macros).


SIMD is important to hand-coders, we get this (so does Dart, and sauce for the goose...).

> It's possible to do this later, after (and if) asm.js becomes popular

+1, and also when JS is more "done" (ES7 or 8; http://sweetjs.org/ + SIMD + value objects + minutiae is the nirvana.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: