Add the internals field and necessary structures for metering.

This commit is contained in:
losfair
2019-05-17 01:10:21 +08:00
parent 4e5ac24517
commit 6aa87a0bbf
6 changed files with 46 additions and 4 deletions

View File

@ -15,7 +15,20 @@ use crate::{
},
vm,
};
use std::slice;
use std::{
slice,
fmt::Debug,
};
pub const INTERNALS_SIZE: usize = 256;
pub(crate) struct Internals(pub(crate) [u64; INTERNALS_SIZE]);
impl Debug for Internals {
fn fmt(&self, formatter: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
write!(formatter, "Internals({:?})", &self.0[..])
}
}
/// The `LocalBacking` "owns" the memory used by all the local resources of an Instance.
/// That is, local memories, tables, and globals (as well as some additional
@ -40,6 +53,8 @@ pub struct LocalBacking {
/// as well) are subject to change.
pub(crate) dynamic_sigindices: BoxedMap<SigIndex, vm::SigId>,
pub(crate) local_functions: BoxedMap<LocalFuncIndex, *const vm::Func>,
pub(crate) internals: Internals,
}
impl LocalBacking {
@ -66,6 +81,8 @@ impl LocalBacking {
dynamic_sigindices,
local_functions,
internals: Internals([0; 256]),
}
}