Commit Graph

89 Commits

Author SHA1 Message Date
Benjamin Bouvier
5f3cd868cd [wasm] Rename native_pointer() to pointer_type() to make it more apparent it's a type; 2018-07-20 13:11:36 -07:00
Dan Gohman
f4dbd38a4c Rename Cretonne to Cranelift! 2018-07-13 09:15:16 -07:00
Benjamin Bouvier
25508ac66e [clippy] Pass more types by value;
wasmparser::Type is an enum, and there was one Location I missed.
2018-07-11 13:47:25 -07:00
Benjamin Bouvier
bea843519c [clippy] Return explicit unit values; 2018-07-11 13:47:25 -07:00
Dan Gohman
7a55a107ae Say "Global Variable" when referring to the WebAssembly concept.
This helps avoid confusion between wasm global variables and cretonne
global values.
2018-07-02 08:05:01 -07:00
Lachlan Sneff
5c320a0d30 Change GlobalVar to GlobalValue 2018-06-15 18:33:30 -07:00
Dan Gohman
c506f4cf6b Use WasmError::Unsupported rather than panic for unsupported extensions. 2018-06-15 08:38:40 -07:00
Dan Gohman
c03d67a4ff Update for wasm memory instruction renaming.
The wasm spec renamed `grow_memory` and `current_memory` to
`memory.grow` and `memory.size`, respectively. Update cretonne's names
to follow.

