Commit Graph

1858 Commits

Author SHA1 Message Date
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
Alex Crichton
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
Alex Crichton
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
Alex Crichton
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
Nick Fitzgerald
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
Alex Crichton
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
Joni Katajamäki
83f9f54b04 Fix getFloat64 comments 2018-10-15 16:24:49 +03:00
Joni Katajamäki
968b5e0154 Add overloads with endianness parameter to DataView gets and sets 2018-10-15 14:32:17 +03:00
Alex Crichton
2b90532db5
Merge pull request #965 from djozis/master
Removed buffer copy from webgl example
2018-10-14 22:08:38 -05:00
David Jozis
b369932b37 Fixed typo 2018-10-14 17:00:56 -04:00
David Jozis
30bb9b09d3 Switched from raw pointer casts to using as_ptr() 2018-10-14 16:50:35 -04:00
David Jozis
52128e9baa Cleaned up memory buffer access 2018-10-14 13:28:27 -04:00
David Jozis
f408310ab7 Removed buffer copy from webgl example 2018-10-14 13:28:27 -04:00
Alex Crichton
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
Nick Fitzgerald
aac8696d05
Merge pull request #959 from alexcrichton/moreundef
Fix generated shims if APIs don't exist
2018-10-12 10:18:44 -07:00
Alex Crichton
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
Alex Crichton
e03e40451e
Merge pull request #955 from alexcrichton/non-send
Ensure that `JsValue` isn't considered `Send`
2018-10-10 17:41:49 -07:00
Alex Crichton
41d3a08028
Merge pull request #958 from alexcrichton/no-global-cache
js_sys: Use a thread local to cache `global()`
2018-10-10 17:41:41 -07:00
Alex Crichton
e0b73abc7e
Merge pull request #957 from alexcrichton/promise-clone
js_sys: Add `#[derive(Clone, Debug)]` to `Promise`
2018-10-10 16:52:57 -07:00
Alex Crichton
e72ae12e77
Merge pull request #956 from alexcrichton/js-sys-typed-array-slice
js-sys: Add bindings for `TypedArray.slice`
2018-10-10 16:52:39 -07:00
Alex Crichton
4993e45fd9 Squash a few warnings that snuck in by accident 2018-10-10 16:09:24 -07:00
Alex Crichton
105a6bc853 js_sys: Use a thread local to cache global()
When we add threads it's not actually valid to have a global cache as
the index is only valid on one thread! Instead let's use a per-thread
cache using `thread_local!` which compiles to basically the same code as
before for single-threaded wasm.
2018-10-10 16:01:32 -07:00
Alex Crichton
e9fa209dcf js_sys: Add #[derive(Clone, Debug)] to Promise
I think we just forgot this from earlier!
2018-10-10 15:58:47 -07:00
Alex Crichton
f9d2dbd0b6 js-sys: Add bindings for TypedArray.slice
This commit adds support for the `slice` function on all `TypedArray`
instances. The `slice` function is similar to `subarray` except that it
actually copies the data, whereas `subarray` just returns a different
view into data.
2018-10-10 15:57:00 -07:00
Alex Crichton
e46537e6c2 Ensure that JsValue isn't considered Send
The `JsValue` type wraps a slab/heap of js objects which is managed by
the wasm-bindgen shim, and everything here is not actually able to cross
any thread boundaries. When wasm actually has threads, for example, each
thread will have to have its own slab of objects generated by
wasm-bindgen, and indices in one slab aren't valid in any other slabs.

This is technically a breaking change because `JsValue` was previously
`Send` and `Sync`, but I'm hoping that in practice this isn't actually a
breaking change because nothing in wasm can be using threads which in
theory shouldn't activate the `Send` and/or `Sync` bounds.
2018-10-10 15:47:07 -07:00
Nick Fitzgerald
dd82a3e134 Bump to 0.2.25 2018-10-10 13:19:40 -07:00
Alex Crichton
70e13705b4
Merge pull request #952 from alexcrichton/field-export
Fix bindings for classes only referenced through struct fields
2018-10-10 11:55:24 -07:00
Nick Fitzgerald
fe35750448
Merge pull request #953 from alexcrichton/bigint
Add caveat for `BigInt` and `u64` in browser support
2018-10-10 11:44:04 -07:00
Alex Crichton
5957289ef2 Add caveat for BigInt and u64 in browser support
Closes #948
2018-10-10 10:30:32 -07:00
Alex Crichton
f6cb73442a Fix bindings for classes only referenced through struct fields
The bindings generation for a class would accidentally omit the `__wrap`
function if it was only discovered very late in the process that
`__wrap` was needed, after we'd already passed the point where we needed
to have decided that.

