Skip to main content

Module convert

Module convert 

Source
Expand description

The bridge: engine Value ⇄ C JsValue.

Two directions, both total for the values that can cross the boundary:

  • encode never fails. Primitives become their bit pattern; anything with a reference count is boxed (see crate::alloc), because C will eventually decrement the count through a pointer it only knows because we allocated one.
  • decode answers None for 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 a JS_TAG_SHORT_BIG_INT, which this engine does not produce because a BigInt here 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.

Functions§

decode⚠
C value → engine value.
encode
Engine value → C value.
is_ours
Whether a C value is one this layer produced.