diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
commit | 8dd16259287f58f9273002717ec4d27e97127719 (patch) | |
tree | 3863e62a53829a84037444beab3abd4ed9dfc7d0 /third_party/rust/wasm-encoder/src/core/memories.rs | |
parent | Releasing progress-linux version 126.0.1-1~progress7.99u1. (diff) | |
download | firefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz firefox-8dd16259287f58f9273002717ec4d27e97127719.zip |
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/wasm-encoder/src/core/memories.rs')
-rw-r--r-- | third_party/rust/wasm-encoder/src/core/memories.rs | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/third_party/rust/wasm-encoder/src/core/memories.rs b/third_party/rust/wasm-encoder/src/core/memories.rs index 892545eb98..d64ef01210 100644 --- a/third_party/rust/wasm-encoder/src/core/memories.rs +++ b/third_party/rust/wasm-encoder/src/core/memories.rs @@ -15,6 +15,7 @@ use crate::{encode_section, Encode, Section, SectionId}; /// maximum: None, /// memory64: false, /// shared: false, +/// page_size_log2: None, /// }); /// /// let mut module = Module::new(); @@ -75,26 +76,41 @@ pub struct MemoryType { pub memory64: bool, /// Whether or not this memory is shared. pub shared: bool, + /// The log base 2 of a custom page size for this memory. + /// + /// The default page size for Wasm memories is 64KiB, i.e. 2<sup>16</sup> or + /// `65536`. + /// + /// After the introduction of [the custom-page-sizes + /// proposal](https://github.com/WebAssembly/custom-page-sizes), Wasm can + /// customize the page size. It must be a power of two that is less than or + /// equal to 64KiB. Attempting to encode an invalid page size may panic. + pub page_size_log2: Option<u32>, } impl Encode for MemoryType { fn encode(&self, sink: &mut Vec<u8>) { let mut flags = 0; if self.maximum.is_some() { - flags |= 0b001; + flags |= 0b0001; } if self.shared { - flags |= 0b010; + flags |= 0b0010; } if self.memory64 { - flags |= 0b100; + flags |= 0b0100; + } + if self.page_size_log2.is_some() { + flags |= 0b1000; } - sink.push(flags); self.minimum.encode(sink); if let Some(max) = self.maximum { max.encode(sink); } + if let Some(p) = self.page_size_log2 { + p.encode(sink); + } } } @@ -106,6 +122,7 @@ impl From<wasmparser::MemoryType> for MemoryType { maximum: memory_ty.maximum, memory64: memory_ty.memory64, shared: memory_ty.shared, + page_size_log2: memory_ty.page_size_log2, } } } |