Commit Graph

18 Commits

Author SHA1 Message Date
Dan Gohman
caa87048ab Wasmtime 0.18.0 and Cranelift 0.65.0. 2020-06-11 17:49:56 -07:00
Dan Gohman
a76639c6fb Wasmtime 0.17.0 and Cranelift 0.64.0. (#1805) 2020-06-02 18:51:59 -07:00
Nick Fitzgerald
d5bdce99c7 Remove executable bit from Rust source files 2020-06-01 15:09:51 -07:00
Alex Crichton
caada922e8 Disable tests for the peepmatic-macro crate
I'm not actually sure that it's possible to write `#[test]` in a
`proc-macro` crate. Regardless I don't think it's too too conventional,
so let's disable this for now.

Closes #1775
2020-05-28 07:07:32 -07:00
Nick Fitzgerald
9d2100e54a Limit the size of automaton keys in the peepmatic_simple_automata fuzz target
Fixes https://oss-fuzz.com/testcase-detail/5742905129172992
2020-05-19 09:12:50 -07:00
Nick Fitzgerald
28d6df0db6 Limit the size of automaton keys in the peepmatic_fst_diff fuzz target (#1724)
This should avoid timeouts caused by large keys.

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=22251
2020-05-18 21:27:00 -05:00
Nick Fitzgerald
e9ef8ea3d5 peepmatic: remove unused member from PeepholeOptimizer
This is dead code, left over from an earlier design.
2020-05-14 11:08:59 -07:00
Nick Fitzgerald
8d7ed0fd13 deps: Update wast to 15.0.0
This also updates `wat` in the lockfile so that the SIMD spec tests are passing
again.
2020-05-14 07:52:23 -07:00
Nick Fitzgerald
22a070ed4f peepmatic: Apply some review suggestions from @bjorn3 2020-05-14 07:52:23 -07:00
Nick Fitzgerald
fd4f08e75f peepmatic: rustfmt 2020-05-14 07:52:23 -07:00
Nick Fitzgerald
eb2dab0aa4 peepmatic: Save RHS actions as a boxed slice, not vec
A boxed slice is only two words, while a vec is three words. This should cut
down on the memory size of our automata and improve cache usage.
2020-05-14 07:52:23 -07:00
Nick Fitzgerald
210b036320 peepmatic: Represent various id types with u16
These ids end up in the automaton, so making them smaller should give us better
data cache locality and also smaller serialized sizes.
2020-05-14 07:52:23 -07:00
Nick Fitzgerald
469104c4d3 peepmatic: Make the results of match operations a smaller and more cache friendly 2020-05-14 07:52:23 -07:00
Nick Fitzgerald
1a7670f964 peepmatic: Introduce the peepmatic-fuzzing crate
This crate contains oracles, generators, and fuzz targets for use with fuzzing
engines (e.g. libFuzzer). This doesn't contain the actual
`libfuzzer_sys::fuzz_target!` definitions (those are in the `peepmatic-fuzz`
crate) but does those definitions are one liners calling out to functions
defined in this crate.
2020-05-14 07:50:58 -07:00
Nick Fitzgerald
2828da1f56 peepmatic: Introduce the peepmatic-test crate
This crate provides testing utilities for `peepmatic`, and a test-only
instruction set we can use to check that various optimizations do or don't
apply.
2020-05-14 07:50:58 -07:00
Nick Fitzgerald
197a9e88cb peepmatic: Introduce the peepmatic-runtime crate
The `peepmatic-runtime` crate contains everything required to use a
`peepmatic`-generated peephole optimizer.

In short: build times and code size.

If you are just using a peephole optimizer, you shouldn't need the functions
to construct it from scratch from the DSL (and the implied code size and
compilation time), let alone even build it at all. You should just
deserialize an already-built peephole optimizer, and then use it.

That's all that is contained here in this crate.
2020-05-14 07:50:58 -07:00
Nick Fitzgerald
0f03a97475 peepmatic: Introduce the peepmatic-macro crate
This crate provides the derive macros used by `peepmatic`, notable AST-related
derives that enumerate child AST nodes, and operator-related derives that
provide helpers for type checking.
2020-05-14 07:50:58 -07:00
Nick Fitzgerald
c82326a1ae peepmatic: Introduce the peepmatic-automata crate
The `peepmatic-automata` crate builds and queries finite-state transducer
automata.

A transducer is a type of automata that has not only an input that it
accepts or rejects, but also an output. While regular automata check whether
an input string is in the set that the automata accepts, a transducer maps
the input strings to values. A regular automata is sort of a compressed,
immutable set, and a transducer is sort of a compressed, immutable key-value
dictionary. A [trie] compresses a set of strings or map from a string to a
value by sharing prefixes of the input string. Automata and transducers can
compress even better: they can share both prefixes and suffixes. [*Index
1,600,000,000 Keys with Automata and Rust* by Andrew Gallant (aka
burntsushi)][burntsushi-blog-post] is a top-notch introduction.

If you're looking for a general-purpose transducers crate in Rust you're
probably looking for [the `fst` crate][fst-crate]. While this implementation
is fully generic and has no dependencies, its feature set is specific to
`peepmatic`'s needs:

* We need to associate extra data with each state: the match operation to
  evaluate next.

* We can't provide the full input string up front, so this crate must
  support incremental lookups. This is because the peephole optimizer is
  computing the input string incrementally and dynamically: it looks at the
  current state's match operation, evaluates it, and then uses the result as
  the next character of the input string.

* We also support incremental insertion and output when building the
  transducer. This is necessary because we don't want to emit output values
  that bind a match on an optimization's left-hand side's pattern (for
  example) until after we've succeeded in matching it, which might not
  happen until we've reached the n^th state.

* We need to support generic output values. The `fst` crate only supports
  `u64` outputs, while we need to build up an optimization's right-hand side
  instructions.

This implementation is based on [*Direct Construction of Minimal Acyclic
Subsequential Transducers* by Mihov and Maurel][paper]. That means that keys
must be inserted in lexicographic order during construction.

[trie]: https://en.wikipedia.org/wiki/Trie
[burntsushi-blog-post]: https://blog.burntsushi.net/transducers/#ordered-maps
[fst-crate]: https://crates.io/crates/fst
[paper]: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.24.3698&rep=rep1&type=pdf
2020-05-14 07:50:58 -07:00