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.
46 lines
1.6 KiB
Rust
46 lines
1.6 KiB
Rust
//! The shared catalog owns IDs, layouts, effects and charging descriptors.
|
|
use crate::{
|
|
AbiType, BuiltinScalarType, BuiltinTypeKey, IntrinsicCostModel, IntrinsicImplementation,
|
|
IntrinsicMeta,
|
|
};
|
|
const I64: AbiType = AbiType::Scalar(BuiltinScalarType::Int64);
|
|
const FLOAT: AbiType = AbiType::Scalar(BuiltinScalarType::Float);
|
|
const RANDOM: AbiType = AbiType::Builtin(BuiltinTypeKey::new("Random", 1));
|
|
const fn entry(
|
|
id: u32,
|
|
name: &'static str,
|
|
args: &'static [AbiType],
|
|
ret: &'static [AbiType],
|
|
names: &'static [&'static str],
|
|
cost: u64,
|
|
) -> IntrinsicMeta {
|
|
let rejection = id == 0x4003;
|
|
IntrinsicMeta {
|
|
id,
|
|
owner: "random",
|
|
name,
|
|
version: 1,
|
|
arg_layout: args,
|
|
ret_layout: ret,
|
|
parameter_names: names,
|
|
cost_cycles: cost,
|
|
cost_model: if rejection {
|
|
IntrinsicCostModel::RandomRejectionV1
|
|
} else {
|
|
IntrinsicCostModel::Fixed
|
|
},
|
|
attempt_cost_cycles: if rejection { 8 } else { 0 },
|
|
max_attempts: if rejection { crate::random::MAX_ATTEMPTS } else { 0 },
|
|
deterministic: true,
|
|
mutates_guest_state: true,
|
|
may_allocate: id == 0x4000,
|
|
implementation: IntrinsicImplementation::VmOwned,
|
|
}
|
|
}
|
|
pub(crate) const RANDOM_INTRINSICS: [IntrinsicMeta; 4] = [
|
|
entry(0x4000, "new", &[I64], &[RANDOM], &["seed"], 32),
|
|
entry(0x4001, "next", &[RANDOM], &[I64], &["rng"], 8),
|
|
entry(0x4002, "nextf", &[RANDOM], &[FLOAT], &["rng"], 12),
|
|
entry(0x4003, "range", &[RANDOM, I64, I64], &[I64], &["rng", "min", "max"], 4),
|
|
];
|