Commit Graph

2103 Commits

Author SHA1 Message Date
Jake Riesterer
3d1f4263ad Change UnionType to IdlType::Union function to include any supported types instead of returning None when there is at least one unsupported type
For example, the constructor in Response.webidl accepts multiple types. However, one of those types is `ReadableStream` which isn't defined yet, and that causes all constructors for Response to be skipped even though the other argument types could be supported.
2018-11-07 10:39:22 -08:00
Alex Crichton
176eedc63b Make to_idl_type infallible
This commit makes the `to_idl_type` infallible, returning a new enum
variant, `UnknownInterface`, in the one location that we still return
`None`. By making this infallible we can ensure that expansion of unions
which have unknown types still generate methods for all the variants
which we actually have all the methods for!
2018-11-07 10:38:35 -08:00
Alex Crichton
ac6a230d83
Merge pull request #1012 from alexcrichton/rename-exported-type
Implement support for `js_class` on exported types
2018-11-05 17:44:21 -06:00
Alex Crichton
16d5243362 Implement support for js_class on exported types
Allow defining types which have different names in Rust than they have
in JS! (just like can be done with imported types)

Closes #1010
2018-11-05 12:29:14 -08:00
Nick Fitzgerald
7a528d4b6b
Merge pull request #1011 from alexcrichton/import-doc
Add a note about renaming types and `js_class`
2018-11-05 12:18:12 -08:00
Alex Crichton
9478a65e3c Add a note about renaming types and js_class
When a type is renamed in Rust via `js_name` then all method imports
will also need a `js_class` annotation to hook them up correctly.
2018-11-05 11:10:09 -08:00
Sendil Kumar N
3c31a32d51
Merge pull request #1008 from henriiik/optional-typescript-return-values
update typescript generation to reflect that Option<T> can be undefined
2018-11-05 01:35:25 +01:00
Henrik Sjööh
d331b706c3 update typescript generation to reflect that Option<T> can be undefined 2018-11-04 10:26:20 +01:00
Alex Crichton
0d5f514709
Merge pull request #996 from alexcrichton/gc-tests
Add tests for the wasm-gc crate
2018-10-31 10:03:35 -05:00
Alex Crichton
40b68c66d9 Fix a bug in coalescing types with GC
When a duplicate type is found is should no longer be considered used!
2018-10-30 15:45:21 -07:00
Alex Crichton
31c11f0781 GC passive segments
We statically know which passive segments are actually used, so let's be
sure to gc them!
2018-10-29 16:49:02 -07:00
Alex Crichton
91d68a0012 Add tests for the wasm-gc crate
This commit adds a test harness and the beginnings of a test suite for
the crate that performs GC over a wasm module. This crate historically
has had zero tests because it was thought that it would no longer be
used once LLD landed with `--gc-sections`, but `wasm-bindgen` has come
to rely more and more on `wasm-gc` for various purposes.

The last release of `wasm-bindgen` was also released with a bug in the
recently refactored support in the `wasm-gc` crate, providing a perfect
time and motivation to start writing some tests!

All tests added here are `*.wat` files which contain the expected output
after the gc pass is executed. Tests are automatically updated with
`BLESS_TESTS=1` in the environment, which is the expected way to
generate the output for each test.
2018-10-29 15:49:35 -07:00
Alex Crichton
6dfbb4be89 Bump to 0.2.27 2018-10-29 14:30:33 -07:00
Alex Crichton
b1d92aecac
Merge pull request #995 from alexcrichton/gc-too-aggressive
Assume all data/element/table/memory segments needed
2018-10-29 14:16:59 -07:00
Alex Crichton
a0a9ed4686
Merge pull request #986 from alexcrichton/gc-types
Eliminate duplicate types in the type section
2018-10-29 14:11:58 -07:00
Alex Crichton
d172c20b76 Assume all data/element/table/memory segments needed
wasm-gc is in dire need of a better test suite, so I'll work on that
before attempting to de-pessimize this.

