Commit Graph

1006 Commits

Author SHA1 Message Date
Dan Gohman
865a3d9f31 Rename wasmstandalone::StandaloneRuntime to wasmstandalone::Runtime. 2017-10-03 13:01:31 -07:00
Dan Gohman
db88701eaa Use Self. 2017-10-03 12:54:35 -07:00
Dan Gohman
97b877bb9c Use Option::unwrap_or_else. 2017-10-03 12:53:28 -07:00
Dan Gohman
d4438f4006 Drop an unneeded dependency. 2017-10-03 12:48:33 -07:00
Dan Gohman
6c4bbc643c Set the faerie target based on the cretonne target. 2017-10-03 12:39:52 -07:00
Dan Gohman
a68b2619bd Sniff the wasm magic bytes, rather than relying on the filename extension. 2017-10-03 12:23:59 -07:00
Dan Gohman
e5ed1517ce Fix the command name in the usage message. 2017-10-03 12:21:09 -07:00
Dan Gohman
324a395a95 Make the "wat2wasm" error message not panic. 2017-10-03 12:20:37 -07:00
Dan Gohman
cad7e50106 Update to wasmparser 0.11.2. 2017-10-03 12:18:18 -07:00
Dan Gohman
5b0a083124 Avoid unnecessary BufReaders. 2017-10-03 06:56:23 -07:00
Dan Gohman
e64eb79aaf Fix dependency paths. wasmstandalone no longer depends on out-of-tree patches. 2017-09-23 15:38:38 -07:00
Dan Gohman
666d565fd4 Clean up unused imports. 2017-09-23 15:38:38 -07:00
Dan Gohman
0c78a2f298 Import the wasm2obj experiment and minimally update it. 2017-09-23 15:38:38 -07:00
Dan Gohman
06f0b00c2d Add an assert on an implemented feature rather than letting it silently fail. 2017-09-22 16:26:43 -07:00
Dan Gohman
64d596005c Reduce the extent of unsafe code. 2017-09-22 16:21:25 -07:00
Dan Gohman
ecd746718b Remove comments about manually saving callee-saved registers.
Even though Cretonne doesn't implement callee-saved registers yet,
it will, so we shouldn't need manual save/restore code when calling it.
2017-09-22 16:17:08 -07:00
Dan Gohman
4c5f584d01 Use debug_assert_eq! where applicable. 2017-09-22 16:13:04 -07:00
Dan Gohman
b583d75c7a Fix redundant borrows. 2017-09-22 16:11:11 -07:00
Dan Gohman
382415ed0c Fix a useless format!. 2017-09-22 16:09:10 -07:00
Dan Gohman
b89277d9ce Rename "wast" to "wat". 2017-09-22 15:57:32 -07:00
Dan Gohman
cdffc1b50a Roughly update for the recent Cretonne API changes.
Everything builds and simple modules run, though there's still lots more
to do.
2017-09-22 15:56:18 -07:00
Dan Gohman
b3a952ed67 Change the license to MIT/Apache-2.0. 2017-09-15 09:58:09 -07:00
Dan Gohman
73f5adb19d Clippy cleanups. 2017-09-06 09:56:14 -07:00
Dan Gohman
cb7e66d12a Fix missing documentation comment. 2017-09-06 09:19:34 -07:00
Dan Gohman
6c80e81c6c Remove trivial numeric casts. 2017-09-06 09:18:18 -07:00
Dan Gohman
54a3f1fcd4 Fix redundant qualification. 2017-09-06 08:59:10 -07:00
Dan Gohman
6c30cf8f00 Enable deny(missing_docs) in the wasmstandalone library. 2017-09-06 08:54:30 -07:00
Dan Gohman
3868467917 Format with rustfmt 0.9.0. 2017-09-06 08:37:12 -07:00
Dan Gohman
d0fe50a2a8 Check in the wasmstandalone code.
This is based on the code in https://github.com/denismerigoux/cretonne/commits/wasm2cretonne
before wasmstandalone was removed, with minor updates for the new library structure.
It is not yet updated for the latest cretonne API changes.
2017-09-05 17:06:51 -07:00
Dan Gohman
8f6957296e Merge commit '051bc08d23df0930be5e959645c50dd0cdf411d4' 2017-08-29 07:12:47 -07:00
Dan Gohman
344fbed77a Initial commit 2017-08-29 07:01:55 -07:00
Denis Merigoux
051bc08d23 Added description and license to Cargo.toml 2017-08-11 15:49:47 -07:00
Denis Merigoux
727f297ba9 Bugfix: wrong jump arguments for br_if to loops 2017-08-11 13:50:41 -07:00
Denis Merigoux
5fc61bd6f6 Added Fibonacci test case 2017-08-11 11:10:21 -07:00
Denis Merigoux
dfdab56a54 Integrated wasm test suite translation as cretonne test 2017-08-10 16:30:09 -07:00
Denis Merigoux
234e72a5b3 Dumped code from the wasm2cretonne repo 2017-08-10 16:05:04 -07:00
Jakob Stoklund Olesen
378e7cfe6b Switch branch relaxation to a FuncCursor. 2017-08-04 16:00:48 -07:00
Jakob Stoklund Olesen
6f024267c6 Add a FuncCursor type to the cursor library.
A FuncCursor works a like a layout cursor, but it holds a reference to
the entire function and lets you re-borrow the function reference.

