Commit Graph

9255 Commits

Author SHA1 Message Date
Chris Fallin
a412cce615 Infallible extractors, and some fixes to fallibility in return types (Option<T> vs T). 2021-11-11 15:56:55 -08:00
Chris Fallin
6daa55af82 Initial draft of DSL semantics complete.
This latest refactor adds "extractor macros" in place of the
very-confusing-even-to-the-DSL-author reverse-rules-as-extractors
concept. It was beautifully symmetric but also just too mind-bending to
be practical.

It also adds argument polarity to external extractors. This is inspired
by Prolog's similar notion (see e.g. the "+x" vs. "-x" argument notation
in library documentation) where the unification-based semantics allow
for bidirectional flow through arguments. We don't want polymorphism
or dynamism w.r.t. directions/polarities here; the polarities are
static; but it is useful to be able to feed values *into* an extractor
(aside from the one value being extracted). Semantically this still
correlates to a term-rewriting/value-equivalence world since we can
still translate all of this to a list of equality constraints.

To make that work, this change also adds expressions into patterns,
specifically only for extractor "input" args. This required quite a bit
of internal refactoring but is only a small addition to the language
semantics.

I plan to build out the little instruction-selector sketch further but
the one that is here (in `test3.isle`) is starting to get interesting
already with the current DSL semantics.
2021-11-11 15:56:55 -08:00
Chris Fallin
1ceef04680 (and ...) combinator in patterns 2021-11-11 15:56:55 -08:00
Chris Fallin
602b8308ce More work on sketch for isel and some TODO items derived from it. 2021-11-11 15:56:55 -08:00
Chris Fallin
d725ac13b2 Codegen: parameterize on a generated Context trait that contains external ctors/etors. 2021-11-11 15:56:55 -08:00
Chris Fallin
3ccbaf0f69 Generate match {} statements by merging adjacent MatchVariant trie edges. 2021-11-11 15:56:55 -08:00
Chris Fallin
ed4c857082 Priority-trie: merge edges with different priorities into ranges when possible. 2021-11-11 15:56:55 -08:00
Chris Fallin
7865191093 Update long block comment describing priority trie in codegen.rs. 2021-11-11 15:56:55 -08:00
Chris Fallin
b8e916a0ab Another example, testing rule priorities a bit 2021-11-11 15:56:55 -08:00
Chris Fallin
bc91a4e5f6 Add TODO 2021-11-11 15:56:55 -08:00
Chris Fallin
4a2cd78827 Working example and README 2021-11-11 15:56:55 -08:00
Chris Fallin
d7efd9f219 Working extractor and constructor generation from rules! 2021-11-11 15:56:55 -08:00
Chris Fallin
be1140e80a WIP. 2021-11-11 15:56:55 -08:00
Chris Fallin
cd55dc9568 WIP. 2021-11-11 15:56:55 -08:00
Chris Fallin
e5d76db97a WIP. 2021-11-11 15:56:55 -08:00
Chris Fallin
8c727b175a more codegen WIP: start to generate functions 2021-11-11 15:56:55 -08:00
Chris Fallin
638c9edd01 Support for file input and output, including multiple input files with proper position tracking. 2021-11-11 15:56:55 -08:00
Chris Fallin
e9a57d854d Generate internal enum types. 2021-11-11 15:56:54 -08:00
Chris Fallin
5aa72bc060 skeleton for codegen 2021-11-11 15:56:54 -08:00
Chris Fallin
02ec77a45b trie insertion 2021-11-11 15:56:54 -08:00
Chris Fallin
77ed861857 Start of significant rework: compile to a trie, not an FSM, and handle rule priorities appropriately.
See long block comment in codegen.rs. In brief, I think we actually want
to compile to a trie with priority-intervals, a sort of hybrid of a
priority tree and a trie representing decisions keyed on match-ops
(PatternInsts).

The reasons are:

1. The lexicographic ordering that is fundamental to the FSM-building in
   the Peepmatic view of the problem is sort of fundamentally limited
   w.r.t. our notion of rule priorities. See the example in the block
   comment.

2. While the FSM is nice for interpreter-based execution, when compiling
   to a language with structured control flow, what we really want is a
   tree; otherwise, if we want to form DAGs to share substructure, we
   need something like a "diamond-recovery" algorithm that finds common
   suffixes of *input match-op sequences*, and then we need to
   incorporate something like phi-nodes in order to allow captures from
   either side of the diamond to be used.

3. One of the main advantages of the automaton/transducer approach,
   namely sharing suffixes of the *output* sequence (emitting partial
   output at each state transition), is unfortunately not applicable if
   we allow the overall function to be partial. Otherwise, there is
   always the possibility that we fail at the last match op, so we
   cannot allow any external constructors to be called until we reach
   the final state anyway.

