feat: protect existing objects during read-only calls and track reads
This commit is contained in:
@@ -48,6 +48,21 @@ impl Vm {
|
||||
self.call_with_limits(function, arguments, ExecutionLimits::default())
|
||||
}
|
||||
|
||||
/// Allow result allocation while rejecting mutations of objects that were
|
||||
/// already alive on entry. All reads share the call's normal frame budget.
|
||||
/// Returned read handles are borrowed dependency identities, not owned roots.
|
||||
pub fn call_read_only_with_limits(
|
||||
&mut self,
|
||||
function: ObjectRef,
|
||||
arguments: &[Value],
|
||||
limits: ExecutionLimits,
|
||||
) -> Result<(Value, Vec<ObjectRef>), 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)?;
|
||||
result.map(|value| (value, reads))
|
||||
}
|
||||
|
||||
pub fn call_with_limits(
|
||||
&mut self,
|
||||
function: ObjectRef,
|
||||
|
||||
Reference in New Issue
Block a user