Also, update to wasmparser 0.17.0, which also renames its corresponding
operators.
2018-06-12 05:02:25 -07:00
Dan Gohman
eb94664285 Add assertions to check translate_call and translate_call_indirect.
Assert that the results produced by translate_call and
translate_call_indirect match the results of the call signatures.
2018-06-05 09:21:23 -07:00
Dan Gohman
a1fe0f82e1 Update to the latest stable rustfmt, 0.4.2-stable (febbb36 2018-04-12). 2018-05-29 10:37:38 -07:00
Dan Gohman
6b88cd44a8 Update to rustfmt-preview (#348)
* Update to rustfmt-preview.

* Run "cargo fmt --all" with rustfmt 0.4.1.

rustfmt 0.4.1 is the latest release of rustfmt-preview available on the
stable channel.

* Fix a long line that rustfmt 0.4.1 can't handle.

* Remove unneeded commas left behind by rustfmt.
2018-05-25 11:38:38 -07:00
Dan Gohman
89e7d56120 Allow wasm embedders to reject wasm modules with unsupported features. (#345)
Define `WasmError` (and an accompanying `WasmResult`) to represent
errors translating WebAssembly functions. Make `translate_call` and
related functions return `WasmResult`s so that embedders have the
flexibility to reject features they don't support.

Move `InvalidInput` out of `CtonError` and into `WasmError`, where it's
now named `InvalidWebAssembly`, as it's a WebAssembly-specific error
condition. Also extend it to preserve the original error message and
bytecode offset.
2018-05-21 20:49:19 -07:00
Dan Gohman
bf597b7abf Enable and fix several more clippy lints. 2018-04-17 17:05:03 -07:00
Dan Gohman
24fa169e1f Rename the 'cretonne' crate to 'cretonne-codegen'.
This fixes the next part of #287.
2018-04-17 09:46:56 -07:00
Dan Gohman
7767186dd0 Rename 'cton_*' library names to match the 'cretonne_*' crate names.
This renames `cton_frontend` to `cretonne_frontend` and so on.

This fixes the first part of #287.
2018-04-17 07:55:59 -07:00
Dan Gohman
c50675deb8 Format with nightly rustfmt-preview, then with rustfmt-0.9 again. 2018-03-30 13:23:47 -07:00
Dan Gohman
8d5fecd324 Format with stable rustfmt-preview, then with rustfmt-0.9 again. 2018-03-30 13:17:15 -07:00
Dan Gohman
4af95e37a6 Convert regular comments to documentation comments. 2018-03-28 22:48:30 -07:00
Dan Gohman
57cd69d8b4 Say "IR" instead of "IL".
While the specifics of these terms are debatable, "IR" generally
isn't incorrect in this context, and is the more widely recognized
term at this time.

See also the discussion in #267.

Fixes #267.
2018-03-28 22:07:26 -07:00
Dan Gohman
685cde98a4 Mark loads from globals aligned and notrap.
Mark loads from globals generated by cton_wasm or by legalization as
`aligned` and `notrap`, since memory for these globals should be
allocated by the runtime environment for that purpose. This reduces
the number of potentially trapping instructions, which can reduce
the amount of metadata required by embedding environments.
2018-03-26 21:21:54 -07:00
Pat Hickey
03ee007624 Use clippy (#276)
* cton-util: fix some clippy unnecessary pass-by-value warnings

* clippy: ignore too many arguments / cyclomatic complexity in module

since these functions are taking args coming from the command line, i
dont think this is actually a valid lint, morally the arguments are all
from one structure

* cton-util: take care of remaining clippy warnings

* cton-reader: fix all non-suspicious clippy warnings

* cton-reader: disable clippy at site of suspicious lint

* cton-frontend: disable clippy at the site of an invalid lint

* cton-frontend: fix clippy warnings, or ignore benign ones

* clippy: ignore the camelcase word WebAssembly in docs

* cton-wasm: fix clippy complaints or ignore benign ones

* cton-wasm tests: fix clippy complaints

* cretonne: starting point turns off all clippy warnings

* cretonne: clippy fixes, or lower allow() to source of problem

* cretonne: more clippy fixes

* cretonne: fix or disable needless_lifetimes lint

this linter is buggy when the declared lifetime is used for another type
constraint.

* cretonne: fix clippy complaint about Pass::NoPass

* rustfmt

* fix prev minor api changes clippy suggested

* add clippy to test-all

* cton-filetests: clippy fixes

* simplify clippy reporting in test-all

* cretonne: document clippy allows better

* cretonne: fix some more clippy lints

* cretonne: fix clippy lints (mostly doc comments)

* cretonne: allow all needless_lifetimes clippy warnings

remove overrides at the false positives

* rustfmt
2018-03-22 13:10:41 -07:00
Dan Gohman
2b3df1a506 Add use declarations for std features.
Merge the `use` parts of the `no_std` branch. This reduces the diffs
between master and the `no_std` branch, making it easier to maintain.

Most of these changes are derived from patches by @lachlansneff in
https://github.com/Cretonne/cretonne/tree/no_std.
2018-03-20 14:07:05 -07:00
Dan Gohman
f6b8cf86a5 Factor out br_if translation into helper functions. 2018-03-20 13:28:32 -07:00
Dan Gohman
c333a52e3e Factor out fcmp and icmp translation into helper functions. 2018-03-20 13:27:45 -07:00
Dan Gohman
d99b43e4b7 Add a hook to the wasm FuncEnvironment for emitting loop headers.
This will allow wasm implementations that wish to insert code into
every loop, for example to insert an interrupt check or a safepoint.
do so without relying on asynchronous signals.
2018-03-18 14:54:05 -07:00
Dan Gohman
832d9d9a0d Minor code simplification. 2018-03-18 14:54:05 -07:00
Dan Gohman
30f8daa9d6 Replace assert! with debug_assert! in production code paths.
This allows the assertions to be disabled in release builds, so that
the code is faster and smaller, at the expense of not performing the
checks. Assertions can be re-enabled in release builds with the
debug-assertions flag in Cargo.toml, as the top-level Cargo.toml
file does.
2018-03-12 12:38:30 -07:00
Dan Gohman
ad363d7e6b Replace cretonne-wasm's Local with cretonne-frontend's Variable.
Previously, cretonne-wasm used its own Local struct for identifying
local variables. However, now that cretonne-frontend provides a
Variable struct, just use that instead.
2018-03-12 12:38:30 -07:00
Dan Gohman
56c7d85727 More minor code simplifications. 2018-03-09 15:08:54 -08:00
Dan Gohman
55d0efcb14 Pass the wasmparser::Operator by value, simplifying the code. 2018-03-09 15:08:54 -08:00
Dan Gohman
c59e9180de Tidy up whitespace. 2018-03-05 06:55:27 -08:00
Bruce Mitchener
d2d02565fb I64Extend16S should operate on 16 bits, not 8.
This showed up in clippy warnings as the code for this case was
the same as for `I64Extend8S`.
2018-03-05 06:53:13 -08:00
Bruce Mitchener
125270e2b0 Fix some typos. 2018-03-04 21:33:04 -08:00
Dan Gohman
1cf9a8d669 Implement the wasm sign-extension-ops proposal.
https://github.com/WebAssembly/sign-extension-ops/
2018-02-28 12:02:14 -08:00
Dan Gohman
0e22c74085 Track wasm reachability explicitly.
Maintain an explicit "reachable" flag when decoding wasm. Push placeholder
frames on the control-flow stack instead of just maintaining a count of
the stack depth in unreachable code, so that we can whether If blocks
have Elses, and whether block exits are branched to, in all contexts.

Fixes #217.
2018-02-26 15:24:33 -08:00
Dan Gohman
42e1616b82 Update to wasmparser 0.14.1. 2018-02-13 20:14:54 -08:00
Dan Gohman
889b06fd16 Replace as casts with type-conversion functions. 2017-11-08 10:48:44 -08:00
Dan Gohman
b7f979a8be Combine identical match arms. 2017-11-08 10:40:43 -08:00
Dan Gohman
849f090562 Fix nondeterminism in br_table translation. 2017-11-07 15:33:35 -08:00
Dan Gohman
cce2384ede Remove switch_to_block's jump_args argument.
switch_to_block doesn't need its jump_args argument, since jump
arguments are handled by the `jump` instruction and others, rather
than on the switch to a new ebb itself.
2017-11-06 16:38:13 -08:00
Dan Gohman
2d5faa01af Simplify code using the FunctionBuilder helper functions. 2017-10-24 15:28:28 -07:00
Jakob Stoklund Olesen
921bcc6c25 Use the term "EBB parameter" everywhere.
Add EBB parameter and EBB argument to the langref glossary to clarify
the distinction between formal EBB parameter values and arguments passed
to branches.

- Replace "ebb_arg" with "ebb_param" in function names that deal with
  EBB parameters.
- Rename the ValueDef variants to Result and Param.
- A bunch of other small langref fixes.

No functional changes intended.
2017-10-19 16:17:09 -07:00
Dan Gohman
ee0f061ee8 Rename "runtime" to "environment". 2017-10-18 16:55:32 -07:00
Dan Gohman
ac85ba0d68 Update to wasmparser 0.12.1. 2017-10-11 11:33:02 -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
53404a9387 Check for invalid special type constraints.
The extend and reduce instructions have additional type constraints.

Stop inserting sextend instructions after ctz, clz, and popcnt when
translating from WebAssembly. The Cretonne instructions have the same
signature as the WebAssembly equivalents.
2017-09-28 16:30:19 -07:00
Dan Gohman
36585ddc4f Wasm control stack entries only need the number of return types.
This eliminates heap-allocated vectors which stored the actual types.
2017-09-25 13:05:29 -07:00
Dan Gohman
55e48ce7aa Simplify translate_type's return type. 2017-09-25 13:05:29 -07:00
Jakob Stoklund Olesen
e8723be33f Add trap codes to the Cretonne IL.
The trap and trapz/trapnz instructions now take a trap code immediate
operand which indicates the reason for trapping.
2017-09-20 15:50:02 -07:00
Dan Gohman
1ab207b93c Add support for emitting code with a single return at the end. (#153)
This also enables testing of the wasmtests tests.

This also updates for wabt updating to the official "wat" filename
extension, as opposed to "wast".
2017-09-12 13:27:36 -07:00