Implement table.init and elem.drop from the bulk memory proposal
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
use crate::externals::Extern;
|
||||
use crate::module::Module;
|
||||
use crate::runtime::Store;
|
||||
use crate::runtime::{Config, Store};
|
||||
use crate::trap::Trap;
|
||||
use anyhow::{Error, Result};
|
||||
use wasmtime_jit::{CompiledModule, Resolver};
|
||||
use wasmtime_runtime::{Export, InstanceHandle, InstantiationError};
|
||||
use wasmtime_runtime::{Export, InstanceHandle, InstantiationError, LinkError};
|
||||
|
||||
struct SimpleResolver<'a> {
|
||||
imports: &'a [Extern],
|
||||
@@ -19,6 +19,7 @@ impl Resolver for SimpleResolver<'_> {
|
||||
}
|
||||
|
||||
fn instantiate(
|
||||
config: &Config,
|
||||
compiled_module: &CompiledModule,
|
||||
imports: &[Extern],
|
||||
) -> Result<InstanceHandle, Error> {
|
||||
@@ -29,6 +30,14 @@ fn instantiate(
|
||||
.map_err(|e| -> Error {
|
||||
match e {
|
||||
InstantiationError::StartTrap(trap) => Trap::from_jit(trap).into(),
|
||||
e @ InstantiationError::TableOutOfBounds(_) => {
|
||||
let msg = e.to_string();
|
||||
if config.validating_config.operator_config.enable_bulk_memory {
|
||||
Trap::new(msg).into()
|
||||
} else {
|
||||
InstantiationError::Link(LinkError(msg)).into()
|
||||
}
|
||||
}
|
||||
other => other.into(),
|
||||
}
|
||||
})?;
|
||||
@@ -105,7 +114,8 @@ impl Instance {
|
||||
/// [issue]: https://github.com/bytecodealliance/wasmtime/issues/727
|
||||
pub fn new(module: &Module, imports: &[Extern]) -> Result<Instance, Error> {
|
||||
let store = module.store();
|
||||
let instance_handle = instantiate(module.compiled_module(), imports)?;
|
||||
let config = store.engine().config();
|
||||
let instance_handle = instantiate(config, module.compiled_module(), imports)?;
|
||||
|
||||
let exports = {
|
||||
let mut exports = Vec::with_capacity(module.exports().len());
|
||||
|
||||
Reference in New Issue
Block a user