Skip to content

Commit da98073

Browse files
alexcrichtongnzlbg
authored andcommitted
Add assert_instr for wasm memory intrinsics
1 parent eff5fed commit da98073

File tree

5 files changed

+27
-14
lines changed

5 files changed

+27
-14
lines changed

Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ opt-level = 3
1414
[profile.bench]
1515
debug = 1
1616
opt-level = 3
17+
18+
[patch.crates-io]
19+
wasm-bindgen = { git = 'https://github.com/rustwasm/wasm-bindgen' }
20+
wasm-bindgen-test = { git = 'https://github.com/rustwasm/wasm-bindgen' }

ci/docker/wasm32-unknown-unknown/Dockerfile

+11-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,17 @@ RUN make -C wabt -j$(nproc)
1717
ENV PATH=$PATH:/wabt/bin
1818

1919
# Install `wasm-bindgen-test-runner`
20-
RUN curl -L https://github.com/rustwasm/wasm-bindgen/releases/download/0.2.15/wasm-bindgen-0.2.15-x86_64-unknown-linux-musl.tar.gz \
21-
| tar xzf -
22-
ENV PATH=$PATH:/wasm-bindgen-0.2.15-x86_64-unknown-linux-musl
20+
# RUN curl -L https://github.com/rustwasm/wasm-bindgen/releases/download/0.2.15/wasm-bindgen-0.2.15-x86_64-unknown-linux-musl.tar.gz \
21+
# | tar xzf -
22+
# ENV PATH=$PATH:/wasm-bindgen-0.2.15-x86_64-unknown-linux-musl
23+
# TODO: remove these lines once we can use published releases
24+
ENV CARGO_HOME=/cargo RUSTUP_HOME=/rustup
25+
ENV PATH=$PATH:/cargo/bin
26+
RUN curl https://sh.rustup.rs | sh -s -- -y
27+
ENV LIBZ_SYS_STATIC=1
28+
RUN cargo install --git https://github.com/rustwasm/wasm-bindgen \
29+
wasm-bindgen-cli --features vendored-openssl
30+
2331
ENV CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER=wasm-bindgen-test-runner
2432

2533
# Install `node`

ci/run-docker.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ run() {
1313
--user `id -u`:`id -g` \
1414
--rm \
1515
--init \
16-
--volume $HOME/.cargo:/cargo \
17-
--env CARGO_HOME=/cargo \
16+
--volume $HOME/.cargo:/cargo-h \
17+
--env CARGO_HOME=/cargo-h \
1818
--volume `rustc --print sysroot`:/rust:ro \
1919
--env TARGET=$target \
2020
--env STDSIMD_TEST_EVERYTHING \
@@ -25,7 +25,7 @@ run() {
2525
--privileged \
2626
stdsimd \
2727
bash \
28-
-c 'PATH=$PATH:/rust/bin exec ci/run.sh'
28+
-c 'PATH=/rust/bin:$PATH exec ci/run.sh'
2929
}
3030

3131
if [ -z "$1" ]; then

coresimd/wasm32/mod.rs

+7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ mod simd128;
77
pub mod simd128;
88
pub use self::simd128::*;
99

10+
#[cfg(test)]
11+
use stdsimd_test::assert_instr;
12+
#[cfg(test)]
13+
use wasm_bindgen_test::wasm_bindgen_test;
14+
1015
extern "C" {
1116
#[link_name = "llvm.wasm.grow.memory.i32"]
1217
fn llvm_grow_memory(pages: i32) -> i32;
@@ -21,6 +26,7 @@ extern "C" {
2126
///
2227
/// [instr]: https://github.com/WebAssembly/design/blob/master/Semantics.md#resizing
2328
#[inline]
29+
#[cfg_attr(test, assert_instr("memory.size"))]
2430
pub unsafe fn current_memory() -> i32 {
2531
llvm_current_memory()
2632
}
@@ -34,6 +40,7 @@ pub unsafe fn current_memory() -> i32 {
3440
///
3541
/// [instr]: https://github.com/WebAssembly/design/blob/master/Semantics.md#resizing
3642
#[inline]
43+
#[cfg_attr(test, assert_instr("memory.grow"))]
3744
pub unsafe fn grow_memory(delta: i32) -> i32 {
3845
llvm_grow_memory(delta)
3946
}

crates/stdsimd-test/src/lib.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -259,19 +259,13 @@ fn parse_dumpbin(output: &str) -> HashMap<String, Vec<Function>> {
259259
}
260260

261261

262-
#[cfg_attr(feature = "git_wasm_bindgen",
263-
wasm_bindgen(module = "child_process"))]
264-
#[cfg_attr(not(feature = "git_wasm_bindgen"),
265-
wasm_bindgen(module = "child_process", version = "*"))]
262+
#[wasm_bindgen(module = "child_process")]
266263
extern "C" {
267264
#[wasm_bindgen(js_name = execSync)]
268265
fn exec_sync(cmd: &str) -> Buffer;
269266
}
270267

271-
#[cfg_attr(feature = "git_wasm_bindgen",
272-
wasm_bindgen(module = "buffer"))]
273-
#[cfg_attr(not(feature = "git_wasm_bindgen"),
274-
wasm_bindgen(module = "buffer", version = "*"))]
268+
#[wasm_bindgen(module = "buffer")]
275269
extern "C" {
276270
type Buffer;
277271
#[wasm_bindgen(method, js_name = toString)]

0 commit comments

Comments
 (0)