← All docs

hrtime() — internals

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

hrtime() — internals

Where it lives

Lowering notes

  • Lowers hrtime([$as_number]) through the monotonic-clock runtime helper.
  • __rt_hrtime reads the as-number flag from the integer result register (x0/rax) and returns
  • an already-boxed Mixed result — a boxed [sec, nsec] array when the flag is 0/false, or a
  • boxed nanosecond integer when truthy — so no post-call boxing is needed. Unlike the timestamp
  • builtins the omitted-argument default is 0 (array form), not the -1 current-time sentinel.

Runtime helpers

The following runtime helpers are referenced:

  • __rt_hrtime
  • __rt_http_response_code

Signature summary

function hrtime(bool $as_number = false): mixed

What the type checker enforces

  • Arity: takes 0–1 arguments (1 optional).

Eval interpreter (magician)

Cross-references