Compare commits
4
Commits
f7d7c16753
...
dcf6561ea7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dcf6561ea7
|
||
|
|
69ad1931de
|
||
|
|
57992cf214
|
||
|
|
d9b9eeb171
|
@@ -179,7 +179,7 @@ pub fn assemble(src: &str) -> Result<Vec<u8>, AsmError> {
|
||||
emit_u16(CoreOpCode::Ret as u16, &mut out);
|
||||
}
|
||||
"YIELD" | "SLEEP" | "SPAWN" => {
|
||||
return Err(AsmError::InvalidOperand("retired coroutine instruction".into()))
|
||||
return Err(AsmError::InvalidOperand("retired coroutine instruction".into()));
|
||||
}
|
||||
"FRAME_SYNC" => {
|
||||
emit_u16(CoreOpCode::FrameSync as u16, &mut out);
|
||||
@@ -345,7 +345,7 @@ pub fn assemble(src: &str) -> Result<Vec<u8>, AsmError> {
|
||||
emit_u32(ty, &mut out);
|
||||
emit_u32(field, &mut out);
|
||||
}
|
||||
"STRUCT_NEW" | "ARRAY_NEW" | "ARRAY_LEN" | "ARRAY_GET" | "ARRAY_SET" => {
|
||||
"STRUCT_NEW" | "ARRAY_NEW" | "ARRAY_LEN" | "ARRAY_GET" | "ARRAY_SET" | "ARRAY_COPY" => {
|
||||
if ops.is_empty() {
|
||||
return Err(AsmError::MissingOperand(line.into()));
|
||||
}
|
||||
@@ -354,23 +354,32 @@ pub fn assemble(src: &str) -> Result<Vec<u8>, AsmError> {
|
||||
"ARRAY_NEW" => CoreOpCode::ArrayNew,
|
||||
"ARRAY_LEN" => CoreOpCode::ArrayLen,
|
||||
"ARRAY_GET" => CoreOpCode::ArrayGet,
|
||||
"ARRAY_COPY" => CoreOpCode::ArrayCopy,
|
||||
_ => CoreOpCode::ArraySet,
|
||||
};
|
||||
emit_u16(op as u16, &mut out);
|
||||
emit_u32(parse_u32_any(ops)?, &mut out);
|
||||
}
|
||||
"DYN_PACK" | "DYN_UNPACK" | "DYN_CAN_UNPACK" => {
|
||||
"DYN_PACK" | "DYN_UNPACK" | "DYN_CAN_UNPACK" | "REF_IDENTITY_HASH" => {
|
||||
if ops.is_empty() {
|
||||
return Err(AsmError::MissingOperand(line.into()));
|
||||
}
|
||||
let opcode = match mn {
|
||||
"DYN_PACK" => CoreOpCode::DynPack,
|
||||
"DYN_UNPACK" => CoreOpCode::DynUnpack,
|
||||
"REF_IDENTITY_HASH" => CoreOpCode::RefIdentityHash,
|
||||
_ => CoreOpCode::DynCanUnpack,
|
||||
};
|
||||
emit_u16(opcode as u16, &mut out);
|
||||
emit_u32(parse_u32_any(ops)?, &mut out);
|
||||
}
|
||||
"REF_IDENTITY_EQ" => {
|
||||
let (a, b) = parse_keyvals(ops)?;
|
||||
let (left, right) = parse_pair(a, "left", b, "right")?;
|
||||
emit_u16(CoreOpCode::RefIdentityEq as u16, &mut out);
|
||||
emit_u32(left, &mut out);
|
||||
emit_u32(right, &mut out);
|
||||
}
|
||||
"REF_IS_EXACT" | "REF_IMPLEMENTS" | "REF_TO_TRAIT" | "REF_CAST" => {
|
||||
if ops.is_empty() {
|
||||
return Err(AsmError::MissingOperand(line.into()));
|
||||
|
||||
@@ -65,12 +65,14 @@ fn format_operand(op: CoreOpCode, imm: &[u8]) -> String {
|
||||
| CoreOpCode::Hostcall
|
||||
| CoreOpCode::DynPack
|
||||
| CoreOpCode::DynUnpack
|
||||
| CoreOpCode::RefIdentityHash
|
||||
| CoreOpCode::DynCanUnpack
|
||||
| CoreOpCode::StructNew
|
||||
| CoreOpCode::ArrayNew
|
||||
| CoreOpCode::ArrayLen
|
||||
| CoreOpCode::ArrayGet
|
||||
| CoreOpCode::ArraySet => {
|
||||
| CoreOpCode::ArraySet
|
||||
| CoreOpCode::ArrayCopy => {
|
||||
let v = u32::from_le_bytes(imm.try_into().unwrap());
|
||||
format!("{}", v)
|
||||
}
|
||||
@@ -79,6 +81,11 @@ fn format_operand(op: CoreOpCode, imm: &[u8]) -> String {
|
||||
let field = u32::from_le_bytes(imm[4..].try_into().unwrap());
|
||||
format!("type={}, field={}", ty, field)
|
||||
}
|
||||
CoreOpCode::RefIdentityEq => {
|
||||
let left = u32::from_le_bytes(imm[..4].try_into().unwrap());
|
||||
let right = u32::from_le_bytes(imm[4..].try_into().unwrap());
|
||||
format!("left={}, right={}", left, right)
|
||||
}
|
||||
CoreOpCode::RefIsExact
|
||||
| CoreOpCode::RefImplements
|
||||
| CoreOpCode::RefToTrait
|
||||
|
||||
@@ -192,6 +192,10 @@ pub enum OpCode {
|
||||
RefToTrait = 0x95,
|
||||
/// REF_CAST: source:TypeId, target:TypeId; requires validated Registry metadata.
|
||||
RefCast = 0x96,
|
||||
/// Query a complete typed reference identity; source TypeId.
|
||||
RefIdentityHash = 0x97,
|
||||
/// Compare two complete typed references; left/right TypeIds.
|
||||
RefIdentityEq = 0x98,
|
||||
|
||||
// Registry-backed collection operations. cycles() is their base component.
|
||||
StructNew = 0xA0,
|
||||
@@ -201,6 +205,8 @@ pub enum OpCode {
|
||||
ArrayLen = 0xA4,
|
||||
ArrayGet = 0xA5,
|
||||
ArraySet = 0xA6,
|
||||
/// Complete stored groups, overlap-safe; Array TypeId:u32.
|
||||
ArrayCopy = 0xA9,
|
||||
}
|
||||
|
||||
impl TryFrom<u16> for OpCode {
|
||||
@@ -267,6 +273,8 @@ impl TryFrom<u16> for OpCode {
|
||||
0x94 => Ok(OpCode::RefImplements),
|
||||
0x95 => Ok(OpCode::RefToTrait),
|
||||
0x96 => Ok(OpCode::RefCast),
|
||||
0x97 => Ok(OpCode::RefIdentityHash),
|
||||
0x98 => Ok(OpCode::RefIdentityEq),
|
||||
0xA0 => Ok(OpCode::StructNew),
|
||||
0xA1 => Ok(OpCode::StructGet),
|
||||
0xA2 => Ok(OpCode::StructSet),
|
||||
@@ -274,6 +282,7 @@ impl TryFrom<u16> for OpCode {
|
||||
0xA4 => Ok(OpCode::ArrayLen),
|
||||
0xA5 => Ok(OpCode::ArrayGet),
|
||||
0xA6 => Ok(OpCode::ArraySet),
|
||||
0xA9 => Ok(OpCode::ArrayCopy),
|
||||
|
||||
_ => Err(format!("Invalid OpCode: 0x{:04X}", value)),
|
||||
}
|
||||
@@ -344,6 +353,8 @@ impl OpCode {
|
||||
OpCode::RefImplements => 4,
|
||||
OpCode::RefToTrait => 5,
|
||||
OpCode::RefCast => 4,
|
||||
OpCode::RefIdentityHash => 8,
|
||||
OpCode::RefIdentityEq => 4,
|
||||
OpCode::StructNew => 8,
|
||||
OpCode::StructGet => 3,
|
||||
OpCode::StructSet => 4,
|
||||
@@ -351,6 +362,7 @@ impl OpCode {
|
||||
OpCode::ArrayLen => 3,
|
||||
OpCode::ArrayGet => 3,
|
||||
OpCode::ArraySet => 4,
|
||||
OpCode::ArrayCopy => 4,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -596,6 +596,26 @@ impl OpCodeSpecExt for OpCode {
|
||||
may_trap: true,
|
||||
is_safepoint: false,
|
||||
},
|
||||
OpCode::RefIdentityHash => OpcodeSpec {
|
||||
name: "REF_IDENTITY_HASH",
|
||||
imm_bytes: 4,
|
||||
pops: None,
|
||||
pushes: None,
|
||||
is_branch: false,
|
||||
is_terminator: false,
|
||||
may_trap: true,
|
||||
is_safepoint: false,
|
||||
},
|
||||
OpCode::RefIdentityEq => OpcodeSpec {
|
||||
name: "REF_IDENTITY_EQ",
|
||||
imm_bytes: 8,
|
||||
pops: None,
|
||||
pushes: None,
|
||||
is_branch: false,
|
||||
is_terminator: false,
|
||||
may_trap: true,
|
||||
is_safepoint: false,
|
||||
},
|
||||
OpCode::StructNew => OpcodeSpec {
|
||||
name: "STRUCT_NEW",
|
||||
imm_bytes: 4,
|
||||
@@ -666,6 +686,16 @@ impl OpCodeSpecExt for OpCode {
|
||||
may_trap: true,
|
||||
is_safepoint: false,
|
||||
},
|
||||
OpCode::ArrayCopy => OpcodeSpec {
|
||||
name: "ARRAY_COPY",
|
||||
imm_bytes: 4,
|
||||
pops: None,
|
||||
pushes: None,
|
||||
is_branch: false,
|
||||
is_terminator: false,
|
||||
may_trap: true,
|
||||
is_safepoint: false,
|
||||
},
|
||||
OpCode::FrameSync => OpcodeSpec {
|
||||
name: "FRAME_SYNC",
|
||||
imm_bytes: 0,
|
||||
|
||||
@@ -52,6 +52,19 @@ pub enum TypeKind {
|
||||
Trait(Vec<MethodDecl>),
|
||||
Fn(Signature),
|
||||
}
|
||||
impl TypeKind {
|
||||
/// Categories supported by identity queries, not by legacy REF_* conversions.
|
||||
pub fn is_identity_reference(&self) -> bool {
|
||||
matches!(
|
||||
self,
|
||||
Self::Struct(_)
|
||||
| Self::Array(_)
|
||||
| Self::Fn(_)
|
||||
| Self::Trait(_)
|
||||
| Self::Builtin(BuiltinId::RANDOM)
|
||||
)
|
||||
}
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct TypeDecl {
|
||||
pub name: Option<String>,
|
||||
|
||||
@@ -86,7 +86,7 @@ impl DecodedInstr<'_> {
|
||||
)
|
||||
}
|
||||
Op::GetCapture => {
|
||||
return Err(LoadFailure::new(LoadCode::InvalidReference, LoadReason::CaptureIndex))
|
||||
return Err(LoadFailure::new(LoadCode::InvalidReference, LoadReason::CaptureIndex));
|
||||
}
|
||||
Op::CallTrait => {
|
||||
let (ty, method) = self.imm_u32x2().map_err(|_| malformed())?;
|
||||
@@ -133,6 +133,29 @@ impl DecodedInstr<'_> {
|
||||
};
|
||||
(source_layout.storage.slots, pushes)
|
||||
}
|
||||
Op::RefIdentityHash | Op::RefIdentityEq => {
|
||||
let (left, right) = if self.opcode == Op::RefIdentityHash {
|
||||
(self.imm_u32().map_err(|_| malformed())?, None)
|
||||
} else {
|
||||
let (a, b) = self.imm_u32x2().map_err(|_| malformed())?;
|
||||
(a, Some(b))
|
||||
};
|
||||
let mut pops = 0;
|
||||
for id in std::iter::once(left).chain(right) {
|
||||
let (decl, layout) = type_info(id)?;
|
||||
if !decl.kind.is_identity_reference() {
|
||||
return Err(bad_category(id));
|
||||
}
|
||||
pops += layout.storage.slots;
|
||||
}
|
||||
(pops, 1)
|
||||
}
|
||||
Op::ArrayCopy => {
|
||||
let array = self.imm_u32().map_err(|_| malformed())?;
|
||||
let (_, layout) = type_info(array)?;
|
||||
layout.array.ok_or_else(|| bad_category(array))?;
|
||||
(5, 0)
|
||||
}
|
||||
Op::StructNew
|
||||
| Op::StructGet
|
||||
| Op::StructSet
|
||||
|
||||
@@ -34,6 +34,8 @@ fn all_typed_instructions_match_independent_bytes_and_costs() {
|
||||
("REF_IMPLEMENTS source=16909060, target=84281096", &[0x94, 0, 4, 3, 2, 1, 8, 7, 6, 5], 4),
|
||||
("REF_TO_TRAIT source=16909060, target=84281096", &[0x95, 0, 4, 3, 2, 1, 8, 7, 6, 5], 5),
|
||||
("REF_CAST source=16909060, target=84281096", &[0x96, 0, 4, 3, 2, 1, 8, 7, 6, 5], 4),
|
||||
("REF_IDENTITY_HASH 16909060", &[0x97, 0, 4, 3, 2, 1], 8),
|
||||
("REF_IDENTITY_EQ left=16909060, right=84281096", &[0x98, 0, 4, 3, 2, 1, 8, 7, 6, 5], 4),
|
||||
];
|
||||
for &(text, bytes, cycles) in cases {
|
||||
assert_eq!(assemble(text).unwrap(), bytes);
|
||||
@@ -49,8 +51,8 @@ fn all_typed_instructions_match_independent_bytes_and_costs() {
|
||||
}
|
||||
}
|
||||
assert!(matches!(
|
||||
decode_next(0, &[0x97, 0]),
|
||||
Err(DecodeError::UnknownOpcode { opcode: 0x97, .. })
|
||||
decode_next(0, &[0x99, 0]),
|
||||
Err(DecodeError::UnknownOpcode { opcode: 0x99, .. })
|
||||
));
|
||||
}
|
||||
#[test]
|
||||
@@ -68,6 +70,8 @@ fn slot_effects_resolve_semantic_widths_and_reference_categories() {
|
||||
("REF_TO_TRAIT source=4, target=6", 1, 2),
|
||||
("REF_TO_TRAIT source=6, target=6", 2, 2),
|
||||
("REF_CAST source=6, target=4", 2, 1),
|
||||
("REF_IDENTITY_HASH 6", 2, 1),
|
||||
("REF_IDENTITY_EQ left=6, right=4", 3, 1),
|
||||
] {
|
||||
let bytes = assemble(text).unwrap();
|
||||
assert_eq!(
|
||||
@@ -94,6 +98,9 @@ fn invalid_type_immediates_are_contextual_load_errors() {
|
||||
"REF_IS_EXACT source=4, target=6",
|
||||
"REF_TO_TRAIT source=4, target=0",
|
||||
"REF_IMPLEMENTS source=0, target=6",
|
||||
"REF_IDENTITY_HASH 0",
|
||||
"REF_IDENTITY_HASH 3",
|
||||
"REF_IDENTITY_EQ left=4, right=1",
|
||||
] {
|
||||
let bytes = assemble(text).unwrap();
|
||||
let e = decode_next(0, &bytes).unwrap().registry_stack_effect(®istry).unwrap_err();
|
||||
@@ -114,6 +121,10 @@ fn assembler_rejects_missing_overflowing_or_ambiguous_type_ids() {
|
||||
"REF_CAST source=4",
|
||||
"REF_CAST source=4, target=5, target=6",
|
||||
"REF_CAST source=4, trait=6",
|
||||
"REF_IDENTITY_HASH",
|
||||
"REF_IDENTITY_HASH -1",
|
||||
"REF_IDENTITY_EQ left=4",
|
||||
"REF_IDENTITY_EQ left=4, target=5",
|
||||
] {
|
||||
assert!(assemble(text).is_err(), "{text}");
|
||||
}
|
||||
@@ -204,3 +215,62 @@ fn collection_effects_and_cached_initialization_width_are_exact() {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn removed_storage_encodings_and_mnemonics_are_unsupported() {
|
||||
for opcode in [0xa7u16, 0xa8, 0xaa, 0xab] {
|
||||
assert!(Op::try_from(opcode).is_err());
|
||||
let bytes = opcode.to_le_bytes();
|
||||
assert!(
|
||||
matches!(decode_next(0,&bytes),Err(DecodeError::UnknownOpcode{pc:0,opcode: actual}) if actual == opcode)
|
||||
);
|
||||
assert!(disassemble(&bytes).is_err());
|
||||
}
|
||||
for text in
|
||||
["INDEX_GUARD", "ARRAY_CHECK_LENGTH 1", "STORAGE_PUBLISH 1,2,0,1", "FIELDS_PUBLISH 1"]
|
||||
{
|
||||
assert!(assemble(text).is_err(), "{text}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn range_copy_encoding_effects_and_registry_categories_are_independent_oracles() {
|
||||
let bytes = [0xa9, 0, 4, 3, 2, 1];
|
||||
assert_eq!(assemble("ARRAY_COPY 16909060").unwrap(), bytes);
|
||||
assert_eq!(disassemble(&bytes).unwrap(), "ARRAY_COPY 16909060");
|
||||
let instruction = decode_next(0, &bytes).unwrap();
|
||||
assert_eq!(instruction.opcode, Op::ArrayCopy);
|
||||
assert_eq!(instruction.opcode.cycles(), 4);
|
||||
let spec = instruction.opcode.spec();
|
||||
assert_eq!((spec.imm_bytes, spec.pops, spec.pushes), (4, None, None));
|
||||
assert!(instruction.opcode.requires_registry() && spec.may_trap);
|
||||
assert!(!spec.is_safepoint && !spec.is_branch && !spec.is_terminator);
|
||||
for end in 0..6 {
|
||||
assert!(decode_next(0, &bytes[..end]).is_err());
|
||||
}
|
||||
let registry = registry();
|
||||
let bytes = assemble("ARRAY_COPY 5").unwrap();
|
||||
assert_eq!(
|
||||
decode_next(0, &bytes).unwrap().registry_stack_effect(®istry).unwrap(),
|
||||
Some(RegistryStackEffect { pops: 5, pushes: 0 })
|
||||
);
|
||||
for (id, reason) in [
|
||||
(0, LoadReason::Category),
|
||||
(4, LoadReason::Category),
|
||||
(6, LoadReason::Category),
|
||||
(99, LoadReason::TypeId),
|
||||
] {
|
||||
let bytes = assemble(&format!("ARRAY_COPY {id}")).unwrap();
|
||||
let error = decode_next(0, &bytes).unwrap().registry_stack_effect(®istry).unwrap_err();
|
||||
assert_eq!(
|
||||
(error.code, error.reason, error.pc),
|
||||
(LoadCode::InvalidReference, reason, Some(0))
|
||||
);
|
||||
}
|
||||
for text in ["ARRAY_COPY", "ARRAY_COPY -1", "ARRAY_COPY 4294967296", "ARRAY_COPY 1 2"] {
|
||||
assert!(assemble(text).is_err());
|
||||
}
|
||||
// These are legal immediate bytes, not instruction boundaries.
|
||||
let bytes = assemble("PUSH_I64 18735214094965159\nHALT").unwrap();
|
||||
assert!(disassemble(&bytes).is_ok());
|
||||
}
|
||||
|
||||
@@ -235,12 +235,13 @@ pub type IntrinsicHostImplementation =
|
||||
pub enum IntrinsicImplementation {
|
||||
Host(IntrinsicHostImplementation),
|
||||
VmOwned,
|
||||
BorrowedInline(crate::IntrinsicInlineImplementation),
|
||||
}
|
||||
impl IntrinsicImplementation {
|
||||
pub fn host_callback(self) -> Option<IntrinsicHostImplementation> {
|
||||
match self {
|
||||
Self::Host(f) => Some(f),
|
||||
Self::VmOwned => None,
|
||||
Self::VmOwned | Self::BorrowedInline(_) => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -249,12 +250,14 @@ impl IntrinsicImplementation {
|
||||
pub enum IntrinsicCostModel {
|
||||
Fixed,
|
||||
RandomRejectionV1,
|
||||
ArgumentUtf8BytesV1,
|
||||
}
|
||||
impl IntrinsicCostModel {
|
||||
pub const fn name(self) -> &'static str {
|
||||
match self {
|
||||
Self::Fixed => "fixed",
|
||||
Self::RandomRejectionV1 => "random_rejection_v1",
|
||||
Self::ArgumentUtf8BytesV1 => "argument_utf8_bytes_v1",
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -266,11 +269,14 @@ pub struct IntrinsicMeta {
|
||||
pub name: &'static str,
|
||||
pub version: u16,
|
||||
pub arg_layout: &'static [AbiType],
|
||||
pub arg_nullable: &'static [bool],
|
||||
pub ret_layout: &'static [AbiType],
|
||||
pub parameter_names: &'static [&'static str],
|
||||
/// Full fixed cost, or base cost for a variable model.
|
||||
pub cost_cycles: u64,
|
||||
pub cost_model: IntrinsicCostModel,
|
||||
pub cost_arg_index: Option<usize>,
|
||||
pub cost_per_byte: u64,
|
||||
pub attempt_cost_cycles: u64,
|
||||
pub max_attempts: u32,
|
||||
pub mutates_guest_state: bool,
|
||||
@@ -300,7 +306,16 @@ impl IntrinsicMeta {
|
||||
&self,
|
||||
values: &[Value],
|
||||
) -> Result<(), IntrinsicExecutionError> {
|
||||
Self::validate_values(values, self.arg_layout)
|
||||
Self::validate_values(values, self.arg_layout)?;
|
||||
for (index, (value, nullable)) in values.iter().zip(self.arg_nullable).enumerate() {
|
||||
if matches!(value, Value::Null) && !nullable {
|
||||
return Err(IntrinsicExecutionError::TypeMismatch {
|
||||
index,
|
||||
expected: self.arg_layout[index],
|
||||
});
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn validate_values(
|
||||
@@ -563,10 +578,13 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
|
||||
name: "dot",
|
||||
version: 1,
|
||||
arg_layout: &VEC2_DOT_ARGS,
|
||||
arg_nullable: &[false; VEC2_DOT_ARGS.len()],
|
||||
ret_layout: &SINGLE_FLOAT_RET,
|
||||
parameter_names: &["ax", "ay", "bx", "by"],
|
||||
cost_cycles: 10,
|
||||
cost_model: crate::IntrinsicCostModel::Fixed,
|
||||
cost_arg_index: None,
|
||||
cost_per_byte: 0,
|
||||
attempt_cost_cycles: 0,
|
||||
max_attempts: 0,
|
||||
mutates_guest_state: false,
|
||||
@@ -580,10 +598,13 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
|
||||
name: "length",
|
||||
version: 1,
|
||||
arg_layout: &VEC2_LENGTH_ARGS,
|
||||
arg_nullable: &[false; VEC2_LENGTH_ARGS.len()],
|
||||
ret_layout: &SINGLE_FLOAT_RET,
|
||||
parameter_names: &["x", "y"],
|
||||
cost_cycles: 40,
|
||||
cost_model: crate::IntrinsicCostModel::Fixed,
|
||||
cost_arg_index: None,
|
||||
cost_per_byte: 0,
|
||||
attempt_cost_cycles: 0,
|
||||
max_attempts: 0,
|
||||
mutates_guest_state: false,
|
||||
@@ -597,10 +618,13 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
|
||||
name: "from_raw",
|
||||
version: 1,
|
||||
arg_layout: &INT_RET,
|
||||
arg_nullable: &[false; INT_RET.len()],
|
||||
ret_layout: &COLOR_RET,
|
||||
parameter_names: &["raw"],
|
||||
cost_cycles: 1,
|
||||
cost_model: crate::IntrinsicCostModel::Fixed,
|
||||
cost_arg_index: None,
|
||||
cost_per_byte: 0,
|
||||
attempt_cost_cycles: 0,
|
||||
max_attempts: 0,
|
||||
mutates_guest_state: false,
|
||||
@@ -614,10 +638,13 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
|
||||
name: "rgb",
|
||||
version: 1,
|
||||
arg_layout: &COLOR_RGB_ARGS,
|
||||
arg_nullable: &[false; COLOR_RGB_ARGS.len()],
|
||||
ret_layout: &COLOR_RET,
|
||||
parameter_names: &["r", "g", "b"],
|
||||
cost_cycles: 1,
|
||||
cost_model: crate::IntrinsicCostModel::Fixed,
|
||||
cost_arg_index: None,
|
||||
cost_per_byte: 0,
|
||||
attempt_cost_cycles: 0,
|
||||
max_attempts: 0,
|
||||
mutates_guest_state: false,
|
||||
@@ -631,10 +658,13 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
|
||||
name: "rgba",
|
||||
version: 1,
|
||||
arg_layout: &COLOR_RGBA_ARGS,
|
||||
arg_nullable: &[false; COLOR_RGBA_ARGS.len()],
|
||||
ret_layout: &COLOR_RET,
|
||||
parameter_names: &["r", "g", "b", "a"],
|
||||
cost_cycles: 1,
|
||||
cost_model: crate::IntrinsicCostModel::Fixed,
|
||||
cost_arg_index: None,
|
||||
cost_per_byte: 0,
|
||||
attempt_cost_cycles: 0,
|
||||
max_attempts: 0,
|
||||
mutates_guest_state: false,
|
||||
@@ -648,10 +678,13 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
|
||||
name: "html_rgba",
|
||||
version: 1,
|
||||
arg_layout: &COLOR_HTML_RGBA_ARGS,
|
||||
arg_nullable: &[false; COLOR_HTML_RGBA_ARGS.len()],
|
||||
ret_layout: &COLOR_RET,
|
||||
parameter_names: &["value"],
|
||||
cost_cycles: 1,
|
||||
cost_model: crate::IntrinsicCostModel::Fixed,
|
||||
cost_arg_index: None,
|
||||
cost_per_byte: 0,
|
||||
attempt_cost_cycles: 0,
|
||||
max_attempts: 0,
|
||||
mutates_guest_state: false,
|
||||
@@ -665,10 +698,13 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
|
||||
name: "gray_scale",
|
||||
version: 1,
|
||||
arg_layout: &INT_RET,
|
||||
arg_nullable: &[false; INT_RET.len()],
|
||||
ret_layout: &COLOR_RET,
|
||||
parameter_names: &["value"],
|
||||
cost_cycles: 1,
|
||||
cost_model: crate::IntrinsicCostModel::Fixed,
|
||||
cost_arg_index: None,
|
||||
cost_per_byte: 0,
|
||||
attempt_cost_cycles: 0,
|
||||
max_attempts: 0,
|
||||
mutates_guest_state: false,
|
||||
@@ -682,10 +718,13 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
|
||||
name: "hex",
|
||||
version: 1,
|
||||
arg_layout: &COLOR_ARGS,
|
||||
arg_nullable: &[false; COLOR_ARGS.len()],
|
||||
ret_layout: &INT_RET,
|
||||
parameter_names: &["color"],
|
||||
cost_cycles: 1,
|
||||
cost_model: crate::IntrinsicCostModel::Fixed,
|
||||
cost_arg_index: None,
|
||||
cost_per_byte: 0,
|
||||
attempt_cost_cycles: 0,
|
||||
max_attempts: 0,
|
||||
mutates_guest_state: false,
|
||||
@@ -699,10 +738,13 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
|
||||
name: "alpha",
|
||||
version: 1,
|
||||
arg_layout: &COLOR_ARGS,
|
||||
arg_nullable: &[false; COLOR_ARGS.len()],
|
||||
ret_layout: &INT_RET,
|
||||
parameter_names: &["color"],
|
||||
cost_cycles: 1,
|
||||
cost_model: crate::IntrinsicCostModel::Fixed,
|
||||
cost_arg_index: None,
|
||||
cost_per_byte: 0,
|
||||
attempt_cost_cycles: 0,
|
||||
max_attempts: 0,
|
||||
mutates_guest_state: false,
|
||||
@@ -716,10 +758,13 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
|
||||
name: "black",
|
||||
version: 1,
|
||||
arg_layout: &NO_ARGS,
|
||||
arg_nullable: &[false; NO_ARGS.len()],
|
||||
ret_layout: &COLOR_RET,
|
||||
parameter_names: &[],
|
||||
cost_cycles: 1,
|
||||
cost_model: crate::IntrinsicCostModel::Fixed,
|
||||
cost_arg_index: None,
|
||||
cost_per_byte: 0,
|
||||
attempt_cost_cycles: 0,
|
||||
max_attempts: 0,
|
||||
mutates_guest_state: false,
|
||||
@@ -733,10 +778,13 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
|
||||
name: "white",
|
||||
version: 1,
|
||||
arg_layout: &NO_ARGS,
|
||||
arg_nullable: &[false; NO_ARGS.len()],
|
||||
ret_layout: &COLOR_RET,
|
||||
parameter_names: &[],
|
||||
cost_cycles: 1,
|
||||
cost_model: crate::IntrinsicCostModel::Fixed,
|
||||
cost_arg_index: None,
|
||||
cost_per_byte: 0,
|
||||
attempt_cost_cycles: 0,
|
||||
max_attempts: 0,
|
||||
mutates_guest_state: false,
|
||||
@@ -750,10 +798,13 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
|
||||
name: "red",
|
||||
version: 1,
|
||||
arg_layout: &NO_ARGS,
|
||||
arg_nullable: &[false; NO_ARGS.len()],
|
||||
ret_layout: &COLOR_RET,
|
||||
parameter_names: &[],
|
||||
cost_cycles: 1,
|
||||
cost_model: crate::IntrinsicCostModel::Fixed,
|
||||
cost_arg_index: None,
|
||||
cost_per_byte: 0,
|
||||
attempt_cost_cycles: 0,
|
||||
max_attempts: 0,
|
||||
mutates_guest_state: false,
|
||||
@@ -767,10 +818,13 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
|
||||
name: "green",
|
||||
version: 1,
|
||||
arg_layout: &NO_ARGS,
|
||||
arg_nullable: &[false; NO_ARGS.len()],
|
||||
ret_layout: &COLOR_RET,
|
||||
parameter_names: &[],
|
||||
cost_cycles: 1,
|
||||
cost_model: crate::IntrinsicCostModel::Fixed,
|
||||
cost_arg_index: None,
|
||||
cost_per_byte: 0,
|
||||
attempt_cost_cycles: 0,
|
||||
max_attempts: 0,
|
||||
mutates_guest_state: false,
|
||||
@@ -784,10 +838,13 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
|
||||
name: "blue",
|
||||
version: 1,
|
||||
arg_layout: &NO_ARGS,
|
||||
arg_nullable: &[false; NO_ARGS.len()],
|
||||
ret_layout: &COLOR_RET,
|
||||
parameter_names: &[],
|
||||
cost_cycles: 1,
|
||||
cost_model: crate::IntrinsicCostModel::Fixed,
|
||||
cost_arg_index: None,
|
||||
cost_per_byte: 0,
|
||||
attempt_cost_cycles: 0,
|
||||
max_attempts: 0,
|
||||
mutates_guest_state: false,
|
||||
@@ -801,10 +858,13 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
|
||||
name: "yellow",
|
||||
version: 1,
|
||||
arg_layout: &NO_ARGS,
|
||||
arg_nullable: &[false; NO_ARGS.len()],
|
||||
ret_layout: &COLOR_RET,
|
||||
parameter_names: &[],
|
||||
cost_cycles: 1,
|
||||
cost_model: crate::IntrinsicCostModel::Fixed,
|
||||
cost_arg_index: None,
|
||||
cost_per_byte: 0,
|
||||
attempt_cost_cycles: 0,
|
||||
max_attempts: 0,
|
||||
mutates_guest_state: false,
|
||||
@@ -818,10 +878,13 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
|
||||
name: "orange",
|
||||
version: 1,
|
||||
arg_layout: &NO_ARGS,
|
||||
arg_nullable: &[false; NO_ARGS.len()],
|
||||
ret_layout: &COLOR_RET,
|
||||
parameter_names: &[],
|
||||
cost_cycles: 1,
|
||||
cost_model: crate::IntrinsicCostModel::Fixed,
|
||||
cost_arg_index: None,
|
||||
cost_per_byte: 0,
|
||||
attempt_cost_cycles: 0,
|
||||
max_attempts: 0,
|
||||
mutates_guest_state: false,
|
||||
@@ -835,10 +898,13 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
|
||||
name: "indigo",
|
||||
version: 1,
|
||||
arg_layout: &NO_ARGS,
|
||||
arg_nullable: &[false; NO_ARGS.len()],
|
||||
ret_layout: &COLOR_RET,
|
||||
parameter_names: &[],
|
||||
cost_cycles: 1,
|
||||
cost_model: crate::IntrinsicCostModel::Fixed,
|
||||
cost_arg_index: None,
|
||||
cost_per_byte: 0,
|
||||
attempt_cost_cycles: 0,
|
||||
max_attempts: 0,
|
||||
mutates_guest_state: false,
|
||||
@@ -852,10 +918,13 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
|
||||
name: "gray",
|
||||
version: 1,
|
||||
arg_layout: &NO_ARGS,
|
||||
arg_nullable: &[false; NO_ARGS.len()],
|
||||
ret_layout: &COLOR_RET,
|
||||
parameter_names: &[],
|
||||
cost_cycles: 1,
|
||||
cost_model: crate::IntrinsicCostModel::Fixed,
|
||||
cost_arg_index: None,
|
||||
cost_per_byte: 0,
|
||||
attempt_cost_cycles: 0,
|
||||
max_attempts: 0,
|
||||
mutates_guest_state: false,
|
||||
@@ -869,10 +938,13 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
|
||||
name: "cyan",
|
||||
version: 1,
|
||||
arg_layout: &NO_ARGS,
|
||||
arg_nullable: &[false; NO_ARGS.len()],
|
||||
ret_layout: &COLOR_RET,
|
||||
parameter_names: &[],
|
||||
cost_cycles: 1,
|
||||
cost_model: crate::IntrinsicCostModel::Fixed,
|
||||
cost_arg_index: None,
|
||||
cost_per_byte: 0,
|
||||
attempt_cost_cycles: 0,
|
||||
max_attempts: 0,
|
||||
mutates_guest_state: false,
|
||||
@@ -886,10 +958,13 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
|
||||
name: "magenta",
|
||||
version: 1,
|
||||
arg_layout: &NO_ARGS,
|
||||
arg_nullable: &[false; NO_ARGS.len()],
|
||||
ret_layout: &COLOR_RET,
|
||||
parameter_names: &[],
|
||||
cost_cycles: 1,
|
||||
cost_model: crate::IntrinsicCostModel::Fixed,
|
||||
cost_arg_index: None,
|
||||
cost_per_byte: 0,
|
||||
attempt_cost_cycles: 0,
|
||||
max_attempts: 0,
|
||||
mutates_guest_state: false,
|
||||
@@ -903,10 +978,13 @@ const INTRINSICS: [IntrinsicMeta; 21] = [
|
||||
name: "transparent",
|
||||
version: 1,
|
||||
arg_layout: &NO_ARGS,
|
||||
arg_nullable: &[false; NO_ARGS.len()],
|
||||
ret_layout: &COLOR_RET,
|
||||
parameter_names: &[],
|
||||
cost_cycles: 1,
|
||||
cost_model: crate::IntrinsicCostModel::Fixed,
|
||||
cost_arg_index: None,
|
||||
cost_per_byte: 0,
|
||||
attempt_cost_cycles: 0,
|
||||
max_attempts: 0,
|
||||
mutates_guest_state: false,
|
||||
@@ -944,6 +1022,7 @@ pub fn lookup_intrinsic(owner: &str, name: &str, version: u16) -> Option<&'stati
|
||||
.chain(crate::input_intrinsics::INPUT_INTRINSICS.iter())
|
||||
.chain(crate::math_intrinsics::MATH_INTRINSICS.iter())
|
||||
.chain(crate::random_intrinsics::RANDOM_INTRINSICS.iter())
|
||||
.chain(crate::hash_intrinsics::HASH_INTRINSICS.iter())
|
||||
.find(|meta| meta.owner == owner && meta.name == name && meta.version == version)
|
||||
}
|
||||
|
||||
@@ -953,6 +1032,7 @@ pub fn lookup_intrinsic_by_id(id: u32) -> Option<&'static IntrinsicMeta> {
|
||||
.chain(crate::input_intrinsics::INPUT_INTRINSICS.iter())
|
||||
.chain(crate::math_intrinsics::MATH_INTRINSICS.iter())
|
||||
.chain(crate::random_intrinsics::RANDOM_INTRINSICS.iter())
|
||||
.chain(crate::hash_intrinsics::HASH_INTRINSICS.iter())
|
||||
.find(|meta| meta.id == id)
|
||||
}
|
||||
|
||||
@@ -1254,9 +1334,17 @@ pub(crate) fn metered_lookup_intrinsic(
|
||||
.chain(crate::input_intrinsics::INPUT_INTRINSICS.iter())
|
||||
.chain(crate::math_intrinsics::MATH_INTRINSICS.iter())
|
||||
.chain(crate::random_intrinsics::RANDOM_INTRINSICS.iter())
|
||||
.chain(crate::hash_intrinsics::HASH_INTRINSICS.iter())
|
||||
{
|
||||
budget.work(1)?;
|
||||
if meta.id == id {
|
||||
budget.work(meta.arg_slots() + 1)?;
|
||||
meta.validate_descriptor().map_err(|_| {
|
||||
prometeu_bytecode::load_limits::LoadFailure::new(
|
||||
prometeu_bytecode::load_limits::LoadCode::InvalidCode,
|
||||
prometeu_bytecode::load_limits::LoadReason::NativeId,
|
||||
)
|
||||
})?;
|
||||
return Ok(Some(meta));
|
||||
}
|
||||
}
|
||||
@@ -1270,6 +1358,7 @@ pub fn intrinsic_catalog() -> impl Iterator<Item = &'static IntrinsicMeta> {
|
||||
.chain(crate::input_intrinsics::INPUT_INTRINSICS.iter())
|
||||
.chain(crate::math_intrinsics::MATH_INTRINSICS.iter())
|
||||
.chain(crate::random_intrinsics::RANDOM_INTRINSICS.iter())
|
||||
.chain(crate::hash_intrinsics::HASH_INTRINSICS.iter())
|
||||
}
|
||||
pub fn builtin_constant_catalog() -> impl Iterator<Item = &'static BuiltinConstMeta> {
|
||||
BUILTIN_CONSTS.iter()
|
||||
|
||||
@@ -16,14 +16,15 @@ fn atom(t: AbiType) -> String {
|
||||
}
|
||||
pub fn intrinsic_catalog_csv() -> String {
|
||||
let mut out = String::from(
|
||||
"final_id_hex,final_id_dec,canonical_name,canonical_version,owner,name,arg_slots,ret_slots,arg_layout,ret_layout,deterministic,may_allocate,parameter_names,cost_cycles,mutates_guest_state,cost_model,attempt_cost_cycles,max_attempts\n",
|
||||
"final_id_hex,final_id_dec,canonical_name,canonical_version,owner,name,arg_slots,ret_slots,arg_layout,ret_layout,deterministic,may_allocate,parameter_names,cost_cycles,mutates_guest_state,cost_model,attempt_cost_cycles,max_attempts,schema_version,arg_nullable,invocation_model,scratch_model,context_access,cost_arg_index,cost_per_byte\n",
|
||||
);
|
||||
let mut entries: Vec<_> = intrinsic_catalog().collect();
|
||||
entries.sort_by_key(|m| m.id);
|
||||
for m in entries {
|
||||
m.validate_descriptor().expect("valid canonical intrinsic descriptor");
|
||||
writeln!(
|
||||
&mut out,
|
||||
"0x{:04X},{},{}.{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}",
|
||||
"0x{:04X},{},{}.{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},2,{},{},{},{},{},{}",
|
||||
m.id,
|
||||
m.id,
|
||||
m.owner,
|
||||
@@ -42,7 +43,13 @@ pub fn intrinsic_catalog_csv() -> String {
|
||||
m.mutates_guest_state,
|
||||
m.cost_model.name(),
|
||||
m.attempt_cost_cycles,
|
||||
m.max_attempts
|
||||
m.max_attempts,
|
||||
m.arg_nullable.iter().map(bool::to_string).collect::<Vec<_>>().join("|"),
|
||||
m.invocation_model(),
|
||||
m.scratch_model(),
|
||||
m.context_access(),
|
||||
m.cost_arg_index.map_or_else(String::new, |i| i.to_string()),
|
||||
m.cost_per_byte
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
use crate::{
|
||||
AbiType, BuiltinScalarType as S, IntrinsicCostModel as C, IntrinsicExecutionError as E,
|
||||
IntrinsicImplementation as I, IntrinsicMeta, IntrinsicResults,
|
||||
};
|
||||
use prometeu_bytecode::Value;
|
||||
|
||||
const fn entry(
|
||||
id: u32,
|
||||
name: &'static str,
|
||||
abi: AbiType,
|
||||
nullable: bool,
|
||||
handler: crate::IntrinsicInlineImplementation,
|
||||
) -> IntrinsicMeta {
|
||||
IntrinsicMeta {
|
||||
id,
|
||||
owner: "hash",
|
||||
name,
|
||||
version: 1,
|
||||
arg_layout: match abi {
|
||||
AbiType::Scalar(S::Int64) => &[AbiType::Scalar(S::Int64)],
|
||||
AbiType::Scalar(S::Float) => &[AbiType::Scalar(S::Float)],
|
||||
AbiType::Scalar(S::String) => &[AbiType::Scalar(S::String)],
|
||||
_ => panic!("unsupported hash input ABI"),
|
||||
},
|
||||
ret_layout: &[AbiType::Scalar(S::Int64)],
|
||||
arg_nullable: if nullable { &[true] } else { &[false] },
|
||||
parameter_names: &["value"],
|
||||
cost_cycles: 8,
|
||||
cost_model: if matches!(abi, AbiType::Scalar(S::String)) {
|
||||
C::ArgumentUtf8BytesV1
|
||||
} else {
|
||||
C::Fixed
|
||||
},
|
||||
cost_arg_index: if matches!(abi, AbiType::Scalar(S::String)) { Some(0) } else { None },
|
||||
cost_per_byte: if matches!(abi, AbiType::Scalar(S::String)) { 1 } else { 0 },
|
||||
attempt_cost_cycles: 0,
|
||||
max_attempts: 0,
|
||||
mutates_guest_state: false,
|
||||
deterministic: true,
|
||||
may_allocate: false,
|
||||
implementation: I::BorrowedInline(handler),
|
||||
}
|
||||
}
|
||||
pub(crate) const HASH_INTRINSICS: [IntrinsicMeta; 3] = [
|
||||
entry(0x4100, "i64", AbiType::Scalar(S::Int64), false, hash_i64),
|
||||
entry(0x4101, "float", AbiType::Scalar(S::Float), false, hash_float),
|
||||
entry(0x4102, "string", AbiType::Scalar(S::String), true, hash_string),
|
||||
];
|
||||
fn hash_i64(args: &[Value], out: &mut IntrinsicResults) -> Result<(), E> {
|
||||
let Value::Int64(value) = args[0] else { unreachable!("exact validated Int64") };
|
||||
out.push(Value::Int64(crate::hashing::xxh64(&value.to_le_bytes()) as i64))
|
||||
}
|
||||
fn hash_float(args: &[Value], out: &mut IntrinsicResults) -> Result<(), E> {
|
||||
let Value::Float(value) = args[0] else { unreachable!("exact validated Float") };
|
||||
crate::numeric::check_inputs(&[value])?;
|
||||
let bits = if value == 0.0 { 0 } else { value.to_bits() };
|
||||
out.push(Value::Int64(crate::hashing::xxh64(&bits.to_le_bytes()) as i64))
|
||||
}
|
||||
fn hash_string(args: &[Value], out: &mut IntrinsicResults) -> Result<(), E> {
|
||||
let hash = match &args[0] {
|
||||
Value::Null => 0,
|
||||
Value::String(s) => crate::hashing::xxh64(s.as_bytes()) as i64,
|
||||
_ => unreachable!("exact validated nullable String"),
|
||||
};
|
||||
out.push(Value::Int64(hash))
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
//! Hash-v1: portable XXH64, seed zero, over explicit machine byte encodings.
|
||||
use prometeu_bytecode::HeapRef;
|
||||
|
||||
const P1: u64 = 0x9E3779B185EBCA87;
|
||||
const P2: u64 = 0xC2B2AE3D27D4EB4F;
|
||||
const P3: u64 = 0x165667B19E3779F9;
|
||||
const P4: u64 = 0x85EBCA77C2B2AE63;
|
||||
const P5: u64 = 0x27D4EB2F165667C5;
|
||||
|
||||
fn word(bytes: &[u8]) -> u64 {
|
||||
u64::from_le_bytes(bytes[..8].try_into().expect("complete XXH64 lane"))
|
||||
}
|
||||
fn round(acc: u64, lane: u64) -> u64 {
|
||||
acc.wrapping_add(lane.wrapping_mul(P2)).rotate_left(31).wrapping_mul(P1)
|
||||
}
|
||||
fn merge(acc: u64, lane: u64) -> u64 {
|
||||
(acc ^ round(0, lane)).wrapping_mul(P1).wrapping_add(P4)
|
||||
}
|
||||
|
||||
pub(crate) fn xxh64(mut bytes: &[u8]) -> u64 {
|
||||
let length = bytes.len() as u64;
|
||||
let mut hash = if bytes.len() >= 32 {
|
||||
let mut acc = [P1.wrapping_add(P2), P2, 0, 0u64.wrapping_sub(P1)];
|
||||
while bytes.len() >= 32 {
|
||||
for (index, value) in acc.iter_mut().enumerate() {
|
||||
*value = round(*value, word(&bytes[index * 8..]));
|
||||
}
|
||||
bytes = &bytes[32..];
|
||||
}
|
||||
let mut hash = acc[0]
|
||||
.rotate_left(1)
|
||||
.wrapping_add(acc[1].rotate_left(7))
|
||||
.wrapping_add(acc[2].rotate_left(12))
|
||||
.wrapping_add(acc[3].rotate_left(18));
|
||||
for value in acc {
|
||||
hash = merge(hash, value);
|
||||
}
|
||||
hash
|
||||
} else {
|
||||
P5
|
||||
};
|
||||
hash = hash.wrapping_add(length);
|
||||
while bytes.len() >= 8 {
|
||||
hash ^= round(0, word(bytes));
|
||||
hash = hash.rotate_left(27).wrapping_mul(P1).wrapping_add(P4);
|
||||
bytes = &bytes[8..];
|
||||
}
|
||||
if bytes.len() >= 4 {
|
||||
hash ^= u64::from(u32::from_le_bytes(bytes[..4].try_into().unwrap())).wrapping_mul(P1);
|
||||
hash = hash.rotate_left(23).wrapping_mul(P2).wrapping_add(P3);
|
||||
bytes = &bytes[4..];
|
||||
}
|
||||
for byte in bytes {
|
||||
hash ^= u64::from(*byte).wrapping_mul(P5);
|
||||
hash = hash.rotate_left(11).wrapping_mul(P1);
|
||||
}
|
||||
hash ^= hash >> 33;
|
||||
hash = hash.wrapping_mul(P2);
|
||||
hash ^= hash >> 29;
|
||||
hash = hash.wrapping_mul(P3);
|
||||
hash ^ (hash >> 32)
|
||||
}
|
||||
|
||||
pub(crate) fn reference(value: Option<HeapRef>) -> i64 {
|
||||
value.map_or(0, |reference| {
|
||||
let mut bytes = [0; 8];
|
||||
bytes[..4].copy_from_slice(&reference.index.to_le_bytes());
|
||||
bytes[4..].copy_from_slice(&reference.generation.to_le_bytes());
|
||||
xxh64(&bytes) as i64
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
#[test]
|
||||
fn matches_all_independent_c_reference_vectors() {
|
||||
let mut count = 0;
|
||||
for row in include_str!("../tests/fixtures/hash-conformance.tsv").lines().skip(1) {
|
||||
let f: Vec<_> = row.split('\t').collect();
|
||||
let expected = u64::from_str_radix(f[2], 16).unwrap();
|
||||
let actual = match f[0] {
|
||||
"bytes" | "string" => {
|
||||
let bytes: Vec<_> = (0..f[1].len())
|
||||
.step_by(2)
|
||||
.map(|i| u8::from_str_radix(&f[1][i..i + 2], 16).unwrap())
|
||||
.collect();
|
||||
xxh64(&bytes)
|
||||
}
|
||||
"i64" => xxh64(&f[1].parse::<i64>().unwrap().to_le_bytes()),
|
||||
"float" => {
|
||||
let bits = u64::from_str_radix(f[1], 16).unwrap();
|
||||
let bits = if f64::from_bits(bits) == 0.0 { 0 } else { bits };
|
||||
xxh64(&bits.to_le_bytes())
|
||||
}
|
||||
"reference" => {
|
||||
let (index, generation) = f[1].split_once(',').unwrap();
|
||||
reference(Some(HeapRef {
|
||||
index: index.parse().unwrap(),
|
||||
generation: generation.parse().unwrap(),
|
||||
})) as u64
|
||||
}
|
||||
"null" => reference(None) as u64,
|
||||
kind => panic!("unknown vector {kind}"),
|
||||
};
|
||||
assert_eq!(actual, expected, "{row}");
|
||||
count += 1;
|
||||
}
|
||||
assert_eq!(count, 118);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sequential_handles_spread_and_bucket_collisions_do_not_imply_identity() {
|
||||
let mut buckets = [0; 256];
|
||||
let mut first = [None; 256];
|
||||
let mut collisions = 0;
|
||||
for index in 1..=16384 {
|
||||
let handle = HeapRef { index, generation: 1 };
|
||||
let bucket = reference(Some(handle)) as u64 as usize & 255;
|
||||
buckets[bucket] += 1;
|
||||
if let Some(previous) = first[bucket] {
|
||||
assert_ne!(previous, handle);
|
||||
collisions += 1;
|
||||
} else {
|
||||
first[bucket] = Some(handle);
|
||||
}
|
||||
}
|
||||
assert!(buckets.iter().all(|&count| (32..=100).contains(&count)), "{buckets:?}");
|
||||
assert_eq!(collisions, 16384 - 256);
|
||||
}
|
||||
}
|
||||
@@ -428,6 +428,34 @@ impl Heap {
|
||||
self.allocation_count.load(Ordering::Relaxed)
|
||||
}
|
||||
|
||||
/// Host-side observations only, outside guest execution and atomic commits.
|
||||
#[cfg(feature = "resource-diagnostics")]
|
||||
pub fn diagnostic_typed_storage(&self) -> Vec<crate::resource_diagnostics::StorageObject> {
|
||||
use crate::resource_diagnostics::{StorageObject, StorageValue};
|
||||
self.objects
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter_map(|(index, object)| {
|
||||
let storage = object.as_ref()?.typed.as_ref()?;
|
||||
let groups = (0..storage.len())
|
||||
.map(|i| {
|
||||
storage
|
||||
.read(i)
|
||||
.expect("initialized typed storage")
|
||||
.as_slice()
|
||||
.iter()
|
||||
.map(StorageValue::observe)
|
||||
.collect()
|
||||
})
|
||||
.collect();
|
||||
Some(StorageObject {
|
||||
reference: HeapRef { index: index as u32, generation: self.generations[index] },
|
||||
type_id: storage.type_id(),
|
||||
groups,
|
||||
})
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
#[cfg(feature = "resource-diagnostics")]
|
||||
pub(crate) fn diagnostic_handles(&self) -> (usize, usize) {
|
||||
(self.free_list.len(), self.objects.len() - self.free_list.len() - self.len())
|
||||
@@ -520,6 +548,18 @@ impl Heap {
|
||||
value_contract::validate(registry, self, storage.slot_type(index)?, values.as_slice())?;
|
||||
Ok(values)
|
||||
}
|
||||
/// Caller has checked all receivers, bounds and groups for the entire attempt.
|
||||
/// This commit path performs no allocation, provenance lookup or guest callback.
|
||||
pub(crate) fn commit_typed(&mut self, r: HeapRef, index: usize, values: &[Value]) {
|
||||
self.objects[r.index as usize]
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.typed
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.write_validated(index, values)
|
||||
.expect("prevalidated storage publication");
|
||||
}
|
||||
pub(crate) fn store_typed(
|
||||
&mut self,
|
||||
registry: &Registry,
|
||||
|
||||
@@ -20,10 +20,13 @@ const fn query(
|
||||
name,
|
||||
version: 1,
|
||||
arg_layout: &[],
|
||||
arg_nullable: &[],
|
||||
ret_layout,
|
||||
parameter_names: &[],
|
||||
cost_cycles: 1,
|
||||
cost_model: crate::IntrinsicCostModel::Fixed,
|
||||
cost_arg_index: None,
|
||||
cost_per_byte: 0,
|
||||
attempt_cost_cycles: 0,
|
||||
max_attempts: 0,
|
||||
mutates_guest_state: false,
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
//! The native handler variant and descriptor jointly define the invocation contract.
|
||||
use crate::{
|
||||
AbiType, BuiltinScalarType, IntrinsicCostModel, IntrinsicExecutionError as E,
|
||||
IntrinsicImplementation as I, IntrinsicMeta,
|
||||
};
|
||||
use prometeu_bytecode::Value;
|
||||
|
||||
pub type IntrinsicInlineImplementation = fn(&[Value], &mut IntrinsicResults) -> Result<(), E>;
|
||||
const INLINE_SLOTS: usize = 3;
|
||||
|
||||
/// Fixed native staging only; no heap buffer or mutable execution context.
|
||||
#[derive(Debug)]
|
||||
pub struct IntrinsicResults {
|
||||
values: [Value; INLINE_SLOTS],
|
||||
len: usize,
|
||||
limit: usize,
|
||||
overflowed: bool,
|
||||
}
|
||||
impl IntrinsicResults {
|
||||
pub(crate) fn new(limit: usize) -> Self {
|
||||
assert!(limit <= INLINE_SLOTS);
|
||||
Self { values: [const { Value::Null }; INLINE_SLOTS], len: 0, limit, overflowed: false }
|
||||
}
|
||||
pub fn push(&mut self, value: Value) -> Result<(), E> {
|
||||
if self.len >= self.limit {
|
||||
self.overflowed = true;
|
||||
return Err(E::ArityMismatch { expected: self.limit, got: self.len + 1 });
|
||||
}
|
||||
self.values[self.len] = value;
|
||||
self.len += 1;
|
||||
Ok(())
|
||||
}
|
||||
pub(crate) fn validate(&self, meta: &IntrinsicMeta) -> Result<(), E> {
|
||||
if self.overflowed {
|
||||
return Err(E::ArityMismatch { expected: self.limit, got: self.limit + 1 });
|
||||
}
|
||||
meta.validate_result_values(&self.values[..self.len])
|
||||
}
|
||||
pub(crate) fn as_slice(&self) -> &[Value] {
|
||||
&self.values[..self.len]
|
||||
}
|
||||
pub(crate) fn into_values(self) -> impl Iterator<Item = Value> {
|
||||
self.values.into_iter().take(self.len)
|
||||
}
|
||||
}
|
||||
|
||||
impl IntrinsicMeta {
|
||||
pub fn invocation_model(&self) -> &'static str {
|
||||
match self.implementation {
|
||||
I::Host(_) => "host_buffered_v1",
|
||||
I::VmOwned => "vm_owned_v1",
|
||||
I::BorrowedInline(_) => "borrowed_inline_v1",
|
||||
}
|
||||
}
|
||||
pub fn scratch_model(&self) -> &'static str {
|
||||
match self.implementation {
|
||||
I::BorrowedInline(_) => "none",
|
||||
_ => "existing_contract_v1",
|
||||
}
|
||||
}
|
||||
pub fn context_access(&self) -> &'static str {
|
||||
match self.implementation {
|
||||
I::Host(_) => "host",
|
||||
I::VmOwned => "vm_state",
|
||||
I::BorrowedInline(_) => "none",
|
||||
}
|
||||
}
|
||||
/// Derivation from the handler variant makes incompatible profile claims unrepresentable.
|
||||
pub fn validate_descriptor(&self) -> Result<(), &'static str> {
|
||||
if self.arg_nullable.len() != self.arg_slots()
|
||||
|| self.parameter_names.len() != self.arg_slots()
|
||||
{
|
||||
return Err("argument metadata widths disagree");
|
||||
}
|
||||
for abi in self.arg_layout.iter().chain(self.ret_layout) {
|
||||
if !matches!(abi, AbiType::Scalar(_))
|
||||
&& !matches!(abi, AbiType::Builtin(key) if (key.name == "Random" || key.name == "color") && key.version == 1)
|
||||
{
|
||||
return Err("unsupported intrinsic ABI layout");
|
||||
}
|
||||
}
|
||||
for (abi, nullable) in self.arg_layout.iter().zip(self.arg_nullable) {
|
||||
let permits_null = matches!(abi, AbiType::Scalar(BuiltinScalarType::String))
|
||||
|| matches!(abi, AbiType::Builtin(key) if key.name == "Random" && key.version == 1);
|
||||
if *nullable && !permits_null {
|
||||
return Err("non-nullable ABI carrier declared nullable");
|
||||
}
|
||||
}
|
||||
match self.cost_model {
|
||||
IntrinsicCostModel::Fixed => {
|
||||
if self.cost_arg_index.is_some()
|
||||
|| self.cost_per_byte != 0
|
||||
|| self.attempt_cost_cycles != 0
|
||||
|| self.max_attempts != 0
|
||||
{
|
||||
return Err("fixed cost has variable parameters");
|
||||
}
|
||||
}
|
||||
IntrinsicCostModel::RandomRejectionV1 => {
|
||||
if !matches!(self.implementation, I::VmOwned)
|
||||
|| self.cost_arg_index.is_some()
|
||||
|| self.cost_per_byte != 0
|
||||
|| self.attempt_cost_cycles == 0
|
||||
|| self.max_attempts == 0
|
||||
{
|
||||
return Err("invalid random rejection cost parameters");
|
||||
}
|
||||
}
|
||||
IntrinsicCostModel::ArgumentUtf8BytesV1 => {
|
||||
if !matches!(self.implementation, I::BorrowedInline(_))
|
||||
|| self.cost_arg_index.and_then(|i| self.arg_layout.get(i))
|
||||
!= Some(&AbiType::Scalar(BuiltinScalarType::String))
|
||||
|| self.cost_per_byte == 0
|
||||
|| self.attempt_cost_cycles != 0
|
||||
|| self.max_attempts != 0
|
||||
{
|
||||
return Err("invalid String byte-cost parameters");
|
||||
}
|
||||
}
|
||||
}
|
||||
if matches!(self.implementation, I::BorrowedInline(_))
|
||||
&& (self.ret_slots() > INLINE_SLOTS
|
||||
|| self.ret_slots() > self.arg_slots()
|
||||
|| self.may_allocate
|
||||
|| self.mutates_guest_state
|
||||
|| !self.deterministic)
|
||||
{
|
||||
return Err("handler violates bounded invocation capabilities");
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
/// None is checked cost overflow. Wrong/missing carriers have no inferred length.
|
||||
pub(crate) fn attempted_cost(&self, args: &[Value]) -> Option<u64> {
|
||||
if self.cost_model != IntrinsicCostModel::ArgumentUtf8BytesV1 {
|
||||
return Some(self.cost_cycles);
|
||||
}
|
||||
let bytes = match self.cost_arg_index.and_then(|i| args.get(i)) {
|
||||
Some(Value::String(value)) => value.len() as u64,
|
||||
_ => 0,
|
||||
};
|
||||
bytes.checked_mul(self.cost_per_byte)?.checked_add(self.cost_cycles)
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,11 @@
|
||||
extern crate self as prometeu_vm;
|
||||
mod builtins;
|
||||
mod catalog;
|
||||
mod hash_intrinsics;
|
||||
mod hashing;
|
||||
mod intrinsic_contract;
|
||||
pub use catalog::{builtin_constant_catalog_csv, intrinsic_catalog_csv};
|
||||
pub use intrinsic_contract::{IntrinsicInlineImplementation, IntrinsicResults};
|
||||
mod call_frame;
|
||||
mod input_intrinsics;
|
||||
mod math_intrinsics;
|
||||
|
||||
@@ -20,10 +20,17 @@ const fn entry<const ID: u32>(
|
||||
name,
|
||||
version: 1,
|
||||
arg_layout,
|
||||
arg_nullable: match arg_layout.len() {
|
||||
1 => &[false],
|
||||
2 => &[false, false],
|
||||
_ => &[false, false, false],
|
||||
},
|
||||
ret_layout,
|
||||
parameter_names,
|
||||
cost_cycles,
|
||||
cost_model: crate::IntrinsicCostModel::Fixed,
|
||||
cost_arg_index: None,
|
||||
cost_per_byte: 0,
|
||||
attempt_cost_cycles: 0,
|
||||
max_attempts: 0,
|
||||
mutates_guest_state: false,
|
||||
|
||||
@@ -21,6 +21,13 @@ const fn entry(
|
||||
name,
|
||||
version: 1,
|
||||
arg_layout: args,
|
||||
arg_nullable: if id == 0x4000 {
|
||||
&[false]
|
||||
} else if rejection {
|
||||
&[true, false, false]
|
||||
} else {
|
||||
&[true]
|
||||
},
|
||||
ret_layout: ret,
|
||||
parameter_names: names,
|
||||
cost_cycles: cost,
|
||||
@@ -29,6 +36,8 @@ const fn entry(
|
||||
} else {
|
||||
IntrinsicCostModel::Fixed
|
||||
},
|
||||
cost_arg_index: None,
|
||||
cost_per_byte: 0,
|
||||
attempt_cost_cycles: if rejection { 8 } else { 0 },
|
||||
max_attempts: if rejection { crate::random::MAX_ATTEMPTS } else { 0 },
|
||||
deterministic: true,
|
||||
|
||||
@@ -485,6 +485,10 @@ fn transfer(
|
||||
group(&mut working[base..], registry, ty, (instruction.pc as u64) << 32, budget)?;
|
||||
}
|
||||
}
|
||||
Op::RefIdentityHash => {
|
||||
budget.work(1)?;
|
||||
working[base] = Fact::Carrier(I64);
|
||||
}
|
||||
Op::RefCast | Op::RefToTrait => {
|
||||
group(
|
||||
&mut working[base..],
|
||||
@@ -503,6 +507,7 @@ fn transfer(
|
||||
| Op::And
|
||||
| Op::Or
|
||||
| Op::Not
|
||||
| Op::RefIdentityEq
|
||||
| Op::RefIsExact
|
||||
| Op::RefImplements
|
||||
| Op::DynCanUnpack => {
|
||||
@@ -705,6 +710,15 @@ fn check(
|
||||
}
|
||||
}
|
||||
Op::ArrayNew => require(working[end - 1], I64, 0, registry, budget)?,
|
||||
Op::ArrayCopy => {
|
||||
let array = TypeId(instruction.imm_u32().unwrap());
|
||||
let base = end - 5;
|
||||
check_group(&working[base..base + 1], array, registry, budget)?;
|
||||
check_group(&working[base + 2..base + 3], array, registry, budget)?;
|
||||
for i in [1, 3, 4] {
|
||||
require(working[base + i], I64, i, registry, budget)?;
|
||||
}
|
||||
}
|
||||
Op::StructGet | Op::StructSet | Op::ArrayLen | Op::ArrayGet | Op::ArraySet => {
|
||||
budget.work(3)?;
|
||||
let (id, field) = if matches!(instruction.opcode, Op::StructGet | Op::StructSet) {
|
||||
@@ -760,6 +774,21 @@ fn check(
|
||||
return Err(mismatch(1));
|
||||
}
|
||||
}
|
||||
Op::RefIdentityHash | Op::RefIdentityEq => {
|
||||
let (left, right) = if instruction.opcode == Op::RefIdentityHash {
|
||||
(instruction.imm_u32().unwrap(), None)
|
||||
} else {
|
||||
let (a, b) = instruction.imm_u32x2().unwrap();
|
||||
(a, Some(b))
|
||||
};
|
||||
let lw = registry.type_layout(TypeId(left)).unwrap().storage.slots as usize;
|
||||
let rw = right
|
||||
.map_or(0, |id| registry.type_layout(TypeId(id)).unwrap().storage.slots as usize);
|
||||
check_group(&working[end - lw - rw..end - rw], TypeId(left), registry, budget)?;
|
||||
if let Some(id) = right {
|
||||
check_group(&working[end - rw..end], TypeId(id), registry, budget)?;
|
||||
}
|
||||
}
|
||||
Op::RefCast | Op::RefToTrait | Op::RefIsExact | Op::RefImplements => {
|
||||
budget.work(1)?;
|
||||
let ty = TypeId(instruction.imm_u32x2().unwrap().0);
|
||||
@@ -772,7 +801,12 @@ fn check(
|
||||
.unwrap();
|
||||
let base = end - native.arg_slots();
|
||||
for (part, abi) in native.arg_layout.iter().enumerate() {
|
||||
require(working[base + part], abi_mask(*abi), part, registry, budget)?;
|
||||
let accepted = if native.arg_nullable[part] {
|
||||
abi_mask(*abi) | NULL
|
||||
} else {
|
||||
abi_mask(*abi) & !NULL
|
||||
};
|
||||
require(working[base + part], accepted, part, registry, budget)?;
|
||||
}
|
||||
}
|
||||
Op::JmpIfTrue | Op::JmpIfFalse | Op::Not => {
|
||||
|
||||
@@ -87,3 +87,39 @@ mod tests {
|
||||
assert_eq!(h.max_ns, 99);
|
||||
}
|
||||
}
|
||||
|
||||
/// Non-owning storage observations for engineering qualification. These values
|
||||
/// never retain a guest object or a native string owner and cannot write storage.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum StorageValue {
|
||||
Null,
|
||||
Int32(i32),
|
||||
Int64(i64),
|
||||
FloatBits(u64),
|
||||
Boolean(bool),
|
||||
Reference(prometeu_bytecode::HeapRef),
|
||||
StringIdentity { address: usize, bytes: usize },
|
||||
}
|
||||
impl StorageValue {
|
||||
pub(crate) fn observe(value: &prometeu_bytecode::Value) -> Self {
|
||||
use prometeu_bytecode::Value;
|
||||
match value {
|
||||
Value::Null => Self::Null,
|
||||
Value::Int32(n) => Self::Int32(*n),
|
||||
Value::Int64(n) => Self::Int64(*n),
|
||||
Value::Float(n) => Self::FloatBits(n.to_bits()),
|
||||
Value::Boolean(n) => Self::Boolean(*n),
|
||||
Value::HeapRef(r) => Self::Reference(*r),
|
||||
Value::String(s) => Self::StringIdentity {
|
||||
address: std::sync::Arc::as_ptr(s) as *const () as usize,
|
||||
bytes: s.len(),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct StorageObject {
|
||||
pub reference: prometeu_bytecode::HeapRef,
|
||||
pub type_id: prometeu_bytecode::registry::TypeId,
|
||||
pub groups: Vec<Vec<StorageValue>>,
|
||||
}
|
||||
|
||||
@@ -221,6 +221,24 @@ pub(crate) fn unpack_dynamic(
|
||||
|
||||
// All reference operations validate complete source values before querying the
|
||||
// underlying concrete object. Invalid handles/pairs never become false or null.
|
||||
pub(crate) fn identity_reference(
|
||||
registry: &Registry,
|
||||
heap: &Heap,
|
||||
source: TypeId,
|
||||
values: &[Value],
|
||||
) -> Result<Option<HeapRef>, ValueError> {
|
||||
let kind = registry.declarations().types.get(source.0 as usize).ok_or(ValueError::Type)?;
|
||||
if !kind.kind.is_identity_reference() {
|
||||
return Err(ValueError::Type);
|
||||
}
|
||||
validate(registry, heap, source, values)?;
|
||||
match values.first() {
|
||||
Some(Value::Null) => Ok(None),
|
||||
Some(Value::HeapRef(reference)) => Ok(Some(*reference)),
|
||||
_ => Err(ValueError::Type),
|
||||
}
|
||||
}
|
||||
|
||||
fn reference(
|
||||
registry: &Registry,
|
||||
heap: &Heap,
|
||||
|
||||
@@ -1,12 +1,20 @@
|
||||
use crate::numeric;
|
||||
use crate::resource_budget::BudgetVec;
|
||||
mod array_copy;
|
||||
#[cfg(test)]
|
||||
mod array_copy_tests;
|
||||
mod callable;
|
||||
#[cfg(test)]
|
||||
#[path = "../tests/support/collections.rs"]
|
||||
mod collection_test_support;
|
||||
mod collections;
|
||||
#[cfg(test)]
|
||||
mod collections_tests;
|
||||
mod control;
|
||||
mod dynamic;
|
||||
mod gc;
|
||||
mod identity;
|
||||
mod intrinsic;
|
||||
mod lifecycle;
|
||||
mod loader;
|
||||
mod native_arrays;
|
||||
@@ -327,8 +335,10 @@ impl VirtualMachine {
|
||||
}
|
||||
|
||||
let charged_math = if opcode == OpCode::Intrinsic {
|
||||
lookup_intrinsic_by_id(instr.imm_u32().unwrap())
|
||||
.filter(|m| m.owner == "vec2" || m.owner == "mathf" || m.owner.starts_with("math."))
|
||||
lookup_intrinsic_by_id(instr.imm_u32().unwrap()).filter(|m| {
|
||||
matches!(m.implementation, crate::IntrinsicImplementation::Host(_))
|
||||
&& (m.owner == "vec2" || m.owner == "mathf" || m.owner.starts_with("math."))
|
||||
})
|
||||
} else {
|
||||
None
|
||||
};
|
||||
@@ -952,6 +962,12 @@ impl VirtualMachine {
|
||||
)
|
||||
})?;
|
||||
|
||||
if matches!(
|
||||
intrinsic.implementation,
|
||||
crate::IntrinsicImplementation::BorrowedInline(_)
|
||||
) {
|
||||
return self.execute_inline_intrinsic(intrinsic, pc_at_intrinsic);
|
||||
}
|
||||
if matches!(intrinsic.implementation, crate::IntrinsicImplementation::VmOwned) {
|
||||
return self.execute_random(intrinsic, pc_at_intrinsic);
|
||||
}
|
||||
@@ -1083,6 +1099,18 @@ impl VirtualMachine {
|
||||
let (source, target) = instr.imm_u32x2().unwrap();
|
||||
return self.execute_reference(opcode, source, target, start_pc as u32);
|
||||
}
|
||||
OpCode::RefIdentityHash | OpCode::RefIdentityEq => {
|
||||
let (left, right) = if opcode == OpCode::RefIdentityHash {
|
||||
(instr.imm_u32().unwrap(), None)
|
||||
} else {
|
||||
let (left, right) = instr.imm_u32x2().unwrap();
|
||||
(left, Some(right))
|
||||
};
|
||||
return self.execute_identity(opcode, left, right, start_pc as u32);
|
||||
}
|
||||
OpCode::ArrayCopy => {
|
||||
return self.execute_array_copy(instr.imm_u32().unwrap(), start_pc as u32);
|
||||
}
|
||||
OpCode::StructNew
|
||||
| OpCode::StructGet
|
||||
| OpCode::StructSet
|
||||
@@ -3893,3 +3921,7 @@ mod callable_tests;
|
||||
|
||||
#[cfg(feature = "resource-diagnostics")]
|
||||
pub mod string_provenance_qualification;
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "virtual_machine/identity_tests.rs"]
|
||||
mod identity_tests;
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
//! Complete-group snapshot copy: charge, validate, prepare, then commit.
|
||||
use super::*;
|
||||
use crate::value_contract::{ValueError, ValueGroup};
|
||||
use prometeu_bytecode::registry::TypeId;
|
||||
|
||||
fn planned_cost(count: u32, width: u64) -> Option<u64> {
|
||||
u64::from(count).checked_mul(2)?.checked_mul(width)?.checked_add(4)
|
||||
}
|
||||
|
||||
impl VirtualMachine {
|
||||
pub(super) fn execute_array_copy(
|
||||
&mut self,
|
||||
array_id: u32,
|
||||
pc: u32,
|
||||
) -> Result<(), LogicalFrameEndingReason> {
|
||||
let opcode = OpCode::ArrayCopy;
|
||||
self.cycles += opcode.cycles();
|
||||
let image = self.validated_image.clone().expect("validated Array TypeId");
|
||||
let registry = image.registry();
|
||||
let array_ty = TypeId(array_id);
|
||||
let element = registry.type_layout(array_ty).unwrap().array.unwrap().element_type_id;
|
||||
let width = registry.type_layout(element).unwrap().storage.slots;
|
||||
if self.temporary_slots() < 5 {
|
||||
return Err(self.trap(
|
||||
TRAP_STACK_UNDERFLOW,
|
||||
opcode as u16,
|
||||
"Incomplete array copy operands".into(),
|
||||
pc,
|
||||
));
|
||||
}
|
||||
let base = self.operand_stack.len() - 5;
|
||||
// Inspect count only to select cost, without changing ordinary fault order.
|
||||
if let Value::Int64(n) = self.operand_stack[base + 4]
|
||||
&& let Ok(n) = u32::try_from(n)
|
||||
{
|
||||
let cost = planned_cost(n, u64::from(width))
|
||||
.ok_or_else(|| self.collection_size_trap(opcode, pc, u64::MAX))?;
|
||||
self.cycles += cost - opcode.cycles();
|
||||
}
|
||||
let receiver = |offset: usize| {
|
||||
let r = match self.operand_stack[base + offset] {
|
||||
Value::HeapRef(r) => r,
|
||||
Value::Null => return Err(self.value_trap(ValueError::NullReference, opcode, pc)),
|
||||
_ => return Err(self.value_trap(ValueError::Type, opcode, pc)),
|
||||
};
|
||||
if self.heap.concrete_type(r, registry).map_err(|e| self.value_trap(e, opcode, pc))?
|
||||
!= array_ty
|
||||
{
|
||||
return Err(self.value_trap(ValueError::Type, opcode, pc));
|
||||
}
|
||||
Ok(r)
|
||||
};
|
||||
let source = receiver(0)?;
|
||||
let target = receiver(2)?;
|
||||
let integer = |offset: usize| match self.operand_stack[base + offset] {
|
||||
Value::Int64(n) => Ok(n),
|
||||
_ => Err(self.value_trap(ValueError::Type, opcode, pc)),
|
||||
};
|
||||
let source_start = integer(1)?;
|
||||
let target_start = integer(3)?;
|
||||
let count = integer(4)?;
|
||||
let range = |r, start: i64| {
|
||||
let len = self
|
||||
.heap
|
||||
.typed_array_len(r, registry)
|
||||
.map_err(|e| self.value_trap(e, opcode, pc))?;
|
||||
if start < 0 || count < 0 || start > len as i64 || count > len as i64 - start {
|
||||
return Err(self.value_trap(ValueError::Bounds, opcode, pc));
|
||||
}
|
||||
Ok(start as usize)
|
||||
};
|
||||
let source_start = range(source, source_start)?;
|
||||
let target_start = range(target, target_start)?;
|
||||
let count = count as usize;
|
||||
// Operands remain roots; every fallible operation precedes shared writes.
|
||||
let mut prepared =
|
||||
BudgetVec::<ValueGroup>::new(&self.budget, RuntimeResource::TemporaryBytes);
|
||||
prepared.reserve(count).map_err(|e| self.resource_trap(e, opcode, pc))?;
|
||||
for i in 0..count {
|
||||
let group = self
|
||||
.heap
|
||||
.load_typed(registry, source, source_start + i)
|
||||
.map_err(|e| self.value_trap(e, opcode, pc))?;
|
||||
prepared.push(group).expect("complete scratch reservation");
|
||||
}
|
||||
// Snapshot captured. No allocation, validation, GC, callback or scheduler.
|
||||
for (i, group) in prepared.iter().enumerate() {
|
||||
self.heap.commit_typed(target, target_start + i, group.as_slice());
|
||||
}
|
||||
self.operand_stack.truncate(base);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::planned_cost;
|
||||
|
||||
#[test]
|
||||
fn checked_cost_covers_the_full_sum_without_wrap_or_saturation() {
|
||||
assert_eq!(planned_cost(10, 1), Some(24));
|
||||
assert_eq!(planned_cost(10, 3), Some(64));
|
||||
assert_eq!(planned_cost(0, u64::MAX), Some(4));
|
||||
assert_eq!(planned_cost(u32::MAX, 3), Some(25_769_803_774));
|
||||
// Synthetic widths exercise defensive overflow, not valid guest layouts.
|
||||
assert_eq!(planned_cost(1, u64::MAX), None);
|
||||
assert_eq!(planned_cost(1, u64::MAX / 2), None);
|
||||
assert_eq!(planned_cost(u32::MAX, u64::MAX), None);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,487 @@
|
||||
use super::collection_test_support as support;
|
||||
use super::*;
|
||||
use crate::ValidatedProgramImage;
|
||||
use prometeu_bytecode::{assemble, registry::TypeId};
|
||||
use support::Native;
|
||||
|
||||
fn machine(instruction: &str, count: usize) -> VirtualMachine {
|
||||
let mut text = String::new();
|
||||
for i in 0..count {
|
||||
text += &format!("GET_GLOBAL {i}\n");
|
||||
}
|
||||
text += instruction;
|
||||
text += "\nHALT";
|
||||
let mut vm = VirtualMachine::from_image(
|
||||
support::load(&assemble(&text).unwrap()).unwrap(),
|
||||
RuntimeLimits::default(),
|
||||
);
|
||||
vm.prepare_boot_call().unwrap();
|
||||
vm
|
||||
}
|
||||
fn operands(vm: &mut VirtualMachine, values: &[Value]) {
|
||||
vm.globals.extend_from_slice(values).unwrap();
|
||||
for _ in values {
|
||||
vm.step(&mut Native, &mut HostContext::new(None)).unwrap();
|
||||
}
|
||||
}
|
||||
fn step(vm: &mut VirtualMachine) -> Result<(), LogicalFrameEndingReason> {
|
||||
vm.step(&mut Native, &mut HostContext::new(None))
|
||||
}
|
||||
#[test]
|
||||
fn raw_copy_preserves_absence_and_box_identity_without_heap_allocations() {
|
||||
let mut vm = machine("ARRAY_COPY 15", 5);
|
||||
let registry = vm.validated_image.as_ref().unwrap().registry().clone();
|
||||
let a = vm.heap.allocate_typed_array(registry.clone(), TypeId(15), 4).unwrap();
|
||||
let boxed = vm
|
||||
.heap
|
||||
.allocate_dynamic_box(registry.clone(), TypeId(5), &[Value::Float(1.), Value::Float(2.)])
|
||||
.unwrap();
|
||||
let present = [Value::Int64(5), Value::HeapRef(boxed)];
|
||||
vm.heap.store_typed(®istry, a, 0, &present).unwrap();
|
||||
operands(
|
||||
&mut vm,
|
||||
&[Value::HeapRef(a), Value::Int64(0), Value::HeapRef(a), Value::Int64(1), Value::Int64(3)],
|
||||
);
|
||||
let before = vm.heap.allocation_count();
|
||||
vm.budget
|
||||
.test_lower_limit(RuntimeResource::GuestBytes, vm.budget.used(RuntimeResource::GuestBytes));
|
||||
step(&mut vm).unwrap();
|
||||
assert_eq!(vm.heap.allocation_count(), before);
|
||||
assert_eq!(vm.heap.load_typed(®istry, a, 1).unwrap().as_slice(), present);
|
||||
for i in [2, 3] {
|
||||
assert_eq!(
|
||||
vm.heap.load_typed(®istry, a, i).unwrap().as_slice(),
|
||||
[Value::Null, Value::Null]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn pair(ty: u32, len: u32) -> (VirtualMachine, HeapRef, HeapRef) {
|
||||
let mut vm = machine(&format!("ARRAY_COPY {ty}"), 5);
|
||||
let registry = vm.validated_image.as_ref().unwrap().registry().clone();
|
||||
let source = vm.heap.allocate_typed_array(registry.clone(), TypeId(ty), len).unwrap();
|
||||
let target = vm.heap.allocate_typed_array(registry, TypeId(ty), len).unwrap();
|
||||
(vm, source, target)
|
||||
}
|
||||
fn copy_inputs(source: HeapRef, target: HeapRef, count: i64) -> [Value; 5] {
|
||||
[
|
||||
Value::HeapRef(source),
|
||||
Value::Int64(0),
|
||||
Value::HeapRef(target),
|
||||
Value::Int64(0),
|
||||
Value::Int64(count),
|
||||
]
|
||||
}
|
||||
fn refused(vm: &mut VirtualMachine, code: u32, cost: u64) {
|
||||
let inputs = vm.operand_stack.as_slice().to_vec();
|
||||
let (pc, cycles, temporary, objects) =
|
||||
(vm.pc, vm.cycles, vm.budget.used(RuntimeResource::TemporaryBytes), vm.heap.len());
|
||||
let LogicalFrameEndingReason::Trap(info) = step(vm).unwrap_err() else { panic!() };
|
||||
assert_eq!((info.code, info.opcode, info.pc), (code, 0xa9, pc as u32));
|
||||
assert_eq!(vm.cycles - cycles, cost);
|
||||
assert_eq!(vm.operand_stack.as_slice(), inputs);
|
||||
assert_eq!(vm.budget.used(RuntimeResource::TemporaryBytes), temporary);
|
||||
assert_eq!(vm.heap.len(), objects);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn calculable_work_is_precharged_on_receivers_carriers_and_ranges_in_fault_order() {
|
||||
for case in 0..20 {
|
||||
let (mut vm, source, target) = pair(11, 10);
|
||||
let registry = vm.validated_image.as_ref().unwrap().registry().clone();
|
||||
let wrong = vm.heap.allocate_typed_struct(registry.clone(), TypeId(19)).unwrap();
|
||||
let foreign = support::load(&assemble("HALT").unwrap()).unwrap();
|
||||
let foreign_ref =
|
||||
vm.heap.allocate_typed_array(foreign.registry().clone(), TypeId(11), 10).unwrap();
|
||||
let stale = HeapRef { index: source.index, generation: source.generation + 1 };
|
||||
let mut inputs = copy_inputs(source, target, 10);
|
||||
let (offset, value, code) = match case {
|
||||
0 => (0, Value::Null, TRAP_NULL_REFERENCE),
|
||||
1 => (2, Value::Null, TRAP_NULL_REFERENCE),
|
||||
2 => (0, Value::HeapRef(stale), TRAP_INVALID_HANDLE),
|
||||
3 => (2, Value::HeapRef(stale), TRAP_INVALID_HANDLE),
|
||||
4 => (0, Value::HeapRef(wrong), TRAP_TYPE),
|
||||
5 => (2, Value::HeapRef(wrong), TRAP_TYPE),
|
||||
6 => (0, Value::HeapRef(foreign_ref), TRAP_TYPE),
|
||||
7 => (2, Value::Int32(0), TRAP_TYPE),
|
||||
8 => (1, Value::Int32(0), TRAP_TYPE),
|
||||
9 => (3, Value::Null, TRAP_TYPE),
|
||||
10 => (1, Value::Int64(-1), TRAP_OOB),
|
||||
11 => (3, Value::Int64(-1), TRAP_OOB),
|
||||
12 => (1, Value::Int64(1), TRAP_OOB),
|
||||
13 => (3, Value::Int64(1), TRAP_OOB),
|
||||
14 => {
|
||||
inputs[1] = Value::Int32(0); // Receiver fault precedes offset carrier.
|
||||
(2, Value::Null, TRAP_NULL_REFERENCE)
|
||||
}
|
||||
15 => {
|
||||
inputs[1] = Value::Int64(-1); // All carriers precede source range.
|
||||
(3, Value::Int32(0), TRAP_TYPE)
|
||||
}
|
||||
16 => (0, Value::Int32(0), TRAP_TYPE),
|
||||
17 => {
|
||||
let wrong_array =
|
||||
vm.heap.allocate_typed_array(registry.clone(), TypeId(22), 10).unwrap();
|
||||
(2, Value::HeapRef(wrong_array), TRAP_TYPE)
|
||||
}
|
||||
18 => (1, Value::Int64(i64::MAX), TRAP_OOB),
|
||||
_ => (3, Value::Int64(i64::MAX), TRAP_OOB),
|
||||
};
|
||||
inputs[offset] = value;
|
||||
operands(&mut vm, &inputs);
|
||||
// Quota refusal must not mask earlier faults, even with full cost selected.
|
||||
vm.budget.test_lower_limit(
|
||||
RuntimeResource::TemporaryBytes,
|
||||
vm.budget.used(RuntimeResource::TemporaryBytes),
|
||||
);
|
||||
refused(&mut vm, code, 24);
|
||||
for i in 0..10 {
|
||||
assert_eq!(
|
||||
vm.heap.load_typed(®istry, target, i).unwrap().as_slice(),
|
||||
[Value::Int32(0)]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invalid_count_selects_only_base_without_reordering_ordinary_faults() {
|
||||
for count in [
|
||||
Value::Int32(10),
|
||||
Value::Null,
|
||||
Value::Int64(-1),
|
||||
Value::Int64(u32::MAX as i64 + 1),
|
||||
Value::Int64(i64::MAX),
|
||||
] {
|
||||
for bad_receiver in [false, true] {
|
||||
let (mut vm, source, target) = pair(11, 10);
|
||||
let mut inputs = copy_inputs(source, target, 0);
|
||||
inputs[4] = count.clone();
|
||||
if bad_receiver {
|
||||
inputs[0] = Value::Null;
|
||||
}
|
||||
operands(&mut vm, &inputs);
|
||||
let code = if bad_receiver {
|
||||
TRAP_NULL_REFERENCE
|
||||
} else if matches!(count, Value::Int64(_)) {
|
||||
TRAP_OOB
|
||||
} else {
|
||||
TRAP_TYPE
|
||||
};
|
||||
refused(&mut vm, code, 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn incomplete_temporary_operands_never_read_frame_locals_for_cost() {
|
||||
let code = assemble(
|
||||
"GET_GLOBAL 0\nGET_GLOBAL 1\nGET_GLOBAL 2\nGET_GLOBAL 3\nGET_GLOBAL 4\nARRAY_COPY 11\nHALT",
|
||||
)
|
||||
.unwrap();
|
||||
for available in 0..5 {
|
||||
let mut declarations = support::declarations(code.len());
|
||||
declarations.functions[0].local_slots = 5;
|
||||
let image = ValidatedProgramImage::load(
|
||||
&support::bytes_with(&code, declarations),
|
||||
&mut prometeu_bytecode::load_limits::LoadBudget::new(Default::default()),
|
||||
prometeu_hal::syscalls::caps::NONE,
|
||||
)
|
||||
.unwrap();
|
||||
let mut vm = VirtualMachine::from_image(image, RuntimeLimits::default());
|
||||
vm.prepare_boot_call().unwrap();
|
||||
// Internal defense: skip the verified producers, leaving only locals and
|
||||
// an incomplete temporary group. This is not an admitted bad program.
|
||||
vm.operand_stack[4] = Value::Int64(10);
|
||||
vm.operand_stack.extend_from_slice(&vec![Value::Int64(10); available]).unwrap();
|
||||
vm.pc = 30;
|
||||
refused(&mut vm, TRAP_STACK_UNDERFLOW, 4);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn overlap_snapshots_complete_multislot_groups_and_has_no_identity_discount() {
|
||||
for (source_start, target_start, count) in [(0, 1, 3), (1, 0, 3), (0, 0, 4)] {
|
||||
for refuse in [false, true] {
|
||||
let mut vm = machine("ARRAY_COPY 12", 5);
|
||||
let registry = vm.validated_image.as_ref().unwrap().registry().clone();
|
||||
let array = vm.heap.allocate_typed_array(registry.clone(), TypeId(12), 4).unwrap();
|
||||
for i in 0..4 {
|
||||
vm.heap
|
||||
.store_typed(
|
||||
®istry,
|
||||
array,
|
||||
i,
|
||||
&[Value::Float(i as f64), Value::Float(i as f64 + 10.)],
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
let before: Vec<_> = (0..4)
|
||||
.map(|i| vm.heap.load_typed(®istry, array, i).unwrap().as_slice().to_vec())
|
||||
.collect();
|
||||
operands(
|
||||
&mut vm,
|
||||
&[
|
||||
Value::HeapRef(array),
|
||||
Value::Int64(source_start),
|
||||
Value::HeapRef(array),
|
||||
Value::Int64(target_start),
|
||||
Value::Int64(count),
|
||||
],
|
||||
);
|
||||
let temporary = vm.budget.used(RuntimeResource::TemporaryBytes);
|
||||
if refuse {
|
||||
vm.budget.test_lower_limit(RuntimeResource::TemporaryBytes, temporary);
|
||||
refused(&mut vm, TRAP_RESOURCE_LIMIT, if count == 3 { 16 } else { 20 });
|
||||
} else {
|
||||
let cycles = vm.cycles;
|
||||
step(&mut vm).unwrap();
|
||||
assert_eq!(vm.cycles - cycles, if count == 3 { 16 } else { 20 });
|
||||
assert!(vm.operand_stack.is_empty());
|
||||
}
|
||||
for i in 0..4 {
|
||||
let expected =
|
||||
if !refuse && i >= target_start as usize && i < (target_start + count) as usize
|
||||
{
|
||||
&before[(i as i64 - target_start + source_start) as usize]
|
||||
} else {
|
||||
&before[i]
|
||||
};
|
||||
assert_eq!(vm.heap.load_typed(®istry, array, i).unwrap().as_slice(), expected);
|
||||
}
|
||||
assert_eq!(vm.budget.used(RuntimeResource::TemporaryBytes), temporary);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn scratch_quota_and_allocator_refusals_preserve_all_destinations_and_work() {
|
||||
for allocation_failure in [false, true] {
|
||||
let (mut vm, source, target) = pair(11, 10);
|
||||
let registry = vm.validated_image.as_ref().unwrap().registry().clone();
|
||||
for i in 0..10 {
|
||||
vm.heap.store_typed(®istry, source, i, &[Value::Int32(i as i32 + 1)]).unwrap();
|
||||
}
|
||||
operands(&mut vm, ©_inputs(source, target, 10));
|
||||
if allocation_failure {
|
||||
crate::resource_budget::FAIL_NEXT_VEC_ALLOCATION.with(|fail| fail.set(true));
|
||||
} else {
|
||||
vm.budget.test_lower_limit(
|
||||
RuntimeResource::TemporaryBytes,
|
||||
vm.budget.used(RuntimeResource::TemporaryBytes),
|
||||
);
|
||||
}
|
||||
let (cycles, temporary) = (vm.cycles, vm.budget.used(RuntimeResource::TemporaryBytes));
|
||||
let LogicalFrameEndingReason::Trap(info) = step(&mut vm).unwrap_err() else { panic!() };
|
||||
assert_eq!((info.code, info.opcode, info.pc), (TRAP_RESOURCE_LIMIT, 0xa9, 30));
|
||||
let resource = info.resource.unwrap();
|
||||
assert_eq!(resource.resource, RuntimeResource::TemporaryBytes);
|
||||
assert_eq!(
|
||||
resource.reason,
|
||||
if allocation_failure {
|
||||
crate::resource_budget::ResourceReason::AllocationFailed
|
||||
} else {
|
||||
crate::resource_budget::ResourceReason::Limit
|
||||
}
|
||||
);
|
||||
assert_eq!(vm.cycles - cycles, 24);
|
||||
assert_eq!(vm.budget.used(RuntimeResource::TemporaryBytes), temporary);
|
||||
assert_eq!(vm.operand_stack.as_slice(), copy_inputs(source, target, 10));
|
||||
for i in 0..10 {
|
||||
assert_eq!(
|
||||
vm.heap.load_typed(®istry, target, i).unwrap().as_slice(),
|
||||
[Value::Int32(0)]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn late_invalid_source_group_releases_partial_preparation_without_any_write() {
|
||||
let (mut vm, source, target) = pair(17, 10);
|
||||
let registry = vm.validated_image.as_ref().unwrap().registry().clone();
|
||||
let node = vm.heap.allocate_typed_struct(registry.clone(), TypeId(9)).unwrap();
|
||||
vm.heap.store_typed(®istry, source, 0, &[Value::HeapRef(node)]).unwrap();
|
||||
// Internal corruption of the last stored handle exercises a late read fault.
|
||||
vm.heap.commit_typed(
|
||||
source,
|
||||
9,
|
||||
&[Value::HeapRef(HeapRef { index: node.index, generation: node.generation + 1 })],
|
||||
);
|
||||
operands(&mut vm, ©_inputs(source, target, 10));
|
||||
refused(&mut vm, TRAP_INVALID_HANDLE, 24);
|
||||
for i in 0..10 {
|
||||
assert_eq!(vm.heap.load_typed(®istry, target, i).unwrap().as_slice(), [Value::Null]);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn empty_copy_validates_both_receivers_and_strict_ranges_without_scratch() {
|
||||
for case in 0..5 {
|
||||
let (mut vm, source, target) = pair(11, 2);
|
||||
let mut inputs = copy_inputs(source, target, 0);
|
||||
inputs[1] = Value::Int64(2);
|
||||
inputs[3] = Value::Int64(2);
|
||||
let code = match case {
|
||||
0 => None,
|
||||
1 => {
|
||||
inputs[0] = Value::Null;
|
||||
Some(TRAP_NULL_REFERENCE)
|
||||
}
|
||||
2 => {
|
||||
inputs[2] = Value::Null;
|
||||
Some(TRAP_NULL_REFERENCE)
|
||||
}
|
||||
3 => {
|
||||
inputs[1] = Value::Int64(3);
|
||||
Some(TRAP_OOB)
|
||||
}
|
||||
_ => {
|
||||
inputs[3] = Value::Int64(-1);
|
||||
Some(TRAP_OOB)
|
||||
}
|
||||
};
|
||||
operands(&mut vm, &inputs);
|
||||
vm.budget.test_lower_limit(
|
||||
RuntimeResource::TemporaryBytes,
|
||||
vm.budget.used(RuntimeResource::TemporaryBytes),
|
||||
);
|
||||
if let Some(code) = code {
|
||||
refused(&mut vm, code, 4);
|
||||
} else {
|
||||
let cycles = vm.cycles;
|
||||
step(&mut vm).unwrap();
|
||||
assert_eq!(vm.cycles - cycles, 4);
|
||||
assert!(vm.operand_stack.is_empty());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn zero_budget_and_positive_overshoot_preserve_trap_priority_and_step_count() {
|
||||
for fail in [false, true] {
|
||||
let (mut vm, source, target) = pair(11, 10);
|
||||
operands(&mut vm, ©_inputs(source, target, 10));
|
||||
if fail {
|
||||
vm.budget.test_lower_limit(
|
||||
RuntimeResource::TemporaryBytes,
|
||||
vm.budget.used(RuntimeResource::TemporaryBytes),
|
||||
);
|
||||
}
|
||||
let (pc, cycles, inputs) = (vm.pc, vm.cycles, vm.operand_stack.as_slice().to_vec());
|
||||
let report = vm.run_budget(0, &mut Native, &mut HostContext::new(None)).unwrap();
|
||||
assert_eq!((report.cycles_used, report.steps_executed), (0, 0));
|
||||
assert_eq!((vm.pc, vm.cycles), (pc, cycles));
|
||||
assert_eq!(vm.operand_stack.as_slice(), inputs);
|
||||
let report = vm.run_budget(1, &mut Native, &mut HostContext::new(None)).unwrap();
|
||||
assert_eq!((report.cycles_used, report.steps_executed), (24, if fail { 0 } else { 1 }));
|
||||
if fail {
|
||||
let LogicalFrameEndingReason::Trap(info) = report.reason else { panic!() };
|
||||
assert_eq!((info.code, info.opcode, info.pc), (TRAP_RESOURCE_LIMIT, 0xa9, pc as u32));
|
||||
assert_eq!(vm.operand_stack.as_slice(), inputs);
|
||||
} else {
|
||||
assert_eq!(report.reason, LogicalFrameEndingReason::BudgetExhausted);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn copied_groups_preserve_owners_and_references_through_collection_without_guest_growth() {
|
||||
for ty in [11, 12, 13, 14, 15, 16, 17] {
|
||||
let (mut vm, source, target) = pair(ty, 1);
|
||||
let registry = vm.validated_image.as_ref().unwrap().registry().clone();
|
||||
let node = vm.heap.allocate_typed_struct(registry.clone(), TypeId(9)).unwrap();
|
||||
vm.push(Value::String(std::sync::Arc::from("copy owner"))).unwrap();
|
||||
let string = vm.pop().unwrap();
|
||||
let group = match ty {
|
||||
11 => vec![Value::Int32(7)],
|
||||
12 => vec![Value::Float(1.), Value::Float(2.)],
|
||||
13 => vec![Value::Int64(1), Value::Int64(2), Value::Int64(3)],
|
||||
14 => vec![string.clone()],
|
||||
15 => vec![Value::Int64(4), string.clone()],
|
||||
16 => vec![Value::HeapRef(node), Value::Int64(0)],
|
||||
_ => vec![Value::HeapRef(node)],
|
||||
};
|
||||
vm.heap.store_typed(®istry, source, 0, &group).unwrap();
|
||||
operands(&mut vm, ©_inputs(source, target, 1));
|
||||
let objects = vm.heap.allocation_count();
|
||||
let guest = vm.budget.used(RuntimeResource::GuestBytes);
|
||||
for q in [
|
||||
RuntimeResource::GuestBytes,
|
||||
RuntimeResource::HandleSlots,
|
||||
RuntimeResource::AuxiliaryBytes,
|
||||
] {
|
||||
vm.budget.test_lower_limit(q, vm.budget.used(q));
|
||||
}
|
||||
let cycles = vm.cycles;
|
||||
step(&mut vm).unwrap();
|
||||
assert_eq!(
|
||||
vm.cycles - cycles,
|
||||
match ty {
|
||||
12 | 15 | 16 => 8,
|
||||
13 => 10,
|
||||
_ => 6,
|
||||
}
|
||||
);
|
||||
assert_eq!(vm.heap.allocation_count(), objects);
|
||||
assert_eq!(vm.budget.used(RuntimeResource::GuestBytes), guest);
|
||||
assert_eq!(vm.heap.load_typed(®istry, target, 0).unwrap().as_slice(), group);
|
||||
drop(group);
|
||||
drop(string);
|
||||
vm.globals.clear();
|
||||
vm.globals.push(Value::HeapRef(target)).unwrap();
|
||||
vm.gc_alloc_threshold = 1;
|
||||
vm.handle_safepoint().unwrap();
|
||||
assert!(!vm.heap.is_valid(source));
|
||||
assert!(vm.heap.is_valid(target));
|
||||
if [16, 17].contains(&ty) {
|
||||
assert!(vm.heap.is_valid(node));
|
||||
}
|
||||
if [14, 15].contains(&ty) {
|
||||
assert_eq!(vm.budget.used(RuntimeResource::StringAllocations), 1);
|
||||
}
|
||||
// Remove all roots and collect using the actual session root traversal.
|
||||
vm.globals.clear();
|
||||
vm.last_gc_live_count = 0;
|
||||
vm.handle_safepoint().unwrap();
|
||||
assert_eq!(vm.heap.len(), 0);
|
||||
assert_eq!(vm.budget.used(RuntimeResource::StringAllocations), 0);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn refused_copy_keeps_source_and_previous_target_native_owners_rooted() {
|
||||
let (mut vm, source, target) = pair(14, 1);
|
||||
let registry = vm.validated_image.as_ref().unwrap().registry().clone();
|
||||
for (array, text) in [(source, "candidate owner"), (target, "previous owner")] {
|
||||
vm.push(Value::String(std::sync::Arc::from(text))).unwrap();
|
||||
let value = vm.pop().unwrap();
|
||||
vm.heap.store_typed(®istry, array, 0, &[value]).unwrap();
|
||||
}
|
||||
operands(&mut vm, ©_inputs(source, target, 1));
|
||||
let temporary = vm.budget.used(RuntimeResource::TemporaryBytes);
|
||||
vm.budget.test_lower_limit(RuntimeResource::TemporaryBytes, temporary);
|
||||
refused(&mut vm, TRAP_RESOURCE_LIMIT, 6);
|
||||
assert_eq!(
|
||||
vm.heap.load_typed(®istry, source, 0).unwrap().as_slice(),
|
||||
[Value::String(std::sync::Arc::from("candidate owner"))]
|
||||
);
|
||||
assert_eq!(
|
||||
vm.heap.load_typed(®istry, target, 0).unwrap().as_slice(),
|
||||
[Value::String(std::sync::Arc::from("previous owner"))]
|
||||
);
|
||||
vm.budget.test_lower_limit(
|
||||
RuntimeResource::TemporaryBytes,
|
||||
RuntimeLimits::default().get(RuntimeResource::TemporaryBytes),
|
||||
);
|
||||
vm.globals.clear(); // Failed operands are now the only session roots.
|
||||
vm.gc_alloc_threshold = 1;
|
||||
vm.handle_safepoint().unwrap();
|
||||
assert!(vm.heap.is_valid(source) && vm.heap.is_valid(target));
|
||||
assert_eq!(vm.budget.used(RuntimeResource::StringAllocations), 2);
|
||||
vm.operand_stack.clear();
|
||||
vm.last_gc_live_count = 0;
|
||||
vm.handle_safepoint().unwrap();
|
||||
assert_eq!(vm.heap.len(), 0);
|
||||
assert_eq!(vm.budget.used(RuntimeResource::StringAllocations), 0);
|
||||
}
|
||||
@@ -175,7 +175,7 @@ impl VirtualMachine {
|
||||
.expect("result capacity reserved before publication");
|
||||
Ok(())
|
||||
}
|
||||
fn collection_size_trap(
|
||||
pub(super) fn collection_size_trap(
|
||||
&self,
|
||||
opcode: OpCode,
|
||||
pc: u32,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use super::collection_test_support as support;
|
||||
use super::*;
|
||||
#[path = "../../tests/support/collections.rs"]
|
||||
mod support;
|
||||
use crate::value_contract::ValueError;
|
||||
use prometeu_bytecode::assemble;
|
||||
use support::Native;
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
use super::*;
|
||||
use crate::value_contract;
|
||||
use prometeu_bytecode::registry::TypeId;
|
||||
|
||||
impl VirtualMachine {
|
||||
pub(super) fn execute_identity(
|
||||
&mut self,
|
||||
opcode: OpCode,
|
||||
left: u32,
|
||||
right: Option<u32>,
|
||||
pc: u32,
|
||||
) -> Result<(), LogicalFrameEndingReason> {
|
||||
let image = self.validated_image.clone().ok_or_else(|| {
|
||||
self.trap(
|
||||
prometeu_bytecode::TRAP_ILLEGAL_INSTRUCTION,
|
||||
opcode as u16,
|
||||
"Identity instruction requires a validated Registry".into(),
|
||||
pc,
|
||||
)
|
||||
})?;
|
||||
let registry = image.registry();
|
||||
let left = TypeId(left);
|
||||
let right = right.map(TypeId);
|
||||
let lw = registry.type_layout(left).unwrap().storage.slots as usize;
|
||||
let rw = right.map_or(0, |ty| registry.type_layout(ty).unwrap().storage.slots as usize);
|
||||
self.cycles += opcode.cycles() + (lw + rw) as u64;
|
||||
if self.temporary_slots() < lw + rw {
|
||||
return Err(self.trap(
|
||||
TRAP_STACK_UNDERFLOW,
|
||||
opcode as u16,
|
||||
"Incomplete identity operands".into(),
|
||||
pc,
|
||||
));
|
||||
}
|
||||
let base = self.operand_stack.len() - lw - rw;
|
||||
let first = value_contract::identity_reference(
|
||||
registry,
|
||||
&self.heap,
|
||||
left,
|
||||
&self.operand_stack[base..base + lw],
|
||||
)
|
||||
.map_err(|e| self.value_trap(e, opcode, pc))?;
|
||||
let result = if let Some(ty) = right {
|
||||
let second = value_contract::identity_reference(
|
||||
registry,
|
||||
&self.heap,
|
||||
ty,
|
||||
&self.operand_stack[base + lw..],
|
||||
)
|
||||
.map_err(|e| self.value_trap(e, opcode, pc))?;
|
||||
Value::Boolean(first == second)
|
||||
} else {
|
||||
Value::Int64(crate::hashing::reference(first))
|
||||
};
|
||||
self.operand_stack.truncate(base);
|
||||
self.operand_stack.push(result).expect("identity result replaces existing inputs");
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
use super::*;
|
||||
#[path = "../../tests/support/identity.rs"]
|
||||
mod support;
|
||||
use crate::{
|
||||
IntrinsicExecutionError, IntrinsicImplementation, IntrinsicMeta, IntrinsicResults,
|
||||
hash_intrinsics::HASH_INTRINSICS,
|
||||
};
|
||||
use prometeu_bytecode::{HeapRef, RuntimeResource as Q, registry::TypeId};
|
||||
use std::sync::Arc;
|
||||
use support::*;
|
||||
|
||||
fn empty() -> VirtualMachine {
|
||||
vm(&[("RET", sig(&[], &[]))], &[])
|
||||
}
|
||||
fn push(v: &mut VirtualMachine, values: &[Value]) {
|
||||
for value in values {
|
||||
v.operand_stack.push(value.clone()).unwrap();
|
||||
}
|
||||
}
|
||||
fn usage(v: &VirtualMachine) -> Vec<u64> {
|
||||
[
|
||||
Q::GuestBytes,
|
||||
Q::HandleSlots,
|
||||
Q::AuxiliaryBytes,
|
||||
Q::TemporaryBytes,
|
||||
Q::StringBytes,
|
||||
Q::StringAllocations,
|
||||
]
|
||||
.map(|q| v.budget.used(q))
|
||||
.to_vec()
|
||||
}
|
||||
fn fault(result: Result<(), LogicalFrameEndingReason>, expected: u32) {
|
||||
assert!(
|
||||
matches!(result,Err(LogicalFrameEndingReason::Trap(ref t)) if t.code==expected),
|
||||
"{result:?}"
|
||||
);
|
||||
}
|
||||
fn hash(v: &mut VirtualMachine, ty: u32, values: &[Value]) -> i64 {
|
||||
push(v, values);
|
||||
v.execute_identity(OpCode::RefIdentityHash, ty, None, 0).unwrap();
|
||||
let Value::Int64(value) = v.operand_stack.pop().unwrap() else { panic!() };
|
||||
value
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn identity_faults_preserve_complete_groups_and_charge_once_in_left_to_right_order() {
|
||||
let mut v = empty();
|
||||
let registry = v.validated_image.as_ref().unwrap().registry().clone();
|
||||
let live = v.heap.allocate_typed_struct(registry.clone(), TypeId(5)).unwrap();
|
||||
let wrong = v.heap.allocate_typed_struct(registry, TypeId(11)).unwrap();
|
||||
let stale = HeapRef { index: 999999, generation: 1 };
|
||||
for (left, right, values, code) in [
|
||||
(5, None, vec![Value::HeapRef(stale)], TRAP_INVALID_HANDLE),
|
||||
(5, None, vec![Value::HeapRef(wrong)], TRAP_TYPE),
|
||||
(5, None, vec![Value::HeapRef(HeapRef::NULL)], TRAP_TYPE),
|
||||
(6, None, vec![Value::HeapRef(live)], TRAP_TYPE),
|
||||
(9, None, vec![Value::HeapRef(HeapRef::NULL)], TRAP_TYPE),
|
||||
(10, None, vec![Value::HeapRef(HeapRef::NULL)], TRAP_INVALID_HANDLE),
|
||||
(7, None, vec![Value::Null, Value::Int64(0)], TRAP_TYPE),
|
||||
(7, None, vec![Value::HeapRef(live), Value::Null], TRAP_TYPE),
|
||||
(7, None, vec![Value::HeapRef(live), Value::Int64(1)], TRAP_TYPE),
|
||||
(7, None, vec![Value::HeapRef(live), Value::Int64(-1)], TRAP_TYPE),
|
||||
(7, None, vec![Value::HeapRef(live), Value::Int64(999)], TRAP_TYPE),
|
||||
(7, None, vec![Value::HeapRef(stale), Value::Int64(0)], TRAP_INVALID_HANDLE),
|
||||
// A null left side still validates the complete right group.
|
||||
(5, Some(7), vec![Value::Null, Value::HeapRef(live), Value::Int64(1)], TRAP_TYPE),
|
||||
(5, Some(11), vec![Value::Null, Value::HeapRef(stale)], TRAP_INVALID_HANDLE),
|
||||
// Both invalid: left TYPE takes precedence over right INVALID_HANDLE.
|
||||
(5, Some(5), vec![Value::HeapRef(wrong), Value::HeapRef(stale)], TRAP_TYPE),
|
||||
] {
|
||||
v.operand_stack.truncate(8); // Entry's eight reserved local slots.
|
||||
push(&mut v, &values);
|
||||
let operands = v.operand_stack.as_slice().to_vec();
|
||||
let before = usage(&v);
|
||||
let cycles = v.cycles;
|
||||
let op = if right.is_some() { OpCode::RefIdentityEq } else { OpCode::RefIdentityHash };
|
||||
let width = if left == 7 { 2 } else { 1 } + right.map_or(0, |r| if r == 7 { 2 } else { 1 });
|
||||
fault(v.execute_identity(op, left, right, 0), code);
|
||||
assert_eq!(v.operand_stack.as_slice(), operands);
|
||||
assert_eq!(usage(&v), before);
|
||||
assert_eq!(v.cycles - cycles, op.cycles() + width);
|
||||
}
|
||||
v.operand_stack.truncate(8);
|
||||
let before = v.cycles;
|
||||
fault(v.execute_identity(OpCode::RefIdentityEq, 7, Some(7), 0), TRAP_STACK_UNDERFLOW);
|
||||
assert_eq!(v.cycles - before, 8);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gc_preserves_live_aliases_but_hashes_do_not_root_collected_handles() {
|
||||
let mut v = empty();
|
||||
let registry = v.validated_image.as_ref().unwrap().registry().clone();
|
||||
let live = v.heap.allocate_typed_struct(registry.clone(), TypeId(5)).unwrap();
|
||||
let dead = v.heap.allocate_typed_struct(registry.clone(), TypeId(5)).unwrap();
|
||||
let live_hash = hash(&mut v, 5, &[Value::HeapRef(live)]);
|
||||
let dead_hash = hash(&mut v, 5, &[Value::HeapRef(dead)]);
|
||||
v.globals.push(Value::HeapRef(live)).unwrap();
|
||||
v.globals.push(Value::Int64(dead_hash)).unwrap();
|
||||
v.gc_alloc_threshold = 1;
|
||||
v.handle_safepoint().unwrap();
|
||||
assert!(v.heap.is_valid(live));
|
||||
assert!(!v.heap.is_valid(dead));
|
||||
assert_eq!(hash(&mut v, 7, &[Value::HeapRef(live), Value::Int64(0)]), live_hash);
|
||||
let replacement = v.heap.allocate_typed_struct(registry, TypeId(5)).unwrap();
|
||||
assert_eq!(replacement.index, dead.index);
|
||||
assert_ne!(replacement.generation, dead.generation);
|
||||
push(&mut v, &[Value::HeapRef(dead), Value::HeapRef(replacement)]);
|
||||
fault(v.execute_identity(OpCode::RefIdentityEq, 5, Some(5), 0), TRAP_INVALID_HANDLE);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn new_queries_ignore_exhausted_guest_and_scratch_quotas_and_do_not_collect() {
|
||||
let mut v = empty();
|
||||
let registry = v.validated_image.as_ref().unwrap().registry().clone();
|
||||
let live = v.heap.allocate_typed_struct(registry, TypeId(5)).unwrap();
|
||||
push(&mut v, &[Value::HeapRef(live)]);
|
||||
for q in [
|
||||
Q::GuestBytes,
|
||||
Q::HandleSlots,
|
||||
Q::AuxiliaryBytes,
|
||||
Q::TemporaryBytes,
|
||||
Q::StringBytes,
|
||||
Q::StringAllocations,
|
||||
] {
|
||||
v.budget.test_lower_limit(q, v.budget.used(q));
|
||||
}
|
||||
let before = usage(&v);
|
||||
let allocations = v.heap.allocation_count();
|
||||
v.gc_alloc_threshold = 1;
|
||||
v.execute_identity(OpCode::RefIdentityHash, 5, None, 0).unwrap();
|
||||
v.execute_inline_intrinsic(&HASH_INTRINSICS[0], 0).unwrap();
|
||||
assert_eq!(v.heap.allocation_count(), allocations);
|
||||
assert!(v.heap.is_valid(live)); // No root remains, but neither operation is a safepoint.
|
||||
assert_eq!(usage(&v), before);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn inline_faults_preserve_float_bits_owners_and_attempted_cost() {
|
||||
let mut v = empty();
|
||||
for bits in [f64::INFINITY.to_bits(), f64::NEG_INFINITY.to_bits(), 0x7ff8000000001234] {
|
||||
push(&mut v, &[Value::Float(f64::from_bits(bits))]);
|
||||
let before = usage(&v);
|
||||
let cycles = v.cycles;
|
||||
fault(
|
||||
v.execute_inline_intrinsic(&HASH_INTRINSICS[1], 0),
|
||||
prometeu_bytecode::TRAP_NON_FINITE,
|
||||
);
|
||||
assert!(matches!(v.operand_stack.last(),Some(Value::Float(f)) if f.to_bits()==bits));
|
||||
assert_eq!(usage(&v), before);
|
||||
assert_eq!(v.cycles - cycles, 8);
|
||||
v.operand_stack.pop();
|
||||
}
|
||||
let foreign: Arc<str> = Arc::from("owner outside image and session");
|
||||
push(&mut v, &[Value::String(foreign.clone())]);
|
||||
let refs = Arc::strong_count(&foreign);
|
||||
let before = usage(&v);
|
||||
let cycles = v.cycles;
|
||||
fault(v.execute_inline_intrinsic(&HASH_INTRINSICS[2], 0), TRAP_TYPE);
|
||||
assert_eq!(Arc::strong_count(&foreign), refs);
|
||||
assert_eq!(usage(&v), before);
|
||||
assert_eq!(v.cycles - cycles, 8 + foreign.len() as u64);
|
||||
let mut overflow = HASH_INTRINSICS[2];
|
||||
overflow.cost_per_byte = u64::MAX;
|
||||
let cycles = v.cycles;
|
||||
fault(v.execute_inline_intrinsic(&overflow, 0), TRAP_RESOURCE_LIMIT);
|
||||
assert_eq!(v.cycles - cycles, 8);
|
||||
assert_eq!(Arc::strong_count(&foreign), refs);
|
||||
v.operand_stack.pop();
|
||||
let cycles = v.cycles;
|
||||
fault(v.execute_inline_intrinsic(&HASH_INTRINSICS[2], 0), TRAP_STACK_UNDERFLOW);
|
||||
assert_eq!(v.cycles - cycles, 8);
|
||||
push(&mut v, &[Value::Int64(7)]);
|
||||
let cycles = v.cycles;
|
||||
fault(v.execute_inline_intrinsic(&HASH_INTRINSICS[2], 0), TRAP_TYPE);
|
||||
assert_eq!(v.cycles - cycles, 8);
|
||||
assert_eq!(v.operand_stack.last(), Some(&Value::Int64(7)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn equal_string_content_hashes_across_image_session_and_import_owners() {
|
||||
use prometeu_bytecode::model::ConstantPoolEntry as K;
|
||||
let mut v = vm(
|
||||
&[("PUSH_CONST 0\nINTRINSIC 0x4102\nRET", sig(&[], &[0]))],
|
||||
&[K::String("same\0π".into())],
|
||||
);
|
||||
step(&mut v).unwrap();
|
||||
let Value::String(image_owner) = v.operand_stack.last().unwrap().clone() else { panic!() };
|
||||
v.strings = Some(crate::string_ledger::StringLedger::new(v.budget.clone()).unwrap());
|
||||
let session = v.strings.as_ref().unwrap().concat("same", "\0π").unwrap();
|
||||
let imported = v.strings.as_ref().unwrap().import("same\0π").unwrap();
|
||||
assert!(!Arc::ptr_eq(&session, &imported));
|
||||
let mut hashes = vec![];
|
||||
v.operand_stack.pop();
|
||||
for owner in [&image_owner, &session, &imported] {
|
||||
push(&mut v, &[Value::String(owner.clone())]);
|
||||
let before = usage(&v);
|
||||
let count = Arc::strong_count(owner);
|
||||
v.execute_inline_intrinsic(&HASH_INTRINSICS[2], 0).unwrap();
|
||||
assert_eq!(usage(&v), before);
|
||||
assert_eq!(Arc::strong_count(owner), count - 1);
|
||||
hashes.push(v.operand_stack.pop().unwrap());
|
||||
}
|
||||
assert!(hashes.windows(2).all(|pair| pair[0] == pair[1]));
|
||||
}
|
||||
|
||||
fn missing(_: &[Value], _: &mut IntrinsicResults) -> Result<(), IntrinsicExecutionError> {
|
||||
Ok(())
|
||||
}
|
||||
fn wrong(_: &[Value], out: &mut IntrinsicResults) -> Result<(), IntrinsicExecutionError> {
|
||||
out.push(Value::Boolean(true))
|
||||
}
|
||||
fn excess(_: &[Value], out: &mut IntrinsicResults) -> Result<(), IntrinsicExecutionError> {
|
||||
out.push(Value::Int64(1))?;
|
||||
let _ = out.push(Value::Int64(2)); // Ignoring the error cannot publish a partial result.
|
||||
Ok(())
|
||||
}
|
||||
#[test]
|
||||
fn shared_invocation_rejects_bad_outputs_without_consuming_original_string_owner() {
|
||||
let mut v = empty();
|
||||
let Value::String(content) = v.import_string_value(&Value::String(Arc::from("kept"))).unwrap()
|
||||
else {
|
||||
panic!()
|
||||
};
|
||||
push(&mut v, &[Value::String(content.clone())]);
|
||||
let count = Arc::strong_count(&content);
|
||||
let before = usage(&v);
|
||||
for handler in [missing, wrong, excess] {
|
||||
let mut meta: IntrinsicMeta = HASH_INTRINSICS[2];
|
||||
meta.owner = "test"; // The shared executor is independent of the hash namespace.
|
||||
meta.implementation = IntrinsicImplementation::BorrowedInline(handler);
|
||||
fault(v.execute_inline_intrinsic(&meta, 0), TRAP_INVALID_INTRINSIC);
|
||||
assert_eq!(Arc::strong_count(&content), count);
|
||||
assert_eq!(usage(&v), before);
|
||||
assert!(matches!(v.operand_stack.last(),Some(Value::String(s)) if Arc::ptr_eq(s,&content)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
//! Shared borrowed invocation; algorithms receive no host/VM context.
|
||||
use super::*;
|
||||
use crate::{
|
||||
AbiType, IntrinsicExecutionError as E, IntrinsicImplementation as I, IntrinsicMeta,
|
||||
IntrinsicResults,
|
||||
};
|
||||
|
||||
impl VirtualMachine {
|
||||
fn inline_values(
|
||||
&self,
|
||||
values: &[Value],
|
||||
layout: &[AbiType],
|
||||
) -> Result<(), crate::value_contract::ValueError> {
|
||||
use crate::value_contract::ValueError;
|
||||
for (value, abi) in values.iter().zip(layout) {
|
||||
match value {
|
||||
Value::String(content) if self.validated_image.is_some() => {
|
||||
if !self.validated_image.as_ref().unwrap().retains_string(content)
|
||||
&& !self.strings.as_ref().is_some_and(|domain| domain.retains(content))
|
||||
{
|
||||
return Err(ValueError::Type);
|
||||
}
|
||||
}
|
||||
Value::HeapRef(reference) if matches!(abi, AbiType::Builtin(key) if key.name == "Random") =>
|
||||
{
|
||||
self.heap.random_state(*reference)?;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn execute_inline_intrinsic(
|
||||
&mut self,
|
||||
meta: &IntrinsicMeta,
|
||||
pc: u32,
|
||||
) -> Result<(), LogicalFrameEndingReason> {
|
||||
let op = OpCode::Intrinsic;
|
||||
let consumed = meta.arg_slots();
|
||||
let enough = self.temporary_slots() >= consumed;
|
||||
let args =
|
||||
if enough { &self.operand_stack[self.operand_stack.len() - consumed..] } else { &[] };
|
||||
let Some(cost) = meta.attempted_cost(args) else {
|
||||
self.cycles += meta.cost_cycles;
|
||||
return Err(self.trap(
|
||||
TRAP_RESOURCE_LIMIT,
|
||||
op as u16,
|
||||
"Intrinsic attempted cost overflow".into(),
|
||||
pc,
|
||||
));
|
||||
};
|
||||
self.cycles += cost;
|
||||
meta.validate_descriptor()
|
||||
.map_err(|message| self.trap(TRAP_INVALID_INTRINSIC, op as u16, message.into(), pc))?;
|
||||
if !enough {
|
||||
return Err(self.trap(
|
||||
TRAP_STACK_UNDERFLOW,
|
||||
op as u16,
|
||||
"Incomplete intrinsic operands".into(),
|
||||
pc,
|
||||
));
|
||||
}
|
||||
let I::BorrowedInline(handler) = meta.implementation else {
|
||||
return Err(self.trap(
|
||||
TRAP_INVALID_INTRINSIC,
|
||||
op as u16,
|
||||
"Wrong invocation profile".into(),
|
||||
pc,
|
||||
));
|
||||
};
|
||||
let base = self.operand_stack.len() - consumed;
|
||||
let args = &self.operand_stack[base..];
|
||||
meta.validate_argument_values(args).map_err(|_| {
|
||||
self.trap(TRAP_TYPE, op as u16, "Invalid intrinsic argument carrier".into(), pc)
|
||||
})?;
|
||||
self.inline_values(args, meta.arg_layout)
|
||||
.map_err(|error| self.value_trap(error, op, pc))?;
|
||||
let mut out = IntrinsicResults::new(meta.ret_slots());
|
||||
handler(args, &mut out).map_err(|error| match error {
|
||||
E::Numeric(error) => {
|
||||
self.trap(error.code, op as u16, format!("Intrinsic numeric fault: {error:?}"), pc)
|
||||
}
|
||||
_ => self.trap(
|
||||
TRAP_INVALID_INTRINSIC,
|
||||
op as u16,
|
||||
format!("Invalid intrinsic handler output: {error:?}"),
|
||||
pc,
|
||||
),
|
||||
})?;
|
||||
out.validate(meta).map_err(|error| {
|
||||
self.trap(
|
||||
TRAP_INVALID_INTRINSIC,
|
||||
op as u16,
|
||||
format!("Invalid intrinsic result: {error:?}"),
|
||||
pc,
|
||||
)
|
||||
})?;
|
||||
self.inline_values(out.as_slice(), meta.ret_layout).map_err(|_| {
|
||||
self.trap(
|
||||
TRAP_INVALID_INTRINSIC,
|
||||
op as u16,
|
||||
"Invalid intrinsic result ownership".into(),
|
||||
pc,
|
||||
)
|
||||
})?;
|
||||
self.operand_stack.truncate(base);
|
||||
for value in out.into_values() {
|
||||
self.operand_stack.push(value).expect("bounded result replaces admitted inputs");
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -132,3 +132,39 @@ fn collection_load_limits_and_analysis_refusals_keep_context_and_refund_scratch(
|
||||
assert_eq!(budget.used(LoadResource::RegistryBytes), 0);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn removed_storage_opcodes_reject_even_in_unreachable_instruction_positions() {
|
||||
use prometeu_bytecode::load_limits::{LoadCode, LoadReason};
|
||||
use prometeu_vm::VmInitError;
|
||||
for opcode in [0xa7u16, 0xa8, 0xaa, 0xab] {
|
||||
for dead in [false, true] {
|
||||
let mut code = if dead { vec![1, 0] } else { vec![] };
|
||||
let pc = code.len() as u32;
|
||||
code.extend_from_slice(&opcode.to_le_bytes());
|
||||
let VmInitError::RegistryLoadFailed(error) = load(&code).unwrap_err() else { panic!() };
|
||||
assert_eq!(error.code, LoadCode::InvalidCode);
|
||||
assert_eq!(error.reason, LoadReason::UnknownOpcode);
|
||||
assert_eq!((error.function, error.pc), (Some(0), Some(pc)));
|
||||
}
|
||||
}
|
||||
// The same bytes are accepted as an Int64 immediate, never decoded as opcodes.
|
||||
let code = [0x14, 0, 0xa7, 0, 0xa8, 0, 0xaa, 0, 0xab, 0, 1, 0];
|
||||
assert_eq!(
|
||||
run(&code),
|
||||
[Value::Int64(i64::from_le_bytes([0xa7, 0, 0xa8, 0, 0xaa, 0, 0xab, 0]))]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn neutral_pbx_copy_moves_a_range_and_preserves_physical_length() {
|
||||
let code=assemble("PUSH_I64 2\nARRAY_NEW 11\nSET_GLOBAL 0\nGET_GLOBAL 0\nPUSH_I64 0\nPUSH_I32 42\nARRAY_SET 11\nGET_GLOBAL 0\nPUSH_I64 0\nGET_GLOBAL 0\nPUSH_I64 1\nPUSH_I64 1\nARRAY_COPY 11\nGET_GLOBAL 0\nPUSH_I64 1\nARRAY_GET 11\nGET_GLOBAL 0\nARRAY_LEN 11\nHALT").unwrap();
|
||||
assert_eq!(run(&code), [Value::Int64(2), Value::Int32(42)]);
|
||||
for text in [
|
||||
"HALT\nARRAY_COPY 9",
|
||||
"HALT\nARRAY_COPY 99",
|
||||
"PUSH_I64 1\nARRAY_NEW 11\nPUSH_I64 0\nPUSH_I64 1\nARRAY_NEW 11\nPUSH_I64 0\nPUSH_BOOL 1\nARRAY_COPY 11\nHALT",
|
||||
] {
|
||||
assert!(load(&assemble(text).unwrap()).is_err(), "{text}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,3 +134,96 @@ fn provenance_queries_allocate_nothing_at_all_qualification_sizes() {
|
||||
assert_eq!(counts, (1, 1), "only snapshot Value storage allocates");
|
||||
}
|
||||
}
|
||||
|
||||
#[path = "support/identity.rs"]
|
||||
mod identity_support;
|
||||
|
||||
#[test]
|
||||
fn identity_and_borrowed_hash_instruction_regions_do_not_allocate() {
|
||||
use prometeu_bytecode::model::ConstantPoolEntry as K;
|
||||
for (name, initialize, operand, operation, steps, closure) in [
|
||||
("hash_i64", "PUSH_I64 -73\nSET_LOCAL 0", "GET_LOCAL 0", "INTRINSIC 0x4100", 4, false),
|
||||
("hash_float", "PUSH_CONST 0\nSET_LOCAL 0", "GET_LOCAL 0", "INTRINSIC 0x4101", 4, false),
|
||||
("hash_string", "PUSH_CONST 1\nSET_LOCAL 0", "GET_LOCAL 0", "INTRINSIC 0x4102", 4, false),
|
||||
(
|
||||
"struct_hash",
|
||||
"STRUCT_NEW 5\nSET_LOCAL 0",
|
||||
"GET_LOCAL 0",
|
||||
"REF_IDENTITY_HASH 5",
|
||||
4,
|
||||
false,
|
||||
),
|
||||
(
|
||||
"array_hash",
|
||||
"PUSH_I64 0\nARRAY_NEW 6\nSET_LOCAL 0",
|
||||
"GET_LOCAL 0",
|
||||
"REF_IDENTITY_HASH 6",
|
||||
4,
|
||||
false,
|
||||
),
|
||||
(
|
||||
"fn_hash",
|
||||
"MAKE_CLOSURE fn=1,type=9\nSET_LOCAL 0",
|
||||
"GET_LOCAL 0",
|
||||
"REF_IDENTITY_HASH 9",
|
||||
4,
|
||||
true,
|
||||
),
|
||||
(
|
||||
"random_hash",
|
||||
"PUSH_I64 1\nINTRINSIC 0x4000\nSET_LOCAL 0",
|
||||
"GET_LOCAL 0",
|
||||
"REF_IDENTITY_HASH 10",
|
||||
4,
|
||||
false,
|
||||
),
|
||||
(
|
||||
"trait_hash",
|
||||
"STRUCT_NEW 5\nREF_TO_TRAIT source=5,target=7\nSET_LOCAL 1\nSET_LOCAL 0",
|
||||
"GET_LOCAL 0\nGET_LOCAL 1",
|
||||
"REF_IDENTITY_HASH 7",
|
||||
5,
|
||||
false,
|
||||
),
|
||||
(
|
||||
"struct_eq",
|
||||
"STRUCT_NEW 5\nSET_LOCAL 0",
|
||||
"GET_LOCAL 0\nGET_LOCAL 0",
|
||||
"REF_IDENTITY_EQ left=5,right=5",
|
||||
5,
|
||||
false,
|
||||
),
|
||||
(
|
||||
"trait_eq",
|
||||
"STRUCT_NEW 5\nREF_TO_TRAIT source=5,target=7\nSET_LOCAL 1\nSET_LOCAL 0",
|
||||
"GET_LOCAL 0\nGET_LOCAL 1\nGET_LOCAL 0\nGET_LOCAL 1",
|
||||
"REF_IDENTITY_EQ left=7,right=7",
|
||||
7,
|
||||
false,
|
||||
),
|
||||
] {
|
||||
let start = assemble(initialize).unwrap().len();
|
||||
let text = format!("{initialize}\n{operand}\n{operation}\nPOP\nJMP {start}");
|
||||
let mut bodies = vec![(text.as_str(), identity_support::sig(&[], &[]))];
|
||||
if closure {
|
||||
bodies.push(("RET", identity_support::sig(&[], &[])));
|
||||
}
|
||||
let mut vm =
|
||||
identity_support::vm(&bodies, &[K::Float64(-0.0), K::String("π\0".repeat(512))]);
|
||||
let mut host = HostContext::new(None);
|
||||
while vm.pc() != start {
|
||||
vm.step(&mut identity_support::Native, &mut host).unwrap();
|
||||
}
|
||||
for _ in 0..steps * 10 {
|
||||
vm.step(&mut identity_support::Native, &mut host).unwrap();
|
||||
}
|
||||
let heap_allocations = vm.heap().allocation_count();
|
||||
COUNTS.with(|c| c.set(Some((0, 0))));
|
||||
for _ in 0..steps * 1000 {
|
||||
vm.step(&mut identity_support::Native, &mut host).unwrap();
|
||||
}
|
||||
let counts = COUNTS.with(|c| c.replace(None).unwrap());
|
||||
assert_eq!(counts, (0, 0), "{name}: allocations and deallocations");
|
||||
assert_eq!(vm.heap().allocation_count(), heap_allocations, "{name}: guest allocations");
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,23 @@
|
||||
# Hash-v1 oracle provenance
|
||||
|
||||
`hash-conformance.tsv` is generated by `hash-oracle.py` against the official C
|
||||
XXH64 reference, not the Rust VM implementation. Ordinary tests read the checked-in
|
||||
vectors and need no library, network or Python dependency.
|
||||
|
||||
Reference: https://github.com/Cyan4973/xxHash/blob/v0.8.3/xxhash.h
|
||||
|
||||
Header SHA-256: `17973c0dc49d9854ca26caa191f0e12f7a424b68858d9a78de3860d959d85e4b`.
|
||||
The generator verifies both the header digest and `XXH_versionNumber()==803`.
|
||||
|
||||
Example reproduction on macOS, after downloading that pinned header:
|
||||
|
||||
```sh
|
||||
clang -dynamiclib -O2 -x c -DXXH_IMPLEMENTATION -DXXH_STATIC_LINKING_ONLY xxhash.h -o libxxhash-oracle.dylib
|
||||
python3 hash-oracle.py --header xxhash.h --library ./libxxhash-oracle.dylib
|
||||
```
|
||||
|
||||
On Linux, use `-shared -fPIC` instead of `-dynamiclib`. The generator explicitly
|
||||
encodes little-endian integers/reference components and finite Float bit patterns,
|
||||
canonicalizes signed zeros, and uses seed zero. The null row is the machine
|
||||
contract's direct zero result, not a hash of an empty message. Arbitrary `bytes`
|
||||
rows exercise the internal algorithm; they do not expose guest byte strings.
|
||||
@@ -0,0 +1,51 @@
|
||||
"""Regenerate hash-v1 vectors using upstream XXH64, never the Rust executor."""
|
||||
import argparse
|
||||
import ctypes
|
||||
import hashlib
|
||||
from pathlib import Path
|
||||
import struct
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--library", required=True, type=Path)
|
||||
parser.add_argument("--header", required=True, type=Path)
|
||||
parser.add_argument("--output", type=Path, default=Path(__file__).with_name("hash-conformance.tsv"))
|
||||
args = parser.parse_args()
|
||||
expected = "17973c0dc49d9854ca26caa191f0e12f7a424b68858d9a78de3860d959d85e4b"
|
||||
assert hashlib.sha256(args.header.read_bytes()).hexdigest() == expected
|
||||
library = ctypes.CDLL(str(args.library.resolve()))
|
||||
assert library.XXH_versionNumber() == 803
|
||||
digest = library.XXH64
|
||||
digest.argtypes = [ctypes.c_void_p, ctypes.c_size_t, ctypes.c_uint64]
|
||||
digest.restype = ctypes.c_uint64
|
||||
rows = ["kind\tinput\texpected_hash_hex"]
|
||||
|
||||
def emit(kind, value, data):
|
||||
buffer = ctypes.create_string_buffer(data)
|
||||
result = digest(ctypes.cast(buffer, ctypes.c_void_p), len(data), 0)
|
||||
rows.append(f"{kind}\t{value}\t{result:016X}")
|
||||
|
||||
for size in list(range(71)) + [95, 96, 97, 127, 128, 129, 255, 256, 257, 1024, 4097]:
|
||||
data = bytes((i * 131 + 17) & 255 for i in range(size))
|
||||
emit("bytes", data.hex(), data)
|
||||
for value in [0, 1, -1, 2, -2, -(2**63), 2**63 - 1, 2**53 + 1, 2**32]:
|
||||
emit("i64", value, struct.pack("<q", value))
|
||||
for bits in [0, 0x8000000000000000, 0x3FF0000000000000, 0xBFF0000000000000,
|
||||
0x3FE0000000000000, 0xBFE0000000000000, 1, 0x8000000000000001,
|
||||
0x000FFFFFFFFFFFFF, 0x0010000000000000,
|
||||
0x7FEFFFFFFFFFFFFF, 0xFFEFFFFFFFFFFFFF, 0x4340000000000000]:
|
||||
canonical = 0 if bits & 0x7FFFFFFFFFFFFFFF == 0 else bits
|
||||
emit("float", f"{bits:016X}", struct.pack("<Q", canonical))
|
||||
for value in ["", "hello", "\0", "ação 😀", "a" * 31, "a" * 32, "a" * 33, "z" * 1025]:
|
||||
data = value.encode("utf-8")
|
||||
emit("string", data.hex(), data)
|
||||
for index, generation in [(0, 1), (1, 1), (1, 2), (1024, 1), (2**32-1, 2**32-1)]:
|
||||
emit("reference", f"{index},{generation}", struct.pack("<II", index, generation))
|
||||
rows.append("null\tnull\t0000000000000000")
|
||||
args.output.write_text("\n".join(rows) + "\n", encoding="utf-8")
|
||||
print(f"Generated {len(rows)-1} vectors with upstream XXH64 v0.8.3, seed 0.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,152 @@
|
||||
#[path = "support/identity.rs"]
|
||||
mod support;
|
||||
use prometeu_bytecode::{Value, model::ConstantPoolEntry as K};
|
||||
use prometeu_vm::{HostContext, LogicalFrameEndingReason as End};
|
||||
use support::*;
|
||||
|
||||
#[test]
|
||||
fn scalar_pbx_execution_matches_independent_c_reference_vectors() {
|
||||
let mut count = 0;
|
||||
for row in include_str!("fixtures/hash-conformance.tsv").lines().skip(1) {
|
||||
let fields: Vec<_> = row.split('\t').collect();
|
||||
let expected = u64::from_str_radix(fields[2], 16).unwrap() as i64;
|
||||
let (value, id, bytes) = match fields[0] {
|
||||
"i64" => (K::Int64(fields[1].parse().unwrap()), 0x4100, 0),
|
||||
"float" => {
|
||||
(K::Float64(f64::from_bits(u64::from_str_radix(fields[1], 16).unwrap())), 0x4101, 0)
|
||||
}
|
||||
"string" => {
|
||||
let bytes = hex_bytes(fields[1]);
|
||||
let size = bytes.len();
|
||||
(K::String(String::from_utf8(bytes).unwrap()), 0x4102, size)
|
||||
}
|
||||
"null" => (K::Null, 0x4102, 0),
|
||||
_ => continue,
|
||||
};
|
||||
let source = format!("PUSH_CONST 0\nINTRINSIC {id}\nRET");
|
||||
let mut vm = vm(&[(&source, sig(&[], &[0]))], &[value]);
|
||||
step(&mut vm).unwrap();
|
||||
let report = vm.run_budget(1, &mut Native, &mut HostContext::new(None)).unwrap();
|
||||
assert_eq!(report.reason, End::BudgetExhausted);
|
||||
assert_eq!(report.cycles_used, 8 + bytes as u64, "{row}");
|
||||
assert_eq!(&*vm.operand_stack_top(1), &[Value::Int64(expected)], "{row}");
|
||||
assert_eq!(run(&mut vm).reason, End::EndOfRom);
|
||||
count += 1;
|
||||
}
|
||||
assert_eq!(count, 31);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn identities_survive_mutation_and_views_validate_implementation_zero() {
|
||||
let source = "STRUCT_NEW 5\nSET_LOCAL 0\nGET_LOCAL 0\nREF_IDENTITY_HASH 5\nSET_LOCAL 1\nGET_LOCAL 0\nPUSH_I64 73\nSTRUCT_SET type=5,field=0\nGET_LOCAL 0\nREF_IDENTITY_HASH 5\nGET_LOCAL 1\nEQ\nGET_LOCAL 0\nREF_TO_TRAIT source=5,target=7\nREF_IDENTITY_HASH 7\nGET_LOCAL 1\nEQ\nGET_LOCAL 0\nREF_TO_TRAIT source=5,target=7\nGET_LOCAL 0\nREF_TO_TRAIT source=5,target=8\nREF_IDENTITY_EQ left=7,right=8\nGET_LOCAL 0\nSTRUCT_NEW 5\nREF_IDENTITY_EQ left=5,right=5\nRET";
|
||||
let mut vm = vm(&[(source, sig(&[], &[2, 2, 2, 2]))], &[]);
|
||||
assert_eq!(run(&mut vm).reason, End::EndOfRom);
|
||||
assert_eq!(
|
||||
&*vm.operand_stack_top(4),
|
||||
&[Value::Boolean(false), Value::Boolean(true), Value::Boolean(true), Value::Boolean(true)]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn array_closure_and_random_have_instance_identity() {
|
||||
for (source, bodies) in [
|
||||
(
|
||||
"PUSH_I64 1\nARRAY_NEW 6\nSET_LOCAL 0\nGET_LOCAL 0\nREF_IDENTITY_HASH 6\nSET_LOCAL 1\nGET_LOCAL 0\nPUSH_I64 0\nPUSH_I64 42\nARRAY_SET 6\nGET_LOCAL 0\nREF_IDENTITY_HASH 6\nGET_LOCAL 1\nEQ\nRET",
|
||||
false,
|
||||
),
|
||||
(
|
||||
"PUSH_I64 42\nINTRINSIC 0x4000\nSET_LOCAL 0\nGET_LOCAL 0\nREF_IDENTITY_HASH 10\nSET_LOCAL 1\nGET_LOCAL 0\nINTRINSIC 0x4001\nPOP\nGET_LOCAL 0\nREF_IDENTITY_HASH 10\nGET_LOCAL 1\nEQ\nRET",
|
||||
false,
|
||||
),
|
||||
(
|
||||
"MAKE_CLOSURE fn=1,type=9\nSET_LOCAL 0\nGET_LOCAL 0\nGET_LOCAL 0\nREF_IDENTITY_EQ left=9,right=9\nGET_LOCAL 0\nMAKE_CLOSURE fn=1,type=9\nREF_IDENTITY_EQ left=9,right=9\nNOT\nAND\nRET",
|
||||
true,
|
||||
),
|
||||
] {
|
||||
let mut functions = vec![(source, sig(&[], &[2]))];
|
||||
if bodies {
|
||||
functions.push(("RET", sig(&[], &[])));
|
||||
}
|
||||
let mut vm = vm(&functions, &[]);
|
||||
assert_eq!(run(&mut vm).reason, End::EndOfRom);
|
||||
assert_eq!(&*vm.operand_stack_top(1), &[Value::Boolean(true)]);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn canonical_null_groups_compare_and_hash_without_instance_faults() {
|
||||
let source = "PUSH_CONST 0\nPUSH_CONST 0\nREF_IDENTITY_HASH 7\nPUSH_CONST 0\nPUSH_CONST 0\nPUSH_CONST 0\nREF_IDENTITY_EQ left=6,right=7\nRET";
|
||||
let mut vm = vm(&[(source, sig(&[], &[0, 2]))], &[K::Null]);
|
||||
assert_eq!(run(&mut vm).reason, End::EndOfRom);
|
||||
assert_eq!(&*vm.operand_stack_top(2), &[Value::Boolean(true), Value::Int64(0)]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn admission_rejects_ineligible_sources_and_bad_native_ids_even_when_dead() {
|
||||
for instruction in [
|
||||
"REF_IDENTITY_HASH 0",
|
||||
"REF_IDENTITY_HASH 3",
|
||||
"REF_IDENTITY_HASH 4",
|
||||
"REF_IDENTITY_HASH 12",
|
||||
"REF_IDENTITY_HASH 13",
|
||||
"REF_IDENTITY_HASH 14",
|
||||
"REF_IDENTITY_HASH 9999",
|
||||
"REF_IDENTITY_EQ left=5,right=3",
|
||||
"INTRINSIC 0x41FF",
|
||||
] {
|
||||
let text = format!("HALT\n{instruction}");
|
||||
assert!(image(&[(&text, sig(&[], &[]))], &[]).is_err(), "{instruction}");
|
||||
}
|
||||
assert!(image(&[("PUSH_CONST 0\nINTRINSIC 0x4102\nRET", sig(&[], &[0]))], &[K::Null]).is_ok());
|
||||
for id in [0x1103, 0x4100, 0x4101] {
|
||||
let text = format!("PUSH_CONST 0\nINTRINSIC {id}\nPOP\nRET");
|
||||
assert!(image(&[(&text, sig(&[], &[]))], &[K::Null]).is_err(), "{id}");
|
||||
}
|
||||
assert!(image(&[("PUSH_I64 3\nREF_IDENTITY_HASH 5\nRET", sig(&[], &[0]))], &[]).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn whole_instruction_budget_admission_preserves_zero_and_overshoot() {
|
||||
let mut vm = vm(
|
||||
&[("PUSH_CONST 0\nINTRINSIC 0x4102\nRET", sig(&[], &[0]))],
|
||||
&[K::String("x".repeat(65))],
|
||||
);
|
||||
step(&mut vm).unwrap();
|
||||
let before = vm.pc();
|
||||
let zero = vm.run_budget(0, &mut Native, &mut HostContext::new(None)).unwrap();
|
||||
assert_eq!(zero.cycles_used, 0);
|
||||
assert_eq!(vm.pc(), before);
|
||||
let one = vm.run_budget(1, &mut Native, &mut HostContext::new(None)).unwrap();
|
||||
assert_eq!(one.reason, End::BudgetExhausted);
|
||||
assert_eq!(one.cycles_used, 73);
|
||||
assert_eq!(one.steps_executed, 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_eligible_absence_has_zero_hash_and_exact_identity_instruction_cost() {
|
||||
for (ty, width) in [(5, 1), (6, 1), (7, 2), (9, 1), (10, 1)] {
|
||||
let source = format!("{}REF_IDENTITY_HASH {ty}\nRET", "PUSH_CONST 0\n".repeat(width));
|
||||
let mut vm = vm(&[(&source, sig(&[], &[0]))], &[K::Null]);
|
||||
for _ in 0..width {
|
||||
step(&mut vm).unwrap();
|
||||
}
|
||||
let before = vm.pc();
|
||||
let zero = vm.run_budget(0, &mut Native, &mut HostContext::new(None)).unwrap();
|
||||
assert_eq!((zero.cycles_used, zero.steps_executed), (0, 0));
|
||||
assert_eq!(vm.pc(), before);
|
||||
let one = vm.run_budget(1, &mut Native, &mut HostContext::new(None)).unwrap();
|
||||
assert_eq!((one.cycles_used, one.steps_executed), (8 + width as u64, 1));
|
||||
assert_eq!(&*vm.operand_stack_top(1), &[Value::Int64(0)]);
|
||||
}
|
||||
for source in [
|
||||
"PUSH_CONST 0\nSTRUCT_NEW 5\nREF_IDENTITY_EQ left=6,right=5\nRET",
|
||||
"STRUCT_NEW 5\nSTRUCT_NEW 11\nREF_IDENTITY_EQ left=5,right=11\nRET",
|
||||
] {
|
||||
let mut vm = vm(&[(source, sig(&[], &[2]))], &[K::Null]);
|
||||
step(&mut vm).unwrap();
|
||||
step(&mut vm).unwrap();
|
||||
let one = vm.run_budget(1, &mut Native, &mut HostContext::new(None)).unwrap();
|
||||
assert_eq!((one.cycles_used, one.steps_executed), (6, 1));
|
||||
assert_eq!(&*vm.operand_stack_top(1), &[Value::Boolean(false)]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
use prometeu_bytecode::Value;
|
||||
use prometeu_vm::{
|
||||
AbiType, BuiltinScalarType as S, IntrinsicCostModel as C, intrinsic_catalog,
|
||||
intrinsic_catalog_csv, lookup_intrinsic_by_id,
|
||||
};
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
#[test]
|
||||
fn schema_two_has_exact_columns_profiles_and_per_slot_nullable_lists() {
|
||||
let csv = intrinsic_catalog_csv();
|
||||
assert_eq!(csv, include_str!("../../../../docs/vm-arch/INTRINSICS.csv"));
|
||||
let mut rows = csv.lines();
|
||||
assert_eq!(
|
||||
rows.next().unwrap(),
|
||||
"final_id_hex,final_id_dec,canonical_name,canonical_version,owner,name,arg_slots,ret_slots,arg_layout,ret_layout,deterministic,may_allocate,parameter_names,cost_cycles,mutates_guest_state,cost_model,attempt_cost_cycles,max_attempts,schema_version,arg_nullable,invocation_model,scratch_model,context_access,cost_arg_index,cost_per_byte"
|
||||
);
|
||||
let mut ids = BTreeSet::new();
|
||||
let mut keys = BTreeSet::new();
|
||||
let mut previous = 0;
|
||||
for row in rows {
|
||||
let f: Vec<_> = row.split(',').collect();
|
||||
assert_eq!(f.len(), 25);
|
||||
assert_eq!(f[18], "2");
|
||||
let id = f[1].parse::<u32>().unwrap();
|
||||
assert!(id > previous);
|
||||
previous = id;
|
||||
assert!(ids.insert(id));
|
||||
assert!(keys.insert((f[2], f[3])));
|
||||
let meta = lookup_intrinsic_by_id(id).unwrap();
|
||||
meta.validate_descriptor().unwrap();
|
||||
assert_eq!(f[19].split('|').filter(|s| !s.is_empty()).count(), meta.arg_slots());
|
||||
assert_eq!(f[20], meta.invocation_model());
|
||||
assert_eq!(f[21], meta.scratch_model());
|
||||
assert_eq!(f[22], meta.context_access());
|
||||
if id < 0x4100 {
|
||||
assert_eq!(f[21], "existing_contract_v1");
|
||||
assert_eq!(f[23], "");
|
||||
assert_eq!(f[24], "0");
|
||||
assert_eq!(f[20], if f[4] == "random" { "vm_owned_v1" } else { "host_buffered_v1" });
|
||||
for (abi, nullable) in meta.arg_layout.iter().zip(meta.arg_nullable) {
|
||||
assert_eq!(*nullable, matches!(abi,AbiType::Builtin(key) if key.name=="Random"));
|
||||
}
|
||||
} else {
|
||||
assert_eq!(&f[20..23], &["borrowed_inline_v1", "none", "none"]);
|
||||
assert_eq!(meta.cost_cycles, 8);
|
||||
assert_eq!(meta.ret_layout, &[AbiType::Scalar(S::Int64)]);
|
||||
assert_eq!(meta.arg_nullable, &[id == 0x4102]);
|
||||
}
|
||||
}
|
||||
assert_eq!(ids.len(), 108);
|
||||
assert_eq!(intrinsic_catalog().count(), 108);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn incompatible_descriptors_fail_instead_of_gaining_implicit_capabilities() {
|
||||
let original = *lookup_intrinsic_by_id(0x4102).unwrap();
|
||||
for variant in 0..14 {
|
||||
let mut meta = original;
|
||||
match variant {
|
||||
0 => meta.arg_nullable = &[],
|
||||
1 => meta.parameter_names = &[],
|
||||
2 => meta.cost_arg_index = None,
|
||||
3 => meta.cost_arg_index = Some(1),
|
||||
4 => meta.cost_per_byte = 0,
|
||||
5 => meta.attempt_cost_cycles = 1,
|
||||
6 => meta.max_attempts = 1,
|
||||
7 => meta.may_allocate = true,
|
||||
8 => meta.mutates_guest_state = true,
|
||||
9 => meta.deterministic = false,
|
||||
10 => meta.ret_layout = &[AbiType::Scalar(S::Int64); 4],
|
||||
11 => meta.ret_layout = &[AbiType::Scalar(S::Int64); 2],
|
||||
12 => meta.ret_layout = &[AbiType::DynamicPayload],
|
||||
13 => meta.arg_layout = &[AbiType::DynamicTag],
|
||||
_ => unreachable!(),
|
||||
}
|
||||
assert!(meta.validate_descriptor().is_err(), "variant {variant}");
|
||||
}
|
||||
let mut meta = *lookup_intrinsic_by_id(0x4100).unwrap();
|
||||
meta.arg_nullable = &[true];
|
||||
assert!(meta.validate_descriptor().is_err());
|
||||
meta.arg_nullable = &[false];
|
||||
meta.cost_arg_index = Some(0);
|
||||
assert!(meta.validate_descriptor().is_err());
|
||||
meta.cost_model = C::ArgumentUtf8BytesV1;
|
||||
meta.cost_per_byte = 1;
|
||||
assert!(meta.validate_descriptor().is_err());
|
||||
meta.cost_model = C::RandomRejectionV1;
|
||||
meta.cost_arg_index = None;
|
||||
meta.cost_per_byte = 0;
|
||||
meta.attempt_cost_cycles = 8;
|
||||
meta.max_attempts = 64;
|
||||
assert!(meta.validate_descriptor().is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nullability_does_not_relax_existing_string_or_numeric_arguments() {
|
||||
for id in [0x4100, 0x4101, 0x1103] {
|
||||
assert!(
|
||||
lookup_intrinsic_by_id(id).unwrap().validate_argument_values(&[Value::Null]).is_err()
|
||||
);
|
||||
}
|
||||
assert!(
|
||||
lookup_intrinsic_by_id(0x4102).unwrap().validate_argument_values(&[Value::Null]).is_ok()
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
#![allow(dead_code)]
|
||||
use prometeu_bytecode::{
|
||||
assemble, load_limits::LoadBudget, model::ConstantPoolEntry, registry::*,
|
||||
registry_codec::PbxModule,
|
||||
};
|
||||
use prometeu_vm::{
|
||||
HostContext, HostReturn, LogicalFrameEndingReason, NativeInterface, ValidatedProgramImage,
|
||||
VirtualMachine, VmInitError,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
pub struct Native;
|
||||
impl NativeInterface for Native {
|
||||
fn syscall(
|
||||
&mut self,
|
||||
_: u32,
|
||||
_: &[prometeu_bytecode::Value],
|
||||
_: &mut HostReturn,
|
||||
_: &mut HostContext,
|
||||
) -> Result<(), prometeu_hal::vm_fault::VmFault> {
|
||||
panic!("identity corpus uses no host syscall")
|
||||
}
|
||||
}
|
||||
pub fn sig(parameters: &[u32], results: &[u32]) -> Signature {
|
||||
Signature {
|
||||
parameters: parameters
|
||||
.iter()
|
||||
.map(|&id| NamedType { type_id: TypeId(id), name: None })
|
||||
.collect(),
|
||||
results: results.iter().copied().map(TypeId).collect(),
|
||||
}
|
||||
}
|
||||
pub fn types() -> Vec<TypeDecl> {
|
||||
let field = || NamedType { type_id: TypeId(0), name: None };
|
||||
vec![
|
||||
TypeKind::Builtin(BuiltinId::INT64),
|
||||
TypeKind::Builtin(BuiltinId::FLOAT),
|
||||
TypeKind::Builtin(BuiltinId::BOOL),
|
||||
TypeKind::Builtin(BuiltinId::STRING),
|
||||
TypeKind::Builtin(BuiltinId::DYNAMIC),
|
||||
TypeKind::Struct(vec![field()]),
|
||||
TypeKind::Array(TypeId(0)),
|
||||
TypeKind::Trait(vec![]),
|
||||
TypeKind::Trait(vec![]),
|
||||
TypeKind::Fn(sig(&[], &[])),
|
||||
TypeKind::Builtin(BuiltinId::RANDOM),
|
||||
TypeKind::Struct(vec![field()]),
|
||||
TypeKind::Builtin(BuiltinId::COLOR),
|
||||
TypeKind::Builtin(BuiltinId::VEC2),
|
||||
TypeKind::Builtin(BuiltinId::PIXEL),
|
||||
TypeKind::Builtin(BuiltinId::INT32),
|
||||
]
|
||||
.into_iter()
|
||||
.map(|kind| TypeDecl { name: None, kind })
|
||||
.collect()
|
||||
}
|
||||
pub fn image(
|
||||
bodies: &[(&str, Signature)],
|
||||
constants: &[ConstantPoolEntry],
|
||||
) -> Result<Arc<ValidatedProgramImage>, VmInitError> {
|
||||
let mut code = vec![];
|
||||
let mut functions = vec![];
|
||||
for (source, signature) in bodies {
|
||||
let body = assemble(source).unwrap();
|
||||
functions.push(FunctionDecl {
|
||||
signature: signature.clone(),
|
||||
local_slots: 8,
|
||||
max_stack_slots: 64,
|
||||
code_offset: code.len() as u32,
|
||||
code_len: body.len() as u32,
|
||||
..Default::default()
|
||||
});
|
||||
code.extend(body);
|
||||
}
|
||||
let mut budget = LoadBudget::new(Default::default());
|
||||
let registry = Registry::resolve(
|
||||
RegistryDeclarations {
|
||||
types: types(),
|
||||
functions,
|
||||
implementations: vec![
|
||||
ImplementationDecl { owner: TypeId(5), trait_id: TypeId(7), methods: vec![] },
|
||||
ImplementationDecl { owner: TypeId(5), trait_id: TypeId(8), methods: vec![] },
|
||||
],
|
||||
},
|
||||
code.len(),
|
||||
&mut budget,
|
||||
)
|
||||
.unwrap();
|
||||
let bytes = PbxModule {
|
||||
registry: ®istry,
|
||||
code: &code,
|
||||
constants,
|
||||
debug: None,
|
||||
exports: &[],
|
||||
syscalls: &[],
|
||||
}
|
||||
.serialize(&mut budget)
|
||||
.unwrap();
|
||||
ValidatedProgramImage::load(&bytes, &mut LoadBudget::new(Default::default()), 0)
|
||||
}
|
||||
pub fn vm(bodies: &[(&str, Signature)], constants: &[ConstantPoolEntry]) -> VirtualMachine {
|
||||
let mut vm = VirtualMachine::from_image(image(bodies, constants).unwrap(), Default::default());
|
||||
vm.prepare_boot_call().unwrap();
|
||||
vm
|
||||
}
|
||||
pub fn run(vm: &mut VirtualMachine) -> prometeu_vm::BudgetReport {
|
||||
vm.run_budget(1_000_000, &mut Native, &mut HostContext::new(None)).unwrap()
|
||||
}
|
||||
pub fn step(vm: &mut VirtualMachine) -> Result<(), LogicalFrameEndingReason> {
|
||||
vm.step(&mut Native, &mut HostContext::new(None))
|
||||
}
|
||||
pub fn hex_bytes(value: &str) -> Vec<u8> {
|
||||
(0..value.len()).step_by(2).map(|i| u8::from_str_radix(&value[i..i + 2], 16).unwrap()).collect()
|
||||
}
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
---
|
||||
id: LSN-0072
|
||||
ticket: vm-storage-publication-neutrality
|
||||
title: Primitives Need Independent Semantics and Failed Attempts Still Cost Work
|
||||
created: 2026-10-23
|
||||
tags: [vm, isa, storage, atomicity, ownership, cycles, frontend-neutrality]
|
||||
---
|
||||
|
||||
## Context and Published Result
|
||||
|
||||
DEC-0067, accepted from AGD-0068 and implemented by PLN-0198, reduced the storage
|
||||
ISA after reviewing additions requested by a consumer. The runtime removed
|
||||
INDEX_GUARD (0xA7), ARRAY_CHECK_LENGTH (0xA8), STORAGE_PUBLISH (0xAA) and
|
||||
FIELDS_PUBLISH (0xAB). ARRAY_COPY remains at 0xA9 and ARRAY_LEN at 0xA4. The
|
||||
supported encodings and fault/cost contracts live in the
|
||||
[canonical ISA](../../../docs/specs/runtime/02-vm-instruction-set.md#typed-array-range-copy),
|
||||
[time model](../../../docs/specs/runtime/01-time-model-and-cycles.md#collection-attempt-charging)
|
||||
and [memory specification](../../../docs/specs/runtime/03-memory-stack-heap-and-allocation.md#prepared-array-range-copy).
|
||||
The [producer handoff](../../../docs/vm-arch/collection-producer-handoff.md) and
|
||||
[qualification record](../../../docs/vm-arch/STORAGE_QUALIFICATION.md) describe
|
||||
integration obligations and executable evidence. This lesson explains the result;
|
||||
it does not establish a separate contract.
|
||||
|
||||
## A Consumer Request Is Evidence, Not a Permanent ISA Commitment
|
||||
|
||||
A real compiler or SDK can expose missing capabilities. That makes its use cases
|
||||
valuable evidence, but delivery in one consumer does not make every added helper
|
||||
an enduring machine primitive. Re-evaluate the operation's own semantics, failure
|
||||
boundary and reuse across representations. Backward compatibility was explicitly
|
||||
not a requirement for this revision.
|
||||
|
||||
The removed guards expressed logical limits and allocation-free validation that
|
||||
the producer can organize through its existing control flow. ARRAY_LEN remains
|
||||
useful as a direct physical query; removing logical helpers does not remove
|
||||
physical validation from allocation and array access. A collection's logical
|
||||
length can differ from its backing array's physical length.
|
||||
|
||||
The removed publications coupled several mutations into fixed or schema-selected
|
||||
batches. Supporting one current collection algorithm did not justify maintaining
|
||||
those compound machine guarantees. ARRAY_COPY survives because strict typed
|
||||
range transfer, snapshot overlap and complete-group ownership provide independent
|
||||
machine semantics without identifying a source collection.
|
||||
|
||||
Learning from Java, C#, Rust and Go means examining principles and tradeoffs,
|
||||
not selecting a mandatory frontend. JavaScript and Lua were philosophical tests
|
||||
of the architecture's independence. No engine, frontend or object from either
|
||||
language was needed to implement or qualify this change.
|
||||
|
||||
## An Instruction Boundary Does Not Roll Back a Source Operation
|
||||
|
||||
ARRAY_COPY starts with five prepared operands. It reserves full scratch, captures
|
||||
all source groups and then commits prevalidated writes. Failure preserves its
|
||||
operands and destinations while releasing provisional scratch. Earlier source
|
||||
calculations, allocations or callbacks keep their effects.
|
||||
|
||||
Snapshot preparation explains overlap: when copying indices 0..3 to 1..4 of the
|
||||
same array, the source sequence is captured before any destination store. Native
|
||||
String owners, HeapRefs, Dynamic tags/boxes and Trait groups travel together.
|
||||
Splitting carriers or cloning payload graphs would change the operation.
|
||||
|
||||
A series of individually validated STRUCT_SET or ARRAY_SET instructions does not
|
||||
inherit a shared rollback boundary. A consumer that previously relied on a batch
|
||||
must establish its invariant through an appropriate algorithm/representation or
|
||||
explicitly revise its operational guarantee. A renamed helper emitting sequential
|
||||
stores does not prove equivalence. Consumer migration remains an independent
|
||||
delivery; it does not block publication of the runtime's own supported surface.
|
||||
|
||||
## Select Cost Early Without Selecting the First Fault Early
|
||||
|
||||
Let N be count and W the immutable Registry element-slot width. ARRAY_COPY charges
|
||||
4+2*N*W when all five temporary operands are available and N is an exact Int64 in
|
||||
0..u32::MAX. For ten one-slot elements the attempt costs 24 even if a receiver is
|
||||
null, a range is invalid or scratch reservation fails. That charge records the
|
||||
planned work of an admitted attempt, independently of published state.
|
||||
|
||||
Inspecting N early only selects cost. It does not move an invalid count ahead of
|
||||
an invalid receiver in ordinary fault precedence. If count has a wrong carrier or
|
||||
is outside the calculable domain, charge base 4 and follow normal validation.
|
||||
With null source and negative count, the receiver fault still wins. Frame locals
|
||||
must never stand in for missing temporary operands.
|
||||
|
||||
Zero count still validates both receivers and ranges and costs 4. Identity and
|
||||
aliasing do not discount a copy. Checked total-cost overflow has its explicit
|
||||
base-charge/SizeOverflow path; synthetic widths test this defense without claiming
|
||||
that such widths are admitted guest layouts.
|
||||
|
||||
This extends the reasoning in
|
||||
[Collection Attempts Preserve Groups and Charge Work Before Publication](../DSC-0051-game-state-collections-and-objects/LSN-0060-collection-attempts-preserve-groups-and-charge-work-before-publication.md):
|
||||
unchanged state and consumed cycles are compatible outcomes. Positive budget
|
||||
admits an entire instruction with overshoot; zero admits none. A failed attempt
|
||||
reports its trap and charged cycles, but contributes no successful target step.
|
||||
|
||||
## Remove Support at Every Boundary
|
||||
|
||||
Removing dispatch alone leaves assemblers, decoder metadata or dead-code
|
||||
verification advertising obsolete capabilities. This implementation removes all
|
||||
four variants, encodings, metadata, assembler/disassembler cases, Registry effects,
|
||||
verifier paths and executors. Unsupported instruction positions reject during
|
||||
admission, including after HALT. The same byte values inside a legitimate immediate
|
||||
remain data, so a raw byte search is not an admission rule.
|
||||
|
||||
The retained copy now has a dedicated executor. Tests inherited from the compound
|
||||
publication paths were migrated to copy-specific overlap, quota and group cases.
|
||||
That preserves relevant evidence while eliminating tests of obsolete successes.
|
||||
|
||||
## Evidence and Practical Limits
|
||||
|
||||
The qualification record identifies the source baseline and working-tree
|
||||
fingerprints rather than attributing uncommitted code to a new provider SHA.
|
||||
Tests use independent literal encodings and serialized neutral PBX, the production
|
||||
loader/VM, exact cycle/fault oracles, quota and allocation-failure injection,
|
||||
late invalid source groups, overlap in both directions, frame temporary floors,
|
||||
zero/positive budgets, and native/guest owners across collection.
|
||||
|
||||
Internal state injection is labeled separately from admitted-program evidence.
|
||||
The checked-cost overflow test uses synthetic widths; it does not relax Registry
|
||||
layout rules. Test-only cleanup also shares the collection fixture module and
|
||||
removes redundant Copy clones to satisfy Clippy without changing identity/hash
|
||||
semantics. Full gate results and remaining ignored tests are recorded with their
|
||||
actual execution status.
|
||||
|
||||
These results do not establish the Studio SDK's migration, its old compound
|
||||
atomicity guarantees, new collection algorithms, or JavaScript/Lua conformance.
|
||||
Those claims require the consumer's own accepted contract and new evidence on
|
||||
an identified provider.
|
||||
|
||||
## Pitfalls
|
||||
|
||||
- Keeping a primitive solely because a delivered SDK already emits it.
|
||||
- Removing a logical guard while accidentally weakening physical bounds checks.
|
||||
- Charging only after receiver/range validation, which changes failed-attempt cost.
|
||||
- Letting cost inspection reorder value faults or read below the temporary floor.
|
||||
- Dropping ownership/overlap coverage when deleting the old compound executor.
|
||||
- Treating stores as a transaction, or claiming old consumer evidence for a new provider.
|
||||
- Searching arbitrary payload bytes instead of actual instruction boundaries.
|
||||
+146
@@ -0,0 +1,146 @@
|
||||
---
|
||||
id: LSN-0071
|
||||
ticket: vm-identity-and-value-hashing
|
||||
title: Identity domains and borrowed intrinsic invocation
|
||||
created: 2026-10-23
|
||||
tags: [vm, identity, hashing, values, compiler]
|
||||
---
|
||||
|
||||
## Context
|
||||
|
||||
The runtime needed stable identity queries and scalar/content hashing while
|
||||
preserving typed values, faults, owners and execution accounting. Existing
|
||||
Host intrinsics buffered arguments/results and exposed mutable context. That
|
||||
path could not establish the required no-scratch/no-guest-allocation contract
|
||||
by adding a purity flag alone.
|
||||
|
||||
The executed decision was DEC-0066, originating in AGD-0069; PLN-0197 delivered
|
||||
the independent runtime provider. Their permanent lifecycle provenance is in
|
||||
[the discussion index](../../index.ndjson). Workflow control artifacts are
|
||||
removed after completion. Published authority is the
|
||||
[canonical identity/hash specification](../../../docs/specs/runtime/02f-vm-identity-and-value-hashing.md),
|
||||
with the [qualification record](../../../docs/vm-arch/IDENTITY_HASHING_QUALIFICATION.md)
|
||||
and [producer handoff](../../../docs/vm-arch/identity-hashing-producer-handoff.md).
|
||||
This lesson explains the published design; it does not replace its contract.
|
||||
|
||||
## Key decisions
|
||||
|
||||
### Equality belongs to a selected domain
|
||||
|
||||
**What:** The VM provides exact reference identity plus separate Int64, Float
|
||||
and String hashes. SDK/producer policy selects equality, numeric canonicalization,
|
||||
component composition and optional/Dynamic behavior.
|
||||
|
||||
**Why:** Sharing a physical carrier does not establish a semantic equality domain.
|
||||
Two Trait views can share one receiver even with different implementation IDs;
|
||||
two closures with identical code/captures still have separate instance identity.
|
||||
Conversely, separately owned Strings can share content and therefore a content
|
||||
hash. A universal equality layer would silently choose language policy.
|
||||
|
||||
**Trade-offs:** Producers need coherent wrappers and composition. They gain
|
||||
explicit control without duplicating the machine's handle validation or hash
|
||||
algorithm. A hypothetical Lua consumer was a design stress test; no Lua frontend
|
||||
was implemented or needed for provider qualification.
|
||||
|
||||
### Improve intrinsic invocation with an executable profile
|
||||
|
||||
**What:** borrowed_inline_v1 borrows the original stack arguments, computes into
|
||||
fixed native output slots, validates complete output and commits once. Its
|
||||
handler receives no mutable HostContext or VM access. Invocation/scratch/context
|
||||
metadata derive from the handler representation, preventing inconsistent claims.
|
||||
The new profile is shared infrastructure, not a hash-namespace branch.
|
||||
|
||||
**Why:** deterministic, allocation and mutation flags describe separate concerns.
|
||||
A deterministic function can still allocate scratch or mutate seeded state.
|
||||
Purity metadata cannot make a buffered callback transactional. The invocation
|
||||
interface and commit protocol must enforce the resource/ownership story.
|
||||
|
||||
**Trade-offs:** The profile deliberately supports bounded output replacement.
|
||||
Unsupported capacities, ABI layouts and effect/cost combinations fail rather
|
||||
than falling back to dynamic storage. Existing Host and VM-owned Random handlers
|
||||
retain their established contract; they were not broadly migrated.
|
||||
|
||||
### Fault order and charging are part of semantics
|
||||
|
||||
**What:** Charge from safe carrier/Registry metadata before validation; preserve
|
||||
both groups until complete validation and computation succeed. Validate left
|
||||
before right even when a result seems obvious. String's known byte length is
|
||||
charged before ownership refusal; overflow charges base and traps.
|
||||
|
||||
**Why:** Early false/null results can conceal malformed or stale references.
|
||||
Popping operands before work makes failures change roots or drop String owners.
|
||||
Partial fuel checks or duplicate generic INTRINSIC costs change deterministic
|
||||
execution traces and compiler optimization obligations.
|
||||
|
||||
**Trade-offs:** An admitted instruction can overshoot positive fuel, and invalid
|
||||
long Strings still pay traversal-sized virtual cost without being traversed.
|
||||
The contract makes that explicit and testable. Zero fuel executes nothing.
|
||||
|
||||
## Patterns and algorithms
|
||||
|
||||
Reference identity is validated index plus generation, serialized as two LE u32s
|
||||
for XXH64 seed zero. The hash excludes fields, captures, generator state, trait
|
||||
metadata and native addresses. It is stable for a live object but creates no
|
||||
root or persistent cross-session identity. GC may collect an object while an
|
||||
Int64 hash remains; generation advancement still invalidates old handles.
|
||||
|
||||
Scalar hashing uses explicit LE messages. Float hashes binary64 bits, with both
|
||||
zeros canonicalized, and rejects non-finite values. It never performs numerical
|
||||
Float-to-integer conversion. String uses exact UTF-8 bytes, including NUL;
|
||||
accepted absence returns zero directly and empty String hashes the empty message.
|
||||
Signed Int64 carries the unchanged unsigned digest bits.
|
||||
|
||||
Schema 2 appends capability, nullability and cost fields to the original 18 CSV
|
||||
columns. Runtime descriptors generate the catalog, validate consistency and feed
|
||||
static per-entry nullability. Known null for hash.string does not relax older
|
||||
String entries. Explicit legacy profile tokens document the existing contract
|
||||
without claiming the bounded profile's guarantees for every intrinsic.
|
||||
|
||||
## Independent evidence
|
||||
|
||||
The Rust algorithm agrees with 118 vectors generated from the pinned official C
|
||||
XXH64 reference. Raw instruction bytes are checked independently of round-trip
|
||||
assembly. Serialized PBX exercises admission and actual VM dispatch; private
|
||||
fault injection reaches stale handles, NaN payloads and deliberately broken
|
||||
handlers that production admission prevents.
|
||||
|
||||
Ten warmed instruction regions each ran 1,000 iterations without native
|
||||
allocation/deallocation or guest heap allocation. Resource refusal tests preserve
|
||||
operands/owners/accounting. GC/reuse tests distinguish live identity, stale
|
||||
identity and hashes that do not root their source. Distribution tests use reduced
|
||||
buckets and deliberately observe collisions without substituting hash equality
|
||||
for reference equality.
|
||||
|
||||
The default bytecode/VM suites passed 453 tests; the VM diagnostic suite passed
|
||||
401; quality/layer checks passed 19; selected release suites passed 12. Local
|
||||
target/toolchain, existing ignored tests, source fingerprints, catalog/constant
|
||||
checks and exact commands are retained in the qualification record. Those
|
||||
results do not assert cross-target or source frontend integration.
|
||||
|
||||
## Pitfalls
|
||||
|
||||
- Inferring no scratch, no context or purity from deterministic loses independent
|
||||
capability information. Stateful Random is reproducible but still mutates.
|
||||
- Comparing only a Trait receiver without validating its implementation pair
|
||||
accepts malformed views; treating implementation zero as absence breaks valid views.
|
||||
- Reusing physical HeapRef rules for String, Dynamic or arbitrary builtins expands
|
||||
semantic domains without a contract. Eligibility needs its own precise predicate.
|
||||
- Canonical stack null and HeapRef(0,0) have different validation behavior.
|
||||
- Numerical conversion of Float, host-endian messages or native hashing defaults
|
||||
breaks reproducible bit-level results.
|
||||
- Allocation-free algorithms can still hide argument/result buffers in generic
|
||||
invocation. Count the real instruction region, including reallocations.
|
||||
- Updating a catalog mirror alone does not migrate the compiler or installed SDK.
|
||||
Metadata, IR, emission, pinning, resources and normal/optimized source evidence
|
||||
each need a named consumer acceptance target.
|
||||
|
||||
## Takeaways
|
||||
|
||||
Make the safe execution profile an implementation capability and validate its
|
||||
metadata. Preserve original operands as roots through the last fallible step.
|
||||
Separate identity, content and language equality policy. Qualify encoding,
|
||||
algorithm, invocation, ownership and scheduling with independent evidence.
|
||||
|
||||
The runtime provider is complete independently of Studio source integration,
|
||||
Set/Map, storage publication and future frontends. Consumer obligations remain
|
||||
concrete handoff targets rather than an unbounded extension of this delivery.
|
||||
@@ -169,6 +169,16 @@ The [Dynamic/reference instruction table](02c-program-registry-and-pbx-v0.md#dyn
|
||||
|
||||
The [collection ISA table](02-vm-instruction-set.md#typed-collection-instructions) defines complete costs. Metadata widths determine costs independently of native sizeof, allocator, timing, optimizer and GC. Each decoded collection attempt is charged exactly once before validation/refusal. Fixed costs apply even to underflow, invalid receiver, bounds and rejected value groups. ARRAY_NEW charges 8 + N*w(E) whenever an available exact Int64 length is in 0..u32::MAX, including quota/allocation refusal; absent, wrong-carrier, negative or above-u32 length charges eight. Rejected loads execute and charge no guest instruction.
|
||||
|
||||
ARRAY_COPY charges C=4+2*N*W when all five temporary operands are available and
|
||||
count is exact Int64 in 0..u32::MAX. W comes from immutable Registry element
|
||||
storage. Charge C before receiver/range/group validation and scratch reservation,
|
||||
retaining it on refusal. Otherwise charge base 4 and preserve ordinary fault
|
||||
precedence. Checked cost overflow charges base 4 and traps SizeOverflow before
|
||||
ordinary validation. Never inspect frame locals as missing operands. Empty copies
|
||||
still validate and cost 4; identity/overlap give no discount. Ten one-slot elements
|
||||
cost 24 on success, invalid receiver/range or scratch refusal. Full validation
|
||||
order is defined in the [copy contract](02-vm-instruction-set.md#typed-array-range-copy).
|
||||
|
||||
Examples: empty Struct/Array costs eight; a Struct containing Int32, vec2 and Trait costs thirteen; ten vec2 elements cost twenty-eight even on quota refusal; pixel GET costs six including bounds failure; pixel SET costs seven including group rejection; LEN costs three including receiver failure. Charged cycles are never refunded by rollback.
|
||||
|
||||
Budget admission remains between instructions. Zero executes nothing. A positive remaining budget admits the entire next instruction, which may overshoot; continuation then returns BudgetExhausted before the following instruction. Thus ARRAY_NEW of ten vec2 under run_budget(1) consumes twenty-eight cycles. Trap takes priority on refusal, with the same cycle delta and no successful target step. steps_executed counts only successful steps; cycles_used includes failed attempts. Collection operations add no implicit frame sync, tick, GC or coroutine switch, no extra length cap and no cycle pre-admission rule.
|
||||
@@ -192,3 +202,13 @@ remain unchanged. CPU timings never change guest-visible cycle weights.
|
||||
## Random core integration
|
||||
|
||||
The [random core](02e-vm-owned-random-core.md) charges fixed calls before checks and bounded range calls as 4+8*N (at most 64 draws), retaining fault cycles and whole-instruction overshoot.
|
||||
|
||||
## Identity and hash attempts
|
||||
|
||||
The [identity/hash contract](02f-vm-identity-and-value-hashing.md) charges
|
||||
8+w(T) for reference hash, 4+w(A)+w(B) for identity comparison, eight for scalar
|
||||
numeric hashes, and 8+n resident UTF-8 bytes for String. Known lengths charge
|
||||
before traversal/refusal; null/wrong/unavailable String carriers charge eight.
|
||||
Checked cost overflow charges base and faults. These are total attempted costs,
|
||||
without a generic extra INTRINSIC cycle or refunds. Existing whole-instruction
|
||||
overshoot and zero-budget rules apply; the operations introduce no safepoint.
|
||||
|
||||
@@ -161,3 +161,65 @@ Typed callable instructions are MAKE_CLOSURE `(FunctionId,FnTypeId)`, CALL_CLOSU
|
||||
## Random core integration
|
||||
|
||||
INTRINSIC also dispatches the [VM-owned random operations](02e-vm-owned-random-core.md), IDs 0x4000–0x4003. NEW cannot construct Random. TRAP_RANDOM_REJECTION_LIMIT is 0x00000015.
|
||||
|
||||
|
||||
## Typed array range copy
|
||||
|
||||
ARRAY_COPY uses little-endian u16 opcode 0xA9 followed by one little-endian u32
|
||||
Array TypeId. It consumes five operands, bottom to top: source, sourceStart,
|
||||
target, targetStart, count, and produces no result. Receivers require the exact
|
||||
Array type; sourceStart, targetStart and count require exact Int64 carriers.
|
||||
Ranges must be nonnegative and fit each physical array, without clamping,
|
||||
truncation or coercion. An empty range may start at the physical length.
|
||||
|
||||
Loading validates Array identity/category even in unreachable code. Registry
|
||||
verification requires five complete operands. The instruction may trap, but is
|
||||
neither a branch, terminator nor safepoint. ARRAY_LEN (0xA4) remains the physical
|
||||
length query. Logical collection limits and error paths belong to producers.
|
||||
The encodings 0xA7, 0xA8, 0xAA and 0xAB are unsupported and reject at admission,
|
||||
including in unreachable code. Bytes inside immediates or data are not opcodes.
|
||||
There is no multi-owner publication, generic batch or atomic-region replacement.
|
||||
|
||||
Copy preserves complete stored groups, including presence tags, immutable boxes,
|
||||
native String owners, HeapRefs, traits and identities without boxing or payload
|
||||
repacking. All source groups are captured before the first destination write,
|
||||
so overlap observes the pre-attempt source sequence. All copy scratch is reserved
|
||||
under TemporaryBytes before writing and released on success or failure. Original
|
||||
operands remain roots throughout preparation. No guest object or request token
|
||||
is allocated. Quota refusal does not trigger rescue GC.
|
||||
|
||||
Validation, quota or recoverable allocation failure preserves operands and all
|
||||
destinations/owners. Commit uses prevalidated infallible writes; no callback,
|
||||
allocation, GC or scheduler boundary occurs inside the instruction. Consume the
|
||||
five operands only after commit. Cycles and diagnostics retain the attempt.
|
||||
This guarantee begins with prepared operands; it does not undo earlier source
|
||||
calculations, allocations or callbacks, or make a sequence of stores transactional.
|
||||
|
||||
Let N=count and W=element storage slots from the immutable validated Registry.
|
||||
The planned cost is C=4+2*N*W. Charge base 4 for every admitted attempt. Only inspect
|
||||
count for cost selection when all five operands are available in the temporary
|
||||
stack region; frame locals are not operands. If N is exact Int64 in 0..u32::MAX,
|
||||
charge representable C before validating receivers, offsets, ranges, source
|
||||
groups or reserving scratch. Retain C on any later refusal. Otherwise retain base
|
||||
4 and follow ordinary validation; count is neither converted nor accepted.
|
||||
Checked overflow of C retains only base 4 and produces structured RESOURCE_LIMIT
|
||||
with SizeOverflow before ordinary validation, without wrapping or saturation.
|
||||
|
||||
Early count inspection selects cost only. Apart from cost overflow, fault order
|
||||
is temporary height, source receiver, target receiver, carriers of sourceStart,
|
||||
targetStart and count, source range, target range, scratch reservation, then source
|
||||
group reads/validation in order. Thus above-u32 count with otherwise valid inputs
|
||||
fails physical bounds, not an allocation-size check. N=0 still validates receivers
|
||||
and ranges and costs 4. Identity and overlap grant no discount. N=10/W=1 costs 24
|
||||
on success, invalid receiver/range or scratch refusal. Zero budget executes no
|
||||
attempt; a positive budget admits the whole instruction with overshoot. Trap
|
||||
prevails over BudgetExhausted on failure, with no successful target step. Rejected
|
||||
images execute no guest instruction and charge zero guest cycles.
|
||||
|
||||
## Identity and value hashing
|
||||
|
||||
[Identity and value hashing](02f-vm-identity-and-value-hashing.md) defines
|
||||
REF_IDENTITY_HASH 0x0097 and REF_IDENTITY_EQ 0x0098, complete typed source
|
||||
groups, one/two TypeId immediates, exact attempted costs and operand-preserving
|
||||
faults. It also defines intrinsics 0x4100–0x4102 and their shared bounded
|
||||
invocation profile. Old EQ and REF_* categories retain their contracts.
|
||||
|
||||
@@ -306,3 +306,24 @@ precedence, conversions, catalog metadata and producer examples.
|
||||
## Random core integration
|
||||
|
||||
[Random](02e-vm-owned-random-core.md) adds BuiltinId 0x0016 and intrinsic IDs 0x4000–0x4003 using existing PBX v0 encoding. Registry categories remain unchanged; unsupported identities are rejected, without fallback.
|
||||
|
||||
|
||||
## Typed array range copy
|
||||
|
||||
ARRAY_COPY (0xA9) uses one Array TypeId and five operands for complete stored-group
|
||||
range transfer, with no new Registry category or PBX section. Encoding, exact
|
||||
receivers, overlap, preparation, fault order and precharged attempt costs follow
|
||||
the [instruction contract](02-vm-instruction-set.md#typed-array-range-copy).
|
||||
Unsupported opcodes 0xA7, 0xA8, 0xAA and 0xAB reject during bounded instruction
|
||||
admission even after a terminator. Immediate/data bytes are not instructions.
|
||||
ARRAY_LEN remains 0xA4; physical allocation/access checks remain mandatory.
|
||||
|
||||
## Identity queries
|
||||
|
||||
[Identity queries](02f-vm-identity-and-value-hashing.md) add opcodes 0x0097
|
||||
(source TypeId, six bytes) and 0x0098 (left/right TypeIds, ten bytes). Sources
|
||||
are Struct, Array, Fn, Trait and Random; validate complete groups before
|
||||
consulting handles. They add no PBX section, value type or layout change. The
|
||||
older REF_IS_EXACT/IMPLEMENTS/TO_TRAIT/CAST category restrictions remain intact.
|
||||
Intrinsic argument nullability is explicit per entry: hash.string admits known
|
||||
null at load without relaxing the static masks of existing String intrinsics.
|
||||
|
||||
@@ -0,0 +1,178 @@
|
||||
# VM Identity, Value Hashing and Bounded Intrinsic Invocation
|
||||
|
||||
Domain: VM values/intrinsics. Function: normative.
|
||||
|
||||
## Operations
|
||||
|
||||
| Operation | ID | Immediate/inputs, bottom to top | Result | Attempt cycles |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| REF_IDENTITY_HASH | opcode 0x0097 | source:TypeId; complete source group | Int64 | 8+w(source) |
|
||||
| REF_IDENTITY_EQ | opcode 0x0098 | left:TypeId,right:TypeId; left group,right group | Bool | 4+w(left)+w(right) |
|
||||
| hash.i64@1 | intrinsic 0x4100 | value:Int64 | Int64 | 8 |
|
||||
| hash.float@1 | intrinsic 0x4101 | value:Float | Int64 | 8 |
|
||||
| hash.string@1 | intrinsic 0x4102 | value:String, nullable | Int64 | 8+n |
|
||||
|
||||
Opcodes are u16 LE, immediate TypeIds u32 LE. The reference instructions occupy
|
||||
six/ten bytes. INTRINSIC remains opcode 0x0072 followed by u32 ID, six bytes.
|
||||
w(T) is resolved Registry slot width; n is present UTF-8 byte length, zero for
|
||||
null. Success consumes complete groups and publishes one result; failure retains
|
||||
inputs/owners. TypeIds are static metadata, never arbitrary guest selectors.
|
||||
|
||||
## Identity and equality domains
|
||||
|
||||
Identity sources MUST be Struct, Array, Fn, Trait or Random. String, Dynamic,
|
||||
internal boxes and other builtins are invalid categories. The old REF_* source
|
||||
rules and global EQ are unchanged. Validate the complete left group before the
|
||||
right, and both before comparing: exact type/category, liveness/generation and
|
||||
Registry. An invalid right input cannot be hidden by an unequal/absent left.
|
||||
|
||||
Struct/Array identity is instance identity, without traversing fields/elements.
|
||||
Fn identity is Closure identity, including empty captures; distinct creation
|
||||
stays distinct even with identical code/captures. Random identity is generator
|
||||
identity, independent of seed/state; the query neither advances nor hashes state.
|
||||
|
||||
Trait identity is the receiver after validating the entire receiver and
|
||||
ImplementationId against owner/trait metadata. ImplementationId zero is valid
|
||||
for a coherent present view. Static trait type and implementation do not enter
|
||||
the hash. Valid views through different traits and their concrete reference
|
||||
agree. This adds no implicit trait implementation to Fn/Random.
|
||||
|
||||
Canonical stack absence is Null for one-slot references/String and [Null,Null]
|
||||
for Trait. Two eligible absences compare true, absence/present false; absence
|
||||
hashes to Int64(0). Zero is not exclusive to absence. HeapRef(0,0) is not stack
|
||||
absence: existing validators classify it TYPE for Struct/Array/Fn/Trait and
|
||||
INVALID_HANDLE for Random. Malformed/stale values never become false/null.
|
||||
|
||||
The producer controls comparisons across static types and the equality used by
|
||||
collections. Within the selected domain/context, equals(a,b) implies equal
|
||||
hashes; equal hashes do not imply equality. No universal cross-numeric, Dynamic
|
||||
box or object-content equality is introduced. A producer joining integer/Float
|
||||
equality must define coherent canonicalization. Int32 can widen exactly to Int64,
|
||||
Bool map to 0/1; SDK component mixing must preserve order and boundaries.
|
||||
Fold to 32 bits is explicit, not abs or lossy numeric conversion. Equality/hash
|
||||
must remain stable while used as a key; the VM cannot prove custom callbacks.
|
||||
|
||||
## Hash-v1
|
||||
|
||||
Use XXH64, seed u64 zero, per the
|
||||
[upstream v0.8.3 specification](https://github.com/Cyan4973/xxHash/blob/v0.8.3/doc/xxhash_spec.md).
|
||||
Return the digest's identical 64-bit pattern in Int64, including negative values.
|
||||
All algorithm arithmetic wraps modulo 2^64; host word size/endianness is irrelevant.
|
||||
|
||||
| Input | Exact message |
|
||||
| --- | --- |
|
||||
| Int64 | Eight LE two's-complement bytes. |
|
||||
| Finite Float zero | Eight zero bytes for either sign. |
|
||||
| Other finite Float | Eight LE IEEE 754 binary64 bit-pattern bytes. |
|
||||
| Present String | Exact resident UTF-8 bytes and their message length, without terminator/prefix/normalization. |
|
||||
| Present reference | index:u32 LE followed by generation:u32 LE after validation. |
|
||||
| Accepted absence | Return zero directly; do not hash an empty message. |
|
||||
|
||||
Float MUST NOT be numerically converted to integer. NaN/infinity trap NON_FINITE.
|
||||
Empty String hashes the empty message and remains unequal to null. String owners,
|
||||
origin/retention and allocation history do not affect content hashing. Reference
|
||||
hash excludes fields, Random state, FunctionId, captures, view type and native
|
||||
addresses. There is no cryptographic, uniqueness, capability or confidentiality
|
||||
guarantee. The hash cannot be converted into a guest reference and creates no root.
|
||||
|
||||
Same scalar data/content and contract produce identical bits across hosts and
|
||||
sessions. An object's hash remains stable while alive, independently of mutation;
|
||||
reproduction depends on the same VM revision and allocation/collection sequence.
|
||||
Objects have no shared/persistent identity across sessions/revisions. Time, native
|
||||
addresses and host entropy are excluded. Existing entry boundaries preserve heap/
|
||||
session provenance; the handle encoding gains no global session identifier.
|
||||
|
||||
## Shared bounded invocation
|
||||
|
||||
The three scalar hashes declare invocation_model=borrowed_inline_v1,
|
||||
scratch_model=none, context_access=none, deterministic=true, may_allocate=false,
|
||||
mutates_guest_state=false. Protocol/cost selection follows descriptors, not the
|
||||
owner name. Native Rust handler functions are allowed; guest calls/reentry are not.
|
||||
|
||||
1. Resolve metadata and charge using safe carrier inspection.
|
||||
2. Check temporaries above the frame floor and validate borrowed inputs in order.
|
||||
3. Admit resources declared by that entry's profile.
|
||||
4. Compute into bounded local output storage derived from ret_layout.
|
||||
5. Validate the complete result's width and carriers.
|
||||
6. Replace/consume inputs and publish output in an infallible commit.
|
||||
|
||||
Inputs remain original stack roots/owners until commit. No argument BudgetVec,
|
||||
Vec-returning callback or mutable HostContext implements this profile. Unsupported
|
||||
inline result capacity or inconsistent descriptor/handler is rejected without
|
||||
dynamic-buffer fallback. Each new hash replaces one slot with one and requires
|
||||
no stack growth, guest allocation or dynamic scratch. No GC, safepoint, guest
|
||||
callback or scheduling occurs inside the operation. Faults retain inputs and
|
||||
discard partial results. Stateful handlers retain their own preparation/commit;
|
||||
Random keeps its existing candidate-state, allocation and bounded-attempt rules.
|
||||
|
||||
## Costs, faults and admission
|
||||
|
||||
Charge each decoded attempt once, including refusal, without an extra generic
|
||||
INTRINSIC cycle. Numeric hashes use fixed cost eight. String costs 8+n for an
|
||||
available String carrier, before traversal or provenance/ownership refusal.
|
||||
Null/wrong/unavailable carrier and underflow cost eight. Checked cost overflow
|
||||
charges base and traps RESOURCE_LIMIT without wrap or traversal. Reference costs
|
||||
use resolved widths even on underflow/refusal. Charge before height/group checks;
|
||||
validate left then right, and Float finitude after its exact carrier. No refunds.
|
||||
|
||||
| Cause | Outcome |
|
||||
| --- | --- |
|
||||
| Invalid immediate TypeId/category | LOAD_INVALID_REFERENCE. |
|
||||
| Invalid encoding/unknown intrinsic/proven static conflict | Existing structured load rejection, including dead code, no guest cycles. |
|
||||
| Incomplete temporary inputs | STACK_UNDERFLOW 0x08. |
|
||||
| Wrong carrier/type/malformed group/view | TYPE 0x04. |
|
||||
| Dead/stale/invalid reference | INVALID_HANDLE 0x0F under existing typed validation. |
|
||||
| Non-finite Float reaching execution | NON_FINITE 0x14. |
|
||||
| Checked cost/resource overflow | RESOURCE_LIMIT 0x10 with applicable resource detail. |
|
||||
| Handler result violates descriptor | INVALID_INTRINSIC 0x0D; original operands retained. |
|
||||
|
||||
Accepted null does not trap NULL_REFERENCE; Null to a numeric hash is TYPE.
|
||||
TrapInfo retains attempted PC/opcode, available source span and resource context.
|
||||
Budget zero executes nothing; positive fuel admits a whole instruction and can
|
||||
overshoot. There is no per-byte preemption, quota-rescue GC, hash cache/table,
|
||||
new String limit or relaxed ownership/resource quota.
|
||||
|
||||
## Intrinsic catalog schema 2
|
||||
|
||||
Schema version is independent of canonical intrinsic version. INTRINSICS.csv is
|
||||
generated from descriptors, ordered by ID, UTF-8/LF. The exact header is:
|
||||
|
||||
```csv
|
||||
final_id_hex,final_id_dec,canonical_name,canonical_version,owner,name,arg_slots,ret_slots,arg_layout,ret_layout,deterministic,may_allocate,parameter_names,cost_cycles,mutates_guest_state,cost_model,attempt_cost_cycles,max_attempts,schema_version,arg_nullable,invocation_model,scratch_model,context_access,cost_arg_index,cost_per_byte
|
||||
```
|
||||
|
||||
schema_version is 2 on every row. arg_nullable is one lowercase boolean per
|
||||
argument slot, pipe-separated, empty only for no arguments; widths must match
|
||||
arg_layout. cost_arg_index is a zero-based String slot for the byte model and
|
||||
empty for other models. cost_per_byte is one for String hashing and zero for
|
||||
fixed/random_rejection_v1. Base/fixed cost remains cost_cycles. Unsupported or
|
||||
inconsistent schema, profile, model, layout, index or capacity fails explicitly.
|
||||
|
||||
```csv
|
||||
0x4100,16640,hash.i64,1,hash,i64,1,1,Int64,Int64,true,false,value,8,false,fixed,0,0,2,false,borrowed_inline_v1,none,none,,0
|
||||
0x4101,16641,hash.float,1,hash,float,1,1,Float,Int64,true,false,value,8,false,fixed,0,0,2,false,borrowed_inline_v1,none,none,,0
|
||||
0x4102,16642,hash.string,1,hash,string,1,1,String,Int64,true,false,value,8,false,argument_utf8_bytes_v1,0,0,2,true,borrowed_inline_v1,none,none,0,1
|
||||
```
|
||||
|
||||
Static admission and native validation use per-entry arg_nullable. Known null
|
||||
is valid for hash.string; other String intrinsics retain their old static masks.
|
||||
Nullable structural admission does not remove domain preconditions such as a
|
||||
Random mutation requiring a present generator.
|
||||
|
||||
Old Host entries use host_buffered_v1/existing_contract_v1/host; old VM-owned
|
||||
entries vm_owned_v1/existing_contract_v1/vm_state. These retain existing effects,
|
||||
accounting, limits, IDs, signatures, versions and costs, not the new profile's
|
||||
guarantees. Old scalar/color args have false nullability, Random args true;
|
||||
no-arg lists are empty. Legacy cost_arg_index is empty and cost_per_byte zero.
|
||||
No broad migration is required. The builtin constant catalog remains unchanged.
|
||||
|
||||
## Producer boundary
|
||||
|
||||
Publish exact provider revision, schema and catalog digests. Consumers explicitly
|
||||
port metadata, admission, lowering/emission, mirrors, packaged provenance and
|
||||
normal/optimized conformance. CSV-only updates are not completed integration.
|
||||
Reject unsupported data without inferring purity/nullability/zero scratch from
|
||||
deterministic or names. Preserve faults, ordering and charged work even when
|
||||
results are discarded. Collections, defaults and custom/Dynamic strategies remain
|
||||
consumer-owned. Set/Map, storage publication, Lua FE, arbitrary byte strings,
|
||||
a new Float domain and general structural hashing are outside this contract.
|
||||
@@ -221,3 +221,26 @@ Threshold GC opportunities are FRAME_SYNC and successful RET of the last root, a
|
||||
## Random core integration
|
||||
|
||||
[Random objects](02e-vm-owned-random-core.md) use ObjectKind tag 9 (tag 6 remains reserved), 32 logical payload bytes and quota-accounted headers/handles/auxiliary storage. They are opaque GC leaves; Dynamic holds their direct reference and exact TypeId.
|
||||
|
||||
|
||||
## Prepared array range copy
|
||||
|
||||
ARRAY_COPY reserves all copy scratch against TemporaryBytes and captures complete
|
||||
source groups before changing any destination. Preserve Dynamic tags, immutable
|
||||
boxes, native String owners, HeapRefs and trait groups without boxing or new guest
|
||||
objects/request tokens. Operands remain roots; commit has no allocation, fallible
|
||||
validation, callback, GC or scheduler boundary. No rescue GC is performed.
|
||||
Failure preserves destinations and operands and releases provisional scratch;
|
||||
success also releases scratch, then consumes the five operands. Charged cycles
|
||||
are never refunded. Overlap reads the pre-attempt source sequence, without an
|
||||
identity discount. Earlier instructions retain their effects; multiple ordinary
|
||||
stores do not form a transaction. See [the instruction contract](02-vm-instruction-set.md#typed-array-range-copy).
|
||||
|
||||
## Borrowed intrinsic invocation
|
||||
|
||||
The [bounded intrinsic profile](02f-vm-identity-and-value-hashing.md) keeps
|
||||
original arguments/owners rooted until result validation and stack commit. Hash
|
||||
intrinsics use no guest allocation, dynamic scratch or stack growth; native
|
||||
output storage is bounded by the declared result layout. They do not collect,
|
||||
reenter or call guest code. Hash values create no roots. Legacy intrinsic
|
||||
resource/effect contracts remain explicit and do not inherit these guarantees.
|
||||
|
||||
@@ -132,3 +132,7 @@ In those cases:
|
||||
## Random core integration
|
||||
|
||||
The [VM-owned random core](02e-vm-owned-random-core.md) defines opaque Random references, PCG64 and the random intrinsic surface.
|
||||
|
||||
## Identity and hashing integration
|
||||
|
||||
The [identity and value hashing contract](02f-vm-identity-and-value-hashing.md) defines typed reference queries, scalar/content hash-v1, bounded intrinsic invocation and catalog schema 2. See the [producer handoff](../../vm-arch/identity-hashing-producer-handoff.md) and [qualification record](../../vm-arch/IDENTITY_HASHING_QUALIFICATION.md) for implementation evidence and consumer integration targets.
|
||||
|
||||
@@ -202,3 +202,16 @@ The [Program Registry contract](../specs/runtime/02c-program-registry-and-pbx-v0
|
||||
## VM-owned random core
|
||||
|
||||
See the [random contract](../specs/runtime/02e-vm-owned-random-core.md) for Random BuiltinId 0x0016, ObjectKind tag 9, intrinsics 0x4000–0x4003, atomic state mutation, bounded 4+8*N costs and rejection-limit trap 0x00000015. Random is managed by the VM heap and existing GC, without host entropy or PBX changes.
|
||||
|
||||
|
||||
## Typed array range copy
|
||||
|
||||
ARRAY_COPY (0xA9) copies complete groups between exact typed arrays with strict
|
||||
physical ranges and pre-attempt overlap semantics. Preparation reserves scratch
|
||||
before infallible commit; failures preserve operands/destinations and retain
|
||||
charged work. No callbacks, GC or scheduling occur inside the instruction.
|
||||
The [instruction contract](../specs/runtime/02-vm-instruction-set.md#typed-array-range-copy)
|
||||
defines encoding, fault order and early cost selection. ARRAY_LEN remains the
|
||||
physical query; producer algorithms own logical limits and multi-owner invariants.
|
||||
There is no transactional sequence of stores. Encodings 0xA7/0xA8/0xAA/0xAB are
|
||||
unsupported, including in dead code.
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
# Identity and hashing qualification
|
||||
|
||||
Qualification date: 2026-10-23. Target: aarch64-apple-darwin. Toolchain:
|
||||
rustc 1.98.1 (48a229cea 2026-09-01), cargo 1.98.1 (797e8a9bc 2026-08-05).
|
||||
The [machine-readable record](identity-hashing-qualification.json) contains exact
|
||||
source/artifact SHA-256 values and commands. The
|
||||
[canonical contract](../specs/runtime/02f-vm-identity-and-value-hashing.md) is normative;
|
||||
the [producer handoff](identity-hashing-producer-handoff.md) defines consumer work.
|
||||
|
||||
## Delivery identity
|
||||
|
||||
Base revision: `57992cf214e8a5f9de53a40dba9aaa7fab038c91`. This qualification
|
||||
covers working-tree changes identified by source fingerprint
|
||||
`a0d202e46fbca3319d7b04fe09906388c015da7b606216e75bd7c62041011885`.
|
||||
The base revision alone does not contain this delivery. The JSON lists the
|
||||
29 source/test files and their individual digests. To reproduce the aggregate,
|
||||
visit sorted paths and hash the concatenation of path UTF-8, NUL, exact file
|
||||
bytes and NUL for each file.
|
||||
|
||||
| Artifact | SHA-256 |
|
||||
| --- | --- |
|
||||
| Cargo.lock | cffad9ed62f38a591538abd81dd39270d6022397342c8189f4ac6c7baaa8e795 |
|
||||
| INTRINSICS.csv | 7c1c363f5f0f941b3ab27cfc72af41e13e44cd4371c687db8300721288f47e63 |
|
||||
| BUILTIN_CONSTANTS.csv | e407e4718127aa7ef7b1097b5b4b67d86dd979235e73a551a7c36b628cddc039 |
|
||||
| hash-conformance.tsv | a863486eaea14ab1a010f076f355eed0d5738207dad3651f7d10e92fc09f74d4 |
|
||||
|
||||
Schema 2 has 25 columns and 108 intrinsic rows. Comparison against the base
|
||||
revision confirms that all 18 prior fields of each of the 105 old entries are
|
||||
unchanged. Three hash entries were added. Builtin constants are byte-identical.
|
||||
Existing historical math/random qualification records retain their original
|
||||
revision claims.
|
||||
|
||||
## Executed checks
|
||||
|
||||
All commands use the checked-in lockfile and offline dependency cache.
|
||||
|
||||
| Command | Result |
|
||||
| --- | --- |
|
||||
| `cargo test --locked --offline -p prometeu-bytecode -p prometeu-vm --no-fail-fast` | 453 passed, 0 failed, 3 existing ignored. |
|
||||
| `cargo test --locked --offline -p prometeu-vm --features resource-diagnostics --no-fail-fast` | 401 passed, 0 failed, 2 existing ignored. |
|
||||
| `cargo test --locked --offline -p prometeu-quality-checks -p prometeu-layer-tests --no-fail-fast` | 19 passed, 0 failed. |
|
||||
| `cargo test --locked --offline --release -p prometeu-vm --test identity_hashing --test intrinsic_profiles --test execution_allocations` | 12 passed, 0 failed. |
|
||||
| `cargo check --locked --offline --workspace --all-targets` | Passed, including headless/desktop, firmware, tools and shared consumers. |
|
||||
| `cargo fmt --all --check` | Passed. |
|
||||
| `git diff --check` | Passed. |
|
||||
|
||||
## Independent oracles and covered behavior
|
||||
|
||||
The [118 vectors](../../crates/console/prometeu-vm/tests/fixtures/hash-conformance.tsv)
|
||||
come from the official C XXH64 v0.8.3 reference, not the Rust implementation.
|
||||
The [generator and provenance](../../crates/console/prometeu-vm/tests/fixtures/hash-oracle.md)
|
||||
pin the upstream header by SHA-256 and verify its version. Raw byte vectors
|
||||
cover every length through 70 and longer stripe/tail boundaries through 4097;
|
||||
the remaining cases cover signed integer extremes, finite binary64 bit patterns,
|
||||
UTF-8/NUL/empty strings, reference index/generation pairs and direct null zero.
|
||||
Every vector is checked by the Rust algorithm. Scalar/String/null vectors also
|
||||
execute through serialized PBX, typed admission and the real interpreter.
|
||||
|
||||
Independent raw instruction bytes check IDs, LE immediates, truncations,
|
||||
assembler/disassembler behavior and Registry widths. Neutral PBX tests cover
|
||||
Struct/Array/Fn/Random identity, distinct closure creation, aliases, mutation,
|
||||
Random advancement, multiple Trait views, valid implementation zero, all eligible
|
||||
null groups and exact successful instruction costs. Admission rejects ineligible
|
||||
source types, bad immediates/IDs, wrong numeric carriers and old String nulls,
|
||||
including invalid metadata in unreachable code where appropriate.
|
||||
|
||||
Private fault injection covers non-finite Float bits, stale/malformed references,
|
||||
wrong concrete types, invalid/partial Trait pairs, left-before-right validation,
|
||||
invalid right operands despite null left, underflow, foreign String ownership,
|
||||
checked String cost overflow and malformed/missing/excess handler results.
|
||||
Assertions preserve complete operands and String owners, resource usage, Float
|
||||
NaN payload bits and charged cycles. Misbehaving output handlers use a different
|
||||
owner namespace to exercise the shared invocation protocol. Descriptor tests
|
||||
reject unsupported layouts, inconsistent metadata and undeclared capabilities.
|
||||
|
||||
Real GC retains live aliases and permits collection when only an Int64 hash is
|
||||
retained; reuse increments the generation and old handles still fault. Existing
|
||||
generation-exhaustion tests cover retirement without wrap. Hashing equal String
|
||||
content across image, session concatenation and explicit import owners agrees.
|
||||
Sequential handle distribution exercises 256 reduced buckets; deliberate bucket
|
||||
collisions still require reference equality. This is distribution evidence,
|
||||
not a uniqueness or adversarial-resistance claim.
|
||||
|
||||
## Allocation, resources and scheduling
|
||||
|
||||
Ten new warmed instruction regions cover three scalar hashes, five reference
|
||||
hash categories, Struct equality and Trait equality. After ten warmup iterations,
|
||||
1,000 measured iterations per region allocate/deallocate nothing natively,
|
||||
including reallocations, and create no guest heap objects. Original values remain
|
||||
in locals so owner destruction does not contaminate the measured region. The
|
||||
same checks pass in debug, resource-diagnostics and selected release execution.
|
||||
|
||||
Quota-injection tests exhaust guest/handle/auxiliary/temporary/String budgets
|
||||
before reference/scalar queries and check unchanged resource use. New queries do
|
||||
not trigger GC, grow their result stack, request scratch or call the host. Fault
|
||||
checks cover guest resource/owner preservation; the native allocator measurement
|
||||
covers successful warmed execution, not the existing diagnostic formatting path.
|
||||
Zero fuel leaves PC/state unchanged; one positive cycle admits the entire
|
||||
instruction, including a 65-byte String hash costing 73, with no extra generic
|
||||
INTRINSIC cycle. Foreign String owners are rejected only after full byte cost.
|
||||
|
||||
## Scope of evidence
|
||||
|
||||
This record covers the local target and configurations above. Other hosts,
|
||||
architectures and cross-host execution comparisons were not run. The explicit
|
||||
LE implementation and independent vectors support portability but do not replace
|
||||
qualification on additional advertised targets. Studio source compilation,
|
||||
normal/optimized source conformance, catalog pins/mirrors and packaged SDK
|
||||
resources remain the [consumer handoff](identity-hashing-producer-handoff.md).
|
||||
No Lua frontend, Set/Map or structural/Dynamic equality is reported as delivered.
|
||||
+109
-106
@@ -1,106 +1,109 @@
|
||||
final_id_hex,final_id_dec,canonical_name,canonical_version,owner,name,arg_slots,ret_slots,arg_layout,ret_layout,deterministic,may_allocate,parameter_names,cost_cycles,mutates_guest_state,cost_model,attempt_cost_cycles,max_attempts
|
||||
0x1000,4096,vec2.dot,1,vec2,dot,4,1,Float|Float|Float|Float,Float,true,false,ax|ay|bx|by,10,false,fixed,0,0
|
||||
0x1001,4097,vec2.length,1,vec2,length,2,1,Float|Float,Float,true,false,x|y,40,false,fixed,0,0
|
||||
0x1100,4352,color.from_raw,1,color,from_raw,1,1,Int64,builtin:color,true,false,raw,1,false,fixed,0,0
|
||||
0x1101,4353,color.rgb,1,color,rgb,3,1,Int64|Int64|Int64,builtin:color,true,false,r|g|b,1,false,fixed,0,0
|
||||
0x1102,4354,color.rgba,1,color,rgba,4,1,Int64|Int64|Int64|Int64,builtin:color,true,false,r|g|b|a,1,false,fixed,0,0
|
||||
0x1103,4355,color.html_rgba,1,color,html_rgba,1,1,String,builtin:color,true,false,value,1,false,fixed,0,0
|
||||
0x1104,4356,color.gray_scale,1,color,gray_scale,1,1,Int64,builtin:color,true,false,value,1,false,fixed,0,0
|
||||
0x1105,4357,color.hex,1,color,hex,1,1,builtin:color,Int64,true,false,color,1,false,fixed,0,0
|
||||
0x1106,4358,color.alpha,1,color,alpha,1,1,builtin:color,Int64,true,false,color,1,false,fixed,0,0
|
||||
0x1120,4384,color.black,1,color,black,0,1,,builtin:color,true,false,,1,false,fixed,0,0
|
||||
0x1121,4385,color.white,1,color,white,0,1,,builtin:color,true,false,,1,false,fixed,0,0
|
||||
0x1122,4386,color.red,1,color,red,0,1,,builtin:color,true,false,,1,false,fixed,0,0
|
||||
0x1123,4387,color.green,1,color,green,0,1,,builtin:color,true,false,,1,false,fixed,0,0
|
||||
0x1124,4388,color.blue,1,color,blue,0,1,,builtin:color,true,false,,1,false,fixed,0,0
|
||||
0x1125,4389,color.yellow,1,color,yellow,0,1,,builtin:color,true,false,,1,false,fixed,0,0
|
||||
0x1126,4390,color.orange,1,color,orange,0,1,,builtin:color,true,false,,1,false,fixed,0,0
|
||||
0x1127,4391,color.indigo,1,color,indigo,0,1,,builtin:color,true,false,,1,false,fixed,0,0
|
||||
0x1128,4392,color.gray,1,color,gray,0,1,,builtin:color,true,false,,1,false,fixed,0,0
|
||||
0x1129,4393,color.cyan,1,color,cyan,0,1,,builtin:color,true,false,,1,false,fixed,0,0
|
||||
0x112A,4394,color.magenta,1,color,magenta,0,1,,builtin:color,true,false,,1,false,fixed,0,0
|
||||
0x112B,4395,color.transparent,1,color,transparent,0,1,,builtin:color,true,false,,1,false,fixed,0,0
|
||||
0x2100,8448,input.pad.up.pressed,1,input.pad.up,pressed,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x2101,8449,input.pad.up.released,1,input.pad.up,released,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x2102,8450,input.pad.up.down,1,input.pad.up,down,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x2103,8451,input.pad.up.hold,1,input.pad.up,hold,0,1,,Int64,true,false,,1,false,fixed,0,0
|
||||
0x2104,8452,input.pad.down.pressed,1,input.pad.down,pressed,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x2105,8453,input.pad.down.released,1,input.pad.down,released,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x2106,8454,input.pad.down.down,1,input.pad.down,down,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x2107,8455,input.pad.down.hold,1,input.pad.down,hold,0,1,,Int64,true,false,,1,false,fixed,0,0
|
||||
0x2108,8456,input.pad.left.pressed,1,input.pad.left,pressed,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x2109,8457,input.pad.left.released,1,input.pad.left,released,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x210A,8458,input.pad.left.down,1,input.pad.left,down,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x210B,8459,input.pad.left.hold,1,input.pad.left,hold,0,1,,Int64,true,false,,1,false,fixed,0,0
|
||||
0x210C,8460,input.pad.right.pressed,1,input.pad.right,pressed,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x210D,8461,input.pad.right.released,1,input.pad.right,released,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x210E,8462,input.pad.right.down,1,input.pad.right,down,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x210F,8463,input.pad.right.hold,1,input.pad.right,hold,0,1,,Int64,true,false,,1,false,fixed,0,0
|
||||
0x2110,8464,input.pad.a.pressed,1,input.pad.a,pressed,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x2111,8465,input.pad.a.released,1,input.pad.a,released,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x2112,8466,input.pad.a.down,1,input.pad.a,down,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x2113,8467,input.pad.a.hold,1,input.pad.a,hold,0,1,,Int64,true,false,,1,false,fixed,0,0
|
||||
0x2114,8468,input.pad.b.pressed,1,input.pad.b,pressed,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x2115,8469,input.pad.b.released,1,input.pad.b,released,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x2116,8470,input.pad.b.down,1,input.pad.b,down,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x2117,8471,input.pad.b.hold,1,input.pad.b,hold,0,1,,Int64,true,false,,1,false,fixed,0,0
|
||||
0x2118,8472,input.pad.x.pressed,1,input.pad.x,pressed,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x2119,8473,input.pad.x.released,1,input.pad.x,released,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x211A,8474,input.pad.x.down,1,input.pad.x,down,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x211B,8475,input.pad.x.hold,1,input.pad.x,hold,0,1,,Int64,true,false,,1,false,fixed,0,0
|
||||
0x211C,8476,input.pad.y.pressed,1,input.pad.y,pressed,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x211D,8477,input.pad.y.released,1,input.pad.y,released,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x211E,8478,input.pad.y.down,1,input.pad.y,down,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x211F,8479,input.pad.y.hold,1,input.pad.y,hold,0,1,,Int64,true,false,,1,false,fixed,0,0
|
||||
0x2120,8480,input.pad.l.pressed,1,input.pad.l,pressed,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x2121,8481,input.pad.l.released,1,input.pad.l,released,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x2122,8482,input.pad.l.down,1,input.pad.l,down,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x2123,8483,input.pad.l.hold,1,input.pad.l,hold,0,1,,Int64,true,false,,1,false,fixed,0,0
|
||||
0x2124,8484,input.pad.r.pressed,1,input.pad.r,pressed,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x2125,8485,input.pad.r.released,1,input.pad.r,released,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x2126,8486,input.pad.r.down,1,input.pad.r,down,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x2127,8487,input.pad.r.hold,1,input.pad.r,hold,0,1,,Int64,true,false,,1,false,fixed,0,0
|
||||
0x2128,8488,input.pad.start.pressed,1,input.pad.start,pressed,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x2129,8489,input.pad.start.released,1,input.pad.start,released,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x212A,8490,input.pad.start.down,1,input.pad.start,down,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x212B,8491,input.pad.start.hold,1,input.pad.start,hold,0,1,,Int64,true,false,,1,false,fixed,0,0
|
||||
0x212C,8492,input.pad.select.pressed,1,input.pad.select,pressed,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x212D,8493,input.pad.select.released,1,input.pad.select,released,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x212E,8494,input.pad.select.down,1,input.pad.select,down,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x212F,8495,input.pad.select.hold,1,input.pad.select,hold,0,1,,Int64,true,false,,1,false,fixed,0,0
|
||||
0x2130,8496,input.touch.button.pressed,1,input.touch.button,pressed,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x2131,8497,input.touch.button.released,1,input.touch.button,released,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x2132,8498,input.touch.button.down,1,input.touch.button,down,0,1,,Bool,true,false,,1,false,fixed,0,0
|
||||
0x2133,8499,input.touch.button.hold,1,input.touch.button,hold,0,1,,Int64,true,false,,1,false,fixed,0,0
|
||||
0x2134,8500,input.touch.x,1,input.touch,x,0,1,,Int64,true,false,,1,false,fixed,0,0
|
||||
0x2135,8501,input.touch.y,1,input.touch,y,0,1,,Int64,true,false,,1,false,fixed,0,0
|
||||
0x3000,12288,math.i32.min,1,math.i32,min,2,1,Int32|Int32,Int32,true,false,a|b,2,false,fixed,0,0
|
||||
0x3001,12289,math.i32.max,1,math.i32,max,2,1,Int32|Int32,Int32,true,false,a|b,2,false,fixed,0,0
|
||||
0x3002,12290,math.i32.clamp,1,math.i32,clamp,3,1,Int32|Int32|Int32,Int32,true,false,value|min|max,4,false,fixed,0,0
|
||||
0x3003,12291,math.i32.abs,1,math.i32,abs,1,1,Int32,Int32,true,false,value,2,false,fixed,0,0
|
||||
0x3004,12292,math.i64.min,1,math.i64,min,2,1,Int64|Int64,Int64,true,false,a|b,2,false,fixed,0,0
|
||||
0x3005,12293,math.i64.max,1,math.i64,max,2,1,Int64|Int64,Int64,true,false,a|b,2,false,fixed,0,0
|
||||
0x3006,12294,math.i64.clamp,1,math.i64,clamp,3,1,Int64|Int64|Int64,Int64,true,false,value|min|max,4,false,fixed,0,0
|
||||
0x3007,12295,math.i64.abs,1,math.i64,abs,1,1,Int64,Int64,true,false,value,2,false,fixed,0,0
|
||||
0x3008,12296,mathf.min,1,mathf,min,2,1,Float|Float,Float,true,false,a|b,2,false,fixed,0,0
|
||||
0x3009,12297,mathf.max,1,mathf,max,2,1,Float|Float,Float,true,false,a|b,2,false,fixed,0,0
|
||||
0x300A,12298,mathf.clamp,1,mathf,clamp,3,1,Float|Float|Float,Float,true,false,value|min|max,4,false,fixed,0,0
|
||||
0x300B,12299,mathf.abs,1,mathf,abs,1,1,Float,Float,true,false,value,2,false,fixed,0,0
|
||||
0x300C,12300,mathf.floor,1,mathf,floor,1,1,Float,Float,true,false,value,4,false,fixed,0,0
|
||||
0x300D,12301,mathf.ceil,1,mathf,ceil,1,1,Float,Float,true,false,value,4,false,fixed,0,0
|
||||
0x300E,12302,mathf.trunc,1,mathf,trunc,1,1,Float,Float,true,false,value,4,false,fixed,0,0
|
||||
0x300F,12303,mathf.round,1,mathf,round,1,1,Float,Float,true,false,value,4,false,fixed,0,0
|
||||
0x3010,12304,mathf.sqrt,1,mathf,sqrt,1,1,Float,Float,true,false,value,16,false,fixed,0,0
|
||||
0x3011,12305,mathf.sin,1,mathf,sin,1,1,Float,Float,true,false,angle,32,false,fixed,0,0
|
||||
0x3012,12306,mathf.cos,1,mathf,cos,1,1,Float,Float,true,false,angle,32,false,fixed,0,0
|
||||
0x3013,12307,mathf.atan2,1,mathf,atan2,2,1,Float|Float,Float,true,false,y|x,48,false,fixed,0,0
|
||||
0x3014,12308,math.i32.to_i64,1,math.i32,to_i64,1,1,Int32,Int64,true,false,value,2,false,fixed,0,0
|
||||
0x3015,12309,math.i64.to_i32,1,math.i64,to_i32,1,1,Int64,Int32,true,false,value,2,false,fixed,0,0
|
||||
0x3016,12310,math.i32.to_float,1,math.i32,to_float,1,1,Int32,Float,true,false,value,2,false,fixed,0,0
|
||||
0x3017,12311,math.i64.to_float,1,math.i64,to_float,1,1,Int64,Float,true,false,value,2,false,fixed,0,0
|
||||
0x3018,12312,mathf.to_i32,1,mathf,to_i32,1,1,Float,Int32,true,false,value,2,false,fixed,0,0
|
||||
0x3019,12313,mathf.to_i64,1,mathf,to_i64,1,1,Float,Int64,true,false,value,2,false,fixed,0,0
|
||||
0x4000,16384,random.new,1,random,new,1,1,Int64,builtin:Random,true,true,seed,32,true,fixed,0,0
|
||||
0x4001,16385,random.next,1,random,next,1,1,builtin:Random,Int64,true,false,rng,8,true,fixed,0,0
|
||||
0x4002,16386,random.nextf,1,random,nextf,1,1,builtin:Random,Float,true,false,rng,12,true,fixed,0,0
|
||||
0x4003,16387,random.range,1,random,range,3,1,builtin:Random|Int64|Int64,Int64,true,false,rng|min|max,4,true,random_rejection_v1,8,64
|
||||
final_id_hex,final_id_dec,canonical_name,canonical_version,owner,name,arg_slots,ret_slots,arg_layout,ret_layout,deterministic,may_allocate,parameter_names,cost_cycles,mutates_guest_state,cost_model,attempt_cost_cycles,max_attempts,schema_version,arg_nullable,invocation_model,scratch_model,context_access,cost_arg_index,cost_per_byte
|
||||
0x1000,4096,vec2.dot,1,vec2,dot,4,1,Float|Float|Float|Float,Float,true,false,ax|ay|bx|by,10,false,fixed,0,0,2,false|false|false|false,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x1001,4097,vec2.length,1,vec2,length,2,1,Float|Float,Float,true,false,x|y,40,false,fixed,0,0,2,false|false,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x1100,4352,color.from_raw,1,color,from_raw,1,1,Int64,builtin:color,true,false,raw,1,false,fixed,0,0,2,false,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x1101,4353,color.rgb,1,color,rgb,3,1,Int64|Int64|Int64,builtin:color,true,false,r|g|b,1,false,fixed,0,0,2,false|false|false,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x1102,4354,color.rgba,1,color,rgba,4,1,Int64|Int64|Int64|Int64,builtin:color,true,false,r|g|b|a,1,false,fixed,0,0,2,false|false|false|false,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x1103,4355,color.html_rgba,1,color,html_rgba,1,1,String,builtin:color,true,false,value,1,false,fixed,0,0,2,false,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x1104,4356,color.gray_scale,1,color,gray_scale,1,1,Int64,builtin:color,true,false,value,1,false,fixed,0,0,2,false,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x1105,4357,color.hex,1,color,hex,1,1,builtin:color,Int64,true,false,color,1,false,fixed,0,0,2,false,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x1106,4358,color.alpha,1,color,alpha,1,1,builtin:color,Int64,true,false,color,1,false,fixed,0,0,2,false,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x1120,4384,color.black,1,color,black,0,1,,builtin:color,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x1121,4385,color.white,1,color,white,0,1,,builtin:color,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x1122,4386,color.red,1,color,red,0,1,,builtin:color,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x1123,4387,color.green,1,color,green,0,1,,builtin:color,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x1124,4388,color.blue,1,color,blue,0,1,,builtin:color,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x1125,4389,color.yellow,1,color,yellow,0,1,,builtin:color,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x1126,4390,color.orange,1,color,orange,0,1,,builtin:color,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x1127,4391,color.indigo,1,color,indigo,0,1,,builtin:color,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x1128,4392,color.gray,1,color,gray,0,1,,builtin:color,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x1129,4393,color.cyan,1,color,cyan,0,1,,builtin:color,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x112A,4394,color.magenta,1,color,magenta,0,1,,builtin:color,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x112B,4395,color.transparent,1,color,transparent,0,1,,builtin:color,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x2100,8448,input.pad.up.pressed,1,input.pad.up,pressed,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x2101,8449,input.pad.up.released,1,input.pad.up,released,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x2102,8450,input.pad.up.down,1,input.pad.up,down,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x2103,8451,input.pad.up.hold,1,input.pad.up,hold,0,1,,Int64,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x2104,8452,input.pad.down.pressed,1,input.pad.down,pressed,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x2105,8453,input.pad.down.released,1,input.pad.down,released,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x2106,8454,input.pad.down.down,1,input.pad.down,down,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x2107,8455,input.pad.down.hold,1,input.pad.down,hold,0,1,,Int64,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x2108,8456,input.pad.left.pressed,1,input.pad.left,pressed,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x2109,8457,input.pad.left.released,1,input.pad.left,released,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x210A,8458,input.pad.left.down,1,input.pad.left,down,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x210B,8459,input.pad.left.hold,1,input.pad.left,hold,0,1,,Int64,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x210C,8460,input.pad.right.pressed,1,input.pad.right,pressed,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x210D,8461,input.pad.right.released,1,input.pad.right,released,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x210E,8462,input.pad.right.down,1,input.pad.right,down,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x210F,8463,input.pad.right.hold,1,input.pad.right,hold,0,1,,Int64,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x2110,8464,input.pad.a.pressed,1,input.pad.a,pressed,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x2111,8465,input.pad.a.released,1,input.pad.a,released,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x2112,8466,input.pad.a.down,1,input.pad.a,down,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x2113,8467,input.pad.a.hold,1,input.pad.a,hold,0,1,,Int64,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x2114,8468,input.pad.b.pressed,1,input.pad.b,pressed,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x2115,8469,input.pad.b.released,1,input.pad.b,released,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x2116,8470,input.pad.b.down,1,input.pad.b,down,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x2117,8471,input.pad.b.hold,1,input.pad.b,hold,0,1,,Int64,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x2118,8472,input.pad.x.pressed,1,input.pad.x,pressed,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x2119,8473,input.pad.x.released,1,input.pad.x,released,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x211A,8474,input.pad.x.down,1,input.pad.x,down,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x211B,8475,input.pad.x.hold,1,input.pad.x,hold,0,1,,Int64,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x211C,8476,input.pad.y.pressed,1,input.pad.y,pressed,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x211D,8477,input.pad.y.released,1,input.pad.y,released,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x211E,8478,input.pad.y.down,1,input.pad.y,down,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x211F,8479,input.pad.y.hold,1,input.pad.y,hold,0,1,,Int64,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x2120,8480,input.pad.l.pressed,1,input.pad.l,pressed,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x2121,8481,input.pad.l.released,1,input.pad.l,released,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x2122,8482,input.pad.l.down,1,input.pad.l,down,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x2123,8483,input.pad.l.hold,1,input.pad.l,hold,0,1,,Int64,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x2124,8484,input.pad.r.pressed,1,input.pad.r,pressed,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x2125,8485,input.pad.r.released,1,input.pad.r,released,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x2126,8486,input.pad.r.down,1,input.pad.r,down,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x2127,8487,input.pad.r.hold,1,input.pad.r,hold,0,1,,Int64,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x2128,8488,input.pad.start.pressed,1,input.pad.start,pressed,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x2129,8489,input.pad.start.released,1,input.pad.start,released,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x212A,8490,input.pad.start.down,1,input.pad.start,down,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x212B,8491,input.pad.start.hold,1,input.pad.start,hold,0,1,,Int64,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x212C,8492,input.pad.select.pressed,1,input.pad.select,pressed,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x212D,8493,input.pad.select.released,1,input.pad.select,released,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x212E,8494,input.pad.select.down,1,input.pad.select,down,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x212F,8495,input.pad.select.hold,1,input.pad.select,hold,0,1,,Int64,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x2130,8496,input.touch.button.pressed,1,input.touch.button,pressed,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x2131,8497,input.touch.button.released,1,input.touch.button,released,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x2132,8498,input.touch.button.down,1,input.touch.button,down,0,1,,Bool,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x2133,8499,input.touch.button.hold,1,input.touch.button,hold,0,1,,Int64,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x2134,8500,input.touch.x,1,input.touch,x,0,1,,Int64,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x2135,8501,input.touch.y,1,input.touch,y,0,1,,Int64,true,false,,1,false,fixed,0,0,2,,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x3000,12288,math.i32.min,1,math.i32,min,2,1,Int32|Int32,Int32,true,false,a|b,2,false,fixed,0,0,2,false|false,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x3001,12289,math.i32.max,1,math.i32,max,2,1,Int32|Int32,Int32,true,false,a|b,2,false,fixed,0,0,2,false|false,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x3002,12290,math.i32.clamp,1,math.i32,clamp,3,1,Int32|Int32|Int32,Int32,true,false,value|min|max,4,false,fixed,0,0,2,false|false|false,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x3003,12291,math.i32.abs,1,math.i32,abs,1,1,Int32,Int32,true,false,value,2,false,fixed,0,0,2,false,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x3004,12292,math.i64.min,1,math.i64,min,2,1,Int64|Int64,Int64,true,false,a|b,2,false,fixed,0,0,2,false|false,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x3005,12293,math.i64.max,1,math.i64,max,2,1,Int64|Int64,Int64,true,false,a|b,2,false,fixed,0,0,2,false|false,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x3006,12294,math.i64.clamp,1,math.i64,clamp,3,1,Int64|Int64|Int64,Int64,true,false,value|min|max,4,false,fixed,0,0,2,false|false|false,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x3007,12295,math.i64.abs,1,math.i64,abs,1,1,Int64,Int64,true,false,value,2,false,fixed,0,0,2,false,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x3008,12296,mathf.min,1,mathf,min,2,1,Float|Float,Float,true,false,a|b,2,false,fixed,0,0,2,false|false,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x3009,12297,mathf.max,1,mathf,max,2,1,Float|Float,Float,true,false,a|b,2,false,fixed,0,0,2,false|false,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x300A,12298,mathf.clamp,1,mathf,clamp,3,1,Float|Float|Float,Float,true,false,value|min|max,4,false,fixed,0,0,2,false|false|false,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x300B,12299,mathf.abs,1,mathf,abs,1,1,Float,Float,true,false,value,2,false,fixed,0,0,2,false,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x300C,12300,mathf.floor,1,mathf,floor,1,1,Float,Float,true,false,value,4,false,fixed,0,0,2,false,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x300D,12301,mathf.ceil,1,mathf,ceil,1,1,Float,Float,true,false,value,4,false,fixed,0,0,2,false,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x300E,12302,mathf.trunc,1,mathf,trunc,1,1,Float,Float,true,false,value,4,false,fixed,0,0,2,false,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x300F,12303,mathf.round,1,mathf,round,1,1,Float,Float,true,false,value,4,false,fixed,0,0,2,false,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x3010,12304,mathf.sqrt,1,mathf,sqrt,1,1,Float,Float,true,false,value,16,false,fixed,0,0,2,false,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x3011,12305,mathf.sin,1,mathf,sin,1,1,Float,Float,true,false,angle,32,false,fixed,0,0,2,false,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x3012,12306,mathf.cos,1,mathf,cos,1,1,Float,Float,true,false,angle,32,false,fixed,0,0,2,false,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x3013,12307,mathf.atan2,1,mathf,atan2,2,1,Float|Float,Float,true,false,y|x,48,false,fixed,0,0,2,false|false,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x3014,12308,math.i32.to_i64,1,math.i32,to_i64,1,1,Int32,Int64,true,false,value,2,false,fixed,0,0,2,false,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x3015,12309,math.i64.to_i32,1,math.i64,to_i32,1,1,Int64,Int32,true,false,value,2,false,fixed,0,0,2,false,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x3016,12310,math.i32.to_float,1,math.i32,to_float,1,1,Int32,Float,true,false,value,2,false,fixed,0,0,2,false,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x3017,12311,math.i64.to_float,1,math.i64,to_float,1,1,Int64,Float,true,false,value,2,false,fixed,0,0,2,false,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x3018,12312,mathf.to_i32,1,mathf,to_i32,1,1,Float,Int32,true,false,value,2,false,fixed,0,0,2,false,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x3019,12313,mathf.to_i64,1,mathf,to_i64,1,1,Float,Int64,true,false,value,2,false,fixed,0,0,2,false,host_buffered_v1,existing_contract_v1,host,,0
|
||||
0x4000,16384,random.new,1,random,new,1,1,Int64,builtin:Random,true,true,seed,32,true,fixed,0,0,2,false,vm_owned_v1,existing_contract_v1,vm_state,,0
|
||||
0x4001,16385,random.next,1,random,next,1,1,builtin:Random,Int64,true,false,rng,8,true,fixed,0,0,2,true,vm_owned_v1,existing_contract_v1,vm_state,,0
|
||||
0x4002,16386,random.nextf,1,random,nextf,1,1,builtin:Random,Float,true,false,rng,12,true,fixed,0,0,2,true,vm_owned_v1,existing_contract_v1,vm_state,,0
|
||||
0x4003,16387,random.range,1,random,range,3,1,builtin:Random|Int64|Int64,Int64,true,false,rng|min|max,4,true,random_rejection_v1,8,64,2,true|false|false,vm_owned_v1,existing_contract_v1,vm_state,,0
|
||||
0x4100,16640,hash.i64,1,hash,i64,1,1,Int64,Int64,true,false,value,8,false,fixed,0,0,2,false,borrowed_inline_v1,none,none,,0
|
||||
0x4101,16641,hash.float,1,hash,float,1,1,Float,Int64,true,false,value,8,false,fixed,0,0,2,false,borrowed_inline_v1,none,none,,0
|
||||
0x4102,16642,hash.string,1,hash,string,1,1,String,Int64,true,false,value,8,false,argument_utf8_bytes_v1,0,0,2,true,borrowed_inline_v1,none,none,0,1
|
||||
|
||||
|
@@ -107,9 +107,10 @@ Example:
|
||||
- Rows must remain unique by both `(canonical_name, canonical_version)` and `final_id_hex` / `final_id_dec`.
|
||||
- Rows must remain deterministically ordered by final ID.
|
||||
- parameter_names uses ordered | separated names for flattened argument slots.
|
||||
- cost_model is fixed or random_rejection_v1. cost_cycles is the full fixed
|
||||
- cost_model is fixed, random_rejection_v1, or argument_utf8_bytes_v1. cost_cycles is the full fixed
|
||||
cost or the variable base. attempt_cost_cycles/max_attempts are zero for
|
||||
fixed entries; random.range publishes base 4, attempt 8, maximum 64.
|
||||
fixed and String byte-cost entries; random.range publishes base 4, attempt 8, maximum 64.
|
||||
hash.string publishes base 8, argument index 0 and one cycle per UTF-8 byte.
|
||||
- Mathematical and random attempts charge upfront, including failure, without
|
||||
an additional generic INTRINSIC cycle. Random draws retain attempt costs.
|
||||
- mutates_guest_state distinguishes reproducible stateful calls from pure
|
||||
@@ -189,3 +190,30 @@ STRUCT_NEW (0x00A0), STRUCT_GET (0x00A1), STRUCT_SET (0x00A2), ARRAY_NEW (0x00A3
|
||||
## VM-owned random core
|
||||
|
||||
See the [random contract](../specs/runtime/02e-vm-owned-random-core.md) for Random BuiltinId 0x0016, ObjectKind tag 9, intrinsics 0x4000–0x4003, atomic state mutation, bounded 4+8*N costs and rejection-limit trap 0x00000015. Random is managed by the VM heap and existing GC, without host entropy or PBX changes.
|
||||
|
||||
|
||||
## Typed array range copy
|
||||
|
||||
ARRAY_COPY (0xA9, Array TypeId u32) consumes source, sourceStart, target,
|
||||
targetStart, count without a result. Complete groups and owners survive overlap
|
||||
and failed preparation. Charge 4+2*N*W before ordinary validation for available
|
||||
Int64 count in 0..u32::MAX; other counts/underflow charge base 4. Checked cost
|
||||
overflow charges base and traps SizeOverflow. The
|
||||
[canonical contract](../specs/runtime/02-vm-instruction-set.md#typed-array-range-copy)
|
||||
defines fault precedence, scratch and commit. ARRAY_LEN (0xA4) and physical array
|
||||
checks remain. Encodings 0xA7/0xA8/0xAA/0xAB reject at load even in dead code;
|
||||
no replacement publication/guard or transaction is provided.
|
||||
|
||||
## Identity/hash and catalog schema 2
|
||||
|
||||
The [identity/hash specification](../specs/runtime/02f-vm-identity-and-value-hashing.md)
|
||||
defines opcodes 0x0097/0x0098, intrinsics 0x4100–0x4102, XXH64 hash-v1 and
|
||||
borrowed_inline_v1. INTRINSICS.csv schema 2 retains its original eighteen columns
|
||||
and appends schema_version, arg_nullable, invocation_model, scratch_model,
|
||||
context_access, cost_arg_index and cost_per_byte. Descriptors remain authoritative;
|
||||
unknown or inconsistent schemas/profiles/models must fail explicitly. Existing
|
||||
canonical versions, signatures, effects and costs remain unchanged.
|
||||
|
||||
See the [identity/hash producer handoff](identity-hashing-producer-handoff.md) and
|
||||
[qualification record](IDENTITY_HASHING_QUALIFICATION.md) for emitted PBX, catalog
|
||||
provenance and consumer acceptance evidence.
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
# Storage ISA qualification
|
||||
|
||||
This record qualifies the working-tree delivery over baseline `69ad1931de1e12e59c2268f94aa906aed114fb6d` on
|
||||
macOS-27.0.1-arm64-arm-64bit-Mach-O with `rustc 1.98.1 (48a229cea 2026-09-01)`. The baseline commit alone does
|
||||
not contain the changes. No new provider revision is claimed. Source/test/spec
|
||||
SHA-256 fingerprints and exact test commands are stored in
|
||||
[the qualification manifest](storage-qualification.json).
|
||||
|
||||
## Delivered behavior
|
||||
|
||||
Encodings 0xA7/0xA8/0xAA/0xAB are unsupported at real instruction boundaries,
|
||||
including dead code. ARRAY_LEN stays 0xA4 and ARRAY_COPY stays 0xA9. The
|
||||
[copy contract](../specs/runtime/02-vm-instruction-set.md#typed-array-range-copy)
|
||||
defines strict ranges, complete groups/owners, snapshot overlap and precharged
|
||||
4+2*N*W work for calculable counts, including receiver/range/scratch refusal.
|
||||
No replacement publication, guard or transaction was introduced.
|
||||
|
||||
## Verification
|
||||
|
||||
`make ci-domains` passed: formatting, workspace Clippy with warnings denied,
|
||||
workspace tests/all features, all five debugger socket tests, LLVM coverage,
|
||||
coverage ownership audit and all 15 unchanged domain gates.
|
||||
|
||||
| Run | Passed | Ignored |
|
||||
| --- | ---: | ---: |
|
||||
| Workspace/all targets/all features | 1095 | 13 |
|
||||
| Debugger sockets (explicit ignored selection) | 5 | 0 |
|
||||
| LLVM coverage/workspace/all features | 1095 | 13 |
|
||||
| VM release | 400 | 2 |
|
||||
| VM diagnostics checkpoint | 407 | 2 |
|
||||
| Layer and quality suites | 19 | 0 |
|
||||
|
||||
The diagnostics checkpoint preceded test-only fixture import/Copy cleanup; the
|
||||
final all-features workspace and coverage runs include diagnostics on final code.
|
||||
No identity/hash semantic change was made. Default ignored measurement probes,
|
||||
audio probes and packaged-installation smoke remain explicit exclusions. The
|
||||
five debugger socket tests were executed separately and passed; sandbox-local
|
||||
binding had first been denied, so the complete successful gate ran with approval
|
||||
outside the sandbox. Coverage gates were not lowered or skipped.
|
||||
|
||||
Independent bytecode and serialized PBX tests prove decoder/admission rejection
|
||||
without treating immediate/data bytes as instructions. VM tests cover cost/fault
|
||||
precedence, frame temporary floors, empty and overlapping ranges, native and
|
||||
multislot groups, aliases, scratch quota and allocation refusal, late source-group
|
||||
failure, operand/destination preservation, native owners and roots through GC,
|
||||
zero budget, overshoot and successful-step accounting.
|
||||
|
||||
Overflow defense uses synthetic widths to exercise checked multiplication and
|
||||
addition. It does not imply such widths are accepted Registry layouts. Internal
|
||||
corruption tests are labeled separately from admitted-program evidence. There
|
||||
are no JavaScript/Lua engines or frontend fixtures in this qualification.
|
||||
|
||||
Local full logs and the domain audit are under `target/qualification/storage/`;
|
||||
the manifest records their digests. Generated logs/LLVM output are reproducible
|
||||
local evidence, not a runtime or SDK API.
|
||||
|
||||
## Consumer boundary
|
||||
|
||||
The [producer handoff](collection-producer-handoff.md) describes required compiler
|
||||
emission and SDK algorithm/contract changes. Existing consumer evidence still
|
||||
qualifies its original provider only. Compiler/SDK migration, provider pin/catalog
|
||||
import, installed resources and normal/optimized source conformance require
|
||||
consumer-owned delivery and are not claimed here.
|
||||
@@ -15,6 +15,7 @@ Opcodes are little-endian u16, followed by little-endian u32 immediates. TypeId
|
||||
| ARRAY_LEN | 0xA4 | TypeId | ref → Int64 length |
|
||||
| ARRAY_GET | 0xA5 | TypeId | ref, Int64 index → complete element group |
|
||||
| ARRAY_SET | 0xA6 | TypeId | ref, Int64 index, complete element group → [] |
|
||||
| ARRAY_COPY | 0xA9 | TypeId | source, sourceStart, target, targetStart, count → [] |
|
||||
|
||||
The single-immediate forms are six bytes; field forms are ten. Width is one for scalar/String/color/concrete references, two for vec2/Trait/Dynamic, three for pixel. A Trait contains receiver then ImplementationId; Dynamic contains TypeId then payload. Preserve the whole group, including absent [Null, Null]. ImplementationId zero is valid. GET does not implicitly box; Dynamic copies share immutable boxes. NEW initializes canonical defaults without constructing referenced instances. Arrays have fixed lengths. SDKs implement List, Set and Map algorithms using these runtime capabilities.
|
||||
|
||||
@@ -58,7 +59,7 @@ Static bad IDs/categories/fields reject load with typed LOAD_INVALID_REFERENCE c
|
||||
|
||||
## Consumer integration and evidence
|
||||
|
||||
Consumers must recognize all seven encodings, invoke Registry-derived effects in bounded structural/height/type verification and use validated-image execution. The metadata-free verifier and legacy decoder have been removed. Reuse compact typed storage, default initialization, native ownership maps and generational handles; do not replace them with raw Value arrays or SDK container implementations.
|
||||
Consumers must recognize all eight encodings, invoke Registry-derived effects in bounded structural/height/type verification and use validated-image execution. The metadata-free verifier and legacy decoder have been removed. Reuse compact typed storage, default initialization, native ownership maps and generational handles; do not replace them with raw Value arrays or SDK container implementations.
|
||||
|
||||
Executable oracles live in bytecode `tests/registry_isa.rs`, VM `tests/collection_conformance.rs`, VM `virtual_machine/collections_tests.rs` and layer `tests/typed_collections.rs`. They cover independent bytes, default/alias/group operations, attempt costs and refusals, malformed/proven types, ownership and actual FRAME_SYNC graph reclamation. VM unit tests inject otherwise unreachable invalid state only inside tests. Optimized ownership/conformance runs complement debug evidence.
|
||||
|
||||
@@ -70,3 +71,40 @@ never invokes callbacks. Threshold GC runs at FRAME_SYNC and successful last-roo
|
||||
RET after rooting results. Quota refusal cannot invoke rescue GC.
|
||||
|
||||
The published patterns and validation limits are explained in [Collection Attempts Preserve Groups and Charge Work Before Publication](../../discussion/lessons/DSC-0051-game-state-collections-and-objects/LSN-0060-collection-attempts-preserve-groups-and-charge-work-before-publication.md).
|
||||
|
||||
## Range-copy migration contract
|
||||
|
||||
ARRAY_LEN stays 0xA4. ARRAY_COPY is six bytes: `A9 00 04 03 02 01` for encoding
|
||||
oracle TypeId 0x01020304. Actual execution needs an existing exact Array descriptor.
|
||||
The five operands use Int64 offsets/count and exact Array receivers. Physical
|
||||
ranges are strict; an empty range may start at length. Copy snapshots complete
|
||||
source groups before writing, preserving tags, native owners and identity under
|
||||
overlap without boxing. Reserve complete TemporaryBytes scratch first; release it
|
||||
on success/failure. Failed attempts preserve operands/storage; no request token,
|
||||
guest object, callback, GC or scheduler occurs inside the instruction.
|
||||
|
||||
For available five temporary operands and exact Int64 count N in 0..u32::MAX,
|
||||
precharge representable C=4+2*N*W before receiver/range/group validation or scratch
|
||||
reservation. Retain it on refusal: N=10/W=1 costs 24 for success, bad receiver,
|
||||
bad range or scratch quota. Other counts/underflow cost base 4 with normal fault
|
||||
order. Checked cost overflow costs 4 and traps SizeOverflow before ordinary
|
||||
validation. Empty copies validate receivers/ranges and cost 4; aliases give no
|
||||
discount. See the [copy contract](../specs/runtime/02-vm-instruction-set.md#typed-array-range-copy)
|
||||
for exact precedence. Positive budget admits the full attempt with overshoot;
|
||||
Trap wins on refusal and only successful steps count. Zero budget does no work.
|
||||
|
||||
Encodings 0xA7, 0xA8, 0xAA and 0xAB are unsupported in actual instruction
|
||||
positions, including dead code. They are not remapped or emulated. Producers
|
||||
must remove their emission, adapt logical checks/error paths and re-evaluate
|
||||
algorithms, representations and collection guarantees. Sequential stores do not
|
||||
preserve the former multi-owner publication guarantee. Prepare fallible values
|
||||
before mutation and explicitly define the remaining source contract.
|
||||
|
||||
Compiler/SDK migration, provider pinning/catalog import and source/optimized/
|
||||
installed-resource conformance belong to the consumer. Prior List/Linked evidence
|
||||
qualifies earlier providers only. Identity/hash catalog schema 2 import is a
|
||||
separate consumer dependency, not a storage or new-collection implementation here.
|
||||
See `virtual_machine/array_copy_tests.rs` and collection/Registry conformance for
|
||||
current executable oracles. Qualification provenance is recorded in
|
||||
[storage qualification](STORAGE_QUALIFICATION.md); an uncommitted implementation
|
||||
must not be attributed to an earlier committed provider SHA.
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
# Identity and hashing producer handoff
|
||||
|
||||
The runtime provides the five operations in the
|
||||
[identity/hash contract](../specs/runtime/02f-vm-identity-and-value-hashing.md).
|
||||
The [catalog](INTRINSICS.csv) uses schema 2. Compiler/SDK integration is pending
|
||||
consumer work; the neutral PBX corpus qualifies the provider independently of
|
||||
any source language. No host, firmware, syscall or Lua frontend is required.
|
||||
|
||||
## Provider identity
|
||||
|
||||
The [qualification record](IDENTITY_HASHING_QUALIFICATION.md) identifies the
|
||||
source base revision, source fingerprint, toolchain, catalog/constant/vector
|
||||
SHA-256 values and executed commands. Pin the delivered runtime revision and
|
||||
catalog digest together when importing this provider. A catalog-only copy does
|
||||
not establish consumer compatibility. The hash contract version remains one;
|
||||
schema version two changes metadata representation, not old intrinsic versions.
|
||||
|
||||
## Representation and emission
|
||||
|
||||
| Operation | Encoding | Complete input group(s) | Output | Cycles |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| REF_IDENTITY_HASH | u16 0x0097, u32 source TypeId | source | Int64 | 8+w(source) |
|
||||
| REF_IDENTITY_EQ | u16 0x0098, u32 left TypeId, u32 right TypeId | left then right | Bool | 4+w(left)+w(right) |
|
||||
| hash.i64@1 | INTRINSIC u32 0x4100 | Int64 | Int64 | 8 |
|
||||
| hash.float@1 | INTRINSIC u32 0x4101 | Float | Int64 | 8 |
|
||||
| hash.string@1 | INTRINSIC u32 0x4102 | nullable String | Int64 | 8+UTF-8 bytes |
|
||||
|
||||
All fields are little-endian. TypeIds are program-local Registry indices.
|
||||
Reference eligibility is exactly Struct/Array/Fn/Trait/Random; preserve complete
|
||||
Trait pairs and source evaluation order. Valid trait views hash/compare their
|
||||
receiver, including ImplementationId zero. Do not project String/Dynamic through
|
||||
these opcodes or widen the older REF_* category rules.
|
||||
|
||||
For example, with TypeId 5 a Struct and TypeId 7 its Trait, emit:
|
||||
|
||||
```text
|
||||
STRUCT_NEW 5
|
||||
SET_LOCAL 0
|
||||
GET_LOCAL 0
|
||||
REF_IDENTITY_HASH 5
|
||||
GET_LOCAL 0
|
||||
REF_TO_TRAIT source=5,target=7
|
||||
REF_IDENTITY_HASH 7
|
||||
EQ
|
||||
RET
|
||||
```
|
||||
|
||||
The result is true. Trait conversion must have a coherent Registry implementation.
|
||||
Hash values use signed Int64 carriers with unchanged digest bits; negative results
|
||||
are valid. SDK code must define ordered component composition, optional/Dynamic
|
||||
strategies, 32-bit folding, and coherent equality domains. Integer/Float equality
|
||||
across domains requires explicit canonicalization; numerical Float-to-Int64
|
||||
conversion is not the Float hashing algorithm.
|
||||
|
||||
## Metadata import and rejection
|
||||
|
||||
Import all 25 exact columns, including schema_version=2 on every row and ordered
|
||||
arg_nullable booleans matching flattened argument slots. Preserve the existing
|
||||
18 fields. Validate:
|
||||
|
||||
- borrowed_inline_v1/none/none is the hash profile; deterministic=true,
|
||||
may_allocate=false and mutates_guest_state=false are separate claims.
|
||||
- fixed numeric costs have no cost_arg_index and cost_per_byte=0.
|
||||
- argument_utf8_bytes_v1 uses String slot zero, cost_per_byte=1 and base eight;
|
||||
attempt_cost_cycles/max_attempts are zero.
|
||||
- Old Host and VM-owned entries retain their explicit profiles and existing
|
||||
contract; their metadata does not promise the bounded profile's execution model.
|
||||
- Known null is admitted for hash.string only among String arguments; previous
|
||||
String intrinsics and numeric hashes keep non-nullable admission. Random
|
||||
nullable admission still allows runtime receiver precondition faults.
|
||||
|
||||
Reject unsupported schemas, profiles, cost models, capacities and inconsistent
|
||||
layouts/nullable widths/indexes explicitly. Do not infer nullability, scratch,
|
||||
context access or purity from names or deterministic alone. Preserve observable
|
||||
faults and charged work when results are unused. Optimization must not skip
|
||||
complete right-side validation because a left operand is null or differs.
|
||||
|
||||
## Studio consumer ownership and acceptance
|
||||
|
||||
The following targets belong to the Studio/compiler delivery, outside this
|
||||
runtime implementation:
|
||||
|
||||
| Target | Required result and acceptance evidence |
|
||||
| --- | --- |
|
||||
| Manual IRVMIntrinsicDefinition and intrinsic registry | Represent/import schema, nullable mask, invocation/scratch/context and cost parameters; reject unknown or inconsistent entries. |
|
||||
| IR, verifier, lowering and emitter | Represent both typed reference instructions, complete operand groups and exact IDs; admit nullable String per entry; preserve fault order and costs. |
|
||||
| Catalog mirrors and runtime-catalog pin | Copy generated schema 2 artifacts, record runtime revision and SHA-256, retain all old IDs/versions/contracts and constant bytes. |
|
||||
| Packaged compiler and SDK resources | Installed resources and generated code use the same pin, schema and definitions as development execution. |
|
||||
| SDK equality/hash wrappers | Explicit domain policy, null handling, Float zero normalization, Int32 widening, Bool mapping, composition and 32-bit folding. No implicit object-content or universal Dynamic equality. |
|
||||
| Normal and optimized source corpus | Execute emitted PBX against the runtime and compare result bits, faults, retained operands and cycles. Include the neutral cases below and packaged execution. |
|
||||
|
||||
Consumer corpus coverage must include signed Int64 extremes and negative digests;
|
||||
finite Float subnormals/extremes/2^53, both zeros and injected non-finite faults;
|
||||
UTF-8, NUL, empty/null and equal content with different owners; aliases versus
|
||||
distinct objects/closures/generators; mutation and Random advancement; Trait
|
||||
views and implementation zero; absent and malformed groups; stale handles after
|
||||
GC/reuse; rejected right groups despite null/different left groups; zero fuel,
|
||||
positive overshoot and discarded results. Reuse the
|
||||
[reference vectors](../../crates/console/prometeu-vm/tests/fixtures/hash-conformance.tsv)
|
||||
with their [independent oracle provenance](../../crates/console/prometeu-vm/tests/fixtures/hash-oracle.md).
|
||||
|
||||
Set/Map implementation, source frontend integration, general structural equality,
|
||||
storage-publication integration and any future Lua frontend retain their own
|
||||
scope and validation. This handoff does not report those consumers as delivered.
|
||||
@@ -0,0 +1,126 @@
|
||||
{
|
||||
"date": "2026-10-23",
|
||||
"target": "aarch64-apple-darwin",
|
||||
"rustc": "1.98.1 (48a229cea 2026-09-01)",
|
||||
"cargo": "1.98.1 (797e8a9bc 2026-08-05)",
|
||||
"base_revision": "57992cf214e8a5f9de53a40dba9aaa7fab038c91",
|
||||
"delivery_state": "working tree; source and artifact digests identify this qualification",
|
||||
"source_fingerprint_encoding": "For sorted source_files paths, SHA256(path UTF-8 + NUL + file bytes + NUL), concatenated in order.",
|
||||
"source_fingerprint_sha256": "a0d202e46fbca3319d7b04fe09906388c015da7b606216e75bd7c62041011885",
|
||||
"source_files": {
|
||||
"crates/console/prometeu-bytecode/src/assembler.rs": "f6167c76402dda95e32e12d801791625be0232864df96eab6857bedbc94cfe95",
|
||||
"crates/console/prometeu-bytecode/src/disassembler.rs": "c75a82b46d7845ea08d3fdee7abba4ce4f8bfb589c787d8ce72728da973947c7",
|
||||
"crates/console/prometeu-bytecode/src/opcode.rs": "ec3ae01e521190757c882df5119ad86ee35204986bbf894cc57c6a565f31c097",
|
||||
"crates/console/prometeu-bytecode/src/opcode_spec.rs": "cf393b2681bc7326fb79f1646bfbaf507b371e45648a6ef0d835eccbb6b9adba",
|
||||
"crates/console/prometeu-bytecode/src/registry.rs": "6fe288fe41bf753279a8dcbe4b62d8878c82c7c0e7227ef10764af1b4f37e13d",
|
||||
"crates/console/prometeu-bytecode/src/registry_instruction.rs": "957a06d9d9d801021af9341a01b84a21299e2ffe8c1bc50dfcec867ea7e18030",
|
||||
"crates/console/prometeu-bytecode/tests/registry_isa.rs": "c67183a8b7100690fdd3b723b43024fc63afe63b8fb50bbcd1fb61f3f0e75323",
|
||||
"crates/console/prometeu-vm/src/builtins.rs": "061785b356373f92c69cb6c774344b3e6ae77d33014061529e4ce905da5afe33",
|
||||
"crates/console/prometeu-vm/src/catalog.rs": "d4f53cd5da6e7b90a3454aefd696baac1d49b2a4cf8cada2d563a6f3c190f81a",
|
||||
"crates/console/prometeu-vm/src/hash_intrinsics.rs": "40c307e78e773908a42a187ca7a0b42667d38f72a480208d2b8255d8c322e324",
|
||||
"crates/console/prometeu-vm/src/hashing.rs": "5f81f74560fd126e4344fdb47e4a6ba916b94954ccf8ce70af796adbacf10ab1",
|
||||
"crates/console/prometeu-vm/src/input_intrinsics.rs": "5d0f6985f1bb0038405dd853816d9e16b636a3157d870a282aeaf742c30700ae",
|
||||
"crates/console/prometeu-vm/src/intrinsic_contract.rs": "09908ccff4586c0985cdf5b3b65b0844dd175dffa301ed5902d4e0b83f16bc49",
|
||||
"crates/console/prometeu-vm/src/lib.rs": "c69e7fcb9dd6a6d3c174c1ec6ed61d0c3a884254aa3882438bfe1b99e22c273f",
|
||||
"crates/console/prometeu-vm/src/math_intrinsics.rs": "22101a563b5fd5f4a47b463b3482be80d39483a8a0cea285453cff385174cb19",
|
||||
"crates/console/prometeu-vm/src/random_intrinsics.rs": "dfc398ed6a62c2fb50d9316d1ec9e03c04fa1651f6087e8c108ded5668894a2a",
|
||||
"crates/console/prometeu-vm/src/registry_verifier/types.rs": "4a3af80df86c01cdad4d2f78c7e0578cb8e4afab9ff5148d13c431cf4cbc8d85",
|
||||
"crates/console/prometeu-vm/src/value_contract.rs": "69bb9dc6921e3a5ef2f4fc0d36a952ae7717335859ee864afd0744799314ae81",
|
||||
"crates/console/prometeu-vm/src/virtual_machine.rs": "cbe860aaec823400bd3657f6d4fb2cf2b18d65295527ad63a58021e7cf117b03",
|
||||
"crates/console/prometeu-vm/src/virtual_machine/identity.rs": "0f16d16030fd4b233185abc140346fe89134bd1cd783e652c7f2bafa4ce7030a",
|
||||
"crates/console/prometeu-vm/src/virtual_machine/identity_tests.rs": "859d8db588de45129dd70c86260f864fa8412581de3972080dc772bb5e306800",
|
||||
"crates/console/prometeu-vm/src/virtual_machine/intrinsic.rs": "1b7ac3a384b4dee22906d9bfb274a4375eefefe3ce3ba80e1c34b0cc120816e2",
|
||||
"crates/console/prometeu-vm/tests/execution_allocations.rs": "ab21890759be059c93b3b8a54cfbe33f8372b41e608e461fe0923c8f15a5434f",
|
||||
"crates/console/prometeu-vm/tests/fixtures/hash-conformance.tsv": "a863486eaea14ab1a010f076f355eed0d5738207dad3651f7d10e92fc09f74d4",
|
||||
"crates/console/prometeu-vm/tests/fixtures/hash-oracle.md": "2001e073c610a78df79d21fb973aa017ddf23312751716445f106d60b71e4113",
|
||||
"crates/console/prometeu-vm/tests/fixtures/hash-oracle.py": "48bb6cae67b96f9bd8c306236d74ef61dc9aa0309c846c289298f870ceb367a1",
|
||||
"crates/console/prometeu-vm/tests/identity_hashing.rs": "9ec0c42354fb5cc0eaa440aa2405e2fdffea3b91a98f2d8399275d2d1ebf8304",
|
||||
"crates/console/prometeu-vm/tests/intrinsic_profiles.rs": "3bc549f666e4b3b30789704fa7a9f050273a370340e1f40ca33fcd10cc61402c",
|
||||
"crates/console/prometeu-vm/tests/support/identity.rs": "cd8407f94d8c3b4782eaacbd5a934f278f25ee20d604c2f6862e7646bca54069"
|
||||
},
|
||||
"artifact_sha256": {
|
||||
"Cargo.lock": "cffad9ed62f38a591538abd81dd39270d6022397342c8189f4ac6c7baaa8e795",
|
||||
"docs/vm-arch/INTRINSICS.csv": "7c1c363f5f0f941b3ab27cfc72af41e13e44cd4371c687db8300721288f47e63",
|
||||
"docs/vm-arch/BUILTIN_CONSTANTS.csv": "e407e4718127aa7ef7b1097b5b4b67d86dd979235e73a551a7c36b628cddc039",
|
||||
"crates/console/prometeu-vm/tests/fixtures/hash-conformance.tsv": "a863486eaea14ab1a010f076f355eed0d5738207dad3651f7d10e92fc09f74d4"
|
||||
},
|
||||
"checks": [
|
||||
{
|
||||
"command": "cargo test --locked --offline -p prometeu-bytecode -p prometeu-vm --no-fail-fast",
|
||||
"result": "passed",
|
||||
"passed": 453,
|
||||
"failed": 0,
|
||||
"ignored": 3
|
||||
},
|
||||
{
|
||||
"command": "cargo test --locked --offline -p prometeu-vm --features resource-diagnostics --no-fail-fast",
|
||||
"result": "passed",
|
||||
"passed": 401,
|
||||
"failed": 0,
|
||||
"ignored": 2
|
||||
},
|
||||
{
|
||||
"command": "cargo test --locked --offline -p prometeu-quality-checks -p prometeu-layer-tests --no-fail-fast",
|
||||
"result": "passed",
|
||||
"passed": 19,
|
||||
"failed": 0,
|
||||
"ignored": 0
|
||||
},
|
||||
{
|
||||
"command": "cargo test --locked --offline --release -p prometeu-vm --test identity_hashing --test intrinsic_profiles --test execution_allocations",
|
||||
"result": "passed",
|
||||
"passed": 12,
|
||||
"failed": 0,
|
||||
"ignored": 0
|
||||
},
|
||||
{
|
||||
"command": "cargo check --locked --offline --workspace --all-targets",
|
||||
"result": "passed"
|
||||
},
|
||||
{
|
||||
"command": "cargo fmt --all --check",
|
||||
"result": "passed"
|
||||
},
|
||||
{
|
||||
"command": "git diff --check",
|
||||
"result": "passed"
|
||||
},
|
||||
{
|
||||
"command": "Regenerate catalog from runtime descriptors and compare exact bytes",
|
||||
"result": "passed"
|
||||
},
|
||||
{
|
||||
"command": "Regenerate 118 vectors from the pinned official C reference and compare exact bytes",
|
||||
"result": "passed"
|
||||
},
|
||||
{
|
||||
"command": "Compare all 105 legacy catalog entries first 18 fields and constant catalog bytes against base revision",
|
||||
"result": "passed"
|
||||
},
|
||||
{
|
||||
"command": "Verify source/artifact SHA-256 values, changed Markdown links, published workflow references and lesson links",
|
||||
"result": "passed"
|
||||
}
|
||||
],
|
||||
"oracle": {
|
||||
"algorithm": "XXH64 seed 0",
|
||||
"upstream": "xxHash v0.8.3 official C header",
|
||||
"header_sha256": "17973c0dc49d9854ca26caa191f0e12f7a424b68858d9a78de3860d959d85e4b",
|
||||
"vectors": 118
|
||||
},
|
||||
"legacy": {
|
||||
"intrinsic_entries_preserved": 105,
|
||||
"previous_fields_per_entry_preserved": 18,
|
||||
"new_entries": 3,
|
||||
"constant_catalog_byte_identical": true
|
||||
},
|
||||
"allocator": {
|
||||
"new_instruction_regions": 10,
|
||||
"warmup_iterations": 10,
|
||||
"measured_iterations_per_region": 1000,
|
||||
"native_allocations": 0,
|
||||
"native_deallocations": 0,
|
||||
"guest_allocations": 0
|
||||
},
|
||||
"limits": "Local debug/default, debug/resource-diagnostics, and selected release evidence only. No source compiler, Studio packaging, other host/target, or GUI execution qualified."
|
||||
}
|
||||
@@ -0,0 +1,357 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"qualified_at_utc": "2026-10-23T22:32:12.156934+00:00",
|
||||
"base_revision": "69ad1931de1e12e59c2268f94aa906aed114fb6d",
|
||||
"delivery_state": "uncommitted working tree; fingerprints identify this delivery, not base_revision alone",
|
||||
"platform": "macOS-27.0.1-arm64-arm-64bit-Mach-O",
|
||||
"rustc": "rustc 1.98.1 (48a229cea 2026-09-01)",
|
||||
"gate": "make ci-domains",
|
||||
"gate_status": "passed",
|
||||
"execution": "Approved outside sandbox: debugger localhost sockets are blocked in sandbox.",
|
||||
"checks": [
|
||||
{
|
||||
"command": "cargo test --workspace --all-targets --all-features --no-fail-fast",
|
||||
"status": "passed",
|
||||
"passed": 1095,
|
||||
"failed": 0,
|
||||
"ignored": 13
|
||||
},
|
||||
{
|
||||
"command": "cargo test -p prometeu-host-desktop-winit --lib runner::tests -- --ignored",
|
||||
"status": "passed",
|
||||
"passed": 5,
|
||||
"failed": 0,
|
||||
"ignored": 0
|
||||
},
|
||||
{
|
||||
"command": "cargo llvm-cov --workspace --all-features --html --output-dir target/llvm-cov",
|
||||
"status": "passed",
|
||||
"passed": 1095,
|
||||
"failed": 0,
|
||||
"ignored": 13
|
||||
},
|
||||
{
|
||||
"command": "cargo test --locked --offline -p prometeu-vm --release --no-fail-fast",
|
||||
"status": "passed",
|
||||
"passed": 400,
|
||||
"failed": 0,
|
||||
"ignored": 2
|
||||
},
|
||||
{
|
||||
"command": "cargo test --locked --offline -p prometeu-vm --features resource-diagnostics --no-fail-fast",
|
||||
"status": "passed",
|
||||
"phase": "Before Clippy-only fixture import/Copy cleanup; final all-features workspace and coverage also include diagnostics.",
|
||||
"passed": 407,
|
||||
"failed": 0,
|
||||
"ignored": 2
|
||||
},
|
||||
{
|
||||
"command": "cargo test --locked --offline -p prometeu-layer-tests -p prometeu-quality-checks --no-fail-fast",
|
||||
"status": "passed",
|
||||
"passed": 19,
|
||||
"failed": 0,
|
||||
"ignored": 0
|
||||
}
|
||||
],
|
||||
"coverage": {
|
||||
"system/os": {
|
||||
"source_files": 19,
|
||||
"report_files": 10,
|
||||
"lines_count": 1711,
|
||||
"lines_covered": 1410,
|
||||
"functions": {
|
||||
"count": 239,
|
||||
"covered": 184
|
||||
},
|
||||
"regions": {
|
||||
"count": 2976,
|
||||
"covered": 2514
|
||||
},
|
||||
"baseline_percent": 77.24,
|
||||
"line_percent": 82.4,
|
||||
"gate_passed": true
|
||||
},
|
||||
"system/runtime": {
|
||||
"source_files": 14,
|
||||
"report_files": 12,
|
||||
"lines_count": 3309,
|
||||
"lines_covered": 2762,
|
||||
"functions": {
|
||||
"count": 250,
|
||||
"covered": 224
|
||||
},
|
||||
"regions": {
|
||||
"count": 5722,
|
||||
"covered": 4655
|
||||
},
|
||||
"baseline_percent": 76.19,
|
||||
"line_percent": 83.46,
|
||||
"gate_passed": true
|
||||
},
|
||||
"system/fs": {
|
||||
"source_files": 13,
|
||||
"report_files": 9,
|
||||
"lines_count": 2469,
|
||||
"lines_covered": 1944,
|
||||
"functions": {
|
||||
"count": 249,
|
||||
"covered": 204
|
||||
},
|
||||
"regions": {
|
||||
"count": 4450,
|
||||
"covered": 3401
|
||||
},
|
||||
"baseline_percent": 76.08,
|
||||
"line_percent": 78.73,
|
||||
"gate_passed": true
|
||||
},
|
||||
"system/programs": {
|
||||
"source_files": 3,
|
||||
"report_files": 1,
|
||||
"lines_count": 567,
|
||||
"lines_covered": 556,
|
||||
"functions": {
|
||||
"count": 54,
|
||||
"covered": 52
|
||||
},
|
||||
"regions": {
|
||||
"count": 854,
|
||||
"covered": 834
|
||||
},
|
||||
"baseline_percent": 93.05,
|
||||
"line_percent": 98.05,
|
||||
"gate_passed": true
|
||||
},
|
||||
"asset/bank": {
|
||||
"source_files": 8,
|
||||
"report_files": 7,
|
||||
"lines_count": 3434,
|
||||
"lines_covered": 3176,
|
||||
"functions": {
|
||||
"count": 303,
|
||||
"covered": 269
|
||||
},
|
||||
"regions": {
|
||||
"count": 5718,
|
||||
"covered": 5306
|
||||
},
|
||||
"baseline_percent": 86.76,
|
||||
"line_percent": 92.48,
|
||||
"gate_passed": true
|
||||
},
|
||||
"firmware": {
|
||||
"source_files": 16,
|
||||
"report_files": 11,
|
||||
"lines_count": 2314,
|
||||
"lines_covered": 1990,
|
||||
"functions": {
|
||||
"count": 139,
|
||||
"covered": 127
|
||||
},
|
||||
"regions": {
|
||||
"count": 4255,
|
||||
"covered": 3791
|
||||
},
|
||||
"baseline_percent": 83.2,
|
||||
"line_percent": 85.99,
|
||||
"gate_passed": true
|
||||
},
|
||||
"host-dependent": {
|
||||
"source_files": 13,
|
||||
"report_files": 13,
|
||||
"lines_count": 2393,
|
||||
"lines_covered": 1531,
|
||||
"functions": {
|
||||
"count": 203,
|
||||
"covered": 136
|
||||
},
|
||||
"regions": {
|
||||
"count": 4011,
|
||||
"covered": 2599
|
||||
},
|
||||
"baseline_percent": 40.05,
|
||||
"line_percent": 63.97,
|
||||
"gate_passed": true
|
||||
},
|
||||
"host/headless": {
|
||||
"source_files": 6,
|
||||
"report_files": 3,
|
||||
"lines_count": 855,
|
||||
"lines_covered": 739,
|
||||
"functions": {
|
||||
"count": 93,
|
||||
"covered": 69
|
||||
},
|
||||
"regions": {
|
||||
"count": 1451,
|
||||
"covered": 1246
|
||||
},
|
||||
"baseline_percent": 83.39,
|
||||
"line_percent": 86.43,
|
||||
"gate_passed": true
|
||||
},
|
||||
"vm/core": {
|
||||
"source_files": 64,
|
||||
"report_files": 47,
|
||||
"lines_count": 10137,
|
||||
"lines_covered": 9028,
|
||||
"functions": {
|
||||
"count": 945,
|
||||
"covered": 774
|
||||
},
|
||||
"regions": {
|
||||
"count": 19226,
|
||||
"covered": 17054
|
||||
},
|
||||
"baseline_percent": 84.29,
|
||||
"line_percent": 89.05,
|
||||
"gate_passed": true
|
||||
},
|
||||
"bytecode": {
|
||||
"source_files": 19,
|
||||
"report_files": 14,
|
||||
"lines_count": 3374,
|
||||
"lines_covered": 3157,
|
||||
"functions": {
|
||||
"count": 299,
|
||||
"covered": 243
|
||||
},
|
||||
"regions": {
|
||||
"count": 5909,
|
||||
"covered": 5070
|
||||
},
|
||||
"baseline_percent": 88.26,
|
||||
"line_percent": 93.56,
|
||||
"gate_passed": true
|
||||
},
|
||||
"hal/core": {
|
||||
"source_files": 59,
|
||||
"report_files": 27,
|
||||
"lines_count": 2369,
|
||||
"lines_covered": 2093,
|
||||
"functions": {
|
||||
"count": 264,
|
||||
"covered": 227
|
||||
},
|
||||
"regions": {
|
||||
"count": 3341,
|
||||
"covered": 3035
|
||||
},
|
||||
"baseline_percent": 83.56,
|
||||
"line_percent": 88.34,
|
||||
"gate_passed": true
|
||||
},
|
||||
"drivers/core": {
|
||||
"source_files": 13,
|
||||
"report_files": 12,
|
||||
"lines_count": 3107,
|
||||
"lines_covered": 2775,
|
||||
"functions": {
|
||||
"count": 347,
|
||||
"covered": 307
|
||||
},
|
||||
"regions": {
|
||||
"count": 4756,
|
||||
"covered": 4123
|
||||
},
|
||||
"baseline_percent": 79.51,
|
||||
"line_percent": 89.31,
|
||||
"gate_passed": true
|
||||
},
|
||||
"system/core": {
|
||||
"source_files": 12,
|
||||
"report_files": 7,
|
||||
"lines_count": 1444,
|
||||
"lines_covered": 1353,
|
||||
"functions": {
|
||||
"count": 171,
|
||||
"covered": 163
|
||||
},
|
||||
"regions": {
|
||||
"count": 2318,
|
||||
"covered": 2184
|
||||
},
|
||||
"baseline_percent": 87.71,
|
||||
"line_percent": 93.69,
|
||||
"gate_passed": true
|
||||
},
|
||||
"tooling": {
|
||||
"source_files": 8,
|
||||
"report_files": 8,
|
||||
"lines_count": 612,
|
||||
"lines_covered": 396,
|
||||
"functions": {
|
||||
"count": 41,
|
||||
"covered": 31
|
||||
},
|
||||
"regions": {
|
||||
"count": 947,
|
||||
"covered": 621
|
||||
},
|
||||
"baseline_percent": 59.75,
|
||||
"line_percent": 64.7,
|
||||
"gate_passed": true
|
||||
},
|
||||
"dev/test-support": {
|
||||
"source_files": 4,
|
||||
"report_files": 2,
|
||||
"lines_count": 115,
|
||||
"lines_covered": 99,
|
||||
"functions": {
|
||||
"count": 17,
|
||||
"covered": 13
|
||||
},
|
||||
"regions": {
|
||||
"count": 131,
|
||||
"covered": 112
|
||||
},
|
||||
"baseline_percent": 80.96,
|
||||
"line_percent": 86.08,
|
||||
"gate_passed": true
|
||||
}
|
||||
},
|
||||
"fingerprints_sha256": {
|
||||
"crates/console/prometeu-bytecode/src/assembler.rs": "ae718b0881fef0b10bb8a0f5e56c348e13796b1133e2639b7fbd8683faff0792",
|
||||
"crates/console/prometeu-bytecode/src/decoder.rs": "032e9e7606b68c4d722518e7d4e97eac7fa5feecc78453a41ee8e2e14f8b87d9",
|
||||
"crates/console/prometeu-bytecode/src/disassembler.rs": "f5e47a2b0f0595b628f17816ffd2728d48ef92c65aa926ea1aaf7c38fe7a63ec",
|
||||
"crates/console/prometeu-bytecode/src/opcode.rs": "3392129a50e365445439c9c76e379650a474f492df6f4878fe87fee7172630e2",
|
||||
"crates/console/prometeu-bytecode/src/opcode_spec.rs": "d2e74d88d68a223e4411ccc159f8003db21d05428511add13016aaa862a66883",
|
||||
"crates/console/prometeu-bytecode/src/registry_instruction.rs": "8bd4d3928f4e85674877be5398279988641da17be203a323edce8df795639f47",
|
||||
"crates/console/prometeu-bytecode/tests/registry_isa.rs": "0a61b8e1ba6054dab542acc6b2c320e8ab9140375fc12780350a75395b10d87a",
|
||||
"crates/console/prometeu-vm/src/registry_verifier.rs": "985446f71017625266483be539514f8a74c61ffcf3a21e5676bd67620ae3575f",
|
||||
"crates/console/prometeu-vm/src/registry_verifier/types.rs": "6776bf04c49f8f9738a1be293d775493557b0d8ba035bf525a1e9aec1323047b",
|
||||
"crates/console/prometeu-vm/src/virtual_machine.rs": "cfa594d54109bfcdca6e138bb287db6d20a003ea3248cf1970eb6c926def9729",
|
||||
"crates/console/prometeu-vm/src/virtual_machine/array_copy.rs": "122bb20f9041f22a46d7e23398d016fbe365fe93834878a9d6fcc4f4c4b36c1b",
|
||||
"crates/console/prometeu-vm/src/virtual_machine/array_copy_tests.rs": "e0afba27cee5bd94772c1a53498dc7a4185f9a0642b7f029378ed2c0f3be5d12",
|
||||
"crates/console/prometeu-vm/src/virtual_machine/collections_tests.rs": "90ba1cba0d37b2213f0fa13de2b16c04515a5c1d33e858118768a448b06b6c8b",
|
||||
"crates/console/prometeu-vm/src/virtual_machine/identity_tests.rs": "ce3501539df309f154bb1f46f7d72c450cb87c71b9d21a7ca86fc3fcc63a6c44",
|
||||
"crates/console/prometeu-vm/tests/collection_conformance.rs": "bcb40dcd9dc650ffd1234fc4eeb6799742dc7a8f60536126543d6a2db6f37128",
|
||||
"discussion/lessons/DSC-0065-vm-storage-publication-neutrality/LSN-0072-primitives-need-independent-semantics-and-failed-attempts-still-cost-work.md": "a55d2d5f2487301f9b3d18c81c9112a4ad4f104a967e20df849fd3c722aadf3c",
|
||||
"docs/specs/runtime/01-time-model-and-cycles.md": "6c1ba3e023521d5593edb8aefd20f3d6d09fdec5be23d89487871df339f0359f",
|
||||
"docs/specs/runtime/02-vm-instruction-set.md": "26bf012681f6e96ff793e0541f6685c3e15df899ac2b04b62edbe70a4a116726",
|
||||
"docs/specs/runtime/02c-program-registry-and-pbx-v0.md": "e5a42d1aab637467dacde624f2662a615b74fbb3b5111fc437ef1bd0aeffb149",
|
||||
"docs/specs/runtime/03-memory-stack-heap-and-allocation.md": "96bf0859ecfc949390a159166673a7bfa0ad83c651138c5b8d28c87229a5669a",
|
||||
"docs/vm-arch/ARCHITECTURE.md": "d7e3487bb2d9718bba810cf4cfaec175dcbf9b079f7df12a4fad537bd1606146",
|
||||
"docs/vm-arch/ISA_CORE.md": "6b3207f81d3bd782e4f9b445b19c80b64bc599d8aebc5f01d8627a477bd09c8b",
|
||||
"docs/vm-arch/collection-producer-handoff.md": "47e6117fd7585b10927090519c72c8476ea5f4800e5777d201f536fd9a05dc91"
|
||||
},
|
||||
"removed_files": [
|
||||
"crates/console/prometeu-vm/src/virtual_machine/storage_publication.rs",
|
||||
"crates/console/prometeu-vm/src/virtual_machine/storage_publication_tests.rs"
|
||||
],
|
||||
"local_evidence_sha256": {
|
||||
"target/qualification/storage/ci.log": "36adf2b1407ada9101d0b1b94011d870116964dd44655a0694221a4a541ae91d",
|
||||
"target/qualification/storage/diagnostics.log": "8b51fbfd18083b0b49831109c61e29687e799ce0d654711be74caad95f4c7762",
|
||||
"target/qualification/storage/domain-audit.json": "4a08f40ff6d73d5e1b3f405e3cb5556117fb3a6667c58a067e6db71274649189",
|
||||
"target/qualification/storage/layers.log": "6d2a15c2fd90b86050ccb9b92b2f74670fe73f0165ff7b2cef01fdc3afcf12b6",
|
||||
"target/qualification/storage/release.log": "1d9e946e90dfc3d2f3e64af0a1099437cdf85cf9a2ef149ab80189082ca4da25"
|
||||
},
|
||||
"limits": [
|
||||
"No new provider commit is claimed; consumers must select and qualify a revision containing the delivery.",
|
||||
"Consumer compiler/SDK migration is not executed by runtime qualification.",
|
||||
"Cost arithmetic overflow uses synthetic-width defense tests, not an admitted wide Registry.",
|
||||
"Malformed internal-state injection tests are distinct from admitted PBX conformance.",
|
||||
"Default ignored probes/packaged-installation smoke remain explicitly ignored; five debugger socket tests were separately executed.",
|
||||
"Clippy cleanup shares collection fixture imports and removes redundant Copy clones in identity tests without changing identity/hash contracts."
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user