Commit Graph

11145 Commits

Author SHA1 Message Date
Dan Gohman
f90e7ade86 Enable the cretonne verifier by default in debug builds. 2017-10-05 18:01:27 -07:00
Dan Gohman
c39cba4ae0 Start experimenting with cargo fuzz. This isn't very usable yet. 2017-10-05 18:00:54 -07:00
Jakob Stoklund Olesen
b562fdcd5c Remove the dfg::resolve_copies() method.
This method was important back when result values couldn't be moved
between instructions. Now that results can be moved, value aliases do
everything we need.

Copy instructions are still used to break interferences in the register
allocator's coalescing phase, but there isn't really any reason to use a
copy instruction over a value alias anywhere else.

After and during register allocation, copy instructions are significant,
so we never want to "see through" them like the resolve_copies()
function did.

This is related to #166, but probably doesn't fix the underlying
problem.
2017-10-05 14:46:34 -07:00
Jakob Stoklund Olesen
30aeb57083 Add a value location verifier.
This is a verification pass that can be run after register allocation.
It verifies that value locations are consistent with constraints on
their uses, and that the register diversions are consistent.

Make it clear that register diversions are local to an EBB only. This
affects what branch relaxation is allowed to do.

The verify_locations() takes an optional Liveness parameter which is
used to check that no diverted values are live across CFG edges.
2017-10-05 13:59:18 -07:00
Dan Gohman
e4ef2cbf22 Support ISA-specific settings in the --isa command-line option. 2017-10-05 10:06:40 -07:00
Dan Gohman
9f7d0a659c Use VmCtx arg for globals, and a global for the heap.
This replaces the ReservedReg strategy, and is more flexible.
2017-10-05 09:01:38 -07:00
Dan Gohman
b5732bc200 On error, always print the error message and exit with non-zero status. 2017-10-05 08:49:32 -07:00
Jakob Stoklund Olesen
73d4bb47c0 Intel encodings for regspill and regfill.
These are always SP-based.
2017-10-04 17:02:09 -07:00
Jakob Stoklund Olesen
826d4062fb Apply register diversions during binemit tests.
When "binemit" tests encode instructions, keep track of the current set
of register diversions, and use the diverted locations to check operand
constraints.

This matches how constraints are applied during a real binemit phase.
2017-10-04 17:02:09 -07:00
Jakob Stoklund Olesen
dda3efcbdd Add regspill and regfill instructions.
These are parallels to the existing regmove instruction, but the divert
the value to and from a stack slot.

Like regmove diversions, this is a temporary diversion that must be
local to the EBB.
2017-10-04 17:02:09 -07:00
Jakob Stoklund Olesen
d4aeec6ece Generalize RegDiversions to track stack locations too.
For emergency spilling, we need to be able to temporarily divert an SSA
value to a stack slot if there are no available registers.
2017-10-04 17:02:09 -07:00
Jakob Stoklund Olesen
e32aa8ab60 Emergency spilling for the solver's move scheduler.
The register constraint solver schedules a set of move instructions to
execute before the instruction getting colored. In extreme cases, this
is not possible because there are no available registers to break cycles
in the register assignments that must be scheduled.

When that happens, we spill one register to an emergency slot so it
becomes available for implementing the assignment cycle. Then the
original register is restored.

The coloring pass can't yet understand the spill and fill move types.
This will be implemented next.
2017-10-04 17:02:09 -07:00
Jakob Stoklund Olesen
ce4d723a73 Give RegClassData a reference to its parent RegInfo.
This makes it possible to materialize new RegClass references without
requiring a RegInfo reference to be passed around.

- Move the RegInfo::toprc() method to RegClassData.
- Rename RegClassData::intersect() to intersect_index() and provide a
  new intersect() which returns a register class.
- Remove some &RegInfo parameters that are no longer needed.
2017-10-04 17:02:09 -07:00
Dan Gohman
7410ddfe08 Use the WasmRuntime's signature list rather than keeping a separate list.
This way, if the runtime modifies the signature, such as to add special
arguments, they are reflected in the resulting function defintions.
2017-10-04 16:57:39 -07:00
Dan Gohman
196795017b Tidy up handling of the DummyRuntime. 2017-10-04 16:57:39 -07:00
Dan Gohman
c8e015f31a Remove an unused argument. 2017-10-04 12:32:45 -07:00
Dan Gohman
fc857a758e Remove an unneeded block. 2017-10-04 12:22:32 -07:00
Dan Gohman
b4e7e918cc Use the correct index for printing function definitions when imports are present. 2017-10-04 12:22:07 -07:00
Dan Gohman
23bafd1218 Split the runtime and execution code into separate crates. 2017-10-03 14:57:52 -07:00
Jakob Stoklund Olesen
fb0999ce33 Check the top-level register class for available registers.
Fixes #165.