Closes #994
2018-10-29 14:06:06 -07:00
Alex Crichton
93564f159f Fix build of TODO MVC on stable 2018-10-29 13:47:09 -07:00
Alex Crichton
9a3ef7b747
Merge pull request #961 from jonathanKingston/todo-mvc
Todo mvc
2018-10-29 13:24:59 -07:00
Alex Crichton
bb28f76906 Try to improve the publish script 2018-10-29 13:08:22 -07:00
Alex Crichton
7fad2bf0c8 Bump to 0.2.26 2018-10-29 12:56:37 -07:00
Alex Crichton
27001a226d Eliminate duplicate types in the type section
This commit updates the `wasm-gc` pass of wasm-bindgen to eliminate
duplicate types in the type section, effectively enabling a gc of the
type section itself. The main purpose here is ensure that code generated
by `wasm-bindgen` itself doesn't have to go too far out of its way to
deduplicate at generation time, but rather it can rely on the gc pass to
clean up.

Note that this currently depends on paritytech/parity-wasm#231, but this
can be updated if that ends up not landing.
2018-10-29 12:04:11 -07:00
Alex Crichton
ec6e13a0f8
Merge pull request #987 from alexcrichton/gc-locals
Add gc support for locals in functions
2018-10-29 10:11:06 -07:00
Alex Crichton
fab5c795ae Add gc support for locals in functions
This commit adds support for running a gc pass over locals in a
function. This will remove dead local declarations for a function
(completely unused) as well as compact existing entries to ensure that
we don't have two local declarations of the same type.

While this was initially intended for some future support of emitting
shims in `wasm-bindgen`, it turns out this pass is firing quite a lot
over existing functions generated by LLVM. Looks like we may see benefit
from this today with slightly smaller wasm binaries!
2018-10-29 10:10:23 -07:00
Nick Fitzgerald
1ec68009e8
Merge pull request #985 from alexcrichton/differeng-gc
Restructure internals of `wasm-gc`
2018-10-29 10:45:53 +01:00
Nick Fitzgerald
73740ba6ab
Merge pull request #984 from alexcrichton/more-gc
Discard internal LLD symbols during gc
2018-10-29 10:44:50 +01:00
Alex Crichton
9ebbcd3827
Merge pull request #992 from alexcrichton/inline-trivial
Flag a trivial `JsValue` constructor as `#[inline]`
2018-10-28 14:57:53 -07:00
Alex Crichton
8d695b800d
Merge pull request #989 from alexcrichton/stable-ci
Promote CI jobs to using stable Rust
2018-10-28 14:14:49 -07:00
Alex Crichton
451004defc
Merge pull request #991 from alexcrichton/safaridriver
Fix WebDriver compat with Safari
2018-10-28 13:54:03 -07:00
Alex Crichton
6d78c5304a
Merge pull request #990 from alexcrichton/sccache
Try to speed up CI with sccache
2018-10-28 13:53:50 -07:00
Alex Crichton
cfa4aa0e3e Promote CI jobs to using stable Rust
Everything should be stable now so let's test it!
2018-10-28 13:28:02 -07:00
Alex Crichton
f3d9851c2d Flag a trivial JsValue constructor as #[inline]
No reason this shouldn't be inlined in optimized builds!
2018-10-28 13:16:10 -07:00
Alex Crichton
0bc64338e8 Try to speed up CI with sccache
This configures sccache for Linux/OSX/Windows in an attempt to speed up
CI by reusing the results of previous builds, cached on the network with
`sccache`.
2018-10-28 12:53:48 -07:00
Alex Crichton
aa963db854 Fix WebDriver compat with Safari
They've made a few breaking changes in the most recent version, so let's
support that plus the old protocol for now!

Closes #983
2018-10-28 12:44:05 -07:00
Alex Crichton
efd4dd3ceb
Merge pull request #988 from alexcrichton/no-zero-size
Don't pass 0-length mallocs to system allocator
2018-10-28 12:29:03 -07:00
Alex Crichton
4407a791c2 Discard internal LLD symbols during gc
These don't seem to be widely used and they're not needed by
wasm-bindgen itself, so let's remove the symbols by default and
optionally in the future we can add an option to retain them.
2018-10-28 10:11:02 -07:00
Alex Crichton
a0fc095407 Restructure internals of wasm-gc
This commit restructures some of the internals of `wasm-gc` now that
I've actually got a better grasp on the wasm format and what all the
ownership edges look like. This shouldn't actually result in any
user-facing changes, but should make us be a bit more compatible with
operations in the future.

Memories/tables/elements/segments are no longer considered automatic
roots but rather need to be rooted by something else to prevent a gc.
For example an element section is gc'd along with a table if the table
is never referenced, along with data segments as well if the memory
isn't referenced.

Additionally all index sets now don't contained offseted indices, but
rather everything is always stored relative to the "index space" to
ensure consistency.

