Skip to content

Commit

Permalink
Add assert_instr for wasm memory intrinsics
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton authored and gnzlbg committed Aug 15, 2018
1 parent eff5fed commit da98073
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ opt-level = 3
[profile.bench]
debug = 1
opt-level = 3

[patch.crates-io]
wasm-bindgen = { git = 'https://github.com/rustwasm/wasm-bindgen' }
wasm-bindgen-test = { git = 'https://github.com/rustwasm/wasm-bindgen' }
14 changes: 11 additions & 3 deletions ci/docker/wasm32-unknown-unknown/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,17 @@ RUN make -C wabt -j$(nproc)
ENV PATH=$PATH:/wabt/bin

# Install `wasm-bindgen-test-runner`
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 \
| tar xzf -
ENV PATH=$PATH:/wasm-bindgen-0.2.15-x86_64-unknown-linux-musl
# 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 \
# | tar xzf -
# ENV PATH=$PATH:/wasm-bindgen-0.2.15-x86_64-unknown-linux-musl
# TODO: remove these lines once we can use published releases
ENV CARGO_HOME=/cargo RUSTUP_HOME=/rustup
ENV PATH=$PATH:/cargo/bin
RUN curl https://sh.rustup.rs | sh -s -- -y
ENV LIBZ_SYS_STATIC=1
RUN cargo install --git https://github.com/rustwasm/wasm-bindgen \
wasm-bindgen-cli --features vendored-openssl

ENV CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER=wasm-bindgen-test-runner

# Install `node`
Expand Down
6 changes: 3 additions & 3 deletions ci/run-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ run() {
--user `id -u`:`id -g` \
--rm \
--init \
--volume $HOME/.cargo:/cargo \
--env CARGO_HOME=/cargo \
--volume $HOME/.cargo:/cargo-h \
--env CARGO_HOME=/cargo-h \
--volume `rustc --print sysroot`:/rust:ro \
--env TARGET=$target \
--env STDSIMD_TEST_EVERYTHING \
Expand All @@ -25,7 +25,7 @@ run() {
--privileged \
stdsimd \
bash \
-c 'PATH=$PATH:/rust/bin exec ci/run.sh'
-c 'PATH=/rust/bin:$PATH exec ci/run.sh'
}

if [ -z "$1" ]; then
Expand Down
7 changes: 7 additions & 0 deletions coresimd/wasm32/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ mod simd128;
pub mod simd128;
pub use self::simd128::*;

#[cfg(test)]
use stdsimd_test::assert_instr;
#[cfg(test)]
use wasm_bindgen_test::wasm_bindgen_test;

extern "C" {
#[link_name = "llvm.wasm.grow.memory.i32"]
fn llvm_grow_memory(pages: i32) -> i32;
Expand All @@ -21,6 +26,7 @@ extern "C" {
///
/// [instr]: https://github.com/WebAssembly/design/blob/master/Semantics.md#resizing
#[inline]
#[cfg_attr(test, assert_instr("memory.size"))]
pub unsafe fn current_memory() -> i32 {
llvm_current_memory()
}
Expand All @@ -34,6 +40,7 @@ pub unsafe fn current_memory() -> i32 {
///
/// [instr]: https://github.com/WebAssembly/design/blob/master/Semantics.md#resizing
#[inline]
#[cfg_attr(test, assert_instr("memory.grow"))]
pub unsafe fn grow_memory(delta: i32) -> i32 {
llvm_grow_memory(delta)
}
10 changes: 2 additions & 8 deletions crates/stdsimd-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,19 +259,13 @@ fn parse_dumpbin(output: &str) -> HashMap<String, Vec<Function>> {
}


#[cfg_attr(feature = "git_wasm_bindgen",
wasm_bindgen(module = "child_process"))]
#[cfg_attr(not(feature = "git_wasm_bindgen"),
wasm_bindgen(module = "child_process", version = "*"))]
#[wasm_bindgen(module = "child_process")]
extern "C" {
#[wasm_bindgen(js_name = execSync)]
fn exec_sync(cmd: &str) -> Buffer;
}

#[cfg_attr(feature = "git_wasm_bindgen",
wasm_bindgen(module = "buffer"))]
#[cfg_attr(not(feature = "git_wasm_bindgen"),
wasm_bindgen(module = "buffer", version = "*"))]
#[wasm_bindgen(module = "buffer")]
extern "C" {
type Buffer;
#[wasm_bindgen(method, js_name = toString)]
Expand Down

0 comments on commit da98073

Please sign in to comment.