← All docs

zval_pack() — internals

Compiler internals for zval_pack(): lowering path, type checks, and runtime helpers.

zval_pack() — internals

Where it lives

Lowering notes

  • Lowers zval_pack(value) by boxing the operand as a Mixed cell and invoking
  • __rt_zval_pack, which returns a pointer to a freshly allocated 16-byte zval.
  • __rt_zval_pack only reads the (tag, lo, hi) triple out of the boxed Mixed
  • cell; it never retains or frees that cell. When the operand was not already
  • Mixed/Union, emit_box_current_value_as_mixed allocated a fresh owned box
  • (persisting strings, increfing array/object/mixed children), so that box is a
  • throwaway temporary that must be deep-released after the pack call or it leaks
  • one Mixed cell per call. When the operand is already Mixed/Union no box was
  • created, so the operand’s own live cell must not be freed here.

Runtime helpers

The following runtime helpers are referenced:

  • __rt_mixed_free_deep
  • __rt_zval_pack

Signature summary

function zval_pack(mixed $value): pointer

What the type checker enforces

  • Arity: takes exactly 1 argument.

Eval interpreter (magician)

Not callable from eval’d code — the magician interpreter has no entry for this builtin.

Cross-references