Skip to content

Commit

Permalink
Merge pull request bytecodealliance#78 from dhil/wasmfx-merge
Browse files Browse the repository at this point in the history
Weekly merge with upstream
  • Loading branch information
dhil authored Jan 19, 2024
2 parents 8bf8aa1 + 5138790 commit 236bec7
Show file tree
Hide file tree
Showing 786 changed files with 48,255 additions and 41,638 deletions.
35 changes: 9 additions & 26 deletions Cargo.lock

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

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ wasmtime-explorer = { path = "crates/explorer", version = "=18.0.0" }
wasmtime-fiber = { path = "crates/fiber", version = "=18.0.0" }
wasmtime-fibre = { path = "crates/fibre", version = "=18.0.0" }
wasmtime-types = { path = "crates/types", version = "18.0.0" }
wasmtime-jit = { path = "crates/jit", version = "=18.0.0" }
wasmtime-jit-debug = { path = "crates/jit-debug", version = "=18.0.0" }
wasmtime-runtime = { path = "crates/runtime", version = "=18.0.0" }
wasmtime-wast = { path = "crates/wast", version = "=18.0.0" }
Expand All @@ -184,7 +183,7 @@ component-fuzz-util = { path = "crates/misc/component-fuzz-util" }
wiggle = { path = "crates/wiggle", version = "=18.0.0", default-features = false }
wiggle-macro = { path = "crates/wiggle/macro", version = "=18.0.0" }
wiggle-generate = { path = "crates/wiggle/generate", version = "=18.0.0" }
wasi-common = { path = "crates/wasi-common", version = "=18.0.0" }
wasi-common = { path = "crates/wasi-common", version = "=18.0.0", default-features = false }
wasi-tokio = { path = "crates/wasi-common/tokio", version = "=18.0.0" }
wasi-cap-std-sync = { path = "crates/wasi-common/cap-std-sync", version = "=18.0.0" }
wasmtime-fuzzing = { path = "crates/fuzzing" }
Expand Down
21 changes: 19 additions & 2 deletions benches/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ enum IsAsync {
Yes,
YesPooling,
No,
NoPooling,
}

