Skip to main content

Fused

Enum Fused 

Source
pub enum Fused {
    None,
    AddImmLoc,
    AddAtomLoc,
    AddLocLoc,
    AddArgLoc,
    PostIncLoc,
    StoreImm,
    LtLocArgJump,
    LtLocImmJump,
}
Expand description

A fused instruction, and how many records it stands for.

Only shapes that cannot throw are fused, because at — the offset a stack trace reports — names the first instruction of the group. A fused x += 1 that raised would blame the wrong column; a fused x += 1 on integers cannot raise.

Variants§

§

None

Not fused: run Insn::op.

§

AddImmLoc

x += k for an integer k: get_loc x; push k; add; put_loc x.

Four dispatches become one, and this is the most common four-instruction group in JavaScript — i += 1, total += n, every accumulator in every loop.

§

AddAtomLoc

x += "literal": get_loc x; push_atom_value atom; add; put_loc x.

The same group with a string constant instead of an integer, and it exists for one reason beyond dispatch: the reference’s OP_add_loc hands the variable’s own string to JS_ConcatStringInPlace, so text += "abc" in a loop grows one buffer instead of building a new string per iteration. Reproducing it needs the group fused, because only then is the variable’s one handle the only handle — through get_loc alone it has already been cloned once.

§

AddLocLoc

x += y: get_loc x; get_loc y; add; put_loc x.

The same, with the other operand also a local. a is (x << 16) | y, like Fused::LtLocArgJump.

§

AddArgLoc

x += y where y is an argument: get_loc x; get_arg y; add; put_loc x.

Separate from Fused::AddLocLoc rather than a flag bit, because the two read different arrays and a bit would make every reader of the operand check it.

§

PostIncLoc

x++ and the value is dropped: get_loc x; post_inc; put_loc x; drop.

§

StoreImm

x = k: push k; put_loc x.

§

LtLocArgJump

if (!(x < arg)) goto target — a loop’s header: get_loc x; get_arg arg; lt; if_false target.

The condition is the one instruction group that runs on every iteration of every loop, so collapsing it is worth the packed operands: a is (x << 16) | arg, b is the target instruction index.

§

LtLocImmJump

if (!(x < k)) goto target — a loop header whose bound is a literal: get_loc x; push k; lt; if_false target.

Fused::LtLocArgJump covers for (var i = 0; i < n; i++), where the bound is a parameter. This covers for (var i = 0; i < 1000; i++), where it is an immediate — measured as a 40% slowdown against the reference when it did not fuse at all, since the header is four dispatches on every iteration. a is the slot, b is the target instruction index, imm is the bound.

Trait Implementations§

Source§

impl Clone for Fused

Source§

fn clone(&self) -> Self

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
Source§

impl Copy for Fused

Source§

impl Debug for Fused

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Fused

Source§

impl PartialEq for Fused

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Fused

Auto Trait Implementations§

§

impl Forget for Fused

§

impl Freeze for Fused

§

impl Move for Fused

§

impl RefUnwindSafe for Fused

§

impl Send for Fused

§

impl Sync for Fused

§

impl Unpin for Fused

§

impl UnsafeUnpin for Fused

§

impl UnwindSafe for Fused

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.