Commit Graph

2233 Commits

Author SHA1 Message Date
Alex Crichton
de85d99acd
Merge pull request #1002 from alexcrichton/reference-types
Add experimental support for the `anyref` type
2019-02-20 09:29:19 -06:00
Alex Crichton
4181fb311a Add experimental support for the anyref type
This commit adds experimental support to `wasm-bindgen` to emit and
leverage the `anyref` native wasm type. This native type is still in a
proposal status (the reference-types proposal). The intention of
`anyref` is to be able to directly hold JS values in wasm and pass the
to imported functions, namely to empower eventual host bindings (now
renamed WebIDL bindings) integration where we can skip JS shims
altogether for many imports.

This commit doesn't actually affect wasm-bindgen's behavior at all
as-is, but rather this support requires an opt-in env var to be
configured. Once the support is stable in browsers it's intended that
this will add a CLI switch for turning on this support, eventually
defaulting it to `true` in the far future.

The basic strategy here is to take the `stack` and `slab` globals in the
generated JS glue and move them into wasm using a table. This new table
in wasm is managed at the fringes via injected shims. At
`wasm-bindgen`-time the CLI will rewrite exports and imports with shims
that actually use `anyref` if needed, performing loads/stores inside the
wasm module instead of externally in the wasm module.

This should provide a boost over what we have today, but it's not a
fantastic strategy long term. We have a more grand vision for `anyref`
being a first-class type in the language, but that's on a much longer
horizon and this is currently thought to be the best we can do in terms
of integration in the near future.

The stack/heap JS tables are combined into one wasm table. The stack
starts at the end of the table and grows down with a stack pointer (also
injected). The heap starts at the end and grows up (state managed in
linear memory). The anyref transformation here will hook up various
intrinsics in wasm-bindgen to the runtime functionality if the anyref
supoprt is enabled.

The main tricky treatment here was applied to closures, where we need JS
to use a different function pointer than the one Rust gives it to use a
JS function pointer empowered with anyref. This works by switching up a
bit how descriptors work, embedding the shims to call inside descriptors
rather than communicated at runtime. This means that we're accessing
constant values in the generated JS and we can just update the constant
value accessed.
2019-02-20 07:28:54 -08:00
Alex Crichton
8f695782fb
Merge pull request #1278 from alexcrichton/examples
Update idioms of a few examples
2019-02-19 16:14:32 -06:00
Alex Crichton
e66de7b866
Merge pull request #1277 from alexcrichton/upgrade-walrus
Upgrade to walrus 0.4
2019-02-19 16:14:12 -06:00
Alex Crichton
8fb705a1ef Upgrade to walrus 0.4
Also be sure to have an explicit GC pass!
2019-02-19 14:14:01 -08:00
Alex Crichton
b8f080d523 Update idioms of a few examples
* Use `TypedArray::view` now that it exists.
* Don't hack around `instantiateStreaming`
2019-02-19 13:27:30 -08:00
Nick Fitzgerald
5b0cfd7cea
Merge pull request #1274 from alexcrichton/delete-once
Fix an assert while deleting table elements
2019-02-19 10:21:25 -08:00
Nick Fitzgerald
32b72a3ae0
Merge pull request #1275 from alexcrichton/option-classes
Support `Option<RustStruct>` in arguments/returns
2019-02-19 10:20:40 -08:00
Alex Crichton
f831711f5d Support Option<RustStruct> in arguments/returns
Add all the necessary support in a few locations and we should be good
to go!

Closes #1252
2019-02-19 09:08:37 -08:00
Alex Crichton
9bab9d4af1 Fix an assert while deleting table elements
LLVM's mergefunc pass may mean that the same descriptor function is used
for different closure invocation sites even when the closure itself is
different. This typically only happens with LTO but in theory could
happen at any time!

The assert was tripping when we tried to delete the same function table
entry twice, so instead of a `Vec<usize>` of entries to delete this
commit switches to a `HashSet<usize>` which should do the deduplication
for us and enusre that we delete each descriptor only once.

