Struct passerine::vm::tag::Tagged[][src]

pub struct Tagged(_);
Expand description

Tagged implements Nan-tagging around the Data enum. In essence, it’s possible to exploit the representation of f64 NaNs to store pointers to other datatypes.

When laid out, this is what the bit-level representation of a double-precision floating-point number looks like:

SExponent---QIMantissa------------------------------------------
PNaN--------11D-Payload-------------------------------------...T

Where S is sign, Q is quiet flag, I is Intel’s “QNan Floating-Point Indefinite”; P is pointer flag, D is Data Tag (should always be 1), T is Tag.

By exploiting this fact, assuming a 64-bit system, each item on the stack only takes up a machine word. This differs from having a stack of Box’d Data, because small items, like booleans, stack frames, etc. can be encoded directly into the tag rather than having to follow a pointer. It also keeps math fast for f64s, as a simple check and transmutation is all that’s needed to reinterpret the bits as a valid number.

NOTE: implementation modeled after:

  • rpjohnst/dejavu,
  • and the Optimization chapter from Crafting Interpreters.

Thank you!

Implementations

Wraps Data to create a new tagged pointer.

Creates a new stack frame.

Shortcut for creating a new Tagged(Slot::NotInit).

Unwraps a tagged number into the appropriate datatype, consuming the tagged number.

Deeply copies some Tagged data.

Trait Implementations

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

Unwraps a tagged pointer into the literal representation for debugging.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.