impl IsAsync {
Expand All @@ -31,12 +32,13 @@ impl IsAsync {
IsAsync::Yes => "async",
IsAsync::YesPooling => "async-pool",
IsAsync::No => "sync",
IsAsync::NoPooling => "sync-pool",
}
}
fn use_async(&self) -> bool {
match self {
IsAsync::Yes | IsAsync::YesPooling => true,
IsAsync::No => false,
IsAsync::No | IsAsync::NoPooling => false,
}
}
}
Expand All @@ -47,14 +49,29 @@ fn engines() -> Vec<(Engine, IsAsync)> {
#[cfg(feature = "component-model")]
config.wasm_component_model(true);

let mut pool = PoolingAllocationConfig::default();
if std::env::var("WASMTIME_TEST_FORCE_MPK").is_ok() {
pool.memory_protection_keys(MpkEnabled::Enable);
}

vec![
(Engine::new(&config).unwrap(), IsAsync::No),
(
Engine::new(
config
.clone()
.allocation_strategy(InstanceAllocationStrategy::Pooling(pool.clone())),
)
.unwrap(),
IsAsync::NoPooling,
),
(
Engine::new(config.async_support(true)).unwrap(),
IsAsync::Yes,
),
(
Engine::new(config.allocation_strategy(InstanceAllocationStrategy::pooling())).unwrap(),
Engine::new(config.allocation_strategy(InstanceAllocationStrategy::Pooling(pool)))
.unwrap(),
IsAsync::YesPooling,
),
]
Expand Down
2 changes: 2 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ fn ignore(testsuite: &str, testname: &str, strategy: &str) -> bool {
let assert_trap = [
"i32",
"i64",
"call",
"call_indirect",
"conversions",
"table_fill",
"table_init",
"table_copy",
Expand Down
3 changes: 2 additions & 1 deletion cranelift/codegen/src/egraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ pub struct EgraphPass<'a> {
/// Alias analysis, used during optimization.
alias_analysis: &'a mut AliasAnalysis<'a>,
/// "Domtree with children": like `domtree`, but with an explicit
/// list of children, rather than just parent pointers.
/// list of children, complementing the parent pointers stored
/// in `domtree`.
domtree_children: DomTreeWithChildren,
/// Loop analysis results, used for built-in LICM during
/// elaboration.
Expand Down
11 changes: 8 additions & 3 deletions cranelift/codegen/src/egraph/domtree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@ use crate::ir::{Block, Function};
use cranelift_entity::{packed_option::PackedOption, SecondaryMap};

#[derive(Clone, Debug)]
/// Like a [`DominatorTree`], but with an explicit list of children,
/// rather than parent pointers.
pub(crate) struct DomTreeWithChildren {
nodes: SecondaryMap<Block, DomTreeNode>,
root: Block,
}

#[derive(Clone, Copy, Debug, Default)]
struct DomTreeNode {
/// Points to the first child of the node, and implicitly to an entire
/// linked list of the children.
children: PackedOption<Block>,
/// Points to the next sibling, if any.
next: PackedOption<Block>,
}

Expand All @@ -22,15 +27,15 @@ impl DomTreeWithChildren {
SecondaryMap::with_capacity(func.dfg.num_blocks());

for block in func.layout.blocks() {
let idom_inst = match domtree.idom(block) {
Some(idom_inst) => idom_inst,
None => continue,
let Some(idom_inst) = domtree.idom(block) else {
continue;
};
let idom = func
.layout
.inst_block(idom_inst)
.expect("Dominating instruction should be part of a block");

// Insert at the front of nodes[idom].children
nodes[block].next = nodes[idom].children;
nodes[idom].children = block.into();
}
Expand Down
5 changes: 5 additions & 0 deletions crates/component-macro/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fn main() {
println!("cargo:rerun-if-changed=build.rs");
let out_dir = std::env::var("OUT_DIR").unwrap();
println!("cargo:rustc-env=DEBUG_OUTPUT_DIR={out_dir}");
}
27 changes: 26 additions & 1 deletion crates/component-macro/src/bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use quote::ToTokens;
use std::collections::HashMap;
use std::collections::HashSet;
use std::path::{Path, PathBuf};
use std::sync::atomic::{AtomicUsize, Ordering::Relaxed};
use syn::parse::{Error, Parse, ParseStream, Result};
use syn::punctuated::Punctuated;
use syn::{braced, token, Token};
Expand All @@ -24,7 +25,31 @@ pub fn expand(input: &Config) -> Result<TokenStream> {
));
}

let src = input.opts.generate(&input.resolve, input.world);
let mut src = input.opts.generate(&input.resolve, input.world);

// If a magical `WASMTIME_DEBUG_BINDGEN` environment variable is set then
// place a formatted version of the expanded code into a file. This file
// will then show up in rustc error messages for any codegen issues and can
// be inspected manually.
if std::env::var("WASMTIME_DEBUG_BINDGEN").is_ok() {
static INVOCATION: AtomicUsize = AtomicUsize::new(0);
let root = Path::new(env!("DEBUG_OUTPUT_DIR"));
let world_name = &input.resolve.worlds[input.world].name;
let n = INVOCATION.fetch_add(1, Relaxed);
let path = root.join(format!("{world_name}{n}.rs"));

std::fs::write(&path, &src).unwrap();

// optimistically format the code but don't require success
drop(
std::process::Command::new("rustfmt")
.arg(&path)
.arg("--edition=2021")
.output(),
);

src = format!("include!({path:?});");
}
let mut contents = src.parse::<TokenStream>().unwrap();

// Include a dummy `include_str!` for any files we read so rustc knows that
Expand Down
10 changes: 10 additions & 0 deletions crates/component-macro/tests/codegen/wat.wit
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package same:name;

interface this-name-is-duplicated {
resource this-name-is-duplicated {
}
}

world example {
export this-name-is-duplicated;
}
4 changes: 4 additions & 0 deletions crates/environ/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ workspace = true

[dependencies]
anyhow = { workspace = true }
bincode = "1.2.1"
cpp_demangle = { version = "0.3.2", optional = true }
cranelift-entity = { workspace = true }
wasmtime-types = { workspace = true }
wasmtime-continuations = { workspace = true }
Expand All @@ -26,6 +28,7 @@ serde_derive = "1.0.188"
log = { workspace = true }
gimli = { workspace = true, features = ["write"] }
object = { workspace = true, features = ['write_core'] }
rustc-demangle = { version = "0.1.16", optional = true }
target-lexicon = { workspace = true }
wasm-encoder = { workspace = true, optional = true }
wasmprinter = { workspace = true, optional = true }
Expand All @@ -46,3 +49,4 @@ component-model = [
"dep:wasmprinter",
"dep:wasmtime-component-util",
]
demangle = ['dep:rustc-demangle', 'dep:cpp_demangle']
File renamed without changes.
Loading

0 comments on commit 236bec7

Please sign in to comment.