summaryrefslogtreecommitdiffstats
path: root/third_party/rust/wasm-encoder
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/rust/wasm-encoder')
-rw-r--r--third_party/rust/wasm-encoder/.cargo-checksum.json2
-rw-r--r--third_party/rust/wasm-encoder/Cargo.toml10
-rw-r--r--third_party/rust/wasm-encoder/src/component/names.rs2
-rw-r--r--third_party/rust/wasm-encoder/src/core/code.rs89
4 files changed, 99 insertions, 4 deletions
diff --git a/third_party/rust/wasm-encoder/.cargo-checksum.json b/third_party/rust/wasm-encoder/.cargo-checksum.json
index 4c82ccdb63..b9591f5309 100644
--- a/third_party/rust/wasm-encoder/.cargo-checksum.json
+++ b/third_party/rust/wasm-encoder/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"Cargo.toml":"fc84e9fbaaf9adbac39c8099ddbf6bb252a332f84e569392a7efe9a9712c1829","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":"f3b6691f822d53eb743b397a4e735786501cf000451753ae9a65031ae3249835","src/component/start.rs":"4055553d5c99c99abbc01bb8abb928ecb8b909d148b647a9977fbd444bb464a3","src/component/types.rs":"f44501e9b356e5588767323f1844e768221e00843a33354ff2597a76f32def46","src/core.rs":"a00656f82a623656c59a2d7230b40a5849a5083e117bc57061746f6e3022c7bb","src/core/code.rs":"06cc521073c2cd0e33e0e417f3721b9c63b2c64ba778a927c98fb6737c8cdc34","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":"d162eb64168969ae90e8668ca0593b0e47667e315aa08e717a9c9574d700d826"} \ No newline at end of file
+{"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
diff --git a/third_party/rust/wasm-encoder/Cargo.toml b/third_party/rust/wasm-encoder/Cargo.toml
index 1f9750fd1f..aa4ce5bc7c 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.40.0"
+version = "0.201.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.120.0"
+version = "0.201.0"
optional = true
[dev-dependencies.anyhow]
@@ -35,3 +35,9 @@ version = "1.0.58"
[dev-dependencies.tempfile]
version = "3.2.0"
+
+[lints.clippy]
+all = "allow"
+
+[lints.rust]
+unsafe_code = "deny"
diff --git a/third_party/rust/wasm-encoder/src/component/names.rs b/third_party/rust/wasm-encoder/src/component/names.rs
index 99db10bda0..1cbb1062c6 100644
--- a/third_party/rust/wasm-encoder/src/component/names.rs
+++ b/third_party/rust/wasm-encoder/src/component/names.rs
@@ -1,7 +1,7 @@
use std::borrow::Cow;
use super::*;
-use crate::{encoding_size, CustomSection, Encode, ExportKind, NameMap, SectionId};
+use crate::{encoding_size, ExportKind, NameMap, SectionId};
/// Encoding for the `component-name` custom section which assigns
/// human-readable names to items within a component.
diff --git a/third_party/rust/wasm-encoder/src/core/code.rs b/third_party/rust/wasm-encoder/src/core/code.rs
index cec2d4191e..76bfd7afde 100644
--- a/third_party/rust/wasm-encoder/src/core/code.rs
+++ b/third_party/rust/wasm-encoder/src/core/code.rs
@@ -3188,6 +3188,11 @@ impl ConstExpr {
Self { bytes }
}
+ fn with_insn(mut self, insn: Instruction) -> Self {
+ insn.encode(&mut self.bytes);
+ self
+ }
+
/// Create a constant expression containing a single `global.get` instruction.
pub fn global_get(index: u32) -> Self {
Self::new_insn(Instruction::GlobalGet(index))
@@ -3227,6 +3232,90 @@ impl ConstExpr {
pub fn v128_const(value: i128) -> Self {
Self::new_insn(Instruction::V128Const(value))
}
+
+ /// Add a `global.get` instruction to this constant expression.
+ pub fn with_global_get(self, index: u32) -> Self {
+ self.with_insn(Instruction::GlobalGet(index))
+ }
+
+ /// Add a `ref.null` instruction to this constant expression.
+ pub fn with_ref_null(self, ty: HeapType) -> Self {
+ self.with_insn(Instruction::RefNull(ty))
+ }
+
+ /// Add a `ref.func` instruction to this constant expression.
+ pub fn with_ref_func(self, func: u32) -> Self {
+ self.with_insn(Instruction::RefFunc(func))
+ }
+
+ /// Add an `i32.const` instruction to this constant expression.
+ pub fn with_i32_const(self, value: i32) -> Self {
+ self.with_insn(Instruction::I32Const(value))
+ }
+
+ /// Add an `i64.const` instruction to this constant expression.
+ pub fn with_i64_const(self, value: i64) -> Self {
+ self.with_insn(Instruction::I64Const(value))
+ }
+
+ /// Add a `f32.const` instruction to this constant expression.
+ pub fn with_f32_const(self, value: f32) -> Self {
+ self.with_insn(Instruction::F32Const(value))
+ }
+
+ /// Add a `f64.const` instruction to this constant expression.
+ pub fn with_f64_const(self, value: f64) -> Self {
+ self.with_insn(Instruction::F64Const(value))
+ }
+
+ /// Add a `v128.const` instruction to this constant expression.
+ pub fn with_v128_const(self, value: i128) -> Self {
+ self.with_insn(Instruction::V128Const(value))
+ }
+
+ /// Add an `i32.add` instruction to this constant expression.
+ pub fn with_i32_add(self) -> Self {
+ self.with_insn(Instruction::I32Add)
+ }
+
+ /// Add an `i32.sub` instruction to this constant expression.
+ pub fn with_i32_sub(self) -> Self {
+ self.with_insn(Instruction::I32Sub)
+ }
+
+ /// Add an `i32.mul` instruction to this constant expression.
+ pub fn with_i32_mul(self) -> Self {
+ self.with_insn(Instruction::I32Mul)
+ }
+
+ /// Add an `i64.add` instruction to this constant expression.
+ pub fn with_i64_add(self) -> Self {
+ self.with_insn(Instruction::I64Add)
+ }
+
+ /// Add an `i64.sub` instruction to this constant expression.
+ pub fn with_i64_sub(self) -> Self {
+ self.with_insn(Instruction::I64Sub)
+ }
+
+ /// Add an `i64.mul` instruction to this constant expression.
+ pub fn with_i64_mul(self) -> Self {
+ self.with_insn(Instruction::I64Mul)
+ }
+
+ /// Returns the function, if any, referenced by this global.
+ pub fn get_ref_func(&self) -> Option<u32> {
+ let prefix = *self.bytes.get(0)?;
+ // 0xd2 == `ref.func` opcode, and if that's found then load the leb
+ // corresponding to the function index.
+ if prefix != 0xd2 {
+ return None;
+ }
+ leb128::read::unsigned(&mut &self.bytes[1..])
+ .ok()?
+ .try_into()
+ .ok()
+ }
}
impl Encode for ConstExpr {