Closes #1264
2019-02-19 08:17:14 -08:00
Alex Crichton
e498d99b2d
Merge pull request #1266 from ctjhoa/master
Fix missing link on todomvc example
2019-02-19 09:13:47 -06:00
Camille TJHOA
eda7541e45 Fix missing link on todomvc example 2019-02-17 16:19:23 +00:00
Alex Crichton
9e40a6d02b
Merge pull request #1263 from alexcrichton/revert
Revert "Temporarily unconditionally remove producers section"
2019-02-15 14:29:02 -06:00
Alex Crichton
a3c03b5265 Revert "Temporarily unconditionally remove producers section"
This reverts commit f0cd51a566.
2019-02-15 11:22:46 -08:00
Alex Crichton
ebc0f1c07e
Merge pull request #1261 from xtuc/chore-update-webpack
update pinned Webpack versions
2019-02-15 13:22:12 -06:00
Sven Sauleau
f0c9ed4c6e
feat: update root package 2019-02-15 19:43:36 +01:00
Sven Sauleau
5c9ae21e76
chore: update root package 2019-02-15 19:28:05 +01:00
Sven Sauleau
5e7187a95f
chore: update pinned Webpack versions 2019-02-15 19:26:08 +01:00
Alex Crichton
e9f423d57e Bump to 0.2.37 2019-02-15 08:16:24 -08:00
Alex Crichton
4dcaa79ba6
Merge pull request #1260 from alexcrichton/no-producers
Temporarily unconditionally remove producers section
2019-02-15 10:12:17 -06:00
Alex Crichton
f0cd51a566 Temporarily unconditionally remove producers section
We've had a lot of bug reports with upstream webpack currently and while
webpack has a fix it may take a moment to deploy. Let's try and fix
wasm-bindgen in the meantime!

Once webpack is updated we can go back to emitting a producers section
by default and publish a new version of wasm-bindgen.
2019-02-15 07:39:42 -08:00
Alex Crichton
632a2b2979
Merge pull request #1259 from ctjhoa/master
Fix warning on ATOMIC_USIZE_INIT & ATOMIC_BOOL_INIT
2019-02-15 08:59:24 -06:00
Alex Crichton
c57e2b0baf
Merge pull request #1256 from alexcrichton/remove-producers
Add a flag to remove producers section
2019-02-15 08:59:03 -06:00
Camille TJHOA
768b654b58 Fix warning on ATOMIC_USIZE_INIT & ATOMIC_BOOL_INIT 2019-02-15 11:58:48 +00:00
Alex Crichton
5e3cedfaf2 Add a flag to remove producers section
This should help handle instances like the recent Webpack bug and is
also a useful flag in its own right. For now it's set to `false`, but if
the Webpack bug persists through to tomorrow we likely want to publish a
version of `wasm-bindgen` with it default set to `true`.
2019-02-14 10:08:24 -08:00
Alex Crichton
7c7acf2aa6
Merge pull request #1255 from fitzgen/configure-walrus
Configure walrus to generate DWARF/names at the right times
2019-02-14 10:19:14 -06:00
Nick Fitzgerald
17dc79e4c5 Configure walrus to generate DWARF/names at the right times
Fixes ##1254
2019-02-14 07:20:43 -08:00
Alex Crichton
c49b87b2d8
Merge pull request #1225 from Pauan/get_index
Adding in Reflect::get_f64, Reflect::get_u32, Reflect::set_f64, and Reflect::set_u32
2019-02-13 13:10:40 -06:00
Alex Crichton
8ead8a1b62
Merge pull request #1248 from selaux/add-srcObject-to-HTMLMediaElement
[HTMLMediaElement] Reintroduce srcObject
2019-02-13 13:00:57 -06:00
Nick Fitzgerald
61243b3014
Merge pull request #1245 from fitzgen/fix-issue-1244
Fix issue 1244
2019-02-12 13:32:22 -08:00
Nick Fitzgerald
802cfedcbd Bump to 0.2.36 2019-02-12 13:19:02 -08:00
Nick Fitzgerald
f20afebdd1 Don't need the old wasm-bindgen-gc crate's Cargo.toml either 2019-02-12 13:16:17 -08:00
Nick Fitzgerald
6f00d9563f interpreter: handle closure descriptors with less than two parameters
This might happen because of LTO.

