rust/compiler/rustc_middle/src/ty
Alex Crichton 482a3d06c3 rustc: Add a new wasm ABI
This commit implements the idea of a new ABI for the WebAssembly target,
one called `"wasm"`. This ABI is entirely of my own invention
and has no current precedent, but I think that the addition of this ABI
might help solve a number of issues with the WebAssembly targets.

When `wasm32-unknown-unknown` was first added to Rust I naively
"implemented an abi" for the target. I then went to write `wasm-bindgen`
which accidentally relied on details of this ABI. Turns out the ABI
definition didn't match C, which is causing issues for C/Rust interop.
Currently the compiler has a "wasm32 bindgen compat" ABI which is the
original implementation I added, and it's purely there for, well,
`wasm-bindgen`.

Another issue with the WebAssembly target is that it's not clear to me
when and if the default C ABI will change to account for WebAssembly's
multi-value feature (a feature that allows functions to return multiple
values). Even if this does happen, though, it seems like the C ABI will
be guided based on the performance of WebAssembly code and will likely
not match even what the current wasm-bindgen-compat ABI is today. This
leaves a hole in Rust's expressivity in binding WebAssembly where given
a particular import type, Rust may not be able to import that signature
with an updated C ABI for multi-value.

To fix these issues I had the idea of a new ABI for WebAssembly, one
called `wasm`. The definition of this ABI is "what you write
maps straight to wasm". The goal here is that whatever you write down in
the parameter list or in the return values goes straight into the
function's signature in the WebAssembly file. This special ABI is for
intentionally matching the ABI of an imported function from the
environment or exporting a function with the right signature.

With the addition of a new ABI, this enables rustc to:

* Eventually remove the "wasm-bindgen compat hack". Once this
  ABI is stable wasm-bindgen can switch to using it everywhere.
  Afterwards the wasm32-unknown-unknown target can have its default ABI
  updated to match C.

* Expose the ability to precisely match an ABI signature for a
  WebAssembly function, regardless of what the C ABI that clang chooses
  turns out to be.

* Continue to evolve the definition of the default C ABI to match what
  clang does on all targets, since the purpose of that ABI will be
  explicitly matching C rather than generating particular function
  imports/exports.

Naturally this is implemented as an unstable feature initially, but it
would be nice for this to get stabilized (if it works) in the near-ish
future to remove the wasm32-unknown-unknown incompatibility with the C
ABI. Doing this, however, requires the feature to be on stable because
wasm-bindgen works with stable Rust.
2021-04-08 08:03:18 -07:00
..
consts update const_eval_resolve 2021-03-20 17:22:24 +01:00
inhabitedness Implement Debug for DefIdForest 2021-01-16 17:56:32 -05:00
print prevent very long compilation runtimes in LateBoundRegionNameCollector 2021-03-31 23:28:01 +02:00
query lazily calls some fns 2021-03-27 10:20:32 +03:00
_match.rs Add tcx lifetime to Binder 2021-03-31 10:13:57 -04:00
adjustment.rs New pass to deduplicate blocks 2021-02-21 21:51:54 +01:00
adt.rs Moved all Adt* types to adt.rs 2021-03-10 14:32:14 -08:00
assoc.rs Moved all Assoc* types to assoc.rs. 2021-03-10 14:32:13 -08:00
binding.rs words 2020-11-16 22:42:09 +01:00
cast.rs Use rustc_type_ir::{IntTy,UintTy,FloatTy} instead of the rustc_ast` ones in types 2021-01-18 21:09:23 +01:00
closure.rs Remove (lots of) dead code 2021-03-27 22:16:33 -04:00
codec.rs Track bound vars 2021-03-31 10:15:27 -04:00
consts.rs Update with comments 2021-03-23 17:16:20 +00:00
context.rs Add var to BoundRegion. Add query to get bound vars for applicable items. 2021-03-31 10:16:37 -04:00
diagnostics.rs hir: Preserve used syntax in TyKind::TraitObject 2021-03-18 03:02:32 +03:00
erase_regions.rs Auto merge of #83207 - oli-obk:valtree2, r=lcnr 2021-04-02 10:28:12 +00:00
error.rs Auto merge of #80828 - SNCPlay42:opaque-projections, r=estebank 2021-04-02 03:39:32 +00:00
fast_reject.rs Use rustc_type_ir::{IntTy,UintTy,FloatTy} instead of the rustc_ast` ones in types 2021-01-18 21:09:23 +01:00
flags.rs Add tcx lifetime to Binder 2021-03-31 10:13:57 -04:00
fold.rs Auto merge of #83207 - oli-obk:valtree2, r=lcnr 2021-04-02 10:28:12 +00:00
generics.rs Update with comments 2021-03-23 17:16:20 +00:00
instance.rs Inline some functions that suddenly show up more in traces 2021-04-01 09:22:12 +00:00
layout.rs rustc: Add a new wasm ABI 2021-04-08 08:03:18 -07:00
list.rs Fix typo 2020-12-23 13:08:15 -08:00
mod.rs Add var to BoundRegion. Add query to get bound vars for applicable items. 2021-03-31 10:16:37 -04:00
normalize_erasing_regions.rs Auto merge of #83207 - oli-obk:valtree2, r=lcnr 2021-04-02 10:28:12 +00:00
outlives.rs Address comments 2020-10-14 00:17:42 -04:00
relate.rs Add tcx lifetime to Binder 2021-03-31 10:13:57 -04:00
structural_impls.rs Track bound vars 2021-03-31 10:15:27 -04:00
sty.rs Add var to BoundRegion. Add query to get bound vars for applicable items. 2021-03-31 10:16:37 -04:00
subst.rs Auto merge of #83207 - oli-obk:valtree2, r=lcnr 2021-04-02 10:28:12 +00:00
trait_def.rs Only look at blanket impls in get_blanket_impls 2021-03-30 12:28:33 -04:00
util.rs Cleanups and comments 2021-03-31 10:16:37 -04:00
walk.rs extract ConstKind::Unevaluated into a struct 2021-03-20 17:21:44 +01:00