News for hackers. Stuff that matters.
Re:What does “asm.js optimizations” mean? by jvilk on Wednesday February 18, 2015 @08:31PM (#9071976)
Follow-up question.

How does it deduce the return type of a foreign function? Can foreign functions return values?

Normally, ASM.js functions require an annotation on the return statement [0].

[0] http://asmjs.org/spec/latest/#return-type-annotations

Re:What does “asm.js optimizations” mean? by azakai on Wednesday February 18, 2015 @10:44PM (#9072305)
FFI calls are just like normal calls: they need a coercion on them.

    i = ffiFunc() | 0; // returns an int
    d = +ffiFunc();    // returns a double
This is identical for FFI and non-FFI calls. A difference though is that asm functions have specific types (an asm function returns either nothing, an int, or a double). But an FFI is just any old JS function. So you could not write the above 2 lines together with an asm function, only an FFI can get an int one time and a double another time from the same function.
Re:What does “asm.js optimizations” mean? by jvilk on Thursday February 19, 2015 @12:03PM (#9075139)
Understood. If `ffiFunc()` returns an empty array at a double call site, does ASM.js just accept it as `0`? (`+[]` is `0`). Or are there runtime checks that verify that the return value is a numeric type?

btw, I hope these questions make it clearer why I grumped a bit about the specification, and result in a more robust spec!