Skip to main content

Runtime

Struct Runtime 

Source
pub struct Runtime { /* private fields */ }
Expand description

The shared context of one run.

Implementations§

Source§

impl Runtime

Source

pub fn new( program: Arc<Program>, sources: Arc<SourceMap>, hosts: Arc<HostRegistry>, ) -> Self

A run over program, reporting against sources and calling through hosts, with tracing switched off.

Source

pub fn with_trace(self, sink: Arc<dyn TraceSink>) -> Self

Sends this run’s trace events to sink. Replaces any sink installed earlier; the default is NullSink, which discards everything.

This is where every event but one goes: task lifecycle (TaskSpawned, TaskCompleted, TaskCancelled), a heap’s (HeapCollected, HeapSummary), and the entry’s own (EntryEnter, EntryExit, RunEnded). The one exception is TraceEvent::HostCall, which reports through HostRegistry::set_trace instead — a separate sink on a separate object, defaulting to its own NullSink. An embedding that installs a sink here and expects host calls on the same tape gets a trace with everything but those, and no diagnostic saying the other sink was never installed.

Source

pub fn program(&self) -> &Program

Source

pub fn sources(&self) -> &SourceMap

Source

pub fn hosts(&self) -> &HostRegistry

The host boundary, so a caller can read a run’s counters after it finishes.

Source

pub fn trace(&self, event: TraceEvent)

Records one trace event, from whichever thread produced it.

Source

pub fn next_task_id(&self) -> u64

The next task id, unique across every thread of this run, and never ENTRY_TASK.

Source

pub fn retire_heap(&self, stats: &HeapStats)

Folds a finished heap’s totals into the run’s.

Only the counters are folded. What a retired heap last measured as live went with the thread that owned it, so summing those would report memory that no longer exists; see Interpreter::heap_stats for where the live figure comes from instead.

Source

pub fn heap_stats(&self) -> HeapStats

What every heap retired so far has done.

Only Interpreter, the tree-walking backend, ever calls Runtime::retire_heap. A run on Vm never does, so this stays at HeapStats::default() for the whole of a VM run — not because the VM is not counting, but because it counts memory in words rather than the bytes and objects this struct holds, and there is no honest way to fold one into the other. Reporting a zero here for a VM run would read as a session that allocated nothing, which is worse than not answering at all.

A Vm embedder reads heap_words, allocated_words, collections and live_words instead — see Vm::live_words for which of those answers “does this run still hold what it allocated”.

Trait Implementations§

Source§

impl Clone for Runtime

Source§

fn clone(&self) -> Runtime

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.