feat: expose precise observations for synchronous read-only calls

This commit is contained in:
2026-10-24 02:17:02 +08:00
parent ee68a0c54c
commit 1aecc7e952
2 changed files with 27 additions and 1 deletions
+15 -1
View File
@@ -59,9 +59,23 @@ impl Vm {
arguments: &[Value],
limits: ExecutionLimits,
) -> Result<(Value, Vec<ObjectRef>), VmError> {
let (value, reads) =
self.call_read_only_precise_with_limits(function, arguments, limits)?;
Ok((value, reads.objects))
}
/// Synchronous read-only call with precise observations as well as the
/// conservative object list. Result ownership and hard limits match call().
/// ReadSet and all identities/value snapshots inside it are borrowed only.
pub fn call_read_only_precise_with_limits(
&mut self,
function: ObjectRef,
arguments: &[Value],
limits: ExecutionLimits,
) -> Result<(Value, crate::ReadSet), VmError> {
let scope = self.objects.begin_read_only();
let result = self.call_with_limits(function, arguments, limits);
let reads = self.objects.end_read_only(scope)?;
let reads = self.objects.end_read_only_precise(scope)?;
result.map(|value| (value, reads))
}