The constraint solver's schedule_move() function sometimes need to use
an extra available register when the moves to be scheduled contains
cycles.

The pending moves have associated register classes that come from the
constraint programming. Since the moves have hard-coded to and from
registers, these register classes are only meant to indicate the
register sizes. In particular, we can use the whole top-level register
class when scavenging for a spare register to break a cycle.
2017-10-03 14:12:18 -07:00
Dan Gohman
6ded83332f Change the reloc sink to use vectors instead of hash maps. 2017-10-03 14:02:41 -07:00
Jakob Stoklund Olesen
739d414d18 Convert regalloc::coloring to use an EncCursor.
No functional change intended, this is just a big fight with the borrow
checker.
2017-10-03 13:39:43 -07:00
Jakob Stoklund Olesen
7c023b2430 Don't omit the controlling typevar for instructions without results.
The controlling type variable passed to the format constructor in the
InstBuilder trait is not just used to generate the result values. In an
EncCursor, it is also used to encode the instruction, so VOID doesn't
work.
2017-10-03 13:39:43 -07:00
Dan Gohman
412fedcc6d Fix reseting of the heap when compiling a module containing multiple functions. 2017-10-03 13:30:12 -07:00
Jakob Stoklund Olesen
e10b3117cb Rename enc_flt() to enc_both().
This encoding method is not only used for floating point instructions.
2017-10-03 13:27:00 -07:00
Dan Gohman
31a962fa1b Support multiple globals. 2017-10-03 13:25:37 -07:00
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
Jakob Stoklund Olesen
c091a695e6 Fix coalescer bug exposed by the gvn-unremovable-phi test.
When we detect interference between the values that have already been
merged into the candidate virtual register and an EBB argument, we first
try to resolve the conflict by splitting. We also check if the existing
interfering value is fundamentally incompatible with the branch
instruction so it needs to be removed from the virtual register,
restarting the merge operation.

However, this existing interfering value is not necessarily the only
interference, so the split is not guaranteed to resolve the conflict. If
it turns out that splitting didn't resolve the conflict, restart the
merge after removing this second conflicting value.
2017-10-03 11:13:46 -07:00
Jakob Stoklund Olesen
ef048b8899 Allow for call args in incoming stack slots.
A value passed as an argument to a function call may live in an incoming
stack slot initially. Fix the call legalizer so it copies such an
argument into the expected outgoing stack slot for the call.
2017-10-03 11:13:46 -07:00
Dan Gohman
374ed3a07b Fix dominator-tree queries on unreachable nodes. 2017-10-03 11:03:06 -07:00
Dan Gohman
d585f09423 Don't silently swallow lexer errors. 2017-10-03 10:05:46 -07:00
Dan Gohman
d857aacec3 Sniff the wasm magic bytes, rather than relying on the filename extension. 2017-10-03 09:43:37 -07:00
Dan Gohman
ba14499fe9 Factor out the code for reading a file into a utility function. 2017-10-03 09:43:30 -07:00
Dan Gohman
f064418652 Refactor set/isa parsing into a utility function. 2017-10-03 09:43:27 -07:00
Dan Gohman
12ab4cd914 Add a cton-util compile command. 2017-10-03 09:42:50 -07:00
Dan Gohman
7c7b1651d8 Do a full compile in 'cton-util wasm'.
This removes the `optimize` option, as one can do that with
`--set`, eg. `--set opt_level=best`. And it adds an option to
print the compilation output.

And, it enables simple_gvn and licm for opt_level=best.
2017-10-03 09:39:07 -07:00
Dan Gohman
25b8b45a41 Avoid unnecessary BufReaders. 2017-10-03 09:34:41 -07:00
Dan Gohman
eba55cb1da Make the "wat2wasm" error message not panic. 2017-10-03 09:31:42 -07:00
Dan Gohman
1efa670f60 Do a full compile in 'cton-util wasm'.
This removes the `optimize` option, as one can do that with
`--set`, eg. `--set opt_level=best`. And it adds an option to
print the compilation output.
2017-10-03 09:30:45 -07:00
Dan Gohman
5b0a083124 Avoid unnecessary BufReaders. 2017-10-03 06:56:23 -07:00
Jakob Stoklund Olesen
3a34c35f95 Don't swap the arguments to the select instruction.
Both WebAssembly and Cretonne use true-value, false-value.
2017-10-02 14:43:30 -07:00
Jakob Stoklund Olesen
5f56f81251 Resolve all value aliases when computing live ranges.
Value aliases are only in the way during register allocation, so make
sure they are all dead as we enter the register allocation passes.
2017-09-29 15:54:06 -07:00