add table_grow_failed
This commit is contained in:
@@ -90,24 +90,28 @@ pub unsafe trait Store {
|
||||
&mut self,
|
||||
) -> (&mut VMExternRefActivationsTable, &dyn ModuleInfoLookup);
|
||||
|
||||
/// Callback invoked to allow the store's resource limiter to reject a memory grow operation.
|
||||
/// Callback invoked to allow the store's resource limiter to reject a
|
||||
/// memory grow operation.
|
||||
fn memory_growing(
|
||||
&mut self,
|
||||
current: usize,
|
||||
desired: usize,
|
||||
maximum: Option<usize>,
|
||||
) -> Result<bool, Error>;
|
||||
/// Callback invoked to notify the store's resource limiter that a memory grow operation has
|
||||
/// failed.
|
||||
/// Callback invoked to notify the store's resource limiter that a memory
|
||||
/// grow operation has failed.
|
||||
fn memory_grow_failed(&mut self, error: &Error);
|
||||
/// Callback invoked to allow the store's resource limiter to reject a table grow operation.
|
||||
/// Callback invoked to allow the store's resource limiter to reject a
|
||||
/// table grow operation.
|
||||
fn table_growing(
|
||||
&mut self,
|
||||
current: u32,
|
||||
desired: u32,
|
||||
maximum: Option<u32>,
|
||||
) -> Result<bool, Error>;
|
||||
|
||||
/// Callback invoked to notify the store's resource limiter that a table
|
||||
/// grow operation has failed.
|
||||
fn table_grow_failed(&mut self, error: &Error);
|
||||
/// Callback invoked whenever fuel runs out by a wasm instance. If an error
|
||||
/// is returned that's raised as a trap. Otherwise wasm execution will
|
||||
/// continue as normal.
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
|
||||
use crate::vmcontext::{VMCallerCheckedAnyfunc, VMTableDefinition};
|
||||
use crate::{Store, Trap, VMExternRef};
|
||||
use anyhow::Error;
|
||||
use anyhow::{bail, Result};
|
||||
use anyhow::{bail, format_err, Error, Result};
|
||||
use std::convert::{TryFrom, TryInto};
|
||||
use std::ops::Range;
|
||||
use std::ptr;
|
||||
@@ -302,6 +301,7 @@ impl Table {
|
||||
|
||||
if let Some(max) = self.maximum() {
|
||||
if new_size > max {
|
||||
store.table_grow_failed(&format_err!("Table maximum size exceeded"));
|
||||
return Ok(None);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user