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§
Structs§
- Arg
- Arguments
- Argument structure
- Basic
Bag - Code
Flags - Code
Object - Primary container of a single code object. Each python function has a code object. Also a module has a code object.
- Code
Unit - Code
Units - Constants
- Exception
Table Entry - Exception table entry for zero-cost exception handling Format: (start, size, target, depth<<1|lasti)
- Stack
Effect - What effect the instruction has on the stack.
Enums§
- AnyInstruction
- Borrowed
Constant - A borrowed Constant
- Constant
Data - A Constant (which usually encapsulates data within it)
- Instruction
- A Single bytecode instruction that are executed by the VM.
- Pseudo
Instruction - Instructions used by the compiler. They are not executed by the VM.
- PyCode
Location Info Kind - 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§
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.