Commit Graph

3117 Commits

Author SHA1 Message Date
Nick Fitzgerald
311ae1941f Wasm interface types should imply multi-value 2019-10-03 12:57:26 -07:00
Kirguir
085924567f Fix guide for tests in the remote browser (#1804) 2019-10-03 09:27:07 -05:00
Colin Eberhardt
ffa6eabffe fixed broken link (#1803) 2019-10-03 09:26:54 -05:00
Nick Fitzgerald
74812bd236
Merge pull request #1802 from alexcrichton/switch-cores
Don't offset the number of rayon workers by 1
2019-10-02 11:25:05 -07:00
Alex Crichton
53c0dcf17a Don't offset the number of rayon workers by 1
If we pass rayon 0 workers it still spawns 1, so both 1 and 2 threads
were actually spawning one thread each. Let's remove the off-by-one so
1 and 2 cores should show a significant difference.
2019-10-01 18:10:18 -07:00
Alex Crichton
6d1dc813c4
Bump to 0.2.51 (#1797)
This notably brings in async/await support for current beta/nightly
users. Yay!
2019-09-26 14:07:28 -05:00
Alex Crichton
599ec8b9f4
Use official node releases for anyref test suite (#1798)
Looks like 12.11.0 has all the support we need!
2019-09-26 14:07:21 -05:00
Pauan
bdcf27c7cb Major improvements to wasm-bindgen-futures (#1760)
This PR contains a few major improvements:

* Code duplication has been removed.

* Everything has been refactored so that the implementation is much easier to understand.

* `future_to_promise` is now implemented with `spawn_local` rather than the other way around (this means `spawn_local` is faster since it doesn't need to create an unneeded `Promise`).

* Both the single threaded and multi threaded executors have been rewritten from scratch:

   * They only create 1-2 allocations in Rust per Task, and all of the allocations happen when the Task is created.

   * The singlethreaded executor creates 1 Promise per tick, rather than 1 Promise per tick per Task.

   * Both executors do *not* create `Closure`s during polling, instead all needed `Closure`s are created ahead of time.

   * Both executors now have correct behavior with regard to spurious wakeups and waking up during the call to `poll`.

   * Both executors cache the `Waker` so it doesn't need to be recreated all the time.

I believe both executors are now optimal in terms of both Rust and JS performance.
2019-09-26 13:33:12 -05:00
Alex Crichton
0b1a764f8a
Guarantee static_method_of uses the right this (#1795)
This came up during #1760 where `Promise.resolve` must be invoked with
`this` as the `Promise` object, but we were erroneously importing it in
such a way that it didn't have a shim and `this` was `undefined`.
2019-09-26 12:33:04 -05:00
Alex Crichton
025b1d8bca
Switch to Cargo's -Zbuild-std for building libstd (#1796)
This commit switches away from `xargo` to using `-Zbuild-std` to
building the standard library for the raytrace-parallel example (which
needs to rebuild std with new target features).
2019-09-26 12:32:50 -05:00
Jay D
6b31777794 Fix local webdriver discovery via PATH (#1794) 2019-09-26 09:49:43 -05:00
Alex Crichton
0607a75b78
Switch CI to testing beta toolchains (#1792)
Don't accidentally leak in nightly features and bring a modicum of
stability to the UI tests
2019-09-25 12:45:49 -05:00
Alex Crichton
6f52f2a37c
Fix logic for is_enabled in the threads transform (#1791)
The threads transform is implicitly enabled nowadays when the memory
looks like it's shared, so ensure that's taken into account in the
`is_enabled` check.
2019-09-25 11:58:55 -05:00
Alex Crichton
f4a7fe3ddb More CHANGELOG updates 2019-09-25 09:31:46 -07:00
Alex Crichton
72f346871c Handle JSON.stringify(undefined)
Turns out that `JSON.stringify(undefined)` doesn't actually return a
string, it returns `undefined`! If we're requested to serialize
`undefined` into JSON instead just interpret it as `null` which should
have the expected semantics of serving as a placeholder for `None`.

Closes #1778
2019-09-25 11:24:48 -05:00
Alex Crichton
55dbf9478f Don't log routine errors as out-of-the-ordinary
To benefit users in debug mode we log any unexpected exceptions to help
diagnose any issues that might arise. It turns out, though, we log this
for *every* exception happening for *every* import, including imports
like `__wbindgen_throw` which are explicitly intended to throw an
exception. This can cause distracting debug logs to get emitted to the
console, so let's squelch the debug logging for known imports that we
shouldn't log for, such as intrinsics.

Closes #1785
2019-09-25 11:24:27 -05:00
Alex Crichton
8b4fd2a946 Update CHANGELOG for upcoming release
No release yet, but wanted to write these things down
2019-09-25 11:24:00 -05:00
Alex Crichton
0afb6aafd3 Fix importing static values of non-JS types
This hasn't ever actually worked in `wasm-bindgen` but there's been
enough refactorings since the initial implementation that it's actually
quite trivial to implement now!

Closes #1777
2019-09-25 11:23:39 -05:00
Alex Crichton
e809a45c61 Update ui test expectations 2019-09-24 08:23:11 -07:00
dependabot-preview[bot]
a88003c2ec Update env_logger requirement from 0.6 to 0.7 (#1786)
Updates the requirements on [env_logger](https://github.com/sebasmagri/env_logger) to permit the latest version.
- [Release notes](https://github.com/sebasmagri/env_logger/releases)
- [Changelog](https://github.com/sebasmagri/env_logger/blob/master/CHANGELOG.md)
- [Commits](https://github.com/sebasmagri/env_logger/compare/v0.6.0...v0.7.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-09-24 09:00:22 -05:00
Alex Crichton
9c330529f2
Fix codegen for descriptors of async fn returns (#1782)
They erroneously reported returning the original return type, not the
promise! Let's also add a bunch of positive tests while we're at it.

Closes #1781
2019-09-20 16:06:27 -05:00
Alex Crichton
8ba0142dd2 Update UI expectations 2019-09-20 11:50:39 -07:00
kpcyrd
d1f104567b Fix file permissions (#1779) 2019-09-20 13:50:00 -05:00
Alex Crichton
93f5bbaf95 Update async-errors test for nightly 2019-09-19 07:03:03 -07:00
Kirguir
eeebec0765 Add ability to run tests on remote webdriver. (#1744)
* Add ability run tests on remote webdriver

* Add parsing `webdriver.json` for configure browser capabilities

* Add docs for configuring of browser capabilities

* Remove webdriver dependency
2019-09-19 09:00:51 -05:00
Nick Fitzgerald
04c9b32e34
Merge pull request #1764 from fitzgen/multi-value-xform
Use multi-value with interface types
2019-09-16 13:36:33 -07:00
Nick Fitzgerald
b2d1165724 CI: Temporarily disable sccache usage
It is failing to install / setup on CI.
2019-09-16 13:15:20 -07:00
Nick Fitzgerald
a0582cd6f2 rustfmt the publish script 2019-09-16 12:54:05 -07:00
Nick Fitzgerald
d9c4164c11 Also publish the wasm-bindgen-wasm-conventions crate 2019-09-16 12:54:05 -07:00
Nick Fitzgerald
2fbb8359e0 Create the wasm-bindgen-wasm-conventions crate
This tiny crate provides utilities for working with Wasm codegen
conventions (typically established by LLVM or lld) such as getting the shadow
stack pointer.

It also de-duplicates all the places in the codebase where we were implementing
these conventions in one-off ways.
2019-09-16 12:54:05 -07:00
Alex Crichton
a1dfa4bf5e Upgrade sccache to 0.2.11 2019-09-16 08:35:15 -07:00
quasicomputational
f5f9467211 Minimum viable ReadableStream.
No methods or attributes are mapped (yet).

This is mostly useful for constructing a `Response` from another one's
body in a streaming fashion.
2019-09-12 16:49:03 -05:00
Nick Fitzgerald
68af85d001 Ensure that various Into/From ABI methods are inlined 2019-09-10 17:32:30 -07:00
Nick Fitzgerald
908fc614c0 cli-support: cargo fmt 2019-09-10 17:32:30 -07:00
Nick Fitzgerald
5f90951441 Use the multi-value xform when targeting interface types 2019-09-10 17:32:30 -07:00
Nick Fitzgerald
fc2c502dfb CI: Run the multi-value xform tests in CI 2019-09-10 17:32:30 -07:00
Nick Fitzgerald
44c3f8ad2d Introduce the multi-value-xform crate
This crate provides a transformation to turn exported functions that use a
return pointer into exported functions that use multi-value.

Consider the following function:

```rust
pub extern "C" fn pair(a: u32, b: u32) -> [u32; 2] {
    [a, b]
}
```

LLVM will by default compile this down into the following Wasm:

```wasm
(func $pair (param i32 i32 i32)
  local.get 0
  local.get 2
  i32.store offset=4
  local.get 0
  local.get 1
  i32.store)
```

What's happening here is that the function is not directly returning the
pair at all, but instead the first `i32` parameter is a pointer to some
scratch space, and the return value is written into the scratch space. LLVM
does this because it doesn't yet have support for multi-value Wasm, and so
it only knows how to return a single value at a time.

Ideally, with multi-value, what we would like instead is this:

```wasm
(func $pair (param i32 i32) (result i32 i32)
  local.get 0
  local.get 1)
```

However, that's not what this transformation does at the moment. This
transformation is a little simpler than mutating existing functions to
produce a multi-value result, instead it introduces new functions that wrap
the original function and translate the return pointer to multi-value
results in this wrapper function.

With our running example, we end up with this:

```wasm
;; The original function.
(func $pair (param i32 i32 i32)
  local.get 0
  local.get 2
  i32.store offset=4
  local.get 0
  local.get 1
  i32.store)

(func $pairWrapper (param i32 i32) (result i32 i32)
  ;; Our return pointer that points to the scratch space we are allocating
  ;; on the shadow stack for calling `$pair`.
  (local i32)

  ;; Allocate space on the shadow stack for the result.
  global.get $shadowStackPointer
  i32.const 8
  i32.sub
  local.tee 2
  global.set $shadowStackPointer

  ;; Call `$pair` with our allocated shadow stack space for its results.
  local.get 2
  local.get 0
  local.get 1
  call $pair

  ;; Copy the return values from the shadow stack to the wasm stack.
  local.get 2
  i32.load
  local.get 2 offset=4
  i32.load

  ;; Finally, restore the shadow stack pointer.
  local.get 2
  i32.const 8
  i32.add
  global.set $shadowStackPointer)
```

This `$pairWrapper` function is what we actually end up exporting instead of
`$pair`.
2019-09-10 17:32:30 -07:00
Nick Fitzgerald
582b733967 Update to walrus 0.12.0 2019-09-10 17:32:30 -07:00
C Burgos
7cca2751c1 remove shell status update (#1758) 2019-09-09 09:59:43 -05:00
C Burgos
f0a55f8930 Feat/date opt params (#1759)
* add date methods/ constructors with opt params

* Run fmt
2019-09-09 09:57:51 -05:00
Alex Crichton
88618116ac
Add support for #[wasm_bindgen] on async fn (#1754)
This commit adds support to attach `#[wasm_bindgen]` on an `async fn`
which will change the return value into a `Promise` in JS. This in
theory has the exact same semantics as an `async` function in JS where
you call it with all the arguments, nothing happens and you get a
promise back, and then later the promise actually resolves.

This commit also adds a helper trait, `IntoJsResult`, to allow `async`
functions with multiple kinds of return values instead of requiring
everything to be `Result<JsValue, JsValue>`.
2019-09-06 13:47:16 -05:00
Alex Crichton
7fd6702c6d Update assertion of stderr on nightly
rustc's error messages changed!
2019-09-05 09:52:14 -07:00
Alex Crichton
84898c1d53
Touch up documentation about futures (#1753) 2019-09-05 11:49:04 -05:00
Alex Crichton
3c887c40b7
Default all async support to std::future (#1741)
This commit defaults all crates in-tree to use `std::future` by default
and none of them support the crates.io `futures` 0.1 crate any more.
This is a breaking change for `wasm-bindgen-futures` and
`wasm-bindgen-test` so they've both received a major version bump to
reflect the new defaults. Historical versions of these crates should
continue to work if necessary, but they won't receive any more
maintenance after this is merged.

The movement here liberally uses `async`/`await` to remove the need for
using any combinators on the `Future` trait. As a result many of the
crates now rely on a much more recent version of the compiler,
especially to run tests.

The `wasm-bindgen-futures` crate was updated to remove all of its
futures-related dependencies and purely use `std::future`, hopefully
improving its compatibility by not having any version compat
considerations over time. The implementations of the executors here are
relatively simple and only delve slightly into the `RawWaker` business
since there are no other stable APIs in `std::task` for wrapping these.

This commit also adds support for:

    #[wasm_bindgen_test]
    async fn foo() {
        // ...
    }

where previously you needed to pass `(async)` now that's inferred
because it's an `async fn`.

Closes #1558
Closes #1695
2019-09-05 11:18:36 -05:00
Pauan
ba85275d7d Adding in more methods for Array (#1749) 2019-09-04 11:46:33 -05:00
Alex Crichton
4e19ead71b
Fix the wasm2js example (#1750)
This needed and update now that we're explicitly importing `*.wasm` to
import `*.js` instead. Additionally this was moved over to the `web`
target to avoid needing Webpack

Closes #1743
2019-09-03 16:05:23 -04:00
Alex Crichton
1f39a3045f
Merge pull request #1738 from freebroccolo/master
Fix warnings in raytrace-parallel example
2019-08-28 12:13:46 -05:00
Darin Morrison
0eba2efe45 Fix warnings in raytrace-parallel example 2019-08-27 12:40:58 -07:00
Alex Crichton
777828aa95
Merge pull request #1739 from xtuc/upgrade-wasm-pack-plugin-1.0.1
upgrade @wasm-tool/wasm-pack-plugin to 1.0.1
2019-08-27 14:24:53 -05:00
Sven Sauleau
312f5d6dca chore: upgrade @wasm-tool/wasm-pack-plugin to 1.0.1 2019-08-27 18:20:24 +01:00