Commit Graph

88 Commits

Author SHA1 Message Date
Dan Gohman
15aff899ee Block no longer needs to implement Hash. 2017-11-07 15:19:55 -08:00
Dan Gohman
6d91a32d39 Add comments about "user" parameters. 2017-11-07 15:13:46 -08:00
Dan Gohman
cbb99bf233 Rename "user_arg_count" to "user_param_count" for consistency. 2017-11-07 15:13:46 -08:00
Dan Gohman
9b15fe7dfd Simplify Ebb parameter creation.
Ebb parameters are appended explicitly by whoever calls create_block,
so they don't need to also be inferred from branches. This makes the
frontend code more flexible for producers that want to create things
in a different order, and it eliminates more temporary allocations.

FunctionBuilder no longer maintains its own list of the function
parameter values; these can be obtained from the ebb parameter list
on the entry block.
2017-11-07 15:13:00 -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
1d8df2ed1e Remove the requirement that Variable implement Default. 2017-11-06 11:10:14 -08:00
Dan Gohman
c7f01f88b2 Clarify some comments. 2017-11-03 11:44:58 -07:00
Dan Gohman
e21479a843 Mark check_return_args as #[cfg(debug_assertions)]. 2017-11-02 12:28:01 -07:00
Dan Gohman
1cbf921d9d Add a function to seal all the blocks at once. 2017-11-02 08:00:55 -07:00
Dan Gohman
c6d39dea5d Add a comment about shrink_to_fit(). 2017-11-01 11:35:15 -07:00
Dan Gohman
61a51f5275 Rename a variable to clarify its purpose. 2017-11-01 11:34:16 -07:00
Dan Gohman
57041ea9eb Tidy up semicolons. 2017-11-01 11:30:37 -07:00
Dan Gohman
39c0fbb6c7 Assert that sealed blocks cannot accept new predecessors. 2017-11-01 11:27:54 -07:00
Dan Gohman
1663f141c8 Tidy up unneeded parentheses. 2017-11-01 11:26:55 -07:00
Dan Gohman
3d83d0e4f0 Clean up redundant blank lines. 2017-10-31 12:45:22 -07:00
Dan Gohman
c2665385b1 Rename FunctionName to ExternalName. 2017-10-30 13:26:56 -07:00
Dan Gohman
683408f30b Break alias cycles by inserting zero values. 2017-10-26 12:22:16 -07:00
Dan Gohman
53e93d94a8 Avoid creating cyclic aliases in unreachable code. 2017-10-26 11:39:53 -07:00
Dan Gohman
2932a9314d Don't allocate srclocs if we only have default SourceLoc values.
This avoids needless extra indentation in `write_function` in the
case where no SourceLoc information is available.
2017-10-25 11:17:29 -07:00
Dan Gohman
dbd75483e8 Rename arg_value to param_value for consistency.
Also rename FunctionBuilder's `pristine` to `params_values_initialized`
to avoid confusion with the unrelated `is_pristine` accessor function.
2017-10-25 10:14:10 -07:00
Dan Gohman
fc0671a0cf Avoid dangling references to block params when sealing an unreachable block. 2017-10-25 10:04:18 -07:00
Dan Gohman
fdf2486c0a Handle uninitialized values of type b1 and vector. 2017-10-23 15:23:57 -07:00
Dan Gohman
c93959de7e Fix a bug handling a use_var of a value not defined in the entry block. 2017-10-20 15:55:04 -07:00
Dan Gohman
f4b25ff058 Have FunctionBuilder clear the ILBuilder's state in its drop(). 2017-10-20 11:37:25 -07:00
Jakob Stoklund Olesen
b3fb41087e Use the term "Function parameter" instead of "argument".
Rename the ArgumentType type to AbiParam since it describes the ABI
characteristics of a parameter or return value, not just the value type.

In Signature, rename members argument_types and return_types to "params"
and "returns". Again, they are not just types.

