Commit Graph

2048 Commits

Author SHA1 Message Date
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
Alex Crichton
f064f5a9d4
Merge pull request #933 from expobrain/basig_usage_fix
Update installation of toolchain in Basic Usage page
2018-10-05 09:25:19 -07:00
Daniele Esposti
882c6ef0ed Update installation of toolchain in Basic Usage page 2018-10-05 17:15:22 +01:00
Alex Crichton
b6caad4df8
Merge pull request #932 from twilco/fix-broken-link
Fix broken link to contribution page
2018-10-05 08:41:03 -07:00
Tyler Wilcock
2aaa4b8fc6 Fix broken link to contribution page 2018-10-05 10:25:55 -05:00
Alex Crichton
e368e49af1
Merge pull request #928 from alexcrichton/node-args
Allow passing extra args to node in test runner
2018-10-04 23:13:58 -07:00
Alex Crichton
7eb49acf0d Allow passing extra args to node in test runner
This can be useful for enabling experimental features
2018-10-04 22:20:23 -07:00
Nick Fitzgerald
64a39703ef
Merge pull request #930 from alexcrichton/ssl
Use `https` on badge url
2018-10-04 12:48:56 -07:00
Alex Crichton
c584b8ac84 Use https on badge url 2018-10-04 11:10:35 -07:00
Nick Fitzgerald
7ea3ee60b7
Merge pull request #927 from alexcrichton/fix-browser
Fix the `no_modules` example by fixing `--browser`
2018-10-03 16:34:31 -07:00
Nick Fitzgerald
0b736c7ef0
Merge pull request #926 from alexcrichton/fix-warnings
Filter only for `RustDeprecated` in attrs
2018-10-03 16:33:46 -07:00