Allow access to memory_index and grow on Instance (#105)
* Changed `memory_grow` and `memory_index` in `Instance` struct to be `pub(crate)` and added the equivalent proxy methods to the `InstanceHandle` struct.
This commit is contained in:
committed by
Dan Gohman
parent
a99107203e
commit
3351befb3b
@@ -520,8 +520,7 @@ impl Instance {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Return the memory index for the given `VMMemoryDefinition`.
|
/// Return the memory index for the given `VMMemoryDefinition`.
|
||||||
/// FIXME: Should this be pub(crate)?
|
pub(crate) fn memory_index(&self, memory: &VMMemoryDefinition) -> DefinedMemoryIndex {
|
||||||
pub fn memory_index(&self, memory: &VMMemoryDefinition) -> DefinedMemoryIndex {
|
|
||||||
let offsets = &self.offsets;
|
let offsets = &self.offsets;
|
||||||
let begin = unsafe {
|
let begin = unsafe {
|
||||||
(&self.vmctx as *const VMContext as *const u8)
|
(&self.vmctx as *const VMContext as *const u8)
|
||||||
@@ -548,8 +547,11 @@ impl Instance {
|
|||||||
///
|
///
|
||||||
/// Returns `None` if memory can't be grown by the specified amount
|
/// Returns `None` if memory can't be grown by the specified amount
|
||||||
/// of pages.
|
/// of pages.
|
||||||
/// FIXME: Should this be pub(crate)?
|
pub(crate) fn memory_grow(
|
||||||
pub fn memory_grow(&mut self, memory_index: DefinedMemoryIndex, delta: u32) -> Option<u32> {
|
&mut self,
|
||||||
|
memory_index: DefinedMemoryIndex,
|
||||||
|
delta: u32,
|
||||||
|
) -> Option<u32> {
|
||||||
let result = self
|
let result = self
|
||||||
.memories
|
.memories
|
||||||
.get_mut(memory_index)
|
.get_mut(memory_index)
|
||||||
@@ -832,6 +834,19 @@ impl InstanceHandle {
|
|||||||
pub fn host_state(&mut self) -> &mut Any {
|
pub fn host_state(&mut self) -> &mut Any {
|
||||||
self.instance_mut().host_state()
|
self.instance_mut().host_state()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return the memory index for the given `VMMemoryDefinition` in this instance.
|
||||||
|
pub fn memory_index(&self, memory: &VMMemoryDefinition) -> DefinedMemoryIndex {
|
||||||
|
self.instance().memory_index(memory)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Grow memory in this instance by the specified amount of pages.
|
||||||
|
///
|
||||||
|
/// Returns `None` if memory can't be grown by the specified amount
|
||||||
|
/// of pages.
|
||||||
|
pub fn memory_grow(&mut self, memory_index: DefinedMemoryIndex, delta: u32) -> Option<u32> {
|
||||||
|
self.instance_mut().memory_grow(memory_index, delta)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl InstanceHandle {
|
impl InstanceHandle {
|
||||||
|
|||||||
Reference in New Issue
Block a user