Commit Graph

2538 Commits

Author SHA1 Message Date
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
93564f159f Fix build of TODO MVC on stable 2018-10-29 13:47:09 -07:00
9a3ef7b747 Merge pull request #961 from jonathanKingston/todo-mvc
Todo mvc
2018-10-29 13:24:59 -07:00
bb28f76906 Try to improve the publish script 2018-10-29 13:08:22 -07:00
7fad2bf0c8 Bump to 0.2.26 0.2.26 2018-10-29 12:56:37 -07:00
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
ec6e13a0f8 Merge pull request #987 from alexcrichton/gc-locals
Add gc support for locals in functions
2018-10-29 10:11:06 -07:00
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
1ec68009e8 Merge pull request #985 from alexcrichton/differeng-gc
Restructure internals of `wasm-gc`
2018-10-29 10:45:53 +01:00
73740ba6ab Merge pull request #984 from alexcrichton/more-gc
Discard internal LLD symbols during gc
2018-10-29 10:44:50 +01:00
9ebbcd3827 Merge pull request #992 from alexcrichton/inline-trivial
Flag a trivial `JsValue` constructor as `#[inline]`
2018-10-28 14:57:53 -07:00
8d695b800d Merge pull request #989 from alexcrichton/stable-ci
Promote CI jobs to using stable Rust
2018-10-28 14:14:49 -07:00
451004defc Merge pull request #991 from alexcrichton/safaridriver
Fix WebDriver compat with Safari
2018-10-28 13:54:03 -07:00
6d78c5304a Merge pull request #990 from alexcrichton/sccache
Try to speed up CI with sccache
2018-10-28 13:53:50 -07:00
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
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
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
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
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
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
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
78f425744f Don't pass 0-length mallocs to system allocator
Part of the unsafe contract!
2018-10-28 10:09:57 -07:00
1fa407d2f9 Merge pull request #980 from alexcrichton/tweka-free
Tweak some logic in `JsValue::drop`
2018-10-26 09:53:08 +02:00
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
f016ae5846 Indicate workable browsers 2018-10-23 08:50:58 -07:00
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
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
b322f46303 Adding in TODO MVC example using web-sys 2018-10-23 14:15:42 +01:00
cb170ef94f Merge pull request #972 from alexcrichton/bulk-memory
Implement support for WebAssembly threads
2018-10-23 11:30:59 +02:00
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
dd80cf1ab1 Merge pull request #974 from alexcrichton/smaller
Shrink binary size of distributed `wasm-bindgen`
2018-10-18 08:40:12 +02:00
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
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
58fb907baa Merge pull request #971 from alexcrichton/update-parity-wasm
Update parity-wasm
2018-10-16 16:20:09 -05:00
a4a2ec605d Update parity-wasm
Bring in some support for bulk-memory-operations instructions
2018-10-16 14:04:40 -07:00
995aefa87e Merge pull request #969 from alexcrichton/no-modules-moudle
Allow passing a `WebAssembly.Module` in `--no-modules`
2018-10-16 14:24:25 -05:00
9effb7c707 Bind more Typed Array constructors in js-sys
Bind `new Int8Array(length)`, `new Int8Array(buffer, offset)` and `new
Int8Array(buffer, offset, length)`.
2018-10-16 11:16:22 -07:00
34b75c35b2 Allow passing a WebAssembly.Module in --no-modules
I've noticed this in a few cases where it's sometimes easy to have a
`WebAssembly.Module` on-hand for the `--no-modules` mode where you don't
want to necessarily `fetch`. This commit changes the exported
initialization function in `--no-modules` mode to support both!
2018-10-16 10:48:07 -07:00
0b59657603 Merge pull request #945 from alexcrichton/remove-json
Don't use JSON for custom section format
2018-10-16 05:49:00 -07:00
79c050a0e6 Merge pull request #966 from katis/dataview_endian_overloads
Add overloads with endianness parameter to DataView gets and sets
2018-10-15 09:35:22 -05:00
83f9f54b04 Fix getFloat64 comments 2018-10-15 16:24:49 +03:00
968b5e0154 Add overloads with endianness parameter to DataView gets and sets 2018-10-15 14:32:17 +03:00
2b90532db5 Merge pull request #965 from djozis/master
Removed buffer copy from webgl example
2018-10-14 22:08:38 -05:00
b369932b37 Fixed typo 2018-10-14 17:00:56 -04:00
30bb9b09d3 Switched from raw pointer casts to using as_ptr() 2018-10-14 16:50:35 -04:00
52128e9baa Cleaned up memory buffer access 2018-10-14 13:28:27 -04:00
f408310ab7 Removed buffer copy from webgl example 2018-10-14 13:28:27 -04:00
f749c7cf95 Don't use JSON for custom section format
This commit migrates away from using Serde for the custom section in
wasm executables. This is a refactoring of a purely-internal data
structure to `wasm-bindgen` and should have no visible functional change
on users.

The motivation for this commit is two fold:

* First, the compile times using `serde_json` and `serde_derive` for the
  syntax extension isn't the most fun.
* Second, eventually we're going to want to stablize the layout of the
  custom section, and it's highly unlikely to be json!

Primarily, though, the intention of this commit is to improve the
cold-cache compile time of `wasm-bindgen` by ensuring that for new users
this project builds as quickly as possible. By removing some heavyweight
dependencies from the procedural macro, `serde`, `serde_derive`, and
`serde_json`, we're able to get a pretty nice build time improvement for
the `wasm-bindgen` crate itself:

|             | single-core build | parallel build |
|-------------|-------------------|----------------|
| master      |             36.5s |          17.3s |
| this commit |             20.5s |          11.8s |

These are't really end-all-be-all wins but they're much better
especially on the spectrum of weaker CPUs (in theory modeled by the
single-core case showing we have 42% less CPU work in theory).
2018-10-12 11:23:00 -07:00
aac8696d05 Merge pull request #959 from alexcrichton/moreundef
Fix generated shims if APIs don't exist
2018-10-12 10:18:44 -07:00
13cac2d0c4 Fix generated shims if APIs don't exist
This commit fixes instantiation of the wasm module even if some of the
improted APIs don't exist. This extends the functionality initially
added in #409 to attempt to gracefully allow importing values from the
environment which don't actually exist in all contexts. In addition to
nonexistent methods being handled now entire nonexistent types are now
also handled.

I suspect that eventually we'll add a CLI flag to `wasm-bindgen` to say
"I assert everything exists, don't check it" to trim out the extra JS
glue generated here. In the meantime though this'll pave the way for a
wasm-bindgen shim to be instantiated in both a web worker and the main
thread, while using DOM-like APIs only on the main thread.
2018-10-10 17:46:51 -07:00