This commit moves struct field generation of bindings much earlier in
the binding generation process which should ensure everything is all
hooked up by the time we generate the classes themselves.

Closes #949
2018-10-10 10:21:19 -07:00
Alex Crichton
35eeb711ad
Merge pull request #947 from fitzgen/use-global-allocator-not-system
Use the global allocator, not the system allocator
2018-10-10 08:43:23 -07:00
Nick Fitzgerald
3ceb0441d3 Use the global allocator, not the system allocator
This was previously causing us to accidentally always pull in the system
allocator, even if users were trying to just use a custom global allocator.
2018-10-09 18:08:46 -07:00
Alex Crichton
d70149dd91
Merge pull request #946 from fitzgen/guide-testing-wasm-pack
guide: clarify testing docs; prefer `wasm-pack`-based workflows
2018-10-09 09:38:18 -07:00
Nick Fitzgerald
8d195d07ee guide: clarify testing docs; prefer wasm-pack-based workflows 2018-10-09 09:31:01 -07:00
Alex Crichton
1410b5253d
Merge pull request #944 from alexcrichton/windows-slash
Fix web-sys build on some Windows builds
2018-10-08 12:46:44 -07:00
Alex Crichton
6a9ad2e5d3
Merge pull request #942 from alexcrichton/parity-wasm-public
Update parity-wasm dependency
2018-10-08 12:46:35 -07:00
Alex Crichton
a40b27da60
Merge pull request #941 from alexcrichton/fix-201
Add tests for internal imports now working
2018-10-08 10:20:05 -07:00
Alex Crichton
18deb5e848 Fix web-sys build on some Windows builds
The official pathname separator on Windows is `\` instead of `/`, but
we've been unconditionally using `/`. This typically works on Windows
because Cargo's default `OUT_DIR` listing is a normal `C:\...` path
which works with either `/` or `\`. If, however, a user sets
`CARGO_TARGET_DIR` to a UNC-style path like `\\?\C:\...` then `/` is
*not* the same as `\`, but rather `/` is interpreted as part of the file
name (to allow file names with `/` in the name).

Let's bypass all this and just use a build script output env var.

Closes #943
2018-10-08 10:19:43 -07:00
Alex Crichton
79e4324a3b Update parity-wasm dependency
While doing this, make `parity-wasm` a public dependency of all crates
instead of using the `Any` trick as that's not really needed any more.
2018-10-08 10:01:53 -07:00
Alex Crichton
b868185637 Add tests for internal imports now working
These compiler bugs have now been fixed on nightly, so we just need to
wait for the bug fixes to ride the trains to be available to everyone!

Closes #201
2018-10-08 09:47:17 -07:00
Alex Crichton
e3e5c0f57d
Merge pull request #938 from killercup/patch-1
Fix unimportant typo
2018-10-06 14:12:25 -07:00
Pascal Hertleif
959deeea5d Fix unimportant typo 2018-10-06 21:09:18 +02:00
Alex Crichton
5ee35524e9
Merge pull request #936 from alexcrichton/import-gc
Import the `wasm-gc-api` crate into this repository
2018-10-05 15:29:49 -07:00
Alex Crichton
4750927f11 Import the wasm-gc-api crate into this repository
The `wasm-bindgen` crate is effectively the only user of this crate now
that the `wasm-gc` tool has been deprecated. It's also much easier to
keep it in this repository as it's easier to sync changes to
`parity-wasm`. I'd also like to start refactoring out utilities for
managing a `parity_wasm::Module` to share between this crate and the
other CLI support code.
2018-10-05 14:21:59 -07:00
Alex Crichton
4357d7d23d
Merge pull request #934 from alexcrichton/bump
Bump to 0.2.24
2018-10-05 11:20:50 -07:00
Alex Crichton
c210ccd596 Bump to 0.2.24 2018-10-05 09:53:19 -07:00