Bump the wasm-tools crates (#3139)
* Bump the wasm-tools crates Pulls in some updates here and there, mostly for updating crates to the latest version to prepare for later memory64 work. * Update lightbeam
This commit is contained in:
34
Cargo.lock
generated
34
Cargo.lock
generated
@@ -593,7 +593,7 @@ dependencies = [
|
|||||||
"smallvec",
|
"smallvec",
|
||||||
"souper-ir",
|
"souper-ir",
|
||||||
"target-lexicon",
|
"target-lexicon",
|
||||||
"wast 36.0.0",
|
"wast 37.0.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2020,7 +2020,7 @@ dependencies = [
|
|||||||
"peepmatic-test-operator",
|
"peepmatic-test-operator",
|
||||||
"peepmatic-traits",
|
"peepmatic-traits",
|
||||||
"serde",
|
"serde",
|
||||||
"wast 36.0.0",
|
"wast 37.0.0",
|
||||||
"z3",
|
"z3",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -2048,7 +2048,7 @@ dependencies = [
|
|||||||
"peepmatic-traits",
|
"peepmatic-traits",
|
||||||
"rand 0.8.3",
|
"rand 0.8.3",
|
||||||
"serde",
|
"serde",
|
||||||
"wast 36.0.0",
|
"wast 37.0.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2073,7 +2073,7 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"serde_test",
|
"serde_test",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"wast 36.0.0",
|
"wast 37.0.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2085,7 +2085,7 @@ dependencies = [
|
|||||||
"peepmatic",
|
"peepmatic",
|
||||||
"peepmatic-test-operator",
|
"peepmatic-test-operator",
|
||||||
"souper-ir",
|
"souper-ir",
|
||||||
"wast 36.0.0",
|
"wast 37.0.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2106,7 +2106,7 @@ version = "0.76.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"peepmatic-traits",
|
"peepmatic-traits",
|
||||||
"serde",
|
"serde",
|
||||||
"wast 36.0.0",
|
"wast 37.0.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -3491,15 +3491,15 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasmparser"
|
name = "wasmparser"
|
||||||
version = "0.79.0"
|
version = "0.80.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5b5894be15a559c85779254700e1d35f02f843b5a69152e5c82c626d9fd66c0e"
|
checksum = "a5f71b80b8193e50910919e7d1bc956d2b4f42b1cb1fad84bacb59332c16f2cf"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasmprinter"
|
name = "wasmprinter"
|
||||||
version = "0.2.27"
|
version = "0.2.28"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fe6f65000c9b653a87ba9b8bebe9230371337db2b7e70db724ee4b79d2b9936f"
|
checksum = "b48e4f2999b9930e9b037e328357d7d2367e0d8ea6e534be90aeff60976c0452"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"wasmparser",
|
"wasmparser",
|
||||||
@@ -3639,7 +3639,7 @@ dependencies = [
|
|||||||
"wasmtime-wasi-crypto",
|
"wasmtime-wasi-crypto",
|
||||||
"wasmtime-wasi-nn",
|
"wasmtime-wasi-nn",
|
||||||
"wasmtime-wast",
|
"wasmtime-wast",
|
||||||
"wast 36.0.0",
|
"wast 37.0.0",
|
||||||
"wat",
|
"wat",
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
@@ -3874,7 +3874,7 @@ version = "0.29.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"wasmtime",
|
"wasmtime",
|
||||||
"wast 36.0.0",
|
"wast 37.0.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -3888,20 +3888,20 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wast"
|
name = "wast"
|
||||||
version = "36.0.0"
|
version = "37.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8b5d7ba374a364571da1cb0a379a3dc302582a2d9937a183bfe35b68ad5bb9c4"
|
checksum = "9bc7b9a76845047ded00e031754ff410afee0d50fbdf62b55bdeecd245063d68"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"leb128",
|
"leb128",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wat"
|
name = "wat"
|
||||||
version = "1.0.38"
|
version = "1.0.39"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "16383df7f0e3901484c2dda6294ed6895caa3627ce4f6584141dcf30a33a23e6"
|
checksum = "2ab2cc8d9a69d1ab28a41d9149bb06bb927aba8fc9d56625f8b597a564c83f50"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"wast 36.0.0",
|
"wast 37.0.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
@@ -38,12 +38,12 @@ anyhow = "1.0.19"
|
|||||||
target-lexicon = { version = "0.12.0", default-features = false }
|
target-lexicon = { version = "0.12.0", default-features = false }
|
||||||
pretty_env_logger = "0.4.0"
|
pretty_env_logger = "0.4.0"
|
||||||
file-per-thread-logger = "0.1.1"
|
file-per-thread-logger = "0.1.1"
|
||||||
wat = "1.0.38"
|
wat = "1.0.39"
|
||||||
libc = "0.2.60"
|
libc = "0.2.60"
|
||||||
log = "0.4.8"
|
log = "0.4.8"
|
||||||
rayon = "1.5.0"
|
rayon = "1.5.0"
|
||||||
humantime = "2.0.0"
|
humantime = "2.0.0"
|
||||||
wasmparser = "0.79.0"
|
wasmparser = "0.80.0"
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
@@ -56,7 +56,7 @@ wasmtime-fuzzing = { path = "crates/fuzzing" }
|
|||||||
wasmtime-runtime = { path = "crates/runtime" }
|
wasmtime-runtime = { path = "crates/runtime" }
|
||||||
tokio = { version = "1.8.0", features = ["rt", "time", "macros", "rt-multi-thread"] }
|
tokio = { version = "1.8.0", features = ["rt", "time", "macros", "rt-multi-thread"] }
|
||||||
tracing-subscriber = "0.2.16"
|
tracing-subscriber = "0.2.16"
|
||||||
wast = "36.0.0"
|
wast = "37.0.0"
|
||||||
criterion = "0.3.4"
|
criterion = "0.3.4"
|
||||||
num_cpus = "1.13.0"
|
num_cpus = "1.13.0"
|
||||||
winapi = { version = "0.3.9", features = ['memoryapi'] }
|
winapi = { version = "0.3.9", features = ['memoryapi'] }
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ peepmatic-traits = { path = "../peepmatic/crates/traits", optional = true, versi
|
|||||||
peepmatic-runtime = { path = "../peepmatic/crates/runtime", optional = true, version = "0.76.0" }
|
peepmatic-runtime = { path = "../peepmatic/crates/runtime", optional = true, version = "0.76.0" }
|
||||||
regalloc = { version = "0.0.31" }
|
regalloc = { version = "0.0.31" }
|
||||||
souper-ir = { version = "2.1.0", optional = true }
|
souper-ir = { version = "2.1.0", optional = true }
|
||||||
wast = { version = "36.0.0", optional = true }
|
wast = { version = "37.0.0", optional = true }
|
||||||
# It is a goal of the cranelift-codegen crate to have minimal external dependencies.
|
# It is a goal of the cranelift-codegen crate to have minimal external dependencies.
|
||||||
# Please don't add any unless they are essential to the task of creating binary
|
# Please don't add any unless they are essential to the task of creating binary
|
||||||
# machine code. Integration tests that need external dependencies can be
|
# machine code. Integration tests that need external dependencies can be
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ peepmatic-macro = { version = "0.76.0", path = "crates/macro" }
|
|||||||
peepmatic-runtime = { version = "0.76.0", path = "crates/runtime", features = ["construct"] }
|
peepmatic-runtime = { version = "0.76.0", path = "crates/runtime", features = ["construct"] }
|
||||||
peepmatic-traits = { version = "0.76.0", path = "crates/traits" }
|
peepmatic-traits = { version = "0.76.0", path = "crates/traits" }
|
||||||
serde = { version = "1.0.105", features = ["derive"] }
|
serde = { version = "1.0.105", features = ["derive"] }
|
||||||
wast = "36.0.0"
|
wast = "37.0.0"
|
||||||
z3 = { version = "0.7.1", features = ["static-link-z3"] }
|
z3 = { version = "0.7.1", features = ["static-link-z3"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|||||||
@@ -21,4 +21,4 @@ peepmatic-test-operator = { path = "../test-operator" }
|
|||||||
peepmatic-traits = { path = "../traits" }
|
peepmatic-traits = { path = "../traits" }
|
||||||
rand = { version = "0.8.3", features = ["small_rng"] }
|
rand = { version = "0.8.3", features = ["small_rng"] }
|
||||||
serde = "1.0.106"
|
serde = "1.0.106"
|
||||||
wast = "36.0.0"
|
wast = "37.0.0"
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ peepmatic-automata = { version = "0.76.0", path = "../automata", features = ["se
|
|||||||
peepmatic-traits = { version = "0.76.0", path = "../traits" }
|
peepmatic-traits = { version = "0.76.0", path = "../traits" }
|
||||||
serde = { version = "1.0.105", features = ["derive"] }
|
serde = { version = "1.0.105", features = ["derive"] }
|
||||||
thiserror = "1.0.15"
|
thiserror = "1.0.15"
|
||||||
wast = { version = "36.0.0", optional = true }
|
wast = { version = "37.0.0", optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
peepmatic-test-operator = { version = "0.76.0", path = "../test-operator" }
|
peepmatic-test-operator = { version = "0.76.0", path = "../test-operator" }
|
||||||
|
|||||||
@@ -16,4 +16,4 @@ log = "0.4.8"
|
|||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
peepmatic = { path = "../..", version = "0.76.0" }
|
peepmatic = { path = "../..", version = "0.76.0" }
|
||||||
peepmatic-test-operator = { version = "0.76.0", path = "../test-operator" }
|
peepmatic-test-operator = { version = "0.76.0", path = "../test-operator" }
|
||||||
wast = "36.0.0"
|
wast = "37.0.0"
|
||||||
|
|||||||
@@ -11,4 +11,4 @@ edition = "2018"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
peepmatic-traits = { version = "0.76.0", path = "../traits" }
|
peepmatic-traits = { version = "0.76.0", path = "../traits" }
|
||||||
serde = { version = "1.0.105", features = ["derive"] }
|
serde = { version = "1.0.105", features = ["derive"] }
|
||||||
wast = "36.0.0"
|
wast = "37.0.0"
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ keywords = ["webassembly", "wasm"]
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
wasmparser = { version = "0.79", default-features = false }
|
wasmparser = { version = "0.80", default-features = false }
|
||||||
cranelift-codegen = { path = "../codegen", version = "0.76.0", default-features = false }
|
cranelift-codegen = { path = "../codegen", version = "0.76.0", default-features = false }
|
||||||
cranelift-entity = { path = "../entity", version = "0.76.0" }
|
cranelift-entity = { path = "../entity", version = "0.76.0" }
|
||||||
cranelift-frontend = { path = "../frontend", version = "0.76.0", default-features = false }
|
cranelift-frontend = { path = "../frontend", version = "0.76.0", default-features = false }
|
||||||
|
|||||||
@@ -2150,7 +2150,7 @@ fn translate_unreachable_operator<FE: FuncEnvironment + ?Sized>(
|
|||||||
fn get_heap_addr(
|
fn get_heap_addr(
|
||||||
heap: ir::Heap,
|
heap: ir::Heap,
|
||||||
addr32: ir::Value,
|
addr32: ir::Value,
|
||||||
offset: u32,
|
offset: u64,
|
||||||
width: u32,
|
width: u32,
|
||||||
addr_ty: Type,
|
addr_ty: Type,
|
||||||
builder: &mut FunctionBuilder,
|
builder: &mut FunctionBuilder,
|
||||||
@@ -2160,6 +2160,9 @@ fn get_heap_addr(
|
|||||||
|
|
||||||
let offset_guard_size: u64 = builder.func.heaps[heap].offset_guard_size.into();
|
let offset_guard_size: u64 = builder.func.heaps[heap].offset_guard_size.into();
|
||||||
|
|
||||||
|
// Currently this function only supports 32-bit memories.
|
||||||
|
let offset = u32::try_from(offset).unwrap();
|
||||||
|
|
||||||
// How exactly the bounds check is performed here and what it's performed
|
// How exactly the bounds check is performed here and what it's performed
|
||||||
// on is a bit tricky. Generally we want to rely on access violations (e.g.
|
// on is a bit tricky. Generally we want to rely on access violations (e.g.
|
||||||
// segfaults) to generate traps since that means we don't have to bounds
|
// segfaults) to generate traps since that means we don't have to bounds
|
||||||
@@ -2239,12 +2242,12 @@ fn prepare_load<FE: FuncEnvironment + ?Sized>(
|
|||||||
state: &mut FuncTranslationState,
|
state: &mut FuncTranslationState,
|
||||||
environ: &mut FE,
|
environ: &mut FE,
|
||||||
) -> WasmResult<(MemFlags, Value, Offset32)> {
|
) -> WasmResult<(MemFlags, Value, Offset32)> {
|
||||||
let addr32 = state.pop1();
|
let addr = state.pop1();
|
||||||
|
|
||||||
let heap = state.get_heap(builder.func, memarg.memory, environ)?;
|
let heap = state.get_heap(builder.func, memarg.memory, environ)?;
|
||||||
let (base, offset) = get_heap_addr(
|
let (base, offset) = get_heap_addr(
|
||||||
heap,
|
heap,
|
||||||
addr32,
|
addr,
|
||||||
memarg.offset,
|
memarg.offset,
|
||||||
loaded_bytes,
|
loaded_bytes,
|
||||||
environ.pointer_type(),
|
environ.pointer_type(),
|
||||||
@@ -2335,11 +2338,14 @@ fn fold_atomic_mem_addr(
|
|||||||
) -> Value {
|
) -> Value {
|
||||||
let access_ty_bytes = access_ty.bytes();
|
let access_ty_bytes = access_ty.bytes();
|
||||||
let final_lma = if memarg.offset > 0 {
|
let final_lma = if memarg.offset > 0 {
|
||||||
|
// Note that 32-bit memories are only supported here at this time, the
|
||||||
|
// logic here (e.g. the `iadd_imm` will need to check for overflow and
|
||||||
|
// other bits and pieces for 64-bit memories.
|
||||||
assert!(builder.func.dfg.value_type(linear_mem_addr) == I32);
|
assert!(builder.func.dfg.value_type(linear_mem_addr) == I32);
|
||||||
let linear_mem_addr = builder.ins().uextend(I64, linear_mem_addr);
|
let linear_mem_addr = builder.ins().uextend(I64, linear_mem_addr);
|
||||||
let a = builder
|
let a = builder
|
||||||
.ins()
|
.ins()
|
||||||
.iadd_imm(linear_mem_addr, i64::from(memarg.offset));
|
.iadd_imm(linear_mem_addr, i64::try_from(memarg.offset).unwrap());
|
||||||
let cflags = builder.ins().ifcmp_imm(a, 0x1_0000_0000i64);
|
let cflags = builder.ins().ifcmp_imm(a, 0x1_0000_0000i64);
|
||||||
builder.ins().trapif(
|
builder.ins().trapif(
|
||||||
IntCC::UnsignedGreaterThanOrEqual,
|
IntCC::UnsignedGreaterThanOrEqual,
|
||||||
@@ -2374,10 +2380,14 @@ fn finalise_atomic_mem_addr<FE: FuncEnvironment + ?Sized>(
|
|||||||
environ: &mut FE,
|
environ: &mut FE,
|
||||||
) -> WasmResult<Value> {
|
) -> WasmResult<Value> {
|
||||||
// Check the alignment of `linear_mem_addr`.
|
// Check the alignment of `linear_mem_addr`.
|
||||||
|
//
|
||||||
|
// Note that the `iadd_imm` here and the `try_from` only works for 32-bit
|
||||||
|
// memories.
|
||||||
let access_ty_bytes = access_ty.bytes();
|
let access_ty_bytes = access_ty.bytes();
|
||||||
|
assert!(builder.func.dfg.value_type(linear_mem_addr) == I32);
|
||||||
let final_lma = builder
|
let final_lma = builder
|
||||||
.ins()
|
.ins()
|
||||||
.iadd_imm(linear_mem_addr, i64::from(memarg.offset));
|
.iadd_imm(linear_mem_addr, i64::try_from(memarg.offset).unwrap());
|
||||||
if access_ty_bytes != 1 {
|
if access_ty_bytes != 1 {
|
||||||
assert!(access_ty_bytes == 2 || access_ty_bytes == 4 || access_ty_bytes == 8);
|
assert!(access_ty_bytes == 2 || access_ty_bytes == 4 || access_ty_bytes == 8);
|
||||||
let final_lma_misalignment = builder
|
let final_lma_misalignment = builder
|
||||||
|
|||||||
@@ -8,9 +8,9 @@
|
|||||||
|
|
||||||
use crate::state::FuncTranslationState;
|
use crate::state::FuncTranslationState;
|
||||||
use crate::translation_utils::{
|
use crate::translation_utils::{
|
||||||
DataIndex, ElemIndex, EntityIndex, EntityType, Event, EventIndex, FuncIndex, Global,
|
DataIndex, ElemIndex, EntityIndex, EntityType, FuncIndex, Global, GlobalIndex, InstanceIndex,
|
||||||
GlobalIndex, InstanceIndex, InstanceTypeIndex, Memory, MemoryIndex, ModuleIndex,
|
InstanceTypeIndex, Memory, MemoryIndex, ModuleIndex, ModuleTypeIndex, SignatureIndex, Table,
|
||||||
ModuleTypeIndex, SignatureIndex, Table, TableIndex, TypeIndex,
|
TableIndex, Tag, TagIndex, TypeIndex,
|
||||||
};
|
};
|
||||||
use core::convert::From;
|
use core::convert::From;
|
||||||
use core::convert::TryFrom;
|
use core::convert::TryFrom;
|
||||||
@@ -771,15 +771,15 @@ pub trait ModuleEnvironment<'data>: TargetEnvironment {
|
|||||||
field: Option<&'data str>,
|
field: Option<&'data str>,
|
||||||
) -> WasmResult<()>;
|
) -> WasmResult<()>;
|
||||||
|
|
||||||
/// Declares an event import to the environment.
|
/// Declares an tag import to the environment.
|
||||||
fn declare_event_import(
|
fn declare_tag_import(
|
||||||
&mut self,
|
&mut self,
|
||||||
event: Event,
|
tag: Tag,
|
||||||
module: &'data str,
|
module: &'data str,
|
||||||
field: Option<&'data str>,
|
field: Option<&'data str>,
|
||||||
) -> WasmResult<()> {
|
) -> WasmResult<()> {
|
||||||
drop((event, module, field));
|
drop((tag, module, field));
|
||||||
Err(WasmError::Unsupported("wasm events".to_string()))
|
Err(WasmError::Unsupported("wasm tags".to_string()))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Declares a global import to the environment.
|
/// Declares a global import to the environment.
|
||||||
@@ -844,16 +844,16 @@ pub trait ModuleEnvironment<'data>: TargetEnvironment {
|
|||||||
/// Declares a memory to the environment
|
/// Declares a memory to the environment
|
||||||
fn declare_memory(&mut self, memory: Memory) -> WasmResult<()>;
|
fn declare_memory(&mut self, memory: Memory) -> WasmResult<()>;
|
||||||
|
|
||||||
/// Provides the number of defined events up front. By default this does nothing, but
|
/// Provides the number of defined tags up front. By default this does nothing, but
|
||||||
/// implementations can use this to preallocate memory if desired.
|
/// implementations can use this to preallocate memory if desired.
|
||||||
fn reserve_events(&mut self, _num: u32) -> WasmResult<()> {
|
fn reserve_tags(&mut self, _num: u32) -> WasmResult<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Declares an event to the environment
|
/// Declares an tag to the environment
|
||||||
fn declare_event(&mut self, event: Event) -> WasmResult<()> {
|
fn declare_tag(&mut self, tag: Tag) -> WasmResult<()> {
|
||||||
drop(event);
|
drop(tag);
|
||||||
Err(WasmError::Unsupported("wasm events".to_string()))
|
Err(WasmError::Unsupported("wasm tags".to_string()))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Provides the number of defined globals up front. By default this does nothing, but
|
/// Provides the number of defined globals up front. By default this does nothing, but
|
||||||
@@ -885,14 +885,10 @@ pub trait ModuleEnvironment<'data>: TargetEnvironment {
|
|||||||
name: &'data str,
|
name: &'data str,
|
||||||
) -> WasmResult<()>;
|
) -> WasmResult<()>;
|
||||||
|
|
||||||
/// Declares an event export to the environment.
|
/// Declares an tag export to the environment.
|
||||||
fn declare_event_export(
|
fn declare_tag_export(&mut self, tag_index: TagIndex, name: &'data str) -> WasmResult<()> {
|
||||||
&mut self,
|
drop((tag_index, name));
|
||||||
event_index: EventIndex,
|
Err(WasmError::Unsupported("wasm tags".to_string()))
|
||||||
name: &'data str,
|
|
||||||
) -> WasmResult<()> {
|
|
||||||
drop((event_index, name));
|
|
||||||
Err(WasmError::Unsupported("wasm events".to_string()))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Declares a global export to the environment.
|
/// Declares a global export to the environment.
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
//! to deal with each part of it.
|
//! to deal with each part of it.
|
||||||
use crate::environ::{ModuleEnvironment, WasmResult};
|
use crate::environ::{ModuleEnvironment, WasmResult};
|
||||||
use crate::sections_translator::{
|
use crate::sections_translator::{
|
||||||
parse_alias_section, parse_data_section, parse_element_section, parse_event_section,
|
parse_alias_section, parse_data_section, parse_element_section, parse_export_section,
|
||||||
parse_export_section, parse_function_section, parse_global_section, parse_import_section,
|
parse_function_section, parse_global_section, parse_import_section, parse_instance_section,
|
||||||
parse_instance_section, parse_memory_section, parse_name_section, parse_start_section,
|
parse_memory_section, parse_name_section, parse_start_section, parse_table_section,
|
||||||
parse_table_section, parse_type_section,
|
parse_tag_section, parse_type_section,
|
||||||
};
|
};
|
||||||
use crate::state::ModuleTranslationState;
|
use crate::state::ModuleTranslationState;
|
||||||
use cranelift_codegen::timing;
|
use cranelift_codegen::timing;
|
||||||
@@ -59,9 +59,9 @@ pub fn translate_module<'data>(
|
|||||||
parse_memory_section(memories, environ)?;
|
parse_memory_section(memories, environ)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Payload::EventSection(events) => {
|
Payload::TagSection(tags) => {
|
||||||
validator.event_section(&events)?;
|
validator.tag_section(&tags)?;
|
||||||
parse_event_section(events, environ)?;
|
parse_tag_section(tags, environ)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Payload::GlobalSection(globals) => {
|
Payload::GlobalSection(globals) => {
|
||||||
|
|||||||
@@ -10,9 +10,9 @@
|
|||||||
use crate::environ::{Alias, ModuleEnvironment, WasmError, WasmResult};
|
use crate::environ::{Alias, ModuleEnvironment, WasmError, WasmResult};
|
||||||
use crate::state::ModuleTranslationState;
|
use crate::state::ModuleTranslationState;
|
||||||
use crate::translation_utils::{
|
use crate::translation_utils::{
|
||||||
tabletype_to_type, type_to_type, DataIndex, ElemIndex, EntityIndex, EntityType, Event,
|
tabletype_to_type, type_to_type, DataIndex, ElemIndex, EntityIndex, EntityType, FuncIndex,
|
||||||
EventIndex, FuncIndex, Global, GlobalIndex, GlobalInit, InstanceIndex, Memory, MemoryIndex,
|
Global, GlobalIndex, GlobalInit, InstanceIndex, Memory, MemoryIndex, ModuleIndex, Table,
|
||||||
ModuleIndex, Table, TableElementType, TableIndex, TypeIndex,
|
TableElementType, TableIndex, Tag, TagIndex, TypeIndex,
|
||||||
};
|
};
|
||||||
use crate::wasm_unsupported;
|
use crate::wasm_unsupported;
|
||||||
use core::convert::TryFrom;
|
use core::convert::TryFrom;
|
||||||
@@ -24,10 +24,10 @@ use std::boxed::Box;
|
|||||||
use std::vec::Vec;
|
use std::vec::Vec;
|
||||||
use wasmparser::{
|
use wasmparser::{
|
||||||
self, Data, DataKind, DataSectionReader, Element, ElementItem, ElementItems, ElementKind,
|
self, Data, DataKind, DataSectionReader, Element, ElementItem, ElementItems, ElementKind,
|
||||||
ElementSectionReader, EventSectionReader, EventType, Export, ExportSectionReader, ExternalKind,
|
ElementSectionReader, Export, ExportSectionReader, ExternalKind, FunctionSectionReader,
|
||||||
FunctionSectionReader, GlobalSectionReader, GlobalType, ImportSectionEntryType,
|
GlobalSectionReader, GlobalType, ImportSectionEntryType, ImportSectionReader,
|
||||||
ImportSectionReader, MemorySectionReader, MemoryType, NameSectionReader, Naming, Operator,
|
MemorySectionReader, MemoryType, NameSectionReader, Naming, Operator, TableSectionReader,
|
||||||
TableSectionReader, TableType, TypeDef, TypeSectionReader,
|
TableType, TagSectionReader, TagType, TypeDef, TypeSectionReader,
|
||||||
};
|
};
|
||||||
|
|
||||||
fn entity_type(
|
fn entity_type(
|
||||||
@@ -45,7 +45,7 @@ fn entity_type(
|
|||||||
EntityType::Instance(environ.type_to_instance_type(TypeIndex::from_u32(sig))?)
|
EntityType::Instance(environ.type_to_instance_type(TypeIndex::from_u32(sig))?)
|
||||||
}
|
}
|
||||||
ImportSectionEntryType::Memory(ty) => EntityType::Memory(memory(ty)),
|
ImportSectionEntryType::Memory(ty) => EntityType::Memory(memory(ty)),
|
||||||
ImportSectionEntryType::Event(evt) => EntityType::Event(event(evt)),
|
ImportSectionEntryType::Tag(t) => EntityType::Tag(tag(t)),
|
||||||
ImportSectionEntryType::Global(ty) => {
|
ImportSectionEntryType::Global(ty) => {
|
||||||
EntityType::Global(global(ty, environ, GlobalInit::Import)?)
|
EntityType::Global(global(ty, environ, GlobalInit::Import)?)
|
||||||
}
|
}
|
||||||
@@ -54,19 +54,16 @@ fn entity_type(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn memory(ty: MemoryType) -> Memory {
|
fn memory(ty: MemoryType) -> Memory {
|
||||||
match ty {
|
assert!(!ty.memory64);
|
||||||
MemoryType::M32 { limits, shared } => Memory {
|
Memory {
|
||||||
minimum: limits.initial,
|
minimum: ty.initial.try_into().unwrap(),
|
||||||
maximum: limits.maximum,
|
maximum: ty.maximum.map(|i| i.try_into().unwrap()),
|
||||||
shared: shared,
|
shared: ty.shared,
|
||||||
},
|
|
||||||
// FIXME(#2361)
|
|
||||||
MemoryType::M64 { .. } => unimplemented!(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn event(e: EventType) -> Event {
|
fn tag(e: TagType) -> Tag {
|
||||||
Event {
|
Tag {
|
||||||
ty: TypeIndex::from_u32(e.type_index),
|
ty: TypeIndex::from_u32(e.type_index),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -78,8 +75,8 @@ fn table(ty: TableType, environ: &mut dyn ModuleEnvironment<'_>) -> WasmResult<T
|
|||||||
Some(t) => TableElementType::Val(t),
|
Some(t) => TableElementType::Val(t),
|
||||||
None => TableElementType::Func,
|
None => TableElementType::Func,
|
||||||
},
|
},
|
||||||
minimum: ty.limits.initial,
|
minimum: ty.initial,
|
||||||
maximum: ty.limits.maximum,
|
maximum: ty.maximum,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,8 +171,8 @@ pub fn parse_import_section<'data>(
|
|||||||
ImportSectionEntryType::Memory(ty) => {
|
ImportSectionEntryType::Memory(ty) => {
|
||||||
environ.declare_memory_import(memory(ty), import.module, import.field)?;
|
environ.declare_memory_import(memory(ty), import.module, import.field)?;
|
||||||
}
|
}
|
||||||
ImportSectionEntryType::Event(e) => {
|
ImportSectionEntryType::Tag(e) => {
|
||||||
environ.declare_event_import(event(e), import.module, import.field)?;
|
environ.declare_tag_import(tag(e), import.module, import.field)?;
|
||||||
}
|
}
|
||||||
ImportSectionEntryType::Global(ty) => {
|
ImportSectionEntryType::Global(ty) => {
|
||||||
let ty = global(ty, environ, GlobalInit::Import)?;
|
let ty = global(ty, environ, GlobalInit::Import)?;
|
||||||
@@ -243,16 +240,16 @@ pub fn parse_memory_section(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parses the Event section of the wasm module.
|
/// Parses the Tag section of the wasm module.
|
||||||
pub fn parse_event_section(
|
pub fn parse_tag_section(
|
||||||
events: EventSectionReader,
|
tags: TagSectionReader,
|
||||||
environ: &mut dyn ModuleEnvironment,
|
environ: &mut dyn ModuleEnvironment,
|
||||||
) -> WasmResult<()> {
|
) -> WasmResult<()> {
|
||||||
environ.reserve_events(events.get_count())?;
|
environ.reserve_tags(tags.get_count())?;
|
||||||
|
|
||||||
for entry in events {
|
for entry in tags {
|
||||||
let event = event(entry?);
|
let tag = tag(entry?);
|
||||||
environ.declare_event(event)?;
|
environ.declare_tag(tag)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -321,7 +318,7 @@ pub fn parse_export_section<'data>(
|
|||||||
ExternalKind::Memory => {
|
ExternalKind::Memory => {
|
||||||
environ.declare_memory_export(MemoryIndex::new(index), field)?
|
environ.declare_memory_export(MemoryIndex::new(index), field)?
|
||||||
}
|
}
|
||||||
ExternalKind::Event => environ.declare_event_export(EventIndex::new(index), field)?,
|
ExternalKind::Tag => environ.declare_tag_export(TagIndex::new(index), field)?,
|
||||||
ExternalKind::Global => {
|
ExternalKind::Global => {
|
||||||
environ.declare_global_export(GlobalIndex::new(index), field)?
|
environ.declare_global_export(GlobalIndex::new(index), field)?
|
||||||
}
|
}
|
||||||
@@ -473,20 +470,31 @@ pub fn parse_name_section<'data>(
|
|||||||
environ.declare_module_name(name);
|
environ.declare_module_name(name);
|
||||||
}
|
}
|
||||||
wasmparser::Name::Local(l) => {
|
wasmparser::Name::Local(l) => {
|
||||||
let mut reader = l.get_function_local_reader()?;
|
let mut reader = l.get_indirect_map()?;
|
||||||
for _ in 0..reader.get_count() {
|
for _ in 0..reader.get_indirect_count() {
|
||||||
let f = reader.read()?;
|
let f = reader.read()?;
|
||||||
if f.func_index == u32::max_value() {
|
if f.indirect_index == u32::max_value() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let mut map = f.get_map()?;
|
let mut map = f.get_map()?;
|
||||||
for _ in 0..map.get_count() {
|
for _ in 0..map.get_count() {
|
||||||
let Naming { index, name } = map.read()?;
|
let Naming { index, name } = map.read()?;
|
||||||
environ.declare_local_name(FuncIndex::from_u32(f.func_index), index, name)
|
environ.declare_local_name(
|
||||||
|
FuncIndex::from_u32(f.indirect_index),
|
||||||
|
index,
|
||||||
|
name,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wasmparser::Name::Unknown { .. } => {}
|
wasmparser::Name::Label(_)
|
||||||
|
| wasmparser::Name::Type(_)
|
||||||
|
| wasmparser::Name::Table(_)
|
||||||
|
| wasmparser::Name::Global(_)
|
||||||
|
| wasmparser::Name::Memory(_)
|
||||||
|
| wasmparser::Name::Element(_)
|
||||||
|
| wasmparser::Name::Data(_)
|
||||||
|
| wasmparser::Name::Unknown { .. } => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -516,7 +524,7 @@ pub fn parse_instance_section<'data>(
|
|||||||
ExternalKind::Instance => {
|
ExternalKind::Instance => {
|
||||||
EntityIndex::Instance(InstanceIndex::from_u32(arg.index))
|
EntityIndex::Instance(InstanceIndex::from_u32(arg.index))
|
||||||
}
|
}
|
||||||
ExternalKind::Event => unimplemented!(),
|
ExternalKind::Tag => unimplemented!(),
|
||||||
|
|
||||||
// this won't pass validation
|
// this won't pass validation
|
||||||
ExternalKind::Type => unreachable!(),
|
ExternalKind::Type => unreachable!(),
|
||||||
|
|||||||
@@ -95,8 +95,8 @@ entity_impl!(InstanceIndex);
|
|||||||
/// Index type of an event inside the WebAssembly module.
|
/// Index type of an event inside the WebAssembly module.
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)]
|
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)]
|
||||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
pub struct EventIndex(u32);
|
pub struct TagIndex(u32);
|
||||||
entity_impl!(EventIndex);
|
entity_impl!(TagIndex);
|
||||||
|
|
||||||
/// Specialized index for just module types.
|
/// Specialized index for just module types.
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)]
|
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)]
|
||||||
@@ -139,7 +139,7 @@ pub enum EntityType {
|
|||||||
/// A linear memory with the specified limits
|
/// A linear memory with the specified limits
|
||||||
Memory(Memory),
|
Memory(Memory),
|
||||||
/// An event definition.
|
/// An event definition.
|
||||||
Event(Event),
|
Tag(Tag),
|
||||||
/// A table with the specified element type and limits
|
/// A table with the specified element type and limits
|
||||||
Table(Table),
|
Table(Table),
|
||||||
/// A function type where the index points to the type section and records a
|
/// A function type where the index points to the type section and records a
|
||||||
@@ -236,7 +236,7 @@ pub struct Memory {
|
|||||||
/// WebAssembly event.
|
/// WebAssembly event.
|
||||||
#[derive(Debug, Clone, Copy, Hash, Eq, PartialEq)]
|
#[derive(Debug, Clone, Copy, Hash, Eq, PartialEq)]
|
||||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||||
pub struct Event {
|
pub struct Tag {
|
||||||
/// The event signature type.
|
/// The event signature type.
|
||||||
pub ty: TypeIndex,
|
pub ty: TypeIndex,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,5 +16,5 @@ cranelift-wasm = { path = "../../cranelift/wasm", version = "0.76.0" }
|
|||||||
cranelift-codegen = { path = "../../cranelift/codegen", version = "0.76.0" }
|
cranelift-codegen = { path = "../../cranelift/codegen", version = "0.76.0" }
|
||||||
cranelift-frontend = { path = "../../cranelift/frontend", version = "0.76.0" }
|
cranelift-frontend = { path = "../../cranelift/frontend", version = "0.76.0" }
|
||||||
cranelift-entity = { path = "../../cranelift/entity", version = "0.76.0" }
|
cranelift-entity = { path = "../../cranelift/entity", version = "0.76.0" }
|
||||||
wasmparser = "0.79.0"
|
wasmparser = "0.80.0"
|
||||||
target-lexicon = "0.12"
|
target-lexicon = "0.12"
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ edition = "2018"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
gimli = "0.25.0"
|
gimli = "0.25.0"
|
||||||
wasmparser = "0.79"
|
wasmparser = "0.80"
|
||||||
object = { version = "0.26.0", default-features = false, features = ["read_core", "elf", "write"] }
|
object = { version = "0.26.0", default-features = false, features = ["read_core", "elf", "write"] }
|
||||||
wasmtime-environ = { path = "../environ", version = "0.29.0" }
|
wasmtime-environ = { path = "../environ", version = "0.29.0" }
|
||||||
target-lexicon = { version = "0.12.0", default-features = false }
|
target-lexicon = { version = "0.12.0", default-features = false }
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ edition = "2018"
|
|||||||
cranelift-codegen = { path = "../../cranelift/codegen", version = "0.76.0", features = ["enable-serde"] }
|
cranelift-codegen = { path = "../../cranelift/codegen", version = "0.76.0", features = ["enable-serde"] }
|
||||||
cranelift-entity = { path = "../../cranelift/entity", version = "0.76.0", features = ["enable-serde"] }
|
cranelift-entity = { path = "../../cranelift/entity", version = "0.76.0", features = ["enable-serde"] }
|
||||||
cranelift-wasm = { path = "../../cranelift/wasm", version = "0.76.0", features = ["enable-serde"] }
|
cranelift-wasm = { path = "../../cranelift/wasm", version = "0.76.0", features = ["enable-serde"] }
|
||||||
wasmparser = "0.79"
|
wasmparser = "0.80"
|
||||||
indexmap = { version = "1.0.2", features = ["serde-1"] }
|
indexmap = { version = "1.0.2", features = ["serde-1"] }
|
||||||
thiserror = "1.0.4"
|
thiserror = "1.0.4"
|
||||||
serde = { version = "1.0.94", features = ["derive"] }
|
serde = { version = "1.0.94", features = ["derive"] }
|
||||||
|
|||||||
@@ -339,7 +339,7 @@ impl<'data> ModuleEnvironment<'data> {
|
|||||||
EntityIndex::Instance(self.result.module.instances.push(ty))
|
EntityIndex::Instance(self.result.module.instances.push(ty))
|
||||||
}
|
}
|
||||||
EntityType::Module(ty) => EntityIndex::Module(self.result.module.modules.push(ty)),
|
EntityType::Module(ty) => EntityIndex::Module(self.result.module.modules.push(ty)),
|
||||||
EntityType::Event(_) => unimplemented!(),
|
EntityType::Tag(_) => unimplemented!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1088,7 +1088,7 @@ and for re-adding support for interface types you can see this issue:
|
|||||||
EntityType::Module(sig) => {
|
EntityType::Module(sig) => {
|
||||||
self.result.module.modules.push(*sig);
|
self.result.module.modules.push(*sig);
|
||||||
}
|
}
|
||||||
EntityType::Event(_) => unimplemented!(),
|
EntityType::Tag(_) => unimplemented!(),
|
||||||
}
|
}
|
||||||
self.result
|
self.result
|
||||||
.module
|
.module
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ arbitrary = { version = "1.0.0", features = ["derive"] }
|
|||||||
env_logger = "0.8.1"
|
env_logger = "0.8.1"
|
||||||
log = "0.4.8"
|
log = "0.4.8"
|
||||||
rayon = "1.2.1"
|
rayon = "1.2.1"
|
||||||
wasmparser = "0.79"
|
wasmparser = "0.80"
|
||||||
wasmprinter = "0.2.27"
|
wasmprinter = "0.2.28"
|
||||||
wasmtime = { path = "../wasmtime" }
|
wasmtime = { path = "../wasmtime" }
|
||||||
wasmtime-wast = { path = "../wast" }
|
wasmtime-wast = { path = "../wast" }
|
||||||
wasm-encoder = "0.5.0"
|
wasm-encoder = "0.5.0"
|
||||||
|
|||||||
@@ -221,10 +221,7 @@ fn predict_rss(wasm: &[u8]) -> Result<usize> {
|
|||||||
// the minimum amount of memory to our predicted rss.
|
// the minimum amount of memory to our predicted rss.
|
||||||
Payload::MemorySection(s) => {
|
Payload::MemorySection(s) => {
|
||||||
for entry in s {
|
for entry in s {
|
||||||
let initial = match entry? {
|
let initial = entry?.initial as usize;
|
||||||
MemoryType::M32 { limits, .. } => limits.initial as usize,
|
|
||||||
MemoryType::M64 { limits, .. } => limits.initial as usize,
|
|
||||||
};
|
|
||||||
prediction += initial * 64 * 1024;
|
prediction += initial * 64 * 1024;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -233,7 +230,7 @@ fn predict_rss(wasm: &[u8]) -> Result<usize> {
|
|||||||
// currently this is 3 pointers per table entry.
|
// currently this is 3 pointers per table entry.
|
||||||
Payload::TableSection(s) => {
|
Payload::TableSection(s) => {
|
||||||
for entry in s {
|
for entry in s {
|
||||||
let initial = entry?.limits.initial as usize;
|
let initial = entry?.initial as usize;
|
||||||
prediction += initial * 3 * mem::size_of::<usize>();
|
prediction += initial * 3 * mem::size_of::<usize>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ rayon = { version = "1.0", optional = true }
|
|||||||
region = "2.2.0"
|
region = "2.2.0"
|
||||||
thiserror = "1.0.4"
|
thiserror = "1.0.4"
|
||||||
target-lexicon = { version = "0.12.0", default-features = false }
|
target-lexicon = { version = "0.12.0", default-features = false }
|
||||||
wasmparser = "0.79"
|
wasmparser = "0.80"
|
||||||
more-asserts = "0.2.1"
|
more-asserts = "0.2.1"
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
cfg-if = "1.0"
|
cfg-if = "1.0"
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ more-asserts = "0.2.1"
|
|||||||
smallvec = "1.6.1"
|
smallvec = "1.6.1"
|
||||||
thiserror = "1.0.9"
|
thiserror = "1.0.9"
|
||||||
typemap = "0.3"
|
typemap = "0.3"
|
||||||
wasmparser = "0.79"
|
wasmparser = "0.80"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
lazy_static = "1.2"
|
lazy_static = "1.2"
|
||||||
|
|||||||
@@ -440,7 +440,7 @@ impl From<WasmMemoryImmediate> for MemoryImmediate {
|
|||||||
assert_eq!(other.memory, 0);
|
assert_eq!(other.memory, 0);
|
||||||
MemoryImmediate {
|
MemoryImmediate {
|
||||||
flags: other.align.into(),
|
flags: other.align.into(),
|
||||||
offset: other.offset,
|
offset: other.offset as u32,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use memoffset::offset_of;
|
|||||||
|
|
||||||
use std::{convert::TryInto, mem};
|
use std::{convert::TryInto, mem};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use wasmparser::{FuncType, MemoryType, Parser, Payload, ResizableLimits, Type};
|
use wasmparser::{FuncType, Parser, Payload, Type};
|
||||||
|
|
||||||
pub trait AsValueType {
|
pub trait AsValueType {
|
||||||
const TYPE: Type;
|
const TYPE: Type;
|
||||||
@@ -104,12 +104,12 @@ pub struct TranslatedModule {
|
|||||||
ctx: SimpleContext,
|
ctx: SimpleContext,
|
||||||
// TODO: Should we wrap this in a `Mutex` so that calling functions from multiple
|
// TODO: Should we wrap this in a `Mutex` so that calling functions from multiple
|
||||||
// threads doesn't cause data races?
|
// threads doesn't cause data races?
|
||||||
memory: Option<ResizableLimits>,
|
memory: Option<(u64, Option<u64>)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TranslatedModule {
|
impl TranslatedModule {
|
||||||
pub fn instantiate(self) -> ExecutableModule {
|
pub fn instantiate(self) -> ExecutableModule {
|
||||||
let mem_size = self.memory.map(|limits| limits.initial).unwrap_or(0) as usize;
|
let mem_size = self.memory.map(|limits| limits.0 as u32).unwrap_or(0) as usize;
|
||||||
let mem: BoxSlice<_> = vec![0u8; mem_size * WASM_PAGE_SIZE]
|
let mem: BoxSlice<_> = vec![0u8; mem_size * WASM_PAGE_SIZE]
|
||||||
.into_boxed_slice()
|
.into_boxed_slice()
|
||||||
.into();
|
.into();
|
||||||
@@ -535,19 +535,12 @@ pub fn translate_only(data: &[u8]) -> Result<TranslatedModule, Error> {
|
|||||||
|
|
||||||
if !mem.is_empty() {
|
if !mem.is_empty() {
|
||||||
let mem = mem[0];
|
let mem = mem[0];
|
||||||
let limits = match mem {
|
if Some(mem.initial) != mem.maximum {
|
||||||
MemoryType::M32 {
|
|
||||||
limits,
|
|
||||||
shared: false,
|
|
||||||
} => limits,
|
|
||||||
_ => return Err(Error::Input("unsupported memory".to_string())),
|
|
||||||
};
|
|
||||||
if Some(limits.initial) != limits.maximum {
|
|
||||||
return Err(Error::Input(
|
return Err(Error::Input(
|
||||||
"Custom memory limits not supported in lightbeam".to_string(),
|
"Custom memory limits not supported in lightbeam".to_string(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
output.memory = Some(limits);
|
output.memory = Some((mem.initial, mem.maximum));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Payload::GlobalSection(s) => {
|
Payload::GlobalSection(s) => {
|
||||||
|
|||||||
@@ -13,6 +13,6 @@ edition = "2018"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
lightbeam = { path = "..", version = "0.29.0" }
|
lightbeam = { path = "..", version = "0.29.0" }
|
||||||
wasmparser = "0.79"
|
wasmparser = "0.80"
|
||||||
cranelift-codegen = { path = "../../../cranelift/codegen", version = "0.76.0" }
|
cranelift-codegen = { path = "../../../cranelift/codegen", version = "0.76.0" }
|
||||||
wasmtime-environ = { path = "../../environ", version = "0.29.0" }
|
wasmtime-environ = { path = "../../environ", version = "0.29.0" }
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ wasmtime-cache = { path = "../cache", version = "0.29.0", optional = true }
|
|||||||
wasmtime-profiling = { path = "../profiling", version = "0.29.0" }
|
wasmtime-profiling = { path = "../profiling", version = "0.29.0" }
|
||||||
wasmtime-fiber = { path = "../fiber", version = "0.29.0", optional = true }
|
wasmtime-fiber = { path = "../fiber", version = "0.29.0", optional = true }
|
||||||
target-lexicon = { version = "0.12.0", default-features = false }
|
target-lexicon = { version = "0.12.0", default-features = false }
|
||||||
wasmparser = "0.79"
|
wasmparser = "0.80"
|
||||||
anyhow = "1.0.19"
|
anyhow = "1.0.19"
|
||||||
region = "2.2.0"
|
region = "2.2.0"
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ impl ExternType {
|
|||||||
let ty = &types.instance_signatures[*ty];
|
let ty = &types.instance_signatures[*ty];
|
||||||
InstanceType::from_wasmtime(types, ty).into()
|
InstanceType::from_wasmtime(types, ty).into()
|
||||||
}
|
}
|
||||||
EntityType::Event(_) => unimplemented!("wasm event support"),
|
EntityType::Tag(_) => unimplemented!("wasm tag support"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ impl MatchCx<'_> {
|
|||||||
EntityType::Global(_) => "global",
|
EntityType::Global(_) => "global",
|
||||||
EntityType::Module(_) => "module",
|
EntityType::Module(_) => "module",
|
||||||
EntityType::Memory(_) => "memory",
|
EntityType::Memory(_) => "memory",
|
||||||
EntityType::Event(_) => "event",
|
EntityType::Tag(_) => "tag",
|
||||||
EntityType::Instance(_) => "instance",
|
EntityType::Instance(_) => "instance",
|
||||||
EntityType::Table(_) => "table",
|
EntityType::Table(_) => "table",
|
||||||
EntityType::Function(_) => "function",
|
EntityType::Function(_) => "function",
|
||||||
@@ -301,7 +301,7 @@ impl MatchCx<'_> {
|
|||||||
}
|
}
|
||||||
_ => bail!("expected module, but found {}", actual_desc),
|
_ => bail!("expected module, but found {}", actual_desc),
|
||||||
},
|
},
|
||||||
EntityType::Event(_) => unimplemented!(),
|
EntityType::Tag(_) => unimplemented!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -332,7 +332,7 @@ impl MatchCx<'_> {
|
|||||||
Extern::Module(actual) => self.module(*expected, actual),
|
Extern::Module(actual) => self.module(*expected, actual),
|
||||||
_ => bail!("expected module, but found {}", actual.desc()),
|
_ => bail!("expected module, but found {}", actual.desc()),
|
||||||
},
|
},
|
||||||
EntityType::Event(_) => unimplemented!(),
|
EntityType::Tag(_) => unimplemented!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -373,6 +373,6 @@ fn entity_desc(ty: &EntityType) -> &'static str {
|
|||||||
EntityType::Function(_) => "func",
|
EntityType::Function(_) => "func",
|
||||||
EntityType::Instance(_) => "instance",
|
EntityType::Instance(_) => "instance",
|
||||||
EntityType::Module(_) => "module",
|
EntityType::Module(_) => "module",
|
||||||
EntityType::Event(_) => "event",
|
EntityType::Tag(_) => "tag",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ edition = "2018"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0.19"
|
anyhow = "1.0.19"
|
||||||
wasmtime = { path = "../wasmtime", version = "0.29.0", default-features = false }
|
wasmtime = { path = "../wasmtime", version = "0.29.0", default-features = false }
|
||||||
wast = "36.0.0"
|
wast = "37.0.0"
|
||||||
|
|
||||||
[badges]
|
[badges]
|
||||||
maintenance = { status = "actively-developed" }
|
maintenance = { status = "actively-developed" }
|
||||||
|
|||||||
@@ -302,9 +302,15 @@ impl<T> WastContext<T> {
|
|||||||
}
|
}
|
||||||
AssertInvalid {
|
AssertInvalid {
|
||||||
span: _,
|
span: _,
|
||||||
mut module,
|
module,
|
||||||
message,
|
message,
|
||||||
} => {
|
} => {
|
||||||
|
let mut module = match module {
|
||||||
|
wast::QuoteModule::Module(m) => m,
|
||||||
|
// This is a `*.wat` parser test which we're not
|
||||||
|
// interested in.
|
||||||
|
wast::QuoteModule::Quote(_) => return Ok(()),
|
||||||
|
};
|
||||||
let bytes = module.encode()?;
|
let bytes = module.encode()?;
|
||||||
let err = match self.module(None, &bytes) {
|
let err = match self.module(None, &bytes) {
|
||||||
Ok(()) => bail!("expected module to fail to build"),
|
Ok(()) => bail!("expected module to fail to build"),
|
||||||
@@ -354,6 +360,7 @@ impl<T> WastContext<T> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
AssertUncaughtException { .. } => bail!("unimplemented assert_uncaught_exception"),
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user