CostModel

Struct CostModel 

Source
pub struct CostModel {
Show 142 fields pub add_32: Cost, pub add_64: Cost, pub add_imm_32: Cost, pub add_imm_64: Cost, pub and: Cost, pub and_imm: Cost, pub and_inverted: Cost, pub branch_eq: Cost, pub branch_eq_imm: Cost, pub branch_greater_or_equal_signed: Cost, pub branch_greater_or_equal_signed_imm: Cost, pub branch_greater_or_equal_unsigned: Cost, pub branch_greater_or_equal_unsigned_imm: Cost, pub branch_greater_signed_imm: Cost, pub branch_greater_unsigned_imm: Cost, pub branch_less_or_equal_signed_imm: Cost, pub branch_less_or_equal_unsigned_imm: Cost, pub branch_less_signed: Cost, pub branch_less_signed_imm: Cost, pub branch_less_unsigned: Cost, pub branch_less_unsigned_imm: Cost, pub branch_not_eq: Cost, pub branch_not_eq_imm: Cost, pub cmov_if_not_zero: Cost, pub cmov_if_not_zero_imm: Cost, pub cmov_if_zero: Cost, pub cmov_if_zero_imm: Cost, pub count_leading_zero_bits_32: Cost, pub count_leading_zero_bits_64: Cost, pub count_set_bits_32: Cost, pub count_set_bits_64: Cost, pub count_trailing_zero_bits_32: Cost, pub count_trailing_zero_bits_64: Cost, pub div_signed_32: Cost, pub div_signed_64: Cost, pub div_unsigned_32: Cost, pub div_unsigned_64: Cost, pub ecalli: Cost, pub fallthrough: Cost, pub jump: Cost, pub jump_indirect: Cost, pub load_i16: Cost, pub load_i32: Cost, pub load_i8: Cost, pub load_imm: Cost, pub load_imm64: Cost, pub load_imm_and_jump: Cost, pub load_imm_and_jump_indirect: Cost, pub load_indirect_i16: Cost, pub load_indirect_i32: Cost, pub load_indirect_i8: Cost, pub load_indirect_u16: Cost, pub load_indirect_u32: Cost, pub load_indirect_u64: Cost, pub load_indirect_u8: Cost, pub load_u16: Cost, pub load_u32: Cost, pub load_u64: Cost, pub load_u8: Cost, pub maximum: Cost, pub maximum_unsigned: Cost, pub memset: Cost, pub minimum: Cost, pub minimum_unsigned: Cost, pub move_reg: Cost, pub mul_32: Cost, pub mul_64: Cost, pub mul_imm_32: Cost, pub mul_imm_64: Cost, pub mul_upper_signed_signed: Cost, pub mul_upper_signed_unsigned: Cost, pub mul_upper_unsigned_unsigned: Cost, pub negate_and_add_imm_32: Cost, pub negate_and_add_imm_64: Cost, pub or: Cost, pub or_imm: Cost, pub or_inverted: Cost, pub rem_signed_32: Cost, pub rem_signed_64: Cost, pub rem_unsigned_32: Cost, pub rem_unsigned_64: Cost, pub reverse_byte: Cost, pub rotate_left_32: Cost, pub rotate_left_64: Cost, pub rotate_right_32: Cost, pub rotate_right_64: Cost, pub rotate_right_imm_32: Cost, pub rotate_right_imm_64: Cost, pub rotate_right_imm_alt_32: Cost, pub rotate_right_imm_alt_64: Cost, pub sbrk: Cost, pub set_greater_than_signed_imm: Cost, pub set_greater_than_unsigned_imm: Cost, pub set_less_than_signed: Cost, pub set_less_than_signed_imm: Cost, pub set_less_than_unsigned: Cost, pub set_less_than_unsigned_imm: Cost, pub shift_arithmetic_right_32: Cost, pub shift_arithmetic_right_64: Cost, pub shift_arithmetic_right_imm_32: Cost, pub shift_arithmetic_right_imm_64: Cost, pub shift_arithmetic_right_imm_alt_32: Cost, pub shift_arithmetic_right_imm_alt_64: Cost, pub shift_logical_left_32: Cost, pub shift_logical_left_64: Cost, pub shift_logical_left_imm_32: Cost, pub shift_logical_left_imm_64: Cost, pub shift_logical_left_imm_alt_32: Cost, pub shift_logical_left_imm_alt_64: Cost, pub shift_logical_right_32: Cost, pub shift_logical_right_64: Cost, pub shift_logical_right_imm_32: Cost, pub shift_logical_right_imm_64: Cost, pub shift_logical_right_imm_alt_32: Cost, pub shift_logical_right_imm_alt_64: Cost, pub sign_extend_16: Cost, pub sign_extend_8: Cost, pub store_imm_indirect_u16: Cost, pub store_imm_indirect_u32: Cost, pub store_imm_indirect_u64: Cost, pub store_imm_indirect_u8: Cost, pub store_imm_u16: Cost, pub store_imm_u32: Cost, pub store_imm_u64: Cost, pub store_imm_u8: Cost, pub store_indirect_u16: Cost, pub store_indirect_u32: Cost, pub store_indirect_u64: Cost, pub store_indirect_u8: Cost, pub store_u16: Cost, pub store_u32: Cost, pub store_u64: Cost, pub store_u8: Cost, pub sub_32: Cost, pub sub_64: Cost, pub trap: Cost, pub unlikely: Cost, pub xnor: Cost, pub xor: Cost, pub xor_imm: Cost, pub zero_extend_16: Cost, pub invalid: u32,
}

