summaryrefslogtreecommitdiffstats
path: root/third_party/rust/wasm-encoder
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--third_party/rust/wasm-encoder/.cargo-checksum.json2
-rw-r--r--third_party/rust/wasm-encoder/Cargo.toml4
-rw-r--r--third_party/rust/wasm-encoder/src/component/types.rs16
-rw-r--r--third_party/rust/wasm-encoder/src/core/code.rs60
-rw-r--r--third_party/rust/wasm-encoder/src/core/data.rs1
-rw-r--r--third_party/rust/wasm-encoder/src/core/globals.rs13
-rw-r--r--third_party/rust/wasm-encoder/src/core/imports.rs1
-rw-r--r--third_party/rust/wasm-encoder/src/core/memories.rs25
-rw-r--r--third_party/rust/wasm-encoder/src/core/types.rs15
9 files changed, 115 insertions, 22 deletions
diff --git a/third_party/rust/wasm-encoder/.cargo-checksum.json b/third_party/rust/wasm-encoder/.cargo-checksum.json
index b9591f5309..ca7d8944ba 100644
--- a/third_party/rust/wasm-encoder/.cargo-checksum.json
+++ b/third_party/rust/wasm-encoder/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"Cargo.toml":"e0d334beb383d7a06a870e93a43cee25fb37c9c416b01e056a8c5589e9b5ae0c","LICENSE":"268872b9816f90fd8e85db5a28d33f8150ebb8dd016653fb39ef1f94f2686bc5","README.md":"ac016c4843a7e1a5737255b39418732783592222dc518020730edf9dd46a1c13","src/component.rs":"700351503077106eadf612f46079418e0b437ed0a6179dc16979768205b2ecbf","src/component/aliases.rs":"be5215154b872ed5664f3bfe2aa1391f36a2575aa9d53971ab61868a1c446e9d","src/component/builder.rs":"ea35c74cb0369181e9c0ce9729ff175d25f05bd63b48dcbbf703a53dfc113c7c","src/component/canonicals.rs":"a4f9c7a2b8ac3783d7337a5579cf71df2f33b315b354965980bd2c483d3aa141","src/component/components.rs":"07b8cae3a400e1955cc39d142569910b4fef2136021053d0ddbd6404d810aa52","src/component/exports.rs":"1af747401f153ccd5c5adfcab55dc4d75e241536cbbdc62624c3a07dd7620056","src/component/imports.rs":"a6cd7f914de7706a1a93a40fb8d0031b4b140786a347da636c70d093401079cd","src/component/instances.rs":"a76c5e7ba0ef73ae4bff5569d177198b7f3a9959dbe9f5c1b4bae7d1a9c839b1","src/component/modules.rs":"9e80907e72360fae4d8057b6b0e7a6b58edd7ba6aba6e63ba17346518e169617","src/component/names.rs":"ca2f46a6dbc872a9cdb297d58c958e16acaf8893318bfdba30e468841107d886","src/component/start.rs":"4055553d5c99c99abbc01bb8abb928ecb8b909d148b647a9977fbd444bb464a3","src/component/types.rs":"f44501e9b356e5588767323f1844e768221e00843a33354ff2597a76f32def46","src/core.rs":"a00656f82a623656c59a2d7230b40a5849a5083e117bc57061746f6e3022c7bb","src/core/code.rs":"23f96e90b57b1334b304bc66c9c39518d9d8baee1e2a7f5e3045f817019c62da","src/core/custom.rs":"4b9f07b701dc7b6990d92fb43016c28fb971411670bb6a48553b92b1c35eb9a3","src/core/data.rs":"c9d59eab2ab811bd950da52e6766c7df2367986c7a3a0d94d7aeb47d86f203ac","src/core/dump.rs":"8feaa532e3851186277ec1f4906e7fdc82c6399b211b8c928b16e293db1205b0","src/core/elements.rs":"2df1ad85f683b5cf3ce43c8cfef3f08f74a17cec9171537e3f24205dc067b4f7","src/core/exports.rs":"9e1eb3db0e0f73e00b66d82431257923feec8c052ac8b98717c8f36ffcc03537","src/core/functions.rs":"c18b9872ac0c21048a3ce32e5e44e8e702f97a57fa1b3a07bdd98c7f6c820f09","src/core/globals.rs":"0ed5f033489318d91e974090e8bf240720baa1ba621d0b5e0956dbd68e2165c1","src/core/imports.rs":"b4b096a6b1f449c4429efff605ca597549ea31873e18a9e6e55c616b4edc76db","src/core/linking.rs":"2f1053d9c2671e91a2b6e253dd38921bfc5f1b8a1a047b10c843033fe0f492de","src/core/memories.rs":"42e11ff5e8b2634bcd87810aef3fb9057c5d0b23c68ca9862a1e99aab5ecad72","src/core/names.rs":"2624a58835b27b17260fdbd20704856dce04e1826eb2b3b6196f8f1ffcf560ef","src/core/producers.rs":"f4916c1cf61e26170cd10fe350de7dad18005461c362909b9557c16c507517bc","src/core/start.rs":"a01d4a91bcd93048977ccafc6af160357297450395bf598351f5a3e6d322e0de","src/core/tables.rs":"c8286f5624ff429d42879932dedf45975513abfd98071a4084271860225af078","src/core/tags.rs":"66251072d5108dfde8177039cef95deac21606a361cddb04f37c08b8a8969db4","src/core/types.rs":"eb61f4f53a6c283ff6788c9724ffb728d2f525a62230bd13494a797ee23fbfef","src/lib.rs":"e61325ab8de1b4c404f4ee7665eef404fca2d23322a9c8f94efec8426edc166b","src/raw.rs":"a6a72cfe8f88ea6476eccee4acf362030ba2d2e5710215bc4f13cde7de6d71ae"},"package":"b9c7d2731df60006819b013f64ccc2019691deccf6e11a1804bc850cd6748f1a"} \ No newline at end of file
+{"files":{"Cargo.toml":"dd8325b9b609ebb74c8fb1472fb2147bae3053bb7b481cf5375e4da172aa05c7","LICENSE":"268872b9816f90fd8e85db5a28d33f8150ebb8dd016653fb39ef1f94f2686bc5","README.md":"ac016c4843a7e1a5737255b39418732783592222dc518020730edf9dd46a1c13","src/component.rs":"700351503077106eadf612f46079418e0b437ed0a6179dc16979768205b2ecbf","src/component/aliases.rs":"be5215154b872ed5664f3bfe2aa1391f36a2575aa9d53971ab61868a1c446e9d","src/component/builder.rs":"ea35c74cb0369181e9c0ce9729ff175d25f05bd63b48dcbbf703a53dfc113c7c","src/component/canonicals.rs":"a4f9c7a2b8ac3783d7337a5579cf71df2f33b315b354965980bd2c483d3aa141","src/component/components.rs":"07b8cae3a400e1955cc39d142569910b4fef2136021053d0ddbd6404d810aa52","src/component/exports.rs":"1af747401f153ccd5c5adfcab55dc4d75e241536cbbdc62624c3a07dd7620056","src/component/imports.rs":"a6cd7f914de7706a1a93a40fb8d0031b4b140786a347da636c70d093401079cd","src/component/instances.rs":"a76c5e7ba0ef73ae4bff5569d177198b7f3a9959dbe9f5c1b4bae7d1a9c839b1","src/component/modules.rs":"9e80907e72360fae4d8057b6b0e7a6b58edd7ba6aba6e63ba17346518e169617","src/component/names.rs":"ca2f46a6dbc872a9cdb297d58c958e16acaf8893318bfdba30e468841107d886","src/component/start.rs":"4055553d5c99c99abbc01bb8abb928ecb8b909d148b647a9977fbd444bb464a3","src/component/types.rs":"069f0ee5fc4001c26a0db4bab32c8db268af68a11bf50a55f07c9365f2317e5f","src/core.rs":"a00656f82a623656c59a2d7230b40a5849a5083e117bc57061746f6e3022c7bb","src/core/code.rs":"49d8b8414f62d2851e7dc1bb5965037a12d2ef2a02bec8f96349779b352e7d9e","src/core/custom.rs":"4b9f07b701dc7b6990d92fb43016c28fb971411670bb6a48553b92b1c35eb9a3","src/core/data.rs":"f209e23710ab75600dd200af176e23940c88fac8a6ca31c3df67b97a911f2c55","src/core/dump.rs":"8feaa532e3851186277ec1f4906e7fdc82c6399b211b8c928b16e293db1205b0","src/core/elements.rs":"2df1ad85f683b5cf3ce43c8cfef3f08f74a17cec9171537e3f24205dc067b4f7","src/core/exports.rs":"9e1eb3db0e0f73e00b66d82431257923feec8c052ac8b98717c8f36ffcc03537","src/core/functions.rs":"c18b9872ac0c21048a3ce32e5e44e8e702f97a57fa1b3a07bdd98c7f6c820f09","src/core/globals.rs":"15408072945d2d96d16c1020ec1a029a348fbe22da26eb35d02d695527f675ba","src/core/imports.rs":"af26ca7dd09cb2b8ecfbe347378252f4d12b92e23818e23d72512591ceee671c","src/core/linking.rs":"2f1053d9c2671e91a2b6e253dd38921bfc5f1b8a1a047b10c843033fe0f492de","src/core/memories.rs":"9e437e878e61933bc731ef20994aefedb0ac4ac6b9464e36b38a8cdc26019dd8","src/core/names.rs":"2624a58835b27b17260fdbd20704856dce04e1826eb2b3b6196f8f1ffcf560ef","src/core/producers.rs":"f4916c1cf61e26170cd10fe350de7dad18005461c362909b9557c16c507517bc","src/core/start.rs":"a01d4a91bcd93048977ccafc6af160357297450395bf598351f5a3e6d322e0de","src/core/tables.rs":"c8286f5624ff429d42879932dedf45975513abfd98071a4084271860225af078","src/core/tags.rs":"66251072d5108dfde8177039cef95deac21606a361cddb04f37c08b8a8969db4","src/core/types.rs":"1f3f5b2bc09ea6f4a569ddfb7e343bf3fb450d8508b3bf338915dad98aad9582","src/lib.rs":"e61325ab8de1b4c404f4ee7665eef404fca2d23322a9c8f94efec8426edc166b","src/raw.rs":"a6a72cfe8f88ea6476eccee4acf362030ba2d2e5710215bc4f13cde7de6d71ae"},"package":"90e95b3563d164f33c1cfb0a7efbd5940c37710019be10cd09f800fdec8b0e5c"} \ No newline at end of file
diff --git a/third_party/rust/wasm-encoder/Cargo.toml b/third_party/rust/wasm-encoder/Cargo.toml
index aa4ce5bc7c..9fd28b544d 100644
--- a/third_party/rust/wasm-encoder/Cargo.toml
+++ b/third_party/rust/wasm-encoder/Cargo.toml
@@ -12,7 +12,7 @@
[package]
edition = "2021"
name = "wasm-encoder"
-version = "0.201.0"
+version = "0.205.0"
authors = ["Nick Fitzgerald <fitzgen@gmail.com>"]
description = """
A low-level WebAssembly encoder.
@@ -27,7 +27,7 @@ repository = "https://github.com/bytecodealliance/wasm-tools/tree/main/crates/wa
version = "0.2.4"
[dependencies.wasmparser]
-version = "0.201.0"
+version = "0.205.0"
optional = true
[dev-dependencies.anyhow]
diff --git a/third_party/rust/wasm-encoder/src/component/types.rs b/third_party/rust/wasm-encoder/src/component/types.rs
index 537e8c5a00..72e0034b6b 100644
--- a/third_party/rust/wasm-encoder/src/component/types.rs
+++ b/third_party/rust/wasm-encoder/src/component/types.rs
@@ -497,10 +497,10 @@ pub enum PrimitiveValType {
S64,
/// The type is an unsigned 64-bit integer.
U64,
- /// The type is a 32-bit floating point number.
- Float32,
- /// The type is a 64-bit floating point number.
- Float64,
+ /// The type is a 32-bit floating point number with only one NaN.
+ F32,
+ /// The type is a 64-bit floating point number with only one NaN.
+ F64,
/// The type is a Unicode character.
Char,
/// The type is a string.
@@ -519,8 +519,8 @@ impl Encode for PrimitiveValType {
Self::U32 => 0x79,
Self::S64 => 0x78,
Self::U64 => 0x77,
- Self::Float32 => 0x76,
- Self::Float64 => 0x75,
+ Self::F32 => 0x76,
+ Self::F64 => 0x75,
Self::Char => 0x74,
Self::String => 0x73,
});
@@ -540,8 +540,8 @@ impl From<wasmparser::PrimitiveValType> for PrimitiveValType {
wasmparser::PrimitiveValType::U32 => PrimitiveValType::U32,
wasmparser::PrimitiveValType::S64 => PrimitiveValType::S64,
wasmparser::PrimitiveValType::U64 => PrimitiveValType::U64,
- wasmparser::PrimitiveValType::Float32 => PrimitiveValType::Float32,
- wasmparser::PrimitiveValType::Float64 => PrimitiveValType::Float64,
+ wasmparser::PrimitiveValType::F32 => PrimitiveValType::F32,
+ wasmparser::PrimitiveValType::F64 => PrimitiveValType::F64,
wasmparser::PrimitiveValType::Char => PrimitiveValType::Char,
wasmparser::PrimitiveValType::String => PrimitiveValType::String,
}
diff --git a/third_party/rust/wasm-encoder/src/core/code.rs b/third_party/rust/wasm-encoder/src/core/code.rs
index 76bfd7afde..4b04b0b72b 100644
--- a/third_party/rust/wasm-encoder/src/core/code.rs
+++ b/third_party/rust/wasm-encoder/src/core/code.rs
@@ -274,6 +274,34 @@ impl Encode for MemArg {
}
}
+/// The memory ordering for atomic instructions.
+///
+/// For an in-depth explanation of memory orderings, see the C++ documentation
+/// for [`memory_order`] or the Rust documentation for [`atomic::Ordering`].
+///
+/// [`memory_order`]: https://en.cppreference.com/w/cpp/atomic/memory_order
+/// [`atomic::Ordering`]: https://doc.rust-lang.org/std/sync/atomic/enum.Ordering.html
+#[derive(Clone, Copy, Debug)]
+pub enum Ordering {
+ /// For a load, it acquires; this orders all operations before the last
+ /// "releasing" store. For a store, it releases; this orders all operations
+ /// before it at the next "acquiring" load.
+ AcqRel,
+ /// Like `AcqRel` but all threads see all sequentially consistent operations
+ /// in the same order.
+ SeqCst,
+}
+
+impl Encode for Ordering {
+ fn encode(&self, sink: &mut Vec<u8>) {
+ let flag: u8 = match self {
+ Ordering::SeqCst => 0,
+ Ordering::AcqRel => 1,
+ };
+ sink.push(flag);
+ }
+}
+
/// Describe an unchecked SIMD lane index.
pub type Lane = u8;
@@ -980,6 +1008,16 @@ pub enum Instruction<'a> {
I64AtomicRmw8CmpxchgU(MemArg),
I64AtomicRmw16CmpxchgU(MemArg),
I64AtomicRmw32CmpxchgU(MemArg),
+
+ // More atomic instructions (the shared-everything-threads proposal)
+ GlobalAtomicGet {
+ ordering: Ordering,
+ global_index: u32,
+ },
+ GlobalAtomicSet {
+ ordering: Ordering,
+ global_index: u32,
+ },
}
impl Encode for Instruction<'_> {
@@ -2787,7 +2825,7 @@ impl Encode for Instruction<'_> {
0x113u32.encode(sink);
}
- // Atmoic instructions from the thread proposal
+ // Atomic instructions from the thread proposal
Instruction::MemoryAtomicNotify(memarg) => {
sink.push(0xFE);
sink.push(0x00);
@@ -3123,6 +3161,26 @@ impl Encode for Instruction<'_> {
sink.push(0x4E);
memarg.encode(sink);
}
+
+ // Atomic instructions from the shared-everything-threads proposal
+ Instruction::GlobalAtomicGet {
+ ordering,
+ global_index,
+ } => {
+ sink.push(0xFE);
+ sink.push(0x4F);
+ ordering.encode(sink);
+ global_index.encode(sink);
+ }
+ Instruction::GlobalAtomicSet {
+ ordering,
+ global_index,
+ } => {
+ sink.push(0xFE);
+ sink.push(0x50);
+ ordering.encode(sink);
+ global_index.encode(sink);
+ }
}
}
}
diff --git a/third_party/rust/wasm-encoder/src/core/data.rs b/third_party/rust/wasm-encoder/src/core/data.rs
index 6439b66e2e..6f408befe5 100644
--- a/third_party/rust/wasm-encoder/src/core/data.rs
+++ b/third_party/rust/wasm-encoder/src/core/data.rs
@@ -18,6 +18,7 @@ use crate::{encode_section, encoding_size, ConstExpr, Encode, Section, SectionId
/// maximum: None,
/// memory64: false,
/// shared: false,
+/// page_size_log2: None,
/// });
///
/// let mut data = DataSection::new();
diff --git a/third_party/rust/wasm-encoder/src/core/globals.rs b/third_party/rust/wasm-encoder/src/core/globals.rs
index 64fec982cd..291ca80472 100644
--- a/third_party/rust/wasm-encoder/src/core/globals.rs
+++ b/third_party/rust/wasm-encoder/src/core/globals.rs
@@ -14,6 +14,7 @@ use crate::{encode_section, ConstExpr, Encode, Section, SectionId, ValType};
/// GlobalType {
/// val_type: ValType::I32,
/// mutable: false,
+/// shared: false,
/// },
/// &ConstExpr::i32_const(42),
/// );
@@ -80,12 +81,21 @@ pub struct GlobalType {
pub val_type: ValType,
/// Whether this global is mutable or not.
pub mutable: bool,
+ /// Whether this global is shared or not.
+ pub shared: bool,
}
impl Encode for GlobalType {
fn encode(&self, sink: &mut Vec<u8>) {
self.val_type.encode(sink);
- sink.push(self.mutable as u8);
+ let mut flag = 0;
+ if self.mutable {
+ flag |= 0b01;
+ }
+ if self.shared {
+ flag |= 0b10;
+ }
+ sink.push(flag);
}
}
@@ -96,6 +106,7 @@ impl TryFrom<wasmparser::GlobalType> for GlobalType {
Ok(GlobalType {
val_type: global_ty.content_type.try_into()?,
mutable: global_ty.mutable,
+ shared: global_ty.shared,
})
}
}
diff --git a/third_party/rust/wasm-encoder/src/core/imports.rs b/third_party/rust/wasm-encoder/src/core/imports.rs
index 0030d640e6..d4db2e65c5 100644
--- a/third_party/rust/wasm-encoder/src/core/imports.rs
+++ b/third_party/rust/wasm-encoder/src/core/imports.rs
@@ -103,6 +103,7 @@ impl TryFrom<wasmparser::TypeRef> for EntityType {
/// maximum: None,
/// memory64: false,
/// shared: false,
+/// page_size_log2: None,
/// }
/// );
///
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,
}
}
}
diff --git a/third_party/rust/wasm-encoder/src/core/types.rs b/third_party/rust/wasm-encoder/src/core/types.rs
index bfc54ae1e3..8b5f340bb6 100644
--- a/third_party/rust/wasm-encoder/src/core/types.rs
+++ b/third_party/rust/wasm-encoder/src/core/types.rs
@@ -450,9 +450,12 @@ pub enum HeapType {
/// The unboxed `i31` heap type.
I31,
- /// The abstract` exception` heap type.
+ /// The abstract `exception` heap type.
Exn,
+ /// The abstract `noexn` heap type.
+ NoExn,
+
/// A concrete Wasm-defined type at the given index.
Concrete(u32),
}
@@ -471,6 +474,7 @@ impl Encode for HeapType {
HeapType::Array => sink.push(0x6A),
HeapType::I31 => sink.push(0x6C),
HeapType::Exn => sink.push(0x69),
+ HeapType::NoExn => sink.push(0x74),
// Note that this is encoded as a signed type rather than unsigned
// as it's decoded as an s33
HeapType::Concrete(i) => i64::from(*i).encode(sink),
@@ -496,6 +500,7 @@ impl TryFrom<wasmparser::HeapType> for HeapType {
wasmparser::HeapType::Array => HeapType::Array,
wasmparser::HeapType::I31 => HeapType::I31,
wasmparser::HeapType::Exn => HeapType::Exn,
+ wasmparser::HeapType::NoExn => HeapType::NoExn,
})
}
}
@@ -645,6 +650,8 @@ impl Section for TypeSection {
#[cfg(test)]
mod tests {
+ use wasmparser::WasmFeatures;
+
use super::*;
use crate::Module;
@@ -661,10 +668,8 @@ mod tests {
module.section(&types);
let wasm_bytes = module.finish();
- let mut validator = wasmparser::Validator::new_with_features(wasmparser::WasmFeatures {
- gc: false,
- ..Default::default()
- });
+ let mut validator =
+ wasmparser::Validator::new_with_features(WasmFeatures::default() & !WasmFeatures::GC);
validator.validate_all(&wasm_bytes).expect(
"Encoding pre Wasm GC type should not accidentally use Wasm GC specific encoding",