Don't create Static memories larger than the Tunables' static bound size.
This commit is contained in:
@@ -54,23 +54,24 @@ impl MemoryStyle {
|
|||||||
/// Decide on an implementation style for the given `Memory`.
|
/// Decide on an implementation style for the given `Memory`.
|
||||||
pub fn for_memory(memory: Memory, tunables: &Tunables) -> (Self, u64) {
|
pub fn for_memory(memory: Memory, tunables: &Tunables) -> (Self, u64) {
|
||||||
if let Some(maximum) = memory.maximum {
|
if let Some(maximum) = memory.maximum {
|
||||||
// A heap with a declared maximum is prepared to be used with
|
if maximum <= tunables.static_memory_bound {
|
||||||
// threads and therefore be immovable, so make it static.
|
// A heap with a declared maximum can be immovable, so make
|
||||||
(
|
// it static.
|
||||||
|
return (
|
||||||
MemoryStyle::Static {
|
MemoryStyle::Static {
|
||||||
bound: cmp::max(tunables.static_memory_bound, maximum),
|
bound: tunables.static_memory_bound,
|
||||||
},
|
},
|
||||||
tunables.static_memory_offset_guard_size,
|
tunables.static_memory_offset_guard_size,
|
||||||
)
|
);
|
||||||
} else {
|
}
|
||||||
// A heap without a declared maximum is likely to want to be small
|
}
|
||||||
// at least some of the time, so make it dynamic.
|
|
||||||
|
// Otherwise, make it dynamic.
|
||||||
(
|
(
|
||||||
MemoryStyle::Dynamic,
|
MemoryStyle::Dynamic,
|
||||||
tunables.dynamic_memory_offset_guard_size,
|
tunables.dynamic_memory_offset_guard_size,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A WebAssembly linear memory description along with our chosen style for
|
/// A WebAssembly linear memory description along with our chosen style for
|
||||||
|
|||||||
Reference in New Issue
Block a user