Code review feedback.
* Add assert to `StackPool::deallocate` to ensure the fiber stack given to it comes from the pool. * Remove outdated comment about windows and stacks as the allocator now returns fiber stacks. * Remove conditional compilation around `stack_size` in the allocators as it was just clutter.
This commit is contained in:
@@ -1329,11 +1329,16 @@ impl Config {
|
||||
}
|
||||
|
||||
pub(crate) fn build_allocator(&self) -> Result<Box<dyn InstanceAllocator>> {
|
||||
#[cfg(feature = "async")]
|
||||
let stack_size = self.async_stack_size;
|
||||
|
||||
#[cfg(not(feature = "async"))]
|
||||
let stack_size = 0;
|
||||
|
||||
match self.allocation_strategy {
|
||||
InstanceAllocationStrategy::OnDemand => Ok(Box::new(OnDemandInstanceAllocator::new(
|
||||
self.mem_creator.clone(),
|
||||
#[cfg(feature = "async")]
|
||||
self.async_stack_size,
|
||||
stack_size,
|
||||
))),
|
||||
InstanceAllocationStrategy::Pooling {
|
||||
strategy,
|
||||
@@ -1343,8 +1348,7 @@ impl Config {
|
||||
strategy.into(),
|
||||
module_limits.into(),
|
||||
instance_limits.into(),
|
||||
#[cfg(feature = "async")]
|
||||
self.async_stack_size,
|
||||
stack_size,
|
||||
)?)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,23 +66,20 @@ fn create_handle(
|
||||
// Use the on-demand allocator when creating handles associated with host objects
|
||||
// The configured instance allocator should only be used when creating module instances
|
||||
// as we don't want host objects to count towards instance limits.
|
||||
let handle = OnDemandInstanceAllocator::new(
|
||||
config.mem_creator.clone(),
|
||||
#[cfg(feature = "async")]
|
||||
config.async_stack_size,
|
||||
)
|
||||
.allocate(InstanceAllocationRequest {
|
||||
module: Arc::new(module),
|
||||
finished_functions: &finished_functions,
|
||||
imports,
|
||||
lookup_shared_signature: &|_| shared_signature_id.unwrap(),
|
||||
host_state,
|
||||
interrupts: store.interrupts(),
|
||||
externref_activations_table: store.externref_activations_table()
|
||||
as *const VMExternRefActivationsTable
|
||||
as *mut _,
|
||||
stack_map_registry: store.stack_map_registry() as *const StackMapRegistry as *mut _,
|
||||
})?;
|
||||
let handle = OnDemandInstanceAllocator::new(config.mem_creator.clone(), 0).allocate(
|
||||
InstanceAllocationRequest {
|
||||
module: Arc::new(module),
|
||||
finished_functions: &finished_functions,
|
||||
imports,
|
||||
lookup_shared_signature: &|_| shared_signature_id.unwrap(),
|
||||
host_state,
|
||||
interrupts: store.interrupts(),
|
||||
externref_activations_table: store.externref_activations_table()
|
||||
as *const VMExternRefActivationsTable
|
||||
as *mut _,
|
||||
stack_map_registry: store.stack_map_registry() as *const StackMapRegistry as *mut _,
|
||||
},
|
||||
)?;
|
||||
|
||||
Ok(store.add_instance(handle, true))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user