Fixes #1244
2019-02-12 12:57:22 -08:00
Nick Fitzgerald
51989aed88 No more wasm-bindgen-gc crate, so we don't need to publish it! 2019-02-12 12:44:45 -08:00
Nick Fitzgerald
d9cf9b3735 Bump to version 0.2.35 2019-02-12 11:36:19 -08:00
Alex Crichton
82b7bdeb93 Fix wasm-interpreter tests 2019-02-12 10:46:43 -08:00
Alex Crichton
db4c3bf77b
Merge pull request #1243 from fitzgen/instantiateStreaming-fallback-round-2
Apply the `instantiateStreaming` incorrect MIME type recovery for no-modules
2019-02-12 12:45:46 -06:00
Nick Fitzgerald
b858875d49 Apply the instantiateStreaming incorrect MIME type recovery for no-modules
It was incorrectly only enabled for the multithreading glue previously.
2019-02-12 10:41:53 -08:00
Alex Crichton
6004454775
Merge pull request #1237 from alexcrichton/walrus
Migrate `wasm-bindgen` to using `walrus`
2019-02-12 09:26:46 -06:00
Alex Crichton
894b479213 Migrate wasm-bindgen to using walrus
This commit moves `wasm-bindgen` the CLI tool from internally using
`parity-wasm` for wasm parsing/serialization to instead use `walrus`.
The `walrus` crate is something we've been working on recently with an
aim to replace the usage of `parity-wasm` in `wasm-bindgen` to make the
current CLI tool more maintainable as well as more future-proof.

The `walrus` crate provides a much nicer AST to work with as well as a
structured `Module`, whereas `parity-wasm` provides a very raw interface
to the wasm module which isn't really appropriate for our use case. The
many transformations and tweaks that wasm-bindgen does have a huge
amount of ad-hoc index management to carefully craft a final wasm
binary, but this is all entirely taken care for us with the `walrus`
crate.

Additionally, `wasm-bindgen` will ingest and rewrite the wasm file,
often changing the binary offsets of functions. Eventually with DWARF
debug information we'll need to be sure to preserve the debug
information throughout the transformations that `wasm-bindgen` does
today. This is practically impossible to do with the `parity-wasm`
architecture, but `walrus` was designed from the get-go to solve this
problem transparently in the `walrus` crate itself. (it doesn't today,
but this is planned work)

It is the intention that this does not end up regressing any
`wasm-bindgen` use cases, neither in functionality or in speed. As a
large change and refactoring, however, it's likely that at least
something will arise! We'll want to continue to remain vigilant to any
issues that come up with this commit.

Note that the `gc` crate has been deleted as part of this change, as the
`gc` crate is no longer necessary since `walrus` does it automatically.
Additionally the `gc` crate was one of the main problems with preserving
debug information as it often deletes wasm items!

Finally, this also starts moving crates to the 2018 edition where
necessary since `walrus` requires the 2018 edition, and in general it's
more pleasant to work within the 2018 edition!
2019-02-12 07:25:53 -08:00
Nick Fitzgerald
c30dbc3179 Write changelog entry for 0.2.34 2019-02-11 19:11:08 -08:00
Nick Fitzgerald
078257943d Bump to 0.2.34 2019-02-11 18:58:54 -08:00
Alex Crichton
92ed368c0a
Merge pull request #1238 from jonathanKingston/fixup_todomvc_warnings
Fixup compiler warnings for Todo MVC example
2019-02-11 13:25:36 -06:00
Jonathan Kingston
5c81125b86 Fixup compiler warnings for Todo MVC example 2019-02-11 18:43:23 +00:00
Alex Crichton
311dafd366
Merge pull request #1235 from fitzgen/some-little-things
A couple small improvements
2019-02-11 06:39:09 -06:00
Nick Fitzgerald
f6362a653c
Merge pull request #1234 from stevebob/guide-fix-broken-links
Fix broken links
2019-02-10 20:45:18 +01:00
Nick Fitzgerald
4975ca2954 Don't give up when servers don't set the application/wasm MIME type
It is quite annoying when using `python -m SimpleHTTPServer` or equivalent.
2019-02-10 13:59:39 -05:00
Nick Fitzgerald
c8ad85dd0b Use unwrap_throw instead of normal unwrap for JsString -> String conversion
Should have less code size.
2019-02-10 13:59:39 -05:00
Nick Fitzgerald
499ae1250e
Merge pull request #1207 from T5uku5hi/add-allow-clippy
Add #[allow(clippy::*)] to the top-level items in codegen.rs
2019-02-10 19:37:27 +01:00
Stephen Sherratt
f774d52ed5 Fix broken links 2019-02-10 14:54:18 +00:00