6 ms·
Very exciting! And really amazing work. It appears that WASM, at least in Firefox, is now going to be on par with JS in terms of performance when calling other
by bluejekyll 8y ago
Very exciting! And really amazing work. It appears that WASM, at least in Firefox, is now going to be on par with JS in terms of performance when calling other JS facilities. Those comparison times are quite impressive.
I think the thing I found most exciting is at the end: “WebAssembly is getting more flexible types very soon. Experimental support for the current proposal is already landed in Firefox Nightly.” Implication being that WASM will have native access to the DOM.
I think at that point WASM could be used to fully work with the DOM with no negative costs, right?
- markharper 8y agoAlmost, that will set the foundation for fully using the DOM APIs. The host bindings proposal mentioned at the end of the article should close the gap.
- benjaminjackman 8y agoMinor clarification: The DOM builtins should be helped by the Reference Types Proposal for WebAssembly. [1] `The host bindings proposal` is going to help speed up new and getter/setter calls. [2] 1: `Currently the only built-ins that we support this for are mostly limited to the math built-ins. That’s because WebAssembly currently only has support for integers and floats as value types. That works well for the math functions because they work with numbers, but it doesn’t work out so well for other things like the DOM built-ins. So currently when you want to call one of those functions, you have to go through JavaScript. That’s what wasm-bindgen does for you. But WebAssembly is getting more flexible types very soon. Experimental support for the current proposal is already landed in Firefox Nightly behind the pref javascript.options.wasm_gc. Once these types are in place, you will be able to call these other built-ins directly from WebAssembly without having to go through JS.` -- https://github.com/WebAssembly/reference-types https://github.com/WebAssembly/reference-types 2: `there are still a couple of built-ins where you will need to go through JavaScript. For example, if those built-ins are called as if they were using new or if they’re using a getter or setter. These remaining built-ins will be addressed with the host-bindings proposal.` -- https://github.com/WebAssembly/host-bindings https://github.com/WebAssembly/host-bindings (BTW I could be mistaken, just quoting the article)
- Karrot_Kream 8y agoWhat is `wasm_gc` all about?
- tyingq 8y agoThe reason the switch is called that... "A new proposal has been made to the WebAssembly specification committee a few months ago: to add reference types to the type system. Reference types are a new way to represent a reference to any host values. In a Web environment, this means being capable of playing with JavaScript values within WebAssembly. This is a huge difference with the existing type system, which only contains primitive types: integers represented on 32 or 64 bits, IEEE754 floating-point numbers represented on 32 or 64 bits. This is also a first step for implementing garbage collection (GC) integration within WebAssembly: since these reference values have been allocated on the GC heap in JavaScript, they need to be traced during wasm execution." https://blog.benj.me/2018/07/04/mozilla-2018-faster-calls-and-anyref/ https://blog.benj.me/2018/07/04/mozilla-2018-faster-calls-an...
- singularity2001 8y agomaybe the most important improvement will be direct memory access to the canvas bitmaps for super fast game rendering.
- vanderZwan 8y agoAssuming that also implies access to typed arrays in general, then applications that involve number crunching become a lot more feasible in JS too.
- mrec 8y agoHuh? We've had typed arrays in JS for years. I think they originally went in to support WebGL, but you can use them for other stuff too. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- vanderZwan 8y agoDirect access to typed arrays from WASM without having to copy them over whole first, or use the memory buffer of the WASM module. You can't really write a "true" generic in-place sort in WASM right now, so to speak, because there is always a copying back and forth step.
- bschwindHN 8y agoWouldn't "super fast game rendering" be done by the GPU via WebGL?
- ranwired 8y agoA lot of game logic also runs on the CPU
- TazeTSchnitzel 8y agocanvas bitmaps are only useful for rendering though.