pub enum DebugValue {
Reference(GcRef),
Scalar(ScalarValue),
Reclaimed,
}Expand description
What a debug slot holds: a reference the collector and the debugger may follow, or a raw scalar neither may.
DebugLocalMeta::read is the only constructor, and it is the only place
in the runtime where a slot word becomes something typed.
Variants§
Reference(GcRef)
A live reference into the heap.
Scalar(ScalarValue)
A payload whose box the compiler elided (ADR-120).
Reclaimed
A reference that was here and whose object the collector has since
reclaimed (ADR-106’s weak arm, RECLAIMED_WORD).
Carries nothing, deliberately: the object is gone, and this variant exists to say that rather than to say anything about it. It is the third thing a slot can be, and it is distinct from “never written”: one is a line that never ran, the other a line that ran and whose result is no longer around to show.
Reaching one is ordinary, not exceptional. ADR-044 decision 2 nulls a
shadow slot the moment its local dies, so a binding stops being a root at
its last use rather than at the end of its scope; any collection after
that point is free to take it, while the debug slot goes on naming it.
var b = "asdf" followed by an allocation big enough to collect is the
whole recipe.
Implementations§
Source§impl DebugValue
impl DebugValue
Sourcepub fn reference(self) -> Option<GcRef>
pub fn reference(self) -> Option<GcRef>
The reference this value names, or None if it is a scalar.
The one door from a debug value back to the heap, so every consumer
that roots, traces, poisons-checks or type-recovers a debug value goes
through a single line that a scalar cannot pass. crash_snapshot’s
push_roots, the collector’s post-sweep scan and the debugger’s
p EXPR bindings are its three callers.
Sourcepub fn is_live(self) -> bool
pub fn is_live(self) -> bool
Whether this slot still holds something the debugger can render.
DebugLocalMeta::read answers Some for a reclaimed slot — a value
was written — but there is nothing left to show, so a consumer
branching on that Option alone has to say which of the two it means.
This is the “renderable” half; fault_span’s question is the other one,
and it wants is_some(): a temp whose expression finished is not where
the frame faulted, whatever became of the result.
Sourcepub fn as_int(&self) -> i64
pub fn as_int(&self) -> i64
Read this value as an Int, whether it is still boxed or was elided
into a scalar slot.
§Panics
If it is neither — the same contract, and the same assertion, as
GcRef::as_int, which this delegates to for a
reference. A caller asking a Vec for its integer has a bug either way,
and ADR-120 part 2 does not make that bug quieter.
Trait Implementations§
Source§impl Clone for DebugValue
impl Clone for DebugValue
Source§fn clone(&self) -> DebugValue
fn clone(&self) -> DebugValue
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more