This should make it a bit easier to add future items to gc!
2018-10-28 10:10:51 -07:00
Alex Crichton
78f425744f Don't pass 0-length mallocs to system allocator
Part of the unsafe contract!
2018-10-28 10:09:57 -07:00
Alex Crichton
1fa407d2f9
Merge pull request #980 from alexcrichton/tweka-free
Tweak some logic in `JsValue::drop`
2018-10-26 09:53:08 +02:00
Alex Crichton
d70257af6c Tweak some logic in JsValue::drop
While technically correct the current implementation sort of made it
only roundaboutedly so. Tweak the logic a bit and the associated comment
to ensure that stack values are never dropped and the global constants
are all skipped.
2018-10-24 23:33:01 -07:00
Alex Crichton
f016ae5846 Indicate workable browsers 2018-10-23 08:50:58 -07:00
Alex Crichton
c8f2f77480
Merge pull request #954 from alexcrichton/fix-futures
Defer future execution to the next event loop tick
2018-10-23 16:40:31 +02:00
Alex Crichton
a1da85a24b Defer future execution to the next event loop tick
Previously whenever a future readiness notification came in we would
immediately start polling a future. This ends up having two downsides,
however:

* First, the stack depth may run a risk of getting blown. There's no
  recursion limit to defer execution to later, which means that if
  futures are always ready we'll keep making the stack deeper.

* Second, and more worrisome in the near term, apparently future
  adapaters in the `futures` crate (namely the unsync oneshot channel)
  doesn't actually work if you immediately poll on readiness. This may
  or may not be a bug in the `futures` crate but it's good to fix it
  here anyway.

As a result whenever a future is ready to get polled again we defer its
polling to the next turn of the event loop. This should ensure that the
current call stack is always drained and we're effectively enqueueing
the future to be polled in the near future.
2018-10-23 07:12:54 -07:00
Jonathan Kingston
b322f46303 Adding in TODO MVC example using web-sys 2018-10-23 14:15:42 +01:00
Alex Crichton
cb170ef94f
Merge pull request #972 from alexcrichton/bulk-memory
Implement support for WebAssembly threads
2018-10-23 11:30:59 +02:00
Alex Crichton
25b26f41e7 Implement support for WebAssembly threads
... and add a parallel raytracing demo!

This commit adds enough support to `wasm-bindgen` to produce a workable
wasm binary *today* with the experimental WebAssembly threads support
implemented in Firefox Nightly. I've tried to comment what's going on in
the commits and such, but at a high level the changes made here are:

* A new transformation, living in a new `wasm-bindgen-threads-xform`
  crate, prepares a wasm module for parallel execution. This performs a
  number of mundane tasks which I hope to detail in a blog post later on.
* The `--no-modules` output is enhanced with more support for when
  shared memory is enabled, allowing passing in the module/memory to
  initialize the wasm instance on multiple threads (sharing both module
  and memory).
* The `wasm-bindgen` crate now offers the ability, in `--no-modules`
  mode, to get a handle on the `WebAssembly.Module` instance.
* The example itself requires Xargo to recompile the standard library
  with atomics and an experimental feature enabled. Afterwards it
  experimentally also enables threading support in wasm-bindgen.

I've also added hopefully enough CI support to compile this example in a
builder so we can upload it and poke around live online. I hope to
detail more about the technical details here in a blog post soon as
well!
2018-10-23 01:20:18 -07:00
Sendil Kumar N
dd80cf1ab1
Merge pull request #974 from alexcrichton/smaller
Shrink binary size of distributed `wasm-bindgen`
2018-10-18 08:40:12 +02:00
Alex Crichton
cb9c9fb011 Shrink binary size of distributed wasm-bindgen
This shaves a little over 2MB off the download locally for Linux,
removing debuginfo (which no one's probably gonna use anyway) as well as
switching from jemalloc to the system allocator.
2018-10-17 19:15:09 -07:00
Alex Crichton
ab8be88e7b
Merge pull request #970 from alexcrichton/more-new
Bind more Typed Array constructors in `js-sys`
2018-10-17 09:57:47 -05:00
Alex Crichton
58fb907baa
Merge pull request #971 from alexcrichton/update-parity-wasm
Update parity-wasm
2018-10-16 16:20:09 -05:00
Alex Crichton
a4a2ec605d Update parity-wasm
Bring in some support for bulk-memory-operations instructions
2018-10-16 14:04:40 -07:00