Skip to content

Commit

Permalink
chore(RUN-892): Sync wasmparser and wasm-encoder to wasmtime
Browse files Browse the repository at this point in the history
  • Loading branch information
adambratschikaye committed Jan 24, 2024
1 parent a044296 commit 0374190
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 163 deletions.
6 changes: 3 additions & 3 deletions Cargo.Bazel.Fuzzing.json.lock
@@ -1,5 +1,5 @@
{
"checksum": "4c57cf57b9b8598aef225caa86dd2e438ee8a03cb791212320aa8b5886d012f7",
"checksum": "43204614b00820e26be48107de22bcc25c07cfdf74439c452d1f16399b782f68",
"crates": {
"abnf 0.12.0": {
"name": "abnf",
Expand Down Expand Up @@ -16280,7 +16280,7 @@
"target": "wasm_bindgen"
},
{
"id": "wasm-encoder 0.35.0",
"id": "wasm-encoder 0.36.2",
"target": "wasm_encoder"
},
{
Expand All @@ -16293,7 +16293,7 @@
"target": "wasm_smith"
},
{
"id": "wasmparser 0.115.0",
"id": "wasmparser 0.116.1",
"target": "wasmparser"
},
{
Expand Down
4 changes: 2 additions & 2 deletions Cargo.Bazel.Fuzzing.toml.lock
Expand Up @@ -3271,10 +3271,10 @@ dependencies = [
"walrus 0.19.0",
"warp",
"wasm-bindgen",
"wasm-encoder 0.35.0",
"wasm-encoder 0.36.2",
"wasm-encoder 0.38.1",
"wasm-smith",
"wasmparser 0.115.0",
"wasmparser 0.116.1",
"wasmprinter",
"wasmtime",
"wasmtime-environ",
Expand Down
88 changes: 3 additions & 85 deletions Cargo.Bazel.json.lock
@@ -1,5 +1,5 @@
{
"checksum": "13580f0105eb946b022e7243814505a4620c871af5d68229c09ff5fe473a9658",
"checksum": "40ddefbb8fda979cb7abf6c6924a1b138fd03c20320ad7c1de53b1fb31ca6375",
"crates": {
"abnf 0.12.0": {
"name": "abnf",
Expand Down Expand Up @@ -16149,7 +16149,7 @@
"target": "wasm_bindgen"
},
{
"id": "wasm-encoder 0.35.0",
"id": "wasm-encoder 0.36.2",
"target": "wasm_encoder"
},
{
Expand All @@ -16162,7 +16162,7 @@
"target": "wasm_smith"
},
{
"id": "wasmparser 0.115.0",
"id": "wasmparser 0.116.1",
"target": "wasmparser"
},
{
Expand Down Expand Up @@ -59713,45 +59713,6 @@
},
"license": "Apache-2.0 WITH LLVM-exception"
},
"wasm-encoder 0.35.0": {
"name": "wasm-encoder",
"version": "0.35.0",
"repository": {
"Http": {
"url": "https://crates.io/api/v1/crates/wasm-encoder/0.35.0/download",
"sha256": "9ca90ba1b5b0a70d3d49473c5579951f3bddc78d47b59256d2f9d4922b150aca"
}
},
"targets": [
{
"Library": {
"crate_name": "wasm_encoder",
"crate_root": "src/lib.rs",
"srcs": [
"**/*.rs"
]
}
}
],
"library_target_name": "wasm_encoder",
"common_attrs": {
"compile_data_glob": [
"**"
],
"deps": {
"common": [
{
"id": "leb128 0.2.5",
"target": "leb128"
}
],
"selects": {}
},
"edition": "2021",
"version": "0.35.0"
},
"license": "Apache-2.0 WITH LLVM-exception"
},
"wasm-encoder 0.36.2": {
"name": "wasm-encoder",
"version": "0.36.2",
Expand Down Expand Up @@ -59996,49 +59957,6 @@
},
"license": "Apache-2.0 WITH LLVM-exception"
},
"wasmparser 0.115.0": {
"name": "wasmparser",
"version": "0.115.0",
"repository": {
"Http": {
"url": "https://crates.io/api/v1/crates/wasmparser/0.115.0/download",
"sha256": "e06c0641a4add879ba71ccb3a1e4278fd546f76f1eafb21d8f7b07733b547cd5"
}
},
"targets": [
{
"Library": {
"crate_name": "wasmparser",
"crate_root": "src/lib.rs",
"srcs": [
"**/*.rs"
]
}
}
],
"library_target_name": "wasmparser",
"common_attrs": {
"compile_data_glob": [
"**"
],
"deps": {
"common": [
{
"id": "indexmap 2.1.0",
"target": "indexmap"
},
{
"id": "semver 1.0.18",
"target": "semver"
}
],
"selects": {}
},
"edition": "2021",
"version": "0.115.0"
},
"license": "Apache-2.0 WITH LLVM-exception"
},
"wasmparser 0.116.1": {
"name": "wasmparser",
"version": "0.116.1",
Expand Down
23 changes: 2 additions & 21 deletions Cargo.Bazel.toml.lock
Expand Up @@ -3260,10 +3260,10 @@ dependencies = [
"walrus 0.19.0",
"warp",
"wasm-bindgen",
"wasm-encoder 0.35.0",
"wasm-encoder 0.36.2",
"wasm-encoder 0.38.1",
"wasm-smith",
"wasmparser 0.115.0",
"wasmparser 0.116.1",
"wasmprinter",
"wasmtime",
"wasmtime-environ",
Expand Down Expand Up @@ -11608,15 +11608,6 @@ dependencies = [
"leb128",
]

[[package]]
name = "wasm-encoder"
version = "0.35.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ca90ba1b5b0a70d3d49473c5579951f3bddc78d47b59256d2f9d4922b150aca"
dependencies = [
"leb128",
]

[[package]]
name = "wasm-encoder"
version = "0.36.2"
Expand Down Expand Up @@ -11691,16 +11682,6 @@ dependencies = [
"semver",
]

[[package]]
name = "wasmparser"
version = "0.115.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e06c0641a4add879ba71ccb3a1e4278fd546f76f1eafb21d8f7b07733b547cd5"
dependencies = [
"indexmap 2.1.0",
"semver",
]

[[package]]
name = "wasmparser"
version = "0.116.1"
Expand Down
29 changes: 5 additions & 24 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions bazel/external_crates.bzl
Expand Up @@ -1316,7 +1316,7 @@ def external_crates_repository(name, cargo_lockfile, lockfile, sanitizers_enable
version = "^0.2",
),
"wasm-encoder": crate.spec(
version = "^0.35.0",
version = "^0.36.2",
),
"wasm-encoder-for-ws": crate.spec(
package = "wasm-encoder",
Expand All @@ -1332,7 +1332,7 @@ def external_crates_repository(name, cargo_lockfile, lockfile, sanitizers_enable
],
),
"wasmparser": crate.spec(
version = "^0.115.0",
version = "^0.116.1",
),
"wasmprinter": crate.spec(
version = "^0.2.50",
Expand Down
4 changes: 2 additions & 2 deletions rs/embedders/Cargo.toml
Expand Up @@ -37,8 +37,8 @@ wasmtime = { version = "15.0.0", default-features = false, features = [
] }
wasmtime-environ = "15.0.0"
wasmtime-runtime = "15.0.0"
wasm-encoder = "0.35.0"
wasmparser = "0.115.0"
wasm-encoder = "0.36.2"
wasmparser = "0.116.1"
rayon = "1.5.1"


Expand Down
13 changes: 6 additions & 7 deletions rs/embedders/src/wasm_utils/instrumentation.rs
Expand Up @@ -129,8 +129,8 @@ use crate::wasmtime_embedder::{
};
use ic_wasm_transform::{self, Global, Module};
use wasmparser::{
BlockType, Export, ExternalKind, FuncType, GlobalType, Import, MemoryType, Operator,
StructuralType, SubType, TypeRef, ValType,
BlockType, CompositeType, Export, ExternalKind, FuncType, GlobalType, Import, MemoryType,
Operator, SubType, TypeRef, ValType,
};

use std::collections::BTreeMap;
Expand Down Expand Up @@ -477,7 +477,7 @@ const STABLE_BYTEMAP_SIZE_IN_WASM_PAGES: u64 = MAX_STABLE_MEMORY_IN_WASM_PAGES /

fn add_func_type(module: &mut Module, ty: FuncType) -> u32 {
for (idx, existing_subtype) in module.types.iter().enumerate() {
if let StructuralType::Func(existing_ty) = &existing_subtype.structural_type {
if let CompositeType::Func(existing_ty) = &existing_subtype.composite_type {
if *existing_ty == ty {
return idx as u32;
}
Expand All @@ -486,7 +486,7 @@ fn add_func_type(module: &mut Module, ty: FuncType) -> u32 {
module.types.push(SubType {
is_final: true,
supertype_idx: None,
structural_type: StructuralType::Func(ty),
composite_type: CompositeType::Func(ty),
});
(module.types.len() - 1) as u32
}
Expand Down Expand Up @@ -742,13 +742,12 @@ pub(super) fn instrument(
// type) reference to the `code_section`.
let mut func_types = Vec::new();
for i in 0..module.code_sections.len() {
if let StructuralType::Func(t) = &module.types[module.functions[i] as usize].structural_type
{
if let CompositeType::Func(t) = &module.types[module.functions[i] as usize].composite_type {
func_types.push((i, t.clone()));
} else {
return Err(WasmInstrumentationError::InvalidFunctionType(format!(
"Function has type which is not a function type. Found type: {:?}",
&module.types[module.functions[i] as usize].structural_type
&module.types[module.functions[i] as usize].composite_type
)));
}
}
Expand Down
10 changes: 5 additions & 5 deletions rs/embedders/src/wasm_utils/validation.rs
Expand Up @@ -24,7 +24,7 @@ use crate::{
},
MIN_GUARD_REGION_SIZE,
};
use wasmparser::{ExternalKind, FuncType, Operator, StructuralType, TypeRef, ValType};
use wasmparser::{CompositeType, ExternalKind, FuncType, Operator, TypeRef, ValType};

/// Symbols that are reserved and cannot be exported by canisters.
#[doc(hidden)] // pub for usage in tests
Expand Down Expand Up @@ -753,8 +753,8 @@ fn validate_import_section(module: &Module) -> Result<WasmImportsDetails, WasmVa
let field = entry.name;
match &entry.ty {
TypeRef::Func(index) => {
let func_ty = if let StructuralType::Func(func_ty) =
&module.types[*index as usize].structural_type
let func_ty = if let CompositeType::Func(func_ty) =
&module.types[*index as usize].composite_type
{
func_ty
} else {
Expand Down Expand Up @@ -906,8 +906,8 @@ fn validate_export_section(
}
let actual_fn_index = fn_index - import_count;
let type_index = module.functions[actual_fn_index] as usize;
let func_ty = if let StructuralType::Func(func_ty) =
&module.types[type_index].structural_type
let func_ty = if let CompositeType::Func(func_ty) =
&module.types[type_index].composite_type
{
func_ty
} else {
Expand Down
2 changes: 1 addition & 1 deletion rs/execution_environment/Cargo.toml
Expand Up @@ -79,7 +79,7 @@ proptest = "1.0"
tempfile = "3.1.0"
test-strategy = "0.2"
wat = "1.0.52"
wasmparser = "0.115.0"
wasmparser = "0.116.1"

[build-dependencies]
escargot = "0.5"
Expand Down
4 changes: 2 additions & 2 deletions rs/wasm_transform/Cargo.toml
Expand Up @@ -7,8 +7,8 @@ description.workspace = true
documentation.workspace = true

[dependencies]
wasm-encoder = "0.35.0"
wasmparser = "0.115.0"
wasm-encoder = "0.36.2"
wasmparser = "0.116.1"


[dev-dependencies]
Expand Down

0 comments on commit 0374190

Please sign in to comment.