implement PLN-0034 internal allocation evidence

This commit is contained in:
2026-04-20 08:50:01 +01:00
parent 09821cf9cc
commit 811af09ea7
13 changed files with 125 additions and 8 deletions
@@ -1,8 +1,11 @@
use serde::{Deserialize, Serialize};
use std::cmp::Ordering;
use std::fmt::Write;
use std::sync::atomic::{AtomicU64, Ordering as AtomicOrdering};
use std::sync::Arc;
static STRING_MATERIALIZATION_COUNT: AtomicU64 = AtomicU64::new(0);
/// Opaque handle that references an object stored in the VM heap.
///
/// This is an index-based handle. It does not imply ownership and carries
@@ -76,6 +79,14 @@ impl PartialOrd for Value {
}
impl Value {
pub fn string<S>(value: S) -> Self
where
S: Into<Arc<str>>,
{
STRING_MATERIALIZATION_COUNT.fetch_add(1, AtomicOrdering::Relaxed);
Value::String(value.into())
}
pub fn as_float(&self) -> Option<f64> {
match self {
Value::Int32(i) => Some(*i as f64),
@@ -137,6 +148,10 @@ impl Value {
}
}
pub fn string_materialization_count() -> u64 {
STRING_MATERIALIZATION_COUNT.load(AtomicOrdering::Relaxed)
}
#[cfg(test)]
mod tests {
use super::*;