Skip to content

Commit 24620d9

Browse files
authored
Enable warnings if pooling-allocator is disabled (bytecodealliance#10142)
* Enable warnings if `pooling-allocator` is disabled Continuation of work in bytecodealliance#10131 * Fix windows build
1 parent a7d76ec commit 24620d9

File tree

8 files changed

+27
-3
lines changed

8 files changed

+27
-3
lines changed

crates/wasmtime/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,6 @@
290290
not(feature = "gc-drc"),
291291
not(feature = "gc-null"),
292292
not(feature = "cranelift"),
293-
not(feature = "pooling-allocator"),
294293
not(feature = "runtime"),
295294
not(feature = "std"),
296295
),

crates/wasmtime/src/runtime/vm.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ impl ModuleRuntimeInfo {
350350
/// A unique ID for this particular module. This can be used to
351351
/// allow for fastpaths to optimize a "re-instantiate the same
352352
/// module again" case.
353+
#[cfg(feature = "pooling-allocator")]
353354
fn unique_id(&self) -> Option<CompiledModuleId> {
354355
match self {
355356
ModuleRuntimeInfo::Module(m) => Some(m.id()),

crates/wasmtime/src/runtime/vm/instance/allocator.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ pub struct InstanceAllocationRequest<'a> {
7474

7575
/// Request that the instance's memories be protected by a specific
7676
/// protection key.
77+
#[cfg_attr(
78+
not(feature = "pooling-allocator"),
79+
expect(
80+
dead_code,
81+
reason = "easier to keep this field than remove it, not perf-critical to remove"
82+
)
83+
)]
7784
pub pkey: Option<ProtectionKey>,
7885

7986
/// Tunable configuration options the engine is using.
@@ -126,6 +133,7 @@ impl Default for MemoryAllocationIndex {
126133

127134
impl MemoryAllocationIndex {
128135
/// Get the underlying index of this `MemoryAllocationIndex`.
136+
#[cfg(feature = "pooling-allocator")]
129137
pub fn index(&self) -> usize {
130138
self.0 as usize
131139
}
@@ -145,6 +153,7 @@ impl Default for TableAllocationIndex {
145153

146154
impl TableAllocationIndex {
147155
/// Get the underlying index of this `TableAllocationIndex`.
156+
#[cfg(feature = "pooling-allocator")]
148157
pub fn index(&self) -> usize {
149158
self.0 as usize
150159
}

crates/wasmtime/src/runtime/vm/memory.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ pub use self::mmap::MmapMemory;
9494
mod malloc;
9595
pub use self::malloc::MallocMemory;
9696

97+
#[cfg(feature = "pooling-allocator")]
9798
mod static_;
99+
#[cfg(feature = "pooling-allocator")]
98100
use self::static_::StaticMemory;
99101

100102
#[cfg(feature = "threads")]
@@ -244,6 +246,7 @@ impl Memory {
244246
}
245247

246248
/// Create a new static (immovable) memory instance for the specified plan.
249+
#[cfg(feature = "pooling-allocator")]
247250
pub fn new_static(
248251
ty: &wasmtime_environ::Memory,
249252
tunables: &Tunables,
@@ -732,6 +735,7 @@ impl LocalMemory {
732735
base..end
733736
}
734737

738+
#[cfg(feature = "pooling-allocator")]
735739
pub fn unwrap_static_image(self) -> MemoryImageSlot {
736740
self.memory_image.unwrap()
737741
}

crates/wasmtime/src/runtime/vm/mpk/disabled.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@
33
44
#![allow(missing_docs)]
55

6+
#[cfg(feature = "pooling-allocator")]
67
use crate::prelude::*;
78

9+
#[cfg(feature = "pooling-allocator")]
810
pub fn is_supported() -> bool {
911
false
1012
}
13+
14+
#[cfg(feature = "pooling-allocator")]
1115
pub fn keys(_: usize) -> &'static [ProtectionKey] {
1216
&[]
1317
}
18+
1419
pub fn allow(_: ProtectionMask) {}
1520

1621
pub fn current_mask() -> ProtectionMask {
@@ -20,9 +25,11 @@ pub fn current_mask() -> ProtectionMask {
2025
#[derive(Clone, Copy, Debug)]
2126
pub enum ProtectionKey {}
2227
impl ProtectionKey {
28+
#[cfg(feature = "pooling-allocator")]
2329
pub fn protect(&self, _: &mut [u8]) -> Result<()> {
2430
match *self {}
2531
}
32+
#[cfg(feature = "pooling-allocator")]
2633
pub fn as_stripe(&self) -> usize {
2734
match *self {}
2835
}
@@ -34,9 +41,11 @@ impl ProtectionMask {
3441
pub fn all() -> Self {
3542
Self
3643
}
44+
#[cfg(feature = "pooling-allocator")]
3745
pub fn zero() -> Self {
3846
Self
3947
}
48+
#[cfg(feature = "pooling-allocator")]
4049
pub fn or(self, _: ProtectionKey) -> Self {
4150
Self
4251
}

crates/wasmtime/src/runtime/vm/mpk/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ cfg_if::cfg_if! {
3939
mod enabled;
4040
mod pkru;
4141
mod sys;
42-
pub use enabled::{allow, current_mask, is_supported, keys, ProtectionKey, ProtectionMask};
42+
pub use enabled::*;
4343
} else {
4444
mod disabled;
45-
pub use disabled::{allow, current_mask, is_supported, keys, ProtectionKey, ProtectionMask};
45+
pub use disabled::*;
4646
}
4747
}

crates/wasmtime/src/runtime/vm/sys/unix/vm.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ pub unsafe fn commit_pages(_addr: *mut u8, _len: usize) -> io::Result<()> {
3434
Ok(())
3535
}
3636

37+
#[cfg(feature = "pooling-allocator")]
3738
pub unsafe fn decommit_pages(addr: *mut u8, len: usize) -> io::Result<()> {
3839
if len == 0 {
3940
return Ok(());

crates/wasmtime/src/runtime/vm/sys/windows/vm.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ pub unsafe fn commit_pages(addr: *mut u8, len: usize) -> io::Result<()> {
3737
expose_existing_mapping(addr, len)
3838
}
3939

40+
#[cfg(feature = "pooling-allocator")]
4041
pub unsafe fn decommit_pages(addr: *mut u8, len: usize) -> io::Result<()> {
4142
erase_existing_mapping(addr, len)
4243
}

0 commit comments

Comments
 (0)