Skip to main content

Module bytecode

Module bytecode 

Source
Expand description

Implement python as a virtual machine with bytecode. This module implements bytecode structure.

Re-exports§

pub use crate::bytecode::oparg::BinaryOperator;
pub use crate::bytecode::oparg::BuildSliceArgCount;
pub use crate::bytecode::oparg::CommonConstant;
pub use crate::bytecode::oparg::ComparisonOperator;
pub use crate::bytecode::oparg::ConvertValueOparg;
pub use crate::bytecode::oparg::IntrinsicFunction1;
pub use crate::bytecode::oparg::IntrinsicFunction2;
pub use crate::bytecode::oparg::Invert;
pub use crate::bytecode::oparg::Label;
pub use crate::bytecode::oparg::LoadAttr;
pub use crate::bytecode::oparg::LoadSuperAttr;
pub use crate::bytecode::oparg::MakeFunctionFlag;
pub use crate::bytecode::oparg::MakeFunctionFlags;
pub use crate::bytecode::oparg::NameIdx;
pub use crate::bytecode::oparg::OpArg;
pub use crate::bytecode::oparg::OpArgByte;
pub use crate::bytecode::oparg::OpArgState;
pub use crate::bytecode::oparg::OpArgType;
pub use crate::bytecode::oparg::RaiseKind;
pub use crate::bytecode::oparg::SpecialMethod;
pub use crate::bytecode::oparg::UnpackExArgs;

Modules§

oparg

Structs§

Arg
Arguments
Argument structure
BasicBag
CodeFlags
CodeObject
Primary container of a single code object. Each python function has a code object. Also a module has a code object.
CodeUnit
CodeUnits
Constants
ExceptionTableEntry
Exception table entry for zero-cost exception handling Format: (start, size, target, depth<<1|lasti)
StackEffect
What effect the instruction has on the stack.

Enums§

AnyInstruction
BorrowedConstant
A borrowed Constant
ConstantData
A Constant (which usually encapsulates data within it)
Instruction
A Single bytecode instruction that are executed by the VM.
PseudoInstruction
Instructions used by the compiler. They are not executed by the VM.
PyCodeLocationInfoKind
CPython 3.11+ linetable location info codes

Constants§

ADAPTIVE_COOLDOWN_VALUE
Adaptive specialization: cooldown counter after a successful specialization.
ADAPTIVE_WARMUP_VALUE
Adaptive specialization: number of executions before attempting specialization.
CO_FAST_CELL
CO_FAST_FREE
CO_FAST_HIDDEN
Per-slot kind flags for localsplus (co_localspluskinds).
CO_FAST_LOCAL
JUMP_BACKWARD_INITIAL_VALUE
Initial JUMP_BACKWARD counter bits (value/backoff = 4095/12).

Traits§

AsBag
Constant
ConstantBag
A Constant Bag
InstrDisplayContext
InstructionMetadata

Functions§

adaptive_counter_backoff
Reset adaptive counter with exponential backoff.
adaptive_counter_bits
Encode an adaptive counter as (value << 4) | backoff.
adaptive_counter_triggers
True when the adaptive counter should trigger specialization.
advance_adaptive_counter
Decrement adaptive counter by one countdown step.
build_no_location_mask
Parse linetable to build a boolean mask indicating which code units have NO_LOCATION (line == -1). Returns a Vec of length num_units.
decode_exception_table
Decode all exception table entries.
encode_exception_table
Encode exception table entries. Uses 6-bit varint encoding with start marker (MSB) and continuation bit.
find_exception_handler
Find exception handler for given instruction offset.