Expand description
Per-thread runtime context: identity, allocation, and the handle stack that roots values held by native code across calls back into the interpreter.
Structs§
- Handle
- An index into the handle stack, valid inside the
Mutator::scopethat created it. - Handle
Scope - A region in which native code can root values across calls back into the interpreter (which may collect). Handles borrow the scope, so the borrow checker keeps them from escaping it; dropping the scope releases them.
- Local
- A rooted value, valid for the lifetime of its
HandleScope. - Mutator
Enums§
- Trap
- A recoverable interruption of execution.
Functions§
- check_
alloc - Checks a request for
countitems ofsizebytes before allocating it, so that sizes the machine cannot provide raise aMemoryErrorpanic (with the program’s stack trace) instead of aborting the process in the allocator. Returns the size in bytes. - note_
external - Memory held outside GC pages (vector buffers) counts toward the collection budget.
- panic
- refused
- The
MemoryErrorfor a request the allocator refused (whatsays which). Hands the collector’s headroom back to the OS first, so that reporting the error does not fail too. - try_
collect - Collects
itemsinto a vector, raising aMemoryErrorpanic astry_pushdoes. - try_
push - Pushes
xonto a vector a native is building, raising aMemoryErrorpanic if the vector cannot grow. There is no collection and retry: the vector may hold values that nothing else roots. - try_
string - An empty string with room for exactly
bytesbytes, or aMemoryErrorpanic. - try_vec
- An empty vector with room for exactly
nitems, or aMemoryErrorpanic if that much memory cannot be had (seecheck_alloc).