4. Pragmatically, I found I was having to significantly edit the
   peepmatic_automata implementation to adapt to this use-case
   (compilation to Rust), and it seemed more practical to design the
   data structure we want than to try to shoehorn the existing thing
   into the new problem.

WIP, hopefully working soon.
2021-11-11 15:56:54 -08:00
Chris Fallin
f2399c5384 WIP -- more thinking about how to work priorities into FSM 2021-11-11 15:56:54 -08:00
Chris Fallin
6a567924cd WIP 2021-11-11 15:56:54 -08:00
Chris Fallin
e08160845e WIP: rip out a bunch of stuff and rework 2021-11-11 15:56:54 -08:00
Chris Fallin
84b7612b98 Initial public commit of ISLE prototype DSL compiler. 2021-11-11 15:56:54 -08:00
Alex Crichton
f7543d3d10 Update docs of Module::serialize (#3448)
The docs hadn't been updated since `Module::deserialize` was added!
2021-10-12 09:47:12 -05:00
bjorn3
b2d9faa472 Slightly simplify build script 2021-10-12 15:12:26 +02:00
bjorn3
b0b8c1edbf Remove default_map 2021-10-12 15:12:26 +02:00
bjorn3
6b32fcfcea Remove Constraint 2021-10-12 15:12:26 +02:00
bjorn3
466a446f8c Remove OpcodeNumber 2021-10-12 15:12:26 +02:00
bjorn3
99114547be Remove clobbers_all_regs 2021-10-12 15:12:26 +02:00
bjorn3
e8b18b58a1 Remove is_ghost 2021-10-12 15:12:26 +02:00
bjorn3
a05bf2bf42 Remove instructions necessary for the old regalloc 2021-10-12 14:37:36 +02:00
bjorn3
1fd491dadd Remove fallthrough instruction 2021-10-12 14:22:07 +02:00
bjorn3
5b24e117ee Remove instructions used by old br_table legalization 2021-10-12 14:18:52 +02:00
Chris Fallin
783bb1f759 Merge pull request #3443 from adv-sw/main
Fixes (indirectly) #3419 by providing debugger with ability to resolve sandbox pointers
2021-10-11 13:37:04 -07:00
Chris Fallin
5c2a629871 Merge pull request #2455 from Hywan/feat-cranelift-codegen-re-export-gimli
feat(cranelift-codegen) Re-export `gimli` when `unwind` feature is enabled
2021-10-11 13:09:16 -07:00
Steve
4975bf8b62 Merge branch 'main' of https://github.com/adv-sw/wasmtime 2021-10-11 19:58:18 +01:00
Steve
807619a874 as requested: cargo fmt 2021-10-11 19:57:07 +01:00
Pat Hickey
8554d69e4b update userfaultfd to 0.4.1 (#3442)
which updates nix to 0.23.0, getting rid of the benign RUSTSEC-2021-0119
in our dep tree
2021-10-11 13:06:54 -05:00
Alex Crichton
713ce07d35 Add some debug logging for timing in module compiles (#3417)
* Add some debug logging for timing in module compiles

This is sometimes helpful when debugging slow compiles from fuzz bugs or
similar.

* Fix total duration calculation to not double-count
2021-10-11 12:50:15 -05:00
Advance Software
8194c3a2a1 Merge branch 'bytecodealliance:main' into main 2021-10-11 18:47:02 +01:00
Pat Hickey
3d8253beb5 Merge pull request #3433 from bjorn3/stackslot_remove_dead_code
Remove a lot of dead code from the stackslot module
2021-10-11 10:34:22 -07:00
Chris Fallin
ee60a361e9 Merge pull request #3440 from cfallin/wasmtime-meeting-20211014
Add Wasm EH discussion (#3427) to Wasmtime meeting agenda for 2021-10-14.
2021-10-11 09:54:23 -07:00
Chris Fallin
92eb210ff7 Add Wasm EH discussion (#3427) to Wasmtime meeting agenda for 2021-10-14. 2021-10-11 09:52:08 -07:00
bjorn3
3f87b768d5 Update filetests 2021-10-11 17:44:21 +02:00
bjorn3
a894594ae5 Update parser 2021-10-11 16:41:45 +02:00
bjorn3
20463d60f3 Replace StackSlots struct with a type alias 2021-10-11 16:41:45 +02:00
bjorn3
fd59a3e045 Remove all unused stackslot handling code 2021-10-11 16:41:45 +02:00
Steve
92a10d1ace Added resolve_vmctx_memory function to enable debuggers to resolve sandbox pointers - required because sandbox 'this' pointer cannot be resolved by lldb any other way as lldb expects "this" and "self" to be standard pointers, not sandbox handles. 2021-10-11 09:08:14 +01:00