Jakob Stoklund Olesen
0ac1d0dd94
Add FuncEnvironment trait.
...
This trait is used to provide the environment necessary to translate a
single WebAssembly function without having other global data structures
for the WebAssembly module.
The WasmRuntime trait extends the FuncEnvironment trait for those uses
that want to parse a whole WebAssembly module.
- Change the handling of WebAssembly globals to use the FuncEnvironment
trait as well as the new GlobalVar infrastructure in Cretonne. The
runtime is not consulted on the translation of each
get_global/get_global instruction. Instead it gets to create the
GlobalVar declaration in the function preamble the first time the
global is used.
- Change the handling of heap load/store instructions to use the new
Heap infrastructure in Cretonne. The runtime is called to create the
Heap declaration in the preamble. It is not involved in individual
load/store instructions.
2017-09-05 16:17:52 -07:00
Jakob Stoklund Olesen
19c8ba5021
Eliminate the sig argument to translate_operator.
...
The current function's return types are pushed as the first control
stack frame.
2017-09-05 11:51:32 -07:00
Jakob Stoklund Olesen
2671cbb092
Add TranslationState::in_unreachable_code().
...
Move an unreachable code test and sanity check into this method.
2017-09-05 11:46:08 -07:00
Jakob Stoklund Olesen
6f864f2926
Move translation state initialization into a method.
2017-09-05 11:00:40 -07:00
Dan Gohman
ef3ea72422
Avoid calling Vec::split_off, avoiding more heap allocations.
2017-09-05 09:23:20 -07:00
Dan Gohman
9ea40ad44a
Replace SSABuilder's variables HashMaps with EntityMaps. ( #150 )
...
* Replace SSABuilder's variables HashMaps with EntityMaps.
Current measurements show that memory usage is approximately the same,
and it's about 20% faster.
* Add EntityMap::with_default and use it.
* rustfmt
* Use var_defs[block].expand().
2017-09-02 04:11:51 -07:00
Jakob Stoklund Olesen
03939e4f9f
Move TranslationState into its own module.
...
Add some convenience methods for common state access patterns.
2017-09-01 15:55:02 -07:00
Jakob Stoklund Olesen
6762194801
Move stack and control_stack into TranslationState.
...
This reduces the number of function arguments passed around and it keeps
related information together.
2017-09-01 14:29:35 -07:00
Dan Gohman
0c2ab06e66
Make EntitySet::contains return false for out-of-bounds indices.
...
This is consistent with EntityMap.
2017-09-01 14:04:38 -07:00
Dan Gohman
de92b2b967
Use Vec::resize.
2017-09-01 14:04:38 -07:00
Jakob Stoklund Olesen
52cbbcd069
Add a CtonError::InvalidInput variant.
...
This error code will be used to complain when a WebAssembly binary code
can't be parsed.
2017-09-01 13:08:07 -07:00
Dan Gohman
8237893113
Eliminate a temporary heap allocation when splitting a critical edge.
2017-09-01 12:50:51 -07:00
Dan Gohman
d4c53935b4
Introduce EntitySet, and use it to replace the HashSet in the frontend.
2017-09-01 12:23:53 -07:00
Dan Gohman
fe12fe0e63
Avoid unneeded calls to .as_slice().
2017-09-01 12:15:14 -07:00
Dan Gohman
9d2fbdae62
Avoid cloning a jump argument vector to the heap.
2017-09-01 12:15:14 -07:00
Dan Gohman
28779dc7e4
Avoid allocating jump arguments on the heap.
...
Instead of allocating a vector to store jump arguments for processing
later, just have the later code rescan through the predecessors to
obtain the values, which are memoized.
This also eliminates a linear search through the predecessor list when
splitting a critical edge.
2017-09-01 12:15:14 -07:00
Jakob Stoklund Olesen
9bc4264a33
Update dependency to wasmparser v0.8.2.
...
Soon we'll need the BinaryReader::read_local_decl() method which was
added in that release.
2017-09-01 09:31:39 -07:00
Dan Gohman
7049cc78ae
Refactor out an append helper function for SideEffects.
2017-08-31 17:49:39 -07:00
Dan Gohman
ec3972f515
Avoid allocating a vector for predecessor variables in the single-value case.
2017-08-31 17:42:19 -07:00
Dan Gohman
52335c9e0f
Delete an obsolete TODO comment.
2017-08-31 17:06:14 -07:00
Dan Gohman
566c772e20
Eliminate more unnecessary calls to .iter().
2017-08-31 17:03:12 -07:00
Dan Gohman
de02976162
Minor comment cleanups.
2017-08-31 17:02:26 -07:00
Dan Gohman
1d03244e90
Use debug_assert instead of assert in code where performance is important.
2017-08-31 16:36:18 -07:00
Dan Gohman
583487bfac
Refactor the non-local case of use_var into a separate function.
2017-08-31 16:32:48 -07:00
Dan Gohman
e3227e38ce
Avoid cloning precessor lists to the heap.
2017-08-31 16:09:26 -07:00
Dan Gohman
539a5b3378
Avoid a heap allocation for a block's undef_variables.
2017-08-31 15:42:37 -07:00
Dan Gohman
79f257060f
Inline resolve_undef_vars, and collapse the resulting redundancy.
2017-08-31 14:49:53 -07:00
Dan Gohman
2d9b902d2e
Clean up a redundant cast.
2017-08-31 14:35:19 -07:00
Dan Gohman
0cacba15b9
Replace as casts with type-conversion functions.
...
https://github.com/rust-lang-nursery/rust-clippy/wiki#cast_lossless
2017-08-31 14:31:23 -07:00
Dan Gohman
dc79d155ff
Comment wording cleanups.
2017-08-31 12:47:05 -07:00
Dan Gohman
bc528917fd
Avoid redundant '@ _' in match patterns.
...
https://github.com/rust-lang-nursery/rust-clippy/wiki#redundant_pattern
2017-08-31 12:47:05 -07:00
Dan Gohman
ebbb836bb9
Use debug_assert_eq rather than debug_assert with an ==.
2017-08-31 12:47:05 -07:00
Dan Gohman
3c5755cfbd
Avoid unneeded return keywords.
2017-08-31 12:47:05 -07:00
Dan Gohman
a7d629c368
Use the Self keyword where applicable.
...
https://github.com/rust-lang-nursery/rust-clippy/wiki#use_self
2017-08-31 12:47:05 -07:00
Dan Gohman
99b361567a
Remove unneeded mut keywords.
2017-08-31 12:47:05 -07:00
Dan Gohman
55ae51acfe
Add an underscore between a literal value and its suffix.
...
https://github.com/rust-lang-nursery/rust-clippy/wiki#unseparated_literal_suffix
2017-08-31 12:47:05 -07:00
Dan Gohman
da2c2151b1
Fix trivial_numeric_casts errors.
2017-08-31 12:47:05 -07:00
Dan Gohman
9726bb7367
Avoid matching with reference patterns.
...
https://github.com/rust-lang-nursery/rust-clippy/wiki#match_ref_pats
2017-08-31 12:47:05 -07:00
Dan Gohman
5a8d1a9fda
Use if let instead of match.
...
https://github.com/rust-lang-nursery/rust-clippy/wiki#single_match
2017-08-31 12:47:05 -07:00
Dan Gohman
574031e4d2
Avoid unneeded passing by value.
...
https://github.com/rust-lang-nursery/rust-clippy/wiki#needless_pass_by_value
2017-08-31 12:47:05 -07:00
Dan Gohman
b6641ff443
Avoid clone() on a Copy type.
...
https://github.com/rust-lang-nursery/rust-clippy/wiki#clone_on_copy
2017-08-31 12:47:05 -07:00
Dan Gohman
105998944e
Avoid redundant borrows.
...
https://github.com/rust-lang-nursery/rust-clippy/wiki#needless_borrow
2017-08-31 12:47:05 -07:00
Dan Gohman
9a8f01b832
Avoid unnecessary '&' in matches.
...
https://github.com/rust-lang-nursery/rust-clippy/wiki#match_ref_pats
2017-08-31 12:47:05 -07:00
Dan Gohman
acf4f1009b
Eliminate redundant uses of format!.
...
https://github.com/rust-lang-nursery/rust-clippy/wiki#useless_format
2017-08-31 12:47:05 -07:00
Dan Gohman
abbc6ddf24
Use is_empty() instead of comparing len() with 0.
...
https://github.com/rust-lang-nursery/rust-clippy/wiki#len_zero
2017-08-31 12:47:05 -07:00
Dan Gohman
adfdd77311
Avoid creating a reference to a reference.
...
https://github.com/rust-lang-nursery/rust-clippy/wiki#needless_borrow
2017-08-31 12:47:05 -07:00
Dan Gohman
b411d01d6d
Use [] instead of .get().unwrap().
...
https://github.com/rust-lang-nursery/rust-clippy/wiki#get_unwrap
2017-08-31 12:47:05 -07:00
Dan Gohman
2efdc0ed37
Update rustfmt to 0.9.0.
2017-08-31 10:44:59 -07:00
Dan Gohman
46fb64cbb4
Add SideEffects::new().
2017-08-31 10:28:56 -07:00
Dan Gohman
52186b8390
Refactor code for obtaining the header block.
2017-08-31 10:28:56 -07:00