Fix a couple lingering references to "EBB arguments".
2017-10-19 17:39:23 -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
1a1774af15 Fix a typo in a comment. 2017-10-19 12:59:10 -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
Jakob Stoklund Olesen
85e4e9f511 Assign source locations when translating WebAssembly to Cretonne.
The source locations are byte code offsets relative to the beginning of
the function.
2017-09-21 14:37:54 -07:00
Dan Gohman
16eb689dd1 Use Self instead of repeating the type name. 2017-09-21 14:21:30 -07:00
Dan Gohman
e5e4b59683 Tidy up some asserts. 2017-09-21 14:21:30 -07:00
Dan Gohman
e75558b800 Fix spelling of "adjustment". 2017-09-21 14:21:30 -07:00
Dan Gohman
dda8293668 Restructure code to avoid a heap allocation. 2017-09-21 14:21:30 -07:00
Dan Gohman
ff18772d0e Avoid a heap allocation. 2017-09-21 14:21:30 -07:00
Dan Gohman
22b769b716 Convert use_var and predecessors_lookup into a state machine to avoid recursion. 2017-09-21 14:21:30 -07:00
Dan Gohman
9cda4eacde Minor refactor. 2017-09-21 14:21:30 -07:00
Dan Gohman
df5ba8bbba Correct a comment. 2017-09-21 14:21:30 -07:00
Dan Gohman
f524977920 Factor some logic out of seal_ebb_header_block into parts.
This allows append_jump_argument to call just the part that it needs
instead of the whole of seal_ebb_header_block, which is a nice cleanup
on its own, and it also eliminates a cycle from the static call graph.
2017-09-21 14:21:30 -07:00
Jakob Stoklund Olesen
1cd91b6f30 Eliminate layout::Cursor from cton_frontend.
Replace all uses with a FuncCursor.

Avoid the anti-pattern of passing parts of a function around as
independent references.
2017-09-21 12:24:27 -07:00
Dan Gohman
74845fed6c Use more helper functions on CursorBase to reduce cursor repositioning. 2017-09-20 11:19:35 -07:00
Dan Gohman
b888894fbb Use CursorBase utility functions to reduce repositioning clutter. 2017-09-20 09:06:17 -07:00
Dan Gohman
144d39a53d Minor code simplification. 2017-09-20 08:17:40 -07:00
Jakob Stoklund Olesen
da4cde8117 Always insert the entry EBB before translating any WASM.
The FuncEnvironment callbacks (make_global in particular) may need to
insert code in the entry EBB. We need to make sure the entry EBB has
been inserted in the layout before making those callbacks.
2017-09-18 11:53:32 -07:00
Jakob Stoklund Olesen
1349a6bdbc Always require a Flags reference for verifying functions.
Add a settings::FlagsOrIsa struct which represents a flags reference and
optionally the ISA it belongs to. Use this for passing flags/isa
information to the verifier.

The verify_function() and verify_context() functions are now generic so
they accept either a &Flags or a &TargetISa argument.

Fix the return_at_end verifier tests which no longer require an ISA
specified. The signle "set return_at_end" flag setting now makes it to
the verifier even when no ISA is present to carry it.
2017-09-14 17:51:15 -07:00
Dan Gohman
2e046d68ce Remove obsolete derivations of Hash. 2017-09-12 12:28:25 -07:00
Dan Gohman
620f1f49e2 Move several functions from FunctionBuilder to Function.
With FuncEnvironment using FuncCursors in place of full
FunctionBuilders, it's useful to move several of these convenience
functions from FunctionBuilder to Function.
2017-09-11 08:40:50 -07:00
Jakob Stoklund Olesen
26048c2ecc Move WasmRuntime::translate_call_indirect() into FuncEnvironment.
Add two new arguments:

- table_index is the WebAssembly table referenced in the indirect call.
- sig_index is the WebAssembly signature index. We still have the SigRef
  that was created by make_indirect_sig(), but the WebAssembly signature
  index may be needed for detecting type mismatches at runtime.

Change the insertion location to a plain FuncCursor rather than a
FunctionBuilder<Local>. The fact that cretonne-wasm uses FunctionBuilder
should be an implementation detail, and the callbacks don't need to
access WebAssembly locals, so they don't need the extended interface.

Add a FunctionBuilder::cursor() method which creates a FuncCursor for
inserting instructions in the current EBB.

Also add a FuncEnvironment::translate_call() method which allows the
environment to override direct calls the same way as indirect calls.
2017-09-06 15:18:55 -07:00
Dan Gohman
d3712575b5 Use mem::replace instead of mem::swap when it's cleaner. 2017-09-05 16:30:44 -07:00
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
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