Rewrite the dominator tree unit tests with a FuncCursor instead of a
layout cursor to demonstrate the difference. It avoids the constrained
lifetimes of the layout cursor in the tests.
2017-08-04 15:31:08 -07:00
Jakob Stoklund Olesen
8b2f5c418b Use EncCursor for reload.rs.
Same deal as for spilling. Place an EncCursor in the context and use
that to reference into the IR function when necessary.
2017-08-04 15:02:46 -07:00
Jakob Stoklund Olesen
3eb80fde15 Use EncCursor in regalloc/spilling.rs
Use an EncCursor instead of a layout cursor to keep track of the
current position in the function. Since the EncCursor holds a reference
to the whole IR function insteadof just the layout, we can rework how IR
borrowing works.

The Context data structure that's live during the spilling pass now owns
an EncCursor which in turn holds references to the function and ISA.
This means that we no longer need to pass around references to parts of
the ir::Function. We can no longer borrow any part of the IR function
across a context method call, but that turns out to be not necessary.
2017-08-04 14:13:56 -07:00
Jakob Stoklund Olesen
0ab1976231 Cursor library.
Add a new cursor module and define an EncCursor data type in it. An
EncCursor is a cursor that inserts instructions with a valid encoding
for the ISA. This is useful for passes generating code after
legalization.

Implement a builder interface via the new InstInserterBase trait such
that the EncCursor builders support with_result().

Use EncCursor in coalescing.rs instead of the layout cursor as a proof
of concept.
2017-08-04 14:05:14 -07:00
Jakob Stoklund Olesen
ff39458f96 Reorganize the instruction builder traits.
Leave the primary InstBuilderBase trait alone, but add an alternative
InstInserterBase trait that can be implemented instead by builders that
always allocate new instructions with dfg.make_inst().

Any implementation of InstInserterBase can be used as an instruction
builder by wrapping it in an InsertBuilder. The InsertBuilder type adds
additional functionality via the with_results() method which makes it
possible to override the result values on the instruction that is built.

The motivation for this shuffle is that the with_result() functionality
can now be reused by different kinds of instruction builders, as long as
they insert new instructions. So ReplaceBuilder doesn't get
with_results().
2017-08-04 11:56:03 -07:00
Jakob Stoklund Olesen
019e5dd894 Add CursorBase builder methods.
The CursorBase::at_* are convenience methods for building a cursor that
points to a specific instruction.
2017-08-04 09:08:24 -07:00
Jakob Stoklund Olesen
78db5b3715 Move most Cursor methods into a CursorBase trait.
The Cursor navigation methods all just depend on the cursor's position
and layout reference. Make a CursorBase trait that provides access to
this information with methods and implement the navigation methods on
top of that.

This makes it possible to have multiple types implement the cursor
interface.
2017-08-04 09:08:24 -07:00
Jakob Stoklund Olesen
81ff9bac72 Avoid evaluating dbg!() arguments in a closure.
The dbg!() macro should behave like a function call in how it evaluates
its arguments, and captures by Rust closures are not fully compatible
with path-specific borrowing. Specifically:

    let borrow = &mut obj.foo;
    dbg!("{}", obj.bar);

would fail because the closure inside dbg!() would borrow all of obj
instead of just obj.foo.

Fix this by using the format_args!() macro to evaluate the dbg!()
arguments and produce an fmt::Arguments object which can be safely
passed to the thread-local closure for printing.

The arguments are still evaluated inside an if { .. } which
constant-folds away in release builds.
2017-08-04 08:54:00 -07:00
Denis Merigoux
e0fd5252d5 Added partial recompute of dominator tree in case of Ebb splitting (#135)
* Partial recompute for dominator tree in case of ebb splitting
Implemented via striding in RPO numbers
2017-08-03 18:26:41 -07:00
Jakob Stoklund Olesen
d591b38b37 Add a prologue_epilogue() hook to TargetIsa.
This will compute the stack frame layout as appropriate for the
function's calling convention and insert prologue and epilogue code.

The default implementation is not useful, each target ISA will need to
override this function.
2017-08-03 13:48:30 -07:00
Jakob Stoklund Olesen
f82004e3c0 Move the stack layout computation into its own module.
This is trying to keep algorithms out if the ir module which deals with
the intermediate representation.

Also give the layout_stack() function a Result return value so it can
report a soft error when the stack frame is too large instead of
asserting. Since local variables can be arbitrarily large, it is easy
enough to overflow the stack with even a small function.
2017-08-03 13:31:58 -07:00
Jakob Stoklund Olesen
7f3b807597 Add a calling convention to all function signatures.
A CallConv enum on every function signature makes it possible to
generate calls to functions with different calling conventions within
the same ISA / within a single function.

The calling conventions also serve as a way of customizing Cretonne's
behavior when embedded inside a VM. As an example, the SpiderWASM
calling convention is used to compile WebAssembly functions that run
inside the SpiderMonkey virtual machine.

All function signatures must have a calling convention at the end, so
this changes the textual IL syntax.

Before:

    sig1 = signature(i32, f64) -> f64

After

    sig1 = (i32, f64) -> f64 native
    sig2 = (i32) spiderwasm

When printing functions, the signature goes after the return types:

    function %r1() -> i32, f32 spiderwasm {
    ebb1:
        ...
    }

In the parser, this calling convention is optional and defaults to
"native". This is mostly to avoid updating all the existing test cases
under filetests/. When printing a function, the calling convention is
always included, including for "native" functions.
2017-08-03 11:40:24 -07:00
Aleksey Kuznetsov
bf1820587c Apply conditional compilation of isa targets 2017-08-03 06:28:16 -07:00