From:  Lars Hansen <>
Date:  07 Sep 2018 16:47:48 Hong Kong Time



So what's the current story about dealing with wrappers inside the engine?

Here's why I ask: I'm implementing a prototype of reference types and
object types for wasm, and these are realized as opaque (ie no exposed
storage) TypedObject instances so that JS can also access them
conveniently.  Some of the fields are pointer fields, and when they are
unrestricted ("anyref") they can be written from both JS and wasm.

Additionally, js can call wasm passing anyref parameters, which wasm can
then try to downcast to references of known type.

When wasm receives a pointer or reads one from an object field it really
does not want to unwrap it; it wants to use it as a raw pointer
immediately.  (Unboxing an anyref to a TO pointer is currently expensive
anyway but we don't want it to remain that way.)  So how much unwrapping is

Luke told me - as I remember it - that we're pretty much getting rid of
wrappers inside the engine, so that we never have to worry about
unwrapping, but a quick search shows a lot of CheckedUnwrap calls still
present in the code.

So: what's the story, and what's the status?