Fields§

§add_32: Cost§add_64: Cost§add_imm_32: Cost§add_imm_64: Cost§and: Cost§and_imm: Cost§and_inverted: Cost§branch_eq: Cost§branch_eq_imm: Cost§branch_greater_or_equal_signed: Cost§branch_greater_or_equal_signed_imm: Cost§branch_greater_or_equal_unsigned: Cost§branch_greater_or_equal_unsigned_imm: Cost§branch_greater_signed_imm: Cost§branch_greater_unsigned_imm: Cost§branch_less_or_equal_signed_imm: Cost§branch_less_or_equal_unsigned_imm: Cost§branch_less_signed: Cost§branch_less_signed_imm: Cost§branch_less_unsigned: Cost§branch_less_unsigned_imm: Cost§branch_not_eq: Cost§branch_not_eq_imm: Cost§cmov_if_not_zero: Cost§cmov_if_not_zero_imm: Cost§cmov_if_zero: Cost§cmov_if_zero_imm: Cost§count_leading_zero_bits_32: Cost§count_leading_zero_bits_64: Cost§count_set_bits_32: Cost§count_set_bits_64: Cost§count_trailing_zero_bits_32: Cost§count_trailing_zero_bits_64: Cost§div_signed_32: Cost§div_signed_64: Cost§div_unsigned_32: Cost§div_unsigned_64: Cost§ecalli: Cost§fallthrough: Cost§jump: Cost§jump_indirect: Cost§load_i16: Cost§load_i32: Cost§load_i8: Cost§load_imm: Cost§load_imm64: Cost§load_imm_and_jump: Cost§load_imm_and_jump_indirect: Cost§load_indirect_i16: Cost§load_indirect_i32: Cost§load_indirect_i8: Cost§load_indirect_u16: Cost§load_indirect_u32: Cost§load_indirect_u64: Cost§load_indirect_u8: Cost§load_u16: Cost§load_u32: Cost§load_u64: Cost§load_u8: Cost§maximum: Cost§maximum_unsigned: Cost§memset: Cost§minimum: Cost§minimum_unsigned: Cost§move_reg: Cost§mul_32: Cost§mul_64: Cost§mul_imm_32: Cost§mul_imm_64: Cost§mul_upper_signed_signed: Cost§mul_upper_signed_unsigned: Cost§mul_upper_unsigned_unsigned: Cost§negate_and_add_imm_32: Cost§negate_and_add_imm_64: Cost§or: Cost§or_imm: Cost§or_inverted: Cost§rem_signed_32: Cost§rem_signed_64: Cost§rem_unsigned_32: Cost§rem_unsigned_64: Cost§reverse_byte: Cost§rotate_left_32: Cost§rotate_left_64: Cost§rotate_right_32: Cost§rotate_right_64: Cost§rotate_right_imm_32: Cost§rotate_right_imm_64: Cost§rotate_right_imm_alt_32: Cost§rotate_right_imm_alt_64: Cost§sbrk: Cost§set_greater_than_signed_imm: Cost§set_greater_than_unsigned_imm: Cost§set_less_than_signed: Cost§set_less_than_signed_imm: Cost§set_less_than_unsigned: Cost§set_less_than_unsigned_imm: Cost§shift_arithmetic_right_32: Cost§shift_arithmetic_right_64: Cost§shift_arithmetic_right_imm_32: Cost§shift_arithmetic_right_imm_64: Cost§shift_arithmetic_right_imm_alt_32: Cost§shift_arithmetic_right_imm_alt_64: Cost§shift_logical_left_32: Cost§shift_logical_left_64: Cost§shift_logical_left_imm_32: Cost§shift_logical_left_imm_64: Cost§shift_logical_left_imm_alt_32: Cost§shift_logical_left_imm_alt_64: Cost§shift_logical_right_32: Cost§shift_logical_right_64: Cost§shift_logical_right_imm_32: Cost§shift_logical_right_imm_64: Cost§shift_logical_right_imm_alt_32: Cost§shift_logical_right_imm_alt_64: Cost§sign_extend_16: Cost§sign_extend_8: Cost§store_imm_indirect_u16: Cost§store_imm_indirect_u32: Cost§store_imm_indirect_u64: Cost§store_imm_indirect_u8: Cost§store_imm_u16: Cost§store_imm_u32: Cost§store_imm_u64: Cost§store_imm_u8: Cost§store_indirect_u16: Cost§store_indirect_u32: Cost§store_indirect_u64: Cost§store_indirect_u8: Cost§store_u16: Cost§store_u32: Cost§store_u64: Cost§store_u8: Cost§sub_32: Cost§sub_64: Cost§trap: Cost§unlikely: Cost§xnor: Cost§xor: Cost§xor_imm: Cost§zero_extend_16: Cost§invalid: u32

Implementations§

Source§

impl CostModel

Source

pub const fn naive() -> Self

A naive gas cost model where every instruction costs one gas.

Source

pub fn serialize(&self) -> Vec<u8>

Serializes the cost model into a byte blob.

Source

pub fn deserialize(blob: &[u8]) -> Option<CostModel>

Deserializes the cost model from a byte blob.

Source

pub fn cost_for_opcode(&self, opcode: Opcode) -> u32

Gets the cost of a given opcode.

Source§

impl CostModel

Trait Implementations§

Source§

impl From<&'static CostModel> for CostModelRef

Source§

fn from(value: &'static CostModel) -> Self

Converts to this type from the input type.
Source§

impl Hash for CostModel

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. 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> 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, 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.