Intrepid/Prometeu/Runtime/pipeline/pr-master This commit looks good
Implement GC-managed random generators, next/nextf intrinsics, bounded ranges and deterministic conformance coverage. Publish the runtime contract and producer guidance. Give coverage domains at least five percentage points of measured headroom while preserving sufficient floors. Record local qualification: make ci-domains passes with 939 tests and all domain gates green.
71 lines
3.3 KiB
Rust
71 lines
3.3 KiB
Rust
//! This module defines the Application Binary Interface (ABI) of the Prometeu Virtual Machine.
|
|
//! It specifies how instructions are encoded in bytes and how they interact with memory.
|
|
|
|
/// Attempted to execute an unknown or invalid opcode.
|
|
pub const TRAP_ILLEGAL_INSTRUCTION: u32 = 0x0000_0001;
|
|
/// Program explicitly requested termination via the TRAP opcode.
|
|
pub const TRAP_EXPLICIT: u32 = 0x0000_0002;
|
|
/// Out-of-bounds access (e.g., stack/heap/local index out of range).
|
|
pub const TRAP_OOB: u32 = 0x0000_0003;
|
|
/// Type mismatch for the attempted operation (e.g., wrong operand type or syscall argument type).
|
|
pub const TRAP_TYPE: u32 = 0x0000_0004;
|
|
/// The syscall ID provided is not recognized by the system.
|
|
pub const TRAP_INVALID_SYSCALL: u32 = 0x0000_0007;
|
|
/// Not enough values on the operand stack for the requested operation/syscall.
|
|
pub const TRAP_STACK_UNDERFLOW: u32 = 0x0000_0008;
|
|
/// Attempted to access a local slot that is out of bounds for the current frame.
|
|
pub const TRAP_INVALID_LOCAL: u32 = 0x0000_0009;
|
|
/// Division or modulo by zero.
|
|
pub const TRAP_DIV_ZERO: u32 = 0x0000_000A;
|
|
/// Attempted to call a function that does not exist in the function table.
|
|
pub const TRAP_INVALID_FUNC: u32 = 0x0000_000B;
|
|
/// Executed RET with an incorrect stack height (mismatch with function metadata).
|
|
pub const TRAP_BAD_RET_SLOTS: u32 = 0x0000_000C;
|
|
/// The intrinsic ID provided is not recognized by the runtime, or its metadata is invalid.
|
|
pub const TRAP_INVALID_INTRINSIC: u32 = 0x0000_000D;
|
|
|
|
/// Valid absence used where an instance is required.
|
|
pub const TRAP_NULL_REFERENCE: u32 = 0x0000_000E;
|
|
/// Invalid, dead or stale generational heap reference.
|
|
pub const TRAP_INVALID_HANDLE: u32 = 0x0000_000F;
|
|
/// Quota, checked size overflow or recoverable allocation failure.
|
|
pub const TRAP_RESOURCE_LIMIT: u32 = 0x0000_0010;
|
|
/// Known input query unavailable on this platform.
|
|
pub const TRAP_UNAVAILABLE: u32 = 0x0000_0011;
|
|
/// Mathematical domain is invalid for the supplied finite arguments.
|
|
pub const TRAP_NUMERIC_DOMAIN: u32 = 0x0000_0012;
|
|
/// Finite input produces an unrepresentable result or integer destination.
|
|
pub const TRAP_NUMERIC_RANGE: u32 = 0x0000_0013;
|
|
/// A NaN or infinite input cannot enter guest numeric computation.
|
|
pub const TRAP_NON_FINITE: u32 = 0x0000_0014;
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
/// Detailed information about a source code span.
|
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
|
|
pub struct SourceSpan {
|
|
pub file_id: u32,
|
|
pub start: u32,
|
|
pub end: u32,
|
|
}
|
|
|
|
/// Detailed information about a runtime trap.
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub struct TrapInfo {
|
|
/// The specific trap code (e.g., TRAP_OOB).
|
|
pub code: u32,
|
|
/// The numeric value of the opcode that triggered the trap.
|
|
pub opcode: u16,
|
|
/// A human-readable message explaining the trap.
|
|
pub message: String,
|
|
/// The absolute Program Counter (PC) address where the trap occurred.
|
|
pub pc: u32,
|
|
/// Optional source span information if debug symbols are available.
|
|
pub span: Option<SourceSpan>,
|
|
/// Machine-readable quota context; messages are not its serialization.
|
|
pub resource: Option<crate::ResourceFailure>,
|
|
}
|
|
|
|
/// All 64 unbiased bounded-random candidates were rejected.
|
|
pub const TRAP_RANDOM_REJECTION_LIMIT: u32 = 0x0000_0015;
|