Skip to content

Options for future asm.js support #8085

Closed
@kripken

Description

@kripken

We currently support asm.js and wasm, and intend to support both for the long term. I had some ideas about options for how exactly we do that for asm.js. Consider that

  • Browsers that validate asm.js - that is, use the asm.js type system to compile it AOT, instead of treating it like other JavaScript - get a speed benefit from that. This is basically most modern browsers, except for safari, going back a few years now.
  • Almost all browsers that validate asm.js have wasm support. And wasm is even faster.
  • If we did not emit fully valid asm.js, we could actually decrease the code size of our "asm.js" output significantly (examples below). It may also actually be faster on non-validating browsers.

In other words, we can in theory support 3 things:

  • wasm
  • asm.js with validation
  • "almost asm.js" that does not validate, but is very similar to asm.js

We currently support the first 2. Maybe supporting the first and the last would be better: smaller code for "asm.js", and anyhow almost all browsers that benefit from asm.js validation can also run wasm. In other words, asm.js with validation was a brief intermediary step - how much do we still care about it? If we do, is the speed worth the code size downsides?

Why can we make "asm.js" that is smaller and faster than validating asm.js? For example,

  • Function pointers - can use just a single table instead of a separate table per type. This saves on the size of the table (no need to be a power of 2, and there's just one) and on every indirect call, e.g. TABLE[x & 511] => TABLE[x]. This is smaller and likely faster.
  • Missing operators - asm.js lacks &&, so we end up doing stuff like x ? y : 0 instead of x && y (smaller, but need to measure if it's faster).

Thoughts?

cc'ing some people that I know use the non-wasm path: @juj @Brion

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions