Hacker News new | ask | show | jobs
by benjaminjackman 2817 days ago
Minor 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

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

(BTW I could be mistaken, just quoting the article)

1 comments

What is `wasm_gc` all about?
The 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-an...