Skip to content

Commit

Permalink
Merge pull request #85 from near/nagisa/merges-upstream-3
Browse files Browse the repository at this point in the history
Merge upstream
  • Loading branch information
nagisa authored Nov 15, 2023
2 parents 8d1ac2b + d7bf6f8 commit 2feb144
Show file tree
Hide file tree
Showing 231 changed files with 36,972 additions and 34,302 deletions.
46 changes: 7 additions & 39 deletions Cargo.lock

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

111 changes: 111 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,119 @@ Unreleased.

### Added

* Multiple versions of interfaces are now supported in `bindgen!`.
[#7172](https://github.com/bytecodealliance/wasmtime/pull/7172)

* UDP has been implemented in `wasi:sockets`.
[#7148](https://github.com/bytecodealliance/wasmtime/pull/7148)
[#7243](https://github.com/bytecodealliance/wasmtime/pull/7243)

* Support for custom stack memory allocation has been added.
[#7209](https://github.com/bytecodealliance/wasmtime/pull/7209)

* The `memory_init_cow` setting can now be configured in the C API.
[#7227](https://github.com/bytecodealliance/wasmtime/pull/7227)

* The `splice` method of WASI streams has been implemented.
[#7234](https://github.com/bytecodealliance/wasmtime/pull/7234)

* Wasmtime binary releases now have a `wasmtime-min` executable in addition to
`libwasmtime-min.*` libraries for the C API. These showcase a minimal
build of Wasmtime for comparison.
[#7282](https://github.com/bytecodealliance/wasmtime/pull/7282)
[#7315](https://github.com/bytecodealliance/wasmtime/pull/7315)
[#7350](https://github.com/bytecodealliance/wasmtime/pull/7350)

### Changed

* Many changes to `wasi:http` WITs have happened to keep up with the proposal as
it prepares to reach a more stable status.
[#7161](https://github.com/bytecodealliance/wasmtime/pull/7161)
[#7406](https://github.com/bytecodealliance/wasmtime/pull/7406)
[#7383](https://github.com/bytecodealliance/wasmtime/pull/7383)
[#7417](https://github.com/bytecodealliance/wasmtime/pull/7417)
[#7451](https://github.com/bytecodealliance/wasmtime/pull/7451)

* Add an error resource to WASI streams.
[#7152](https://github.com/bytecodealliance/wasmtime/pull/7152)

* Syntax in `bindgen!`'s `trappable_error_type` configuration has changed.
[#7170](https://github.com/bytecodealliance/wasmtime/pull/7170)

* TCP errors in `wasi:sockets` have been simplified and clarified.
[#7120](https://github.com/bytecodealliance/wasmtime/pull/7120)

* Wasmtime/Cranelift now require Rust 1.71.0 to compile.
[#7206](https://github.com/bytecodealliance/wasmtime/pull/7206)

* Logging in Wasmtime is now configured with `WASMTIME_LOG` instead of
`RUST_LOG`.
[#7239](https://github.com/bytecodealliance/wasmtime/pull/7239)

* Fuel-related APIs on `Store` have been refactored and reimplemented with two
new methods `set_fuel` and `reset_fuel`. Previous methods have been removed.
[#7240](https://github.com/bytecodealliance/wasmtime/pull/7240)
[#7298](https://github.com/bytecodealliance/wasmtime/pull/7298)

* The `forward` method of WASI streams has been removed.
[#7234](https://github.com/bytecodealliance/wasmtime/pull/7234)

* The WebAssembly `threads`, `multi-memory`, and `relaxed-simd` proposals are
now enabled by default.
[#7285](https://github.com/bytecodealliance/wasmtime/pull/7285)

* Logging is now implemented for `wasmtime serve`.
[#7366](https://github.com/bytecodealliance/wasmtime/pull/7366)

* Filesystem locking has been temporarily removed from WASI.
[#7355](https://github.com/bytecodealliance/wasmtime/pull/7355)

* Wasmtime's implementation of WASI preview1 built on top of preview2
(`-Spreview2`) has been enabled by default.
[#7365](https://github.com/bytecodealliance/wasmtime/pull/7365)

* The `wasi:clocks` interface now has two `subscribe` functions and a `duration`
type.
[#7358](https://github.com/bytecodealliance/wasmtime/pull/7358)

* The `wasi:io/poll` interface has seen some refactoring.
[#7427](https://github.com/bytecodealliance/wasmtime/pull/7427)

### Fixed

* Profiling the first function in a module now works.
[#7254](https://github.com/bytecodealliance/wasmtime/pull/7254)

* Consecutive writes to files in preview2 have been fixed.
[#7394](https://github.com/bytecodealliance/wasmtime/pull/7394)

* Copy-on-write initialization of linear memories has been fixed for components.
[#7459](https://github.com/bytecodealliance/wasmtime/pull/7459)

### Cranelift

* Support for proof-carrying code has been added to Cranelift to assist with an
extra layer of validation about properties such as WebAssembly memory accesses
in the future.
[#7165](https://github.com/bytecodealliance/wasmtime/pull/7165)
[#7180](https://github.com/bytecodealliance/wasmtime/pull/7180)
[#7219](https://github.com/bytecodealliance/wasmtime/pull/7219)
[#7231](https://github.com/bytecodealliance/wasmtime/pull/7231)
[#7262](https://github.com/bytecodealliance/wasmtime/pull/7262)
[#7263](https://github.com/bytecodealliance/wasmtime/pull/7263)
[#7274](https://github.com/bytecodealliance/wasmtime/pull/7274)
[#7280](https://github.com/bytecodealliance/wasmtime/pull/7280)
[#7281](https://github.com/bytecodealliance/wasmtime/pull/7281)
[#7352](https://github.com/bytecodealliance/wasmtime/pull/7352)
[#7389](https://github.com/bytecodealliance/wasmtime/pull/7389)
[#7468](https://github.com/bytecodealliance/wasmtime/pull/7468)

* Rematerialization of values no longer accidentally overrides LICM.
[#7306](https://github.com/bytecodealliance/wasmtime/pull/7306)

* Inline stack probes no longer make Valgrind unhappy.
[#7470](https://github.com/bytecodealliance/wasmtime/pull/7470)

--------------------------------------------------------------------------------

## 14.0.4
Expand Down
35 changes: 30 additions & 5 deletions cranelift/codegen/src/egraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ use crate::ir::{
Block, DataFlowGraph, Function, Inst, InstructionData, Type, Value, ValueDef, ValueListPool,
};
use crate::loop_analysis::LoopAnalysis;
use crate::opts::generated_code::ContextIter;
use crate::opts::IsleContext;
use crate::scoped_hash_map::{Entry as ScopedEntry, ScopedHashMap};
use crate::trace;
use crate::unionfind::UnionFind;
use cranelift_entity::packed_option::ReservedValue;
use cranelift_entity::SecondaryMap;
use smallvec::SmallVec;
use std::hash::Hasher;

mod cost;
Expand Down Expand Up @@ -69,6 +69,9 @@ pub struct EgraphPass<'a> {
eclasses: UnionFind<Value>,
}

// The maximum number of rewrites we will take from a single call into ISLE.
const MATCHES_LIMIT: usize = 5;

/// Context passed through node insertion and optimization.
pub(crate) struct OptimizeCtx<'opt, 'analysis>
where
Expand All @@ -87,6 +90,7 @@ where
// Held locally during optimization of one node (recursively):
pub(crate) rewrite_depth: usize,
pub(crate) subsume_values: FxHashSet<Value>,
optimized_values: SmallVec<[Value; MATCHES_LIMIT]>,
}

/// For passing to `insert_pure_enode`. Sometimes the enode already
Expand Down Expand Up @@ -213,6 +217,7 @@ where
// A pure node always has exactly one result.
let orig_value = self.func.dfg.first_result(inst);

let mut optimized_values = std::mem::take(&mut self.optimized_values);
let mut isle_ctx = IsleContext { ctx: self };

// Limit rewrite depth. When we apply optimization rules, they
Expand All @@ -230,19 +235,35 @@ where
return orig_value;
}
isle_ctx.ctx.rewrite_depth += 1;
trace!(
"Incrementing rewrite depth; now {}",
isle_ctx.ctx.rewrite_depth
);

// Invoke the ISLE toplevel constructor, getting all new
// values produced as equivalents to this value.
trace!("Calling into ISLE with original value {}", orig_value);
isle_ctx.ctx.stats.rewrite_rule_invoked += 1;
let mut optimized_values =
crate::opts::generated_code::constructor_simplify(&mut isle_ctx, orig_value);
debug_assert!(optimized_values.is_empty());
crate::opts::generated_code::constructor_simplify(
&mut isle_ctx,
orig_value,
&mut optimized_values,
);
trace!(
" -> returned from ISLE, generated {} optimized values",
optimized_values.len()
);
if optimized_values.len() > MATCHES_LIMIT {
trace!("Reached maximum matches limit; too many optimized values, ignoring rest.");
optimized_values.truncate(MATCHES_LIMIT);
}

// Create a union of all new values with the original (or
// maybe just one new value marked as "subsuming" the
// original, if present.)
let mut union_value = orig_value;
while let Some(optimized_value) = optimized_values.next(&mut isle_ctx) {
for optimized_value in optimized_values.drain(..) {
trace!(
"Returned from ISLE for {}, got {:?}",
orig_value,
Expand Down Expand Up @@ -289,6 +310,9 @@ where

isle_ctx.ctx.rewrite_depth -= 1;

debug_assert!(isle_ctx.ctx.optimized_values.is_empty());
isle_ctx.ctx.optimized_values = optimized_values;

union_value
}

Expand Down Expand Up @@ -408,7 +432,7 @@ impl<'a> EgraphPass<'a> {
}
}
}
trace!("stats: {:?}", self.stats);
trace!("stats: {:#?}", self.stats);
self.elaborate();
}

Expand Down Expand Up @@ -534,6 +558,7 @@ impl<'a> EgraphPass<'a> {
stats: &mut self.stats,
alias_analysis: self.alias_analysis,
alias_analysis_state: &mut alias_analysis_state,
optimized_values: Default::default(),
};

if is_pure_for_egraph(ctx.func, inst) {
Expand Down
Loading

0 comments on commit 2feb144

Please sign in to comment.