Skip to documentation
SLOP

tiny.mprompt.Prompt

Reference tiny.mprompt Prompt

Defined in tiny.mprompt.

The runtime's record for one prompt: its stacklet, its links to other prompts, its reference count, and the registers saved for its entry and its last suspend.

API (8)

Fields and members

Public fields and members.

No direct callersNo direct callstiny.mpromptPrompt
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Source: lib/mprompt/src/prompt.zig:94

zig
/// The runtime's record for one prompt: its stacklet, its links to other prompts, its reference/// count, and the registers saved for its entry and its last suspend. A prompt marks the point/// where code entered its stacklet, and that code can later suspend back to it. A body receives a/// `*Prompt` for the stacklet it runs on, and `yieldPrompt` takes that pointer as the point to/// suspend back to. The runtime reads and writes every field, and callers pass the pointer through./// A prompt is entered once, and `promptEnter` asserts that it is neither a prompt whose code or/// nested code runs on this thread (active prompt) nor a suspended one. The runtime frees the/// record, or keeps it for reuse, when its reference count reaches zero, so a `*Prompt` stays valid/// only while its code runs or a resumption for it is held.pub const Prompt = extern struct {    /// While the prompt is active, this field holds the next active prompt outward, or null for the    /// outermost. While the prompt is suspended, this field holds null in the prompt the code    /// suspended to. In each prompt captured inside that one, this field holds the next prompt    /// outward in the captured chain. While the record waits in the stack cache, this field holds    /// the next cached record.    parent: ?*Prompt,    /// Holds null while the prompt is active. While the prompt is suspended, this field points to    /// the innermost prompt of the chain captured with it. A new prompt points to itself.    top: ?*Prompt,    /// The number of owners of the prompt, starting at 1. Each saved stack copy adds one owner, as    /// does each resume of a reference-counted handle resumable more than once (multi-shot handle).    /// The runtime frees the prompt's stacklets when the count reaches zero.    refcount: isize,    /// The stacklet the prompt's code runs on. The runtime reserves each stacklet as a fixed-size    /// range of address space with an unmapped gap at each end, and commits its pages as the stack    /// grows into them. The code's type for a stacklet is `GStack`, and the runtime's fatal    /// messages, such as "unable to reserve gstack virtual memory", call it a gstack.    gstack: *GStack,    /// The registers saved by the call that last entered or resumed the prompt. A suspend or a    /// return from the prompt's code jumps there.    return_point: ?*ReturnPoint,    /// Registers saved at the suspend while the prompt is suspended, where a resume jumps. This    /// field is null for a new prompt and after its code returns.    resume_point: ?*ResumePoint,    /// The saved stack pointer for the inactive side of the last switch, XORed with a random    /// per-process value (guard cookie). Before each jump the runtime checks the target against it,    /// and a mismatch stops the program with a "potential stack corruption detected" panic.    sp: ?*anyopaque,    /// The frame record, holding an instruction pointer, that the stack-entry code passes to the    /// prompt's first function. The runtime stores it and reads it nowhere.    unwind_frame: ?*UnwindFrame,};

Source: lib/mprompt/src/root.zig:75

zig
pub const Prompt = raw.Prompt;

Also reachable as

zig_api.Prompt.

Audit

Definitions1
Public names2
Members8
Version26.7.0
Revisiondaab053ee433