Expand description
The bridge: engine Value ⇄ C JsValue.
Two directions, both total for the values that can cross the boundary:
encodenever fails. Primitives become their bit pattern; anything with a reference count is boxed (seecrate::alloc), because C will eventually decrement the count through a pointer it only knows because we allocated one.decodeanswersNonefor a tag the engine has no value for — an internal tag the reference uses for its own containers (JS_TAG_FUNCTION_BYTECODE,JS_TAG_MODULE) or aJS_TAG_SHORT_BIG_INT, which this engine does not produce because aBigInthere is always a heap allocation.
§What is deliberately not here
The engine’s internal markers (CatchOffset, ReturnAddress, Hole, Uninitialized)
never cross this boundary in either direction: they live on the operand stack and in
object slots, and a host never sees one. encode maps the two that have a spelling in
C (Uninitialized is JS_UNINITIALIZED) and treats the rest as a programming error
rather than inventing a tag.