mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-09 22:28:21 +00:00
Merge branch 'master' into add-log-streams-options
This commit is contained in:
4
.github/cross-linux-riscv64/Dockerfile
vendored
4
.github/cross-linux-riscv64/Dockerfile
vendored
@@ -28,7 +28,7 @@ RUN apt-get update && \
|
|||||||
# install rust tools
|
# install rust tools
|
||||||
RUN curl --proto "=https" --tlsv1.2 --retry 3 -sSfL https://sh.rustup.rs | sh -s -- -y
|
RUN curl --proto "=https" --tlsv1.2 --retry 3 -sSfL https://sh.rustup.rs | sh -s -- -y
|
||||||
ENV PATH="/root/.cargo/bin:${PATH}"
|
ENV PATH="/root/.cargo/bin:${PATH}"
|
||||||
RUN rustup -v toolchain install 1.70
|
RUN rustup -v toolchain install 1.73
|
||||||
# add docker the manual way
|
# add docker the manual way
|
||||||
COPY install_docker.sh /
|
COPY install_docker.sh /
|
||||||
RUN /install_docker.sh
|
RUN /install_docker.sh
|
||||||
@@ -61,7 +61,7 @@ ENV CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_GNU_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc
|
|||||||
RUST_TEST_THREADS=1 \
|
RUST_TEST_THREADS=1 \
|
||||||
PKG_CONFIG_PATH="/usr/lib/riscv64-linux-gnu/pkgconfig/:${PKG_CONFIG_PATH}"
|
PKG_CONFIG_PATH="/usr/lib/riscv64-linux-gnu/pkgconfig/:${PKG_CONFIG_PATH}"
|
||||||
|
|
||||||
RUN rustup target add riscv64gc-unknown-linux-gnu --toolchain 1.70-x86_64-unknown-linux-gnu
|
RUN rustup target add riscv64gc-unknown-linux-gnu --toolchain 1.73-x86_64-unknown-linux-gnu
|
||||||
|
|
||||||
#compile libssl-dev for riscv64!
|
#compile libssl-dev for riscv64!
|
||||||
COPY build_openssl.sh /
|
COPY build_openssl.sh /
|
||||||
|
|||||||
2
.github/workflows/benchmark.yaml
vendored
2
.github/workflows/benchmark.yaml
vendored
@@ -7,7 +7,7 @@ on:
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: git
|
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: git
|
||||||
MSRV: "1.70"
|
MSRV: "1.73"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
run_benchmark:
|
run_benchmark:
|
||||||
|
|||||||
35
.github/workflows/build.yml
vendored
35
.github/workflows/build.yml
vendored
@@ -3,7 +3,7 @@ name: Builds
|
|||||||
env:
|
env:
|
||||||
RUST_BACKTRACE: 1
|
RUST_BACKTRACE: 1
|
||||||
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: git
|
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: git
|
||||||
MSRV: "1.70"
|
MSRV: "1.73"
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -60,7 +60,7 @@ jobs:
|
|||||||
use_llvm: true
|
use_llvm: true
|
||||||
build_wasm: false
|
build_wasm: false
|
||||||
- build: macos-arm64
|
- build: macos-arm64
|
||||||
os: macos-11.0
|
os: macos-14
|
||||||
target: aarch64-apple-darwin
|
target: aarch64-apple-darwin
|
||||||
artifact_name: 'wasmer-darwin-arm64'
|
artifact_name: 'wasmer-darwin-arm64'
|
||||||
use_sccache: false
|
use_sccache: false
|
||||||
@@ -98,11 +98,6 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
toolchain: ${{ env.MSRV }}
|
toolchain: ${{ env.MSRV }}
|
||||||
target: ${{ matrix.target }}
|
target: ${{ matrix.target }}
|
||||||
- name: Install Rust nightly (to build capi-headless)
|
|
||||||
uses: dtolnay/rust-toolchain@master
|
|
||||||
with:
|
|
||||||
toolchain: "nightly-2023-05-25"
|
|
||||||
target: ${{ matrix.metadata.target }}
|
|
||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@v2
|
||||||
if: matrix.use_sccache != true
|
if: matrix.use_sccache != true
|
||||||
- name: Install LLVM (macOS Apple Silicon)
|
- name: Install LLVM (macOS Apple Silicon)
|
||||||
@@ -191,17 +186,9 @@ jobs:
|
|||||||
echo 'RUSTC_WRAPPER=${{ runner.tool_cache }}/cargo-sccache/bin/sccache' >> $GITHUB_ENV
|
echo 'RUSTC_WRAPPER=${{ runner.tool_cache }}/cargo-sccache/bin/sccache' >> $GITHUB_ENV
|
||||||
shell: bash
|
shell: bash
|
||||||
- name: Build C API headless
|
- name: Build C API headless
|
||||||
if: matrix.build != 'macos-arm64'
|
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
make package-capi-headless
|
make package-capi-headless
|
||||||
- name: Build C API headless
|
|
||||||
if: matrix.build == 'macos-arm64'
|
|
||||||
run: |
|
|
||||||
make package-capi-headless
|
|
||||||
env:
|
|
||||||
TARGET: aarch64-apple-darwin
|
|
||||||
TARGET_DIR: target/aarch64-apple-darwin/release
|
|
||||||
- name: Build C API
|
- name: Build C API
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
@@ -224,9 +211,10 @@ jobs:
|
|||||||
# run: |
|
# run: |
|
||||||
# make build-wasmer-wasm
|
# make build-wasmer-wasm
|
||||||
- name: Install Nightly Rust for Headless
|
- name: Install Nightly Rust for Headless
|
||||||
|
if: matrix.build != 'linux-musl-x64'
|
||||||
uses: dtolnay/rust-toolchain@master
|
uses: dtolnay/rust-toolchain@master
|
||||||
with:
|
with:
|
||||||
toolchain: "nightly-2023-05-25"
|
toolchain: "nightly-2023-10-05"
|
||||||
target: ${{ matrix.target }}
|
target: ${{ matrix.target }}
|
||||||
components: "rust-src"
|
components: "rust-src"
|
||||||
- name: Build Minimal Wasmer Headless
|
- name: Build Minimal Wasmer Headless
|
||||||
@@ -244,20 +232,12 @@ jobs:
|
|||||||
echo "incremental = false" >> Cargo.toml
|
echo "incremental = false" >> Cargo.toml
|
||||||
echo "codegen-units = 1" >> Cargo.toml
|
echo "codegen-units = 1" >> Cargo.toml
|
||||||
echo "rpath = false" >> Cargo.toml
|
echo "rpath = false" >> Cargo.toml
|
||||||
rustup override set nightly-2023-05-25
|
rustup override set nightly-2023-10-05
|
||||||
make build-wasmer-headless-minimal
|
make build-wasmer-headless-minimal
|
||||||
rustup override unset
|
rustup override unset
|
||||||
- name: Dist
|
- name: Dist
|
||||||
if: matrix.build != 'macos-arm64'
|
|
||||||
run: |
|
run: |
|
||||||
make distribution
|
make distribution
|
||||||
- name: Dist macos-arm64
|
|
||||||
if: matrix.build == 'macos-arm64'
|
|
||||||
run: |
|
|
||||||
make distribution
|
|
||||||
env:
|
|
||||||
TARGET: aarch64-apple-darwin
|
|
||||||
TARGET_DIR: target/aarch64-apple-darwin/release
|
|
||||||
- name: Upload Artifacts
|
- name: Upload Artifacts
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
@@ -278,11 +258,6 @@ jobs:
|
|||||||
- uses: dtolnay/rust-toolchain@stable
|
- uses: dtolnay/rust-toolchain@stable
|
||||||
with:
|
with:
|
||||||
target: x86_64-pc-windows-gnu
|
target: x86_64-pc-windows-gnu
|
||||||
- name: Install Rust nightly (to build capi-headless)
|
|
||||||
uses: dtolnay/rust-toolchain@master
|
|
||||||
with:
|
|
||||||
toolchain: "nightly-2023-05-25"
|
|
||||||
target: x86_64-pc-windows-gnu
|
|
||||||
- name: Install Windows-GNU target
|
- name: Install Windows-GNU target
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
2
.github/workflows/cloudcompiler.yaml
vendored
2
.github/workflows/cloudcompiler.yaml
vendored
@@ -2,7 +2,7 @@ name: Release cloudcompiler.wasm
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
RUST_BACKTRACE: 1
|
RUST_BACKTRACE: 1
|
||||||
MSRV: "1.70"
|
MSRV: "1.73"
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
|||||||
2
.github/workflows/documentation.yaml
vendored
2
.github/workflows/documentation.yaml
vendored
@@ -8,7 +8,7 @@ on:
|
|||||||
- 'lib/**'
|
- 'lib/**'
|
||||||
|
|
||||||
env:
|
env:
|
||||||
MSRV: "1.70"
|
MSRV: "1.73"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
documentation:
|
documentation:
|
||||||
|
|||||||
15
.github/workflows/test.yaml
vendored
15
.github/workflows/test.yaml
vendored
@@ -24,7 +24,7 @@ env:
|
|||||||
# Rust, but it's not stable on 1.69 yet. By explicitly setting the protocol we
|
# Rust, but it's not stable on 1.69 yet. By explicitly setting the protocol we
|
||||||
# can override that behaviour
|
# can override that behaviour
|
||||||
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: git
|
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: git
|
||||||
MSRV: "1.70"
|
MSRV: "1.73"
|
||||||
NEXTEST_PROFILE: "ci"
|
NEXTEST_PROFILE: "ci"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@@ -161,7 +161,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: dtolnay/rust-toolchain@master
|
- uses: dtolnay/rust-toolchain@master
|
||||||
with:
|
with:
|
||||||
toolchain: "nightly-2023-05-25"
|
toolchain: "nightly-2023-10-05"
|
||||||
target: x86_64-unknown-linux-gnu
|
target: x86_64-unknown-linux-gnu
|
||||||
- run: cargo install toml-cli # toml-cli is required to run `make test-build-docs-rs`
|
- run: cargo install toml-cli # toml-cli is required to run `make test-build-docs-rs`
|
||||||
- name: make test-build-docs-rs-ci
|
- name: make test-build-docs-rs-ci
|
||||||
@@ -369,11 +369,6 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
toolchain: ${{ env.MSRV }}
|
toolchain: ${{ env.MSRV }}
|
||||||
target: ${{ matrix.metadata.target }}
|
target: ${{ matrix.metadata.target }}
|
||||||
- name: Install Rust nightly (to build capi-headless)
|
|
||||||
uses: dtolnay/rust-toolchain@master
|
|
||||||
with:
|
|
||||||
toolchain: "nightly-2023-05-25"
|
|
||||||
target: ${{ matrix.metadata.target }}
|
|
||||||
- name: Install Nextest
|
- name: Install Nextest
|
||||||
uses: taiki-e/install-action@nextest
|
uses: taiki-e/install-action@nextest
|
||||||
- name: Install Windows-GNU linker
|
- name: Install Windows-GNU linker
|
||||||
@@ -556,6 +551,12 @@ jobs:
|
|||||||
exe: '',
|
exe: '',
|
||||||
llvm_url: 'https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.7/clang+llvm-15.0.7-x86_64-apple-darwin21.0.tar.xz'
|
llvm_url: 'https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.7/clang+llvm-15.0.7-x86_64-apple-darwin21.0.tar.xz'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
build: macos-arm64,
|
||||||
|
os: macos-14,
|
||||||
|
target: aarch64-apple-darwin,
|
||||||
|
exe: '',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
build: windows-x64,
|
build: windows-x64,
|
||||||
os: windows-2019,
|
os: windows-2019,
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ edition = "2021"
|
|||||||
homepage = "https://wasmer.io/"
|
homepage = "https://wasmer.io/"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
repository = "https://github.com/wasmerio/wasmer"
|
repository = "https://github.com/wasmerio/wasmer"
|
||||||
rust-version = "1.70"
|
rust-version = "1.73"
|
||||||
version = "4.2.5"
|
version = "4.2.5"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
|
|||||||
4
Makefile
4
Makefile
@@ -468,10 +468,10 @@ test-build-docs-rs-ci:
|
|||||||
fi; \
|
fi; \
|
||||||
printf "*** Building doc for package with manifest $$manifest_path ***\n\n"; \
|
printf "*** Building doc for package with manifest $$manifest_path ***\n\n"; \
|
||||||
if [ -z "$$features" ]; then \
|
if [ -z "$$features" ]; then \
|
||||||
RUSTDOCFLAGS="--cfg=docsrs" $(CARGO_BINARY) +nightly-2023-05-25 doc $(CARGO_TARGET_FLAG) --manifest-path "$$manifest_path" --no-deps --locked || exit 1; \
|
RUSTDOCFLAGS="--cfg=docsrs" $(CARGO_BINARY) +nightly-2023-10-05 doc $(CARGO_TARGET_FLAG) --manifest-path "$$manifest_path" --no-deps --locked || exit 1; \
|
||||||
else \
|
else \
|
||||||
printf "Following features are inferred from Cargo.toml: $$features\n\n\n"; \
|
printf "Following features are inferred from Cargo.toml: $$features\n\n\n"; \
|
||||||
RUSTDOCFLAGS="--cfg=docsrs" $(CARGO_BINARY) +nightly-2023-05-25 doc $(CARGO_TARGET_FLAG) --manifest-path "$$manifest_path" --no-deps --features "$$features" --locked || exit 1; \
|
RUSTDOCFLAGS="--cfg=docsrs" $(CARGO_BINARY) +nightly-2023-10-05 doc $(CARGO_TARGET_FLAG) --manifest-path "$$manifest_path" --no-deps --features "$$features" --locked || exit 1; \
|
||||||
fi; \
|
fi; \
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
<br />
|
<br />
|
||||||
|
|
||||||
Wasmer is a _blazing fast_ and _secure_ [**WebAssembly**](https://webassembly.org) runtime that enables incredibly
|
Wasmer is a _blazing fast_ and _secure_ [**WebAssembly**](https://webassembly.org) runtime that enables incredibly
|
||||||
_lightweight containers_ to run anywhere: from _Desktop_ to the _Cloud_, _Edge_ and even the browser.
|
_lightweight containers_ to run anywhere: from _Desktop_ to the _Cloud_, _Edge_ and your browser.
|
||||||
|
|
||||||
- **Secure** by default. No file, network, or environment access, unless explicitly enabled.
|
- **Secure** by default. No file, network, or environment access, unless explicitly enabled.
|
||||||
- **Pluggable**. supports [**WASIX**](https://wasix.org/), [WASI](https://github.com/WebAssembly/WASI) and [Emscripten](https://emscripten.org/) out of the box.
|
- **Pluggable**. supports [**WASIX**](https://wasix.org/), [WASI](https://github.com/WebAssembly/WASI) and [Emscripten](https://emscripten.org/) out of the box.
|
||||||
|
|||||||
@@ -44,8 +44,7 @@ impl From<FromUtf8Error> for MemoryAccessError {
|
|||||||
/// trait which guarantees that reading and writing such a value to untrusted
|
/// trait which guarantees that reading and writing such a value to untrusted
|
||||||
/// memory is safe.
|
/// memory is safe.
|
||||||
///
|
///
|
||||||
/// The address is not required to be aligned: unaligned accesses are fully
|
/// The address is required to be aligned: unaligned accesses cause undefined behavior.
|
||||||
/// supported.
|
|
||||||
///
|
///
|
||||||
/// This wrapper safely handles concurrent modifications of the data by another
|
/// This wrapper safely handles concurrent modifications of the data by another
|
||||||
/// thread.
|
/// thread.
|
||||||
@@ -86,7 +85,7 @@ impl<'a, T: ValueType> WasmRef<'a, T> {
|
|||||||
WasmPtr::new(self.offset)
|
WasmPtr::new(self.offset)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a `WasmPtr` fror this `WasmRef`.
|
/// Get a `WasmPtr` for this `WasmRef`.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn as_ptr<M: MemorySize>(self) -> WasmPtr<T, M> {
|
pub fn as_ptr<M: MemorySize>(self) -> WasmPtr<T, M> {
|
||||||
let offset: M::Offset = self
|
let offset: M::Offset = self
|
||||||
|
|||||||
@@ -259,10 +259,7 @@ unsafe impl<T: ValueType, M: MemorySize> ValueType for WasmPtr<T, M> {
|
|||||||
|
|
||||||
impl<T: ValueType, M: MemorySize> Clone for WasmPtr<T, M> {
|
impl<T: ValueType, M: MemorySize> Clone for WasmPtr<T, M> {
|
||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
Self {
|
*self
|
||||||
offset: self.offset,
|
|
||||||
_phantom: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,41 +8,35 @@ pub use wasmer_compiler::{
|
|||||||
use wasmer_types::Features;
|
use wasmer_types::Features;
|
||||||
use wasmer_types::{DeserializeError, Target};
|
use wasmer_types::{DeserializeError, Target};
|
||||||
|
|
||||||
/// Returns the default engine for the Sys engine
|
/// Get the default config for the sys Engine
|
||||||
pub(crate) fn default_engine() -> Engine {
|
#[allow(unreachable_code)]
|
||||||
// We store them on a function that returns to make
|
pub fn get_default_compiler_config() -> Option<Box<dyn wasmer_compiler::CompilerConfig>> {
|
||||||
// sure this function doesn't emit a compile error even if
|
cfg_if::cfg_if! {
|
||||||
// more than one compiler is enabled.
|
if #[cfg(feature = "cranelift")] {
|
||||||
#[allow(unreachable_code)]
|
Some(Box::<wasmer_compiler_cranelift::Cranelift>::default())
|
||||||
#[cfg(any(feature = "cranelift", feature = "llvm", feature = "singlepass"))]
|
} else if #[cfg(feature = "llvm")] {
|
||||||
fn get_config() -> impl wasmer_compiler::CompilerConfig + 'static {
|
Some(Box::<wasmer_compiler_llvm::LLVM>::default())
|
||||||
cfg_if::cfg_if! {
|
} else if #[cfg(feature = "singlepass")] {
|
||||||
if #[cfg(feature = "cranelift")] {
|
Some(Box::<wasmer_compiler_singlepass::Singlepass>::default())
|
||||||
wasmer_compiler_cranelift::Cranelift::default()
|
}
|
||||||
} else if #[cfg(feature = "llvm")] {
|
else {
|
||||||
wasmer_compiler_llvm::LLVM::default()
|
None
|
||||||
} else if #[cfg(feature = "singlepass")] {
|
|
||||||
wasmer_compiler_singlepass::Singlepass::default()
|
|
||||||
} else {
|
|
||||||
compile_error!("No default compiler chosen")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the default engine for the Sys engine
|
||||||
|
pub(crate) fn default_engine() -> Engine {
|
||||||
#[allow(unreachable_code, unused_mut)]
|
#[allow(unreachable_code, unused_mut)]
|
||||||
fn get_engine() -> Engine {
|
fn get_engine() -> Engine {
|
||||||
cfg_if::cfg_if! {
|
cfg_if::cfg_if! {
|
||||||
if #[cfg(feature = "compiler")] {
|
if #[cfg(feature = "compiler")] {
|
||||||
cfg_if::cfg_if! {
|
if let Some(config) = get_default_compiler_config() {
|
||||||
if #[cfg(any(feature = "cranelift", feature = "llvm", feature = "singlepass"))]
|
EngineBuilder::new(config)
|
||||||
{
|
.engine()
|
||||||
let config = get_config();
|
} else {
|
||||||
EngineBuilder::new(Box::new(config) as Box<dyn wasmer_compiler::CompilerConfig>)
|
EngineBuilder::headless()
|
||||||
.engine()
|
.engine()
|
||||||
} else {
|
|
||||||
EngineBuilder::headless()
|
|
||||||
.engine()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
EngineBuilder::headless().engine()
|
EngineBuilder::headless().engine()
|
||||||
|
|||||||
1
lib/api/src/sys/externals/table.rs
vendored
1
lib/api/src/sys/externals/table.rs
vendored
@@ -120,7 +120,6 @@ impl Table {
|
|||||||
"cross-`Store` table copies are not supported",
|
"cross-`Store` table copies are not supported",
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
let store = store;
|
|
||||||
if dst_table.handle.internal_handle() == src_table.handle.internal_handle() {
|
if dst_table.handle.internal_handle() == src_table.handle.internal_handle() {
|
||||||
let table = dst_table.handle.get_mut(store.objects_mut());
|
let table = dst_table.handle.get_mut(store.objects_mut());
|
||||||
table.copy_within(dst_index, src_index, len)
|
table.copy_within(dst_index, src_index, len)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ pub(crate) mod module;
|
|||||||
pub(super) mod tunables;
|
pub(super) mod tunables;
|
||||||
pub(crate) mod typed_function;
|
pub(crate) mod typed_function;
|
||||||
|
|
||||||
pub use crate::sys::engine::NativeEngineExt;
|
pub use crate::sys::engine::{get_default_compiler_config, NativeEngineExt};
|
||||||
pub use crate::sys::tunables::BaseTunables;
|
pub use crate::sys::tunables::BaseTunables;
|
||||||
#[cfg(feature = "compiler")]
|
#[cfg(feature = "compiler")]
|
||||||
pub use wasmer_compiler::{
|
pub use wasmer_compiler::{
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
use std::{collections::HashSet, time::Duration};
|
use std::{collections::HashSet, pin::Pin, time::Duration};
|
||||||
|
|
||||||
use anyhow::{bail, Context};
|
use anyhow::{bail, Context};
|
||||||
use cynic::{MutationBuilder, QueryBuilder};
|
use cynic::{MutationBuilder, QueryBuilder};
|
||||||
use edge_schema::schema::{NetworkTokenV1, WebcIdent};
|
use edge_schema::schema::{NetworkTokenV1, WebcIdent};
|
||||||
use futures::StreamExt;
|
use futures::{Stream, StreamExt};
|
||||||
use time::OffsetDateTime;
|
use time::OffsetDateTime;
|
||||||
use tracing::Instrument;
|
use tracing::Instrument;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
@@ -11,8 +11,9 @@ use url::Url;
|
|||||||
use crate::{
|
use crate::{
|
||||||
types::{
|
types::{
|
||||||
self, CreateNamespaceVars, DeployApp, DeployAppConnection, DeployAppVersion,
|
self, CreateNamespaceVars, DeployApp, DeployAppConnection, DeployAppVersion,
|
||||||
DeployAppVersionConnection, GetDeployAppAndVersion, GetDeployAppVersionsVars,
|
DeployAppVersionConnection, GetCurrentUserWithAppsVars, GetDeployAppAndVersion,
|
||||||
GetNamespaceAppsVars, Log, LogStream, PackageVersionConnection, PublishDeployAppVars,
|
GetDeployAppVersionsVars, GetNamespaceAppsVars, Log, LogStream, PackageVersionConnection,
|
||||||
|
PublishDeployAppVars,
|
||||||
},
|
},
|
||||||
GraphQLApiFailure, WasmerClient,
|
GraphQLApiFailure, WasmerClient,
|
||||||
};
|
};
|
||||||
@@ -275,17 +276,31 @@ pub async fn get_app_by_id(
|
|||||||
client: &WasmerClient,
|
client: &WasmerClient,
|
||||||
app_id: String,
|
app_id: String,
|
||||||
) -> Result<DeployApp, anyhow::Error> {
|
) -> Result<DeployApp, anyhow::Error> {
|
||||||
client
|
get_app_by_id_opt(client, app_id)
|
||||||
|
.await?
|
||||||
|
.context("app not found")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Retrieve an app by its global id.
|
||||||
|
pub async fn get_app_by_id_opt(
|
||||||
|
client: &WasmerClient,
|
||||||
|
app_id: String,
|
||||||
|
) -> Result<Option<DeployApp>, anyhow::Error> {
|
||||||
|
let app_opt = client
|
||||||
.run_graphql(types::GetDeployAppById::build(
|
.run_graphql(types::GetDeployAppById::build(
|
||||||
types::GetDeployAppByIdVars {
|
types::GetDeployAppByIdVars {
|
||||||
app_id: app_id.into(),
|
app_id: app_id.into(),
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
.await?
|
.await?
|
||||||
.app
|
.app;
|
||||||
.context("app not found")?
|
|
||||||
.into_deploy_app()
|
if let Some(app) = app_opt {
|
||||||
.context("app conversion failed")
|
let app = app.into_deploy_app().context("app conversion failed")?;
|
||||||
|
Ok(Some(app))
|
||||||
|
} else {
|
||||||
|
Ok(None)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieve an app together with a specific version.
|
/// Retrieve an app together with a specific version.
|
||||||
@@ -366,38 +381,45 @@ pub async fn get_app_version_by_id_with_app(
|
|||||||
/// List all apps that are accessible by the current user.
|
/// List all apps that are accessible by the current user.
|
||||||
///
|
///
|
||||||
/// NOTE: this will only include the first pages and does not provide pagination.
|
/// NOTE: this will only include the first pages and does not provide pagination.
|
||||||
pub async fn user_apps(client: &WasmerClient) -> Result<Vec<types::DeployApp>, anyhow::Error> {
|
pub async fn user_apps(
|
||||||
let user = client
|
client: &WasmerClient,
|
||||||
.run_graphql(types::GetCurrentUserWithApps::build(()))
|
) -> impl futures::Stream<Item = Result<Vec<types::DeployApp>, anyhow::Error>> + '_ {
|
||||||
.await?
|
futures::stream::try_unfold(None, move |cursor| async move {
|
||||||
.viewer
|
let user = client
|
||||||
.context("not logged in")?;
|
.run_graphql(types::GetCurrentUserWithApps::build(
|
||||||
|
GetCurrentUserWithAppsVars { after: cursor },
|
||||||
|
))
|
||||||
|
.await?
|
||||||
|
.viewer
|
||||||
|
.context("not logged in")?;
|
||||||
|
|
||||||
let apps = user
|
let apps: Vec<_> = user
|
||||||
.apps
|
.apps
|
||||||
.edges
|
.edges
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.flatten()
|
.flatten()
|
||||||
.filter_map(|x| x.node)
|
.filter_map(|x| x.node)
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
Ok(apps)
|
let cursor = user.apps.page_info.end_cursor;
|
||||||
|
|
||||||
|
if apps.is_empty() {
|
||||||
|
Ok(None)
|
||||||
|
} else {
|
||||||
|
Ok(Some((apps, cursor)))
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// List all apps that are accessible by the current user.
|
/// List all apps that are accessible by the current user.
|
||||||
///
|
|
||||||
/// NOTE: this does not currently do full pagination properly.
|
|
||||||
// TODO(theduke): fix pagination
|
|
||||||
pub async fn user_accessible_apps(
|
pub async fn user_accessible_apps(
|
||||||
client: &WasmerClient,
|
client: &WasmerClient,
|
||||||
) -> Result<Vec<types::DeployApp>, anyhow::Error> {
|
) -> Result<
|
||||||
let mut apps = Vec::new();
|
impl futures::Stream<Item = Result<Vec<types::DeployApp>, anyhow::Error>> + '_,
|
||||||
|
anyhow::Error,
|
||||||
// Get user apps.
|
> {
|
||||||
|
let apps: Pin<Box<dyn Stream<Item = Result<Vec<DeployApp>, anyhow::Error>> + Send + Sync>> =
|
||||||
let user_apps = user_apps(client).await?;
|
Box::pin(user_apps(client).await);
|
||||||
|
|
||||||
apps.extend(user_apps);
|
|
||||||
|
|
||||||
// Get all aps in user-accessible namespaces.
|
// Get all aps in user-accessible namespaces.
|
||||||
let namespace_res = client
|
let namespace_res = client
|
||||||
@@ -415,18 +437,16 @@ pub async fn user_accessible_apps(
|
|||||||
.map(|node| node.name.clone())
|
.map(|node| node.name.clone())
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
for namespace in namespace_names {
|
let mut all_apps = vec![apps];
|
||||||
let out = client
|
for ns in namespace_names {
|
||||||
.run_graphql(types::GetNamespaceApps::build(GetNamespaceAppsVars {
|
let apps: Pin<Box<dyn Stream<Item = Result<Vec<DeployApp>, anyhow::Error>> + Send + Sync>> =
|
||||||
name: namespace.to_string(),
|
Box::pin(namespace_apps(client, ns).await);
|
||||||
}))
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
if let Some(ns) = out.get_namespace {
|
all_apps.push(apps);
|
||||||
let ns_apps = ns.apps.edges.into_iter().flatten().filter_map(|x| x.node);
|
|
||||||
apps.extend(ns_apps);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let apps = futures::stream::select_all(all_apps);
|
||||||
|
|
||||||
Ok(apps)
|
Ok(apps)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -435,27 +455,38 @@ pub async fn user_accessible_apps(
|
|||||||
/// NOTE: only retrieves the first page and does not do pagination.
|
/// NOTE: only retrieves the first page and does not do pagination.
|
||||||
pub async fn namespace_apps(
|
pub async fn namespace_apps(
|
||||||
client: &WasmerClient,
|
client: &WasmerClient,
|
||||||
namespace: &str,
|
namespace: String,
|
||||||
) -> Result<Vec<types::DeployApp>, anyhow::Error> {
|
) -> impl futures::Stream<Item = Result<Vec<types::DeployApp>, anyhow::Error>> + '_ {
|
||||||
let res = client
|
let namespace = namespace.clone();
|
||||||
.run_graphql(types::GetNamespaceApps::build(GetNamespaceAppsVars {
|
|
||||||
name: namespace.to_string(),
|
|
||||||
}))
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
let ns = res
|
futures::stream::try_unfold((None, namespace), move |(cursor, namespace)| async move {
|
||||||
.get_namespace
|
let res = client
|
||||||
.with_context(|| format!("failed to get namespace '{}'", namespace))?;
|
.run_graphql(types::GetNamespaceApps::build(GetNamespaceAppsVars {
|
||||||
|
name: namespace.to_string(),
|
||||||
|
after: cursor,
|
||||||
|
}))
|
||||||
|
.await?;
|
||||||
|
|
||||||
let apps = ns
|
let ns = res
|
||||||
.apps
|
.get_namespace
|
||||||
.edges
|
.with_context(|| format!("failed to get namespace '{}'", namespace))?;
|
||||||
.into_iter()
|
|
||||||
.flatten()
|
|
||||||
.filter_map(|x| x.node)
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
Ok(apps)
|
let apps: Vec<_> = ns
|
||||||
|
.apps
|
||||||
|
.edges
|
||||||
|
.into_iter()
|
||||||
|
.flatten()
|
||||||
|
.filter_map(|x| x.node)
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
let cursor = ns.apps.page_info.end_cursor;
|
||||||
|
|
||||||
|
if apps.is_empty() {
|
||||||
|
Ok(None)
|
||||||
|
} else {
|
||||||
|
Ok(Some((apps, (cursor, namespace))))
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Publish a new app (version).
|
/// Publish a new app (version).
|
||||||
@@ -692,10 +723,7 @@ fn get_app_logs(
|
|||||||
name: name.clone(),
|
name: name.clone(),
|
||||||
owner: owner.clone(),
|
owner: owner.clone(),
|
||||||
version: tag.clone(),
|
version: tag.clone(),
|
||||||
// TODO: increase pagination size
|
first: Some(100),
|
||||||
// See https://github.com/wasmerio/edge/issues/460
|
|
||||||
// first: Some(500),
|
|
||||||
first: Some(10),
|
|
||||||
starting_from: unix_timestamp(start),
|
starting_from: unix_timestamp(start),
|
||||||
until: end.map(unix_timestamp),
|
until: end.map(unix_timestamp),
|
||||||
streams: streams.clone(),
|
streams: streams.clone(),
|
||||||
|
|||||||
@@ -180,17 +180,24 @@ mod queries {
|
|||||||
pub get_deploy_app: Option<DeployApp>,
|
pub get_deploy_app: Option<DeployApp>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(cynic::QueryVariables, Debug)]
|
||||||
|
pub struct GetCurrentUserWithAppsVars {
|
||||||
|
pub after: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(cynic::QueryFragment, Debug)]
|
#[derive(cynic::QueryFragment, Debug)]
|
||||||
#[cynic(graphql_type = "Query")]
|
#[cynic(graphql_type = "Query", variables = "GetCurrentUserWithAppsVars")]
|
||||||
pub struct GetCurrentUserWithApps {
|
pub struct GetCurrentUserWithApps {
|
||||||
pub viewer: Option<UserWithApps>,
|
pub viewer: Option<UserWithApps>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(cynic::QueryFragment, Debug)]
|
#[derive(cynic::QueryFragment, Debug)]
|
||||||
#[cynic(graphql_type = "User")]
|
#[cynic(graphql_type = "User")]
|
||||||
|
#[cynic(variables = "GetCurrentUserWithAppsVars")]
|
||||||
pub struct UserWithApps {
|
pub struct UserWithApps {
|
||||||
pub id: cynic::Id,
|
pub id: cynic::Id,
|
||||||
pub username: String,
|
pub username: String,
|
||||||
|
#[arguments(after: $after)]
|
||||||
pub apps: DeployAppConnection,
|
pub apps: DeployAppConnection,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -537,6 +544,7 @@ mod queries {
|
|||||||
#[derive(cynic::QueryVariables, Debug)]
|
#[derive(cynic::QueryVariables, Debug)]
|
||||||
pub struct GetNamespaceAppsVars {
|
pub struct GetNamespaceAppsVars {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
pub after: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(cynic::QueryFragment, Debug)]
|
#[derive(cynic::QueryFragment, Debug)]
|
||||||
@@ -548,9 +556,11 @@ mod queries {
|
|||||||
|
|
||||||
#[derive(cynic::QueryFragment, Debug)]
|
#[derive(cynic::QueryFragment, Debug)]
|
||||||
#[cynic(graphql_type = "Namespace")]
|
#[cynic(graphql_type = "Namespace")]
|
||||||
|
#[cynic(variables = "GetNamespaceAppsVars")]
|
||||||
pub struct NamespaceWithApps {
|
pub struct NamespaceWithApps {
|
||||||
pub id: cynic::Id,
|
pub id: cynic::Id,
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
#[arguments(after: $after)]
|
||||||
pub apps: DeployAppConnection,
|
pub apps: DeployAppConnection,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
use super::engine::wasm_engine_t;
|
use super::engine::wasm_engine_t;
|
||||||
use std::cell::UnsafeCell;
|
use std::cell::UnsafeCell;
|
||||||
use std::sync::Arc;
|
use std::rc::Rc;
|
||||||
use wasmer_api::{AsStoreMut, AsStoreRef, Store, StoreMut, StoreRef as BaseStoreRef};
|
use wasmer_api::{AsStoreMut, AsStoreRef, Store, StoreMut, StoreRef as BaseStoreRef};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct StoreRef {
|
pub struct StoreRef {
|
||||||
inner: Arc<UnsafeCell<Store>>,
|
inner: Rc<UnsafeCell<Store>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StoreRef {
|
impl StoreRef {
|
||||||
@@ -38,7 +38,7 @@ pub unsafe extern "C" fn wasm_store_new(
|
|||||||
|
|
||||||
Some(Box::new(wasm_store_t {
|
Some(Box::new(wasm_store_t {
|
||||||
inner: StoreRef {
|
inner: StoreRef {
|
||||||
inner: Arc::new(UnsafeCell::new(store)),
|
inner: Rc::new(UnsafeCell::new(store)),
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
//! List Edge apps.
|
//! List Edge apps.
|
||||||
|
|
||||||
|
use std::pin::Pin;
|
||||||
|
|
||||||
|
use futures::{Stream, StreamExt};
|
||||||
|
use wasmer_api::types::DeployApp;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
commands::AsyncCliCommand,
|
commands::AsyncCliCommand,
|
||||||
opts::{ApiOpts, ListFormatOpts},
|
opts::{ApiOpts, ListFormatOpts},
|
||||||
@@ -23,6 +28,14 @@ pub struct CmdAppList {
|
|||||||
/// directly owned by the user and apps in namespaces the user can access.
|
/// directly owned by the user and apps in namespaces the user can access.
|
||||||
#[clap(short = 'a', long)]
|
#[clap(short = 'a', long)]
|
||||||
all: bool,
|
all: bool,
|
||||||
|
|
||||||
|
/// Maximum number of apps to display
|
||||||
|
#[clap(long, default_value = "1000")]
|
||||||
|
max: usize,
|
||||||
|
|
||||||
|
/// Asks whether to display the next page or not
|
||||||
|
#[clap(long, default_value = "false")]
|
||||||
|
paging_mode: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
@@ -32,15 +45,59 @@ impl AsyncCliCommand for CmdAppList {
|
|||||||
async fn run_async(self) -> Result<(), anyhow::Error> {
|
async fn run_async(self) -> Result<(), anyhow::Error> {
|
||||||
let client = self.api.client()?;
|
let client = self.api.client()?;
|
||||||
|
|
||||||
let apps = if let Some(ns) = self.namespace {
|
let apps_stream: Pin<
|
||||||
wasmer_api::query::namespace_apps(&client, &ns).await?
|
Box<dyn Stream<Item = Result<Vec<DeployApp>, anyhow::Error>> + Send + Sync>,
|
||||||
|
> = if let Some(ns) = self.namespace.clone() {
|
||||||
|
Box::pin(wasmer_api::query::namespace_apps(&client, ns).await)
|
||||||
} else if self.all {
|
} else if self.all {
|
||||||
wasmer_api::query::user_accessible_apps(&client).await?
|
Box::pin(wasmer_api::query::user_accessible_apps(&client).await?)
|
||||||
} else {
|
} else {
|
||||||
wasmer_api::query::user_apps(&client).await?
|
Box::pin(wasmer_api::query::user_apps(&client).await)
|
||||||
};
|
};
|
||||||
|
|
||||||
println!("{}", self.fmt.format.render(&apps));
|
let mut apps_stream = std::pin::pin!(apps_stream);
|
||||||
|
|
||||||
|
let mut rem = self.max;
|
||||||
|
|
||||||
|
let mut display_apps = vec![];
|
||||||
|
|
||||||
|
'list: while let Some(apps) = apps_stream.next().await {
|
||||||
|
let mut apps = apps?;
|
||||||
|
|
||||||
|
let limit = std::cmp::min(apps.len(), rem);
|
||||||
|
|
||||||
|
if limit == 0 {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
rem -= limit;
|
||||||
|
|
||||||
|
if self.paging_mode {
|
||||||
|
println!("{}", self.fmt.format.render(&apps));
|
||||||
|
|
||||||
|
loop {
|
||||||
|
println!("next page? [y, n]");
|
||||||
|
|
||||||
|
let mut rsp = String::new();
|
||||||
|
std::io::stdin().read_line(&mut rsp)?;
|
||||||
|
|
||||||
|
if rsp.trim() == "y" {
|
||||||
|
continue 'list;
|
||||||
|
}
|
||||||
|
if rsp.trim() == "n" {
|
||||||
|
break 'list;
|
||||||
|
}
|
||||||
|
|
||||||
|
println!("uknown response: {rsp}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
display_apps.extend(apps.drain(..limit));
|
||||||
|
}
|
||||||
|
|
||||||
|
if !display_apps.is_empty() {
|
||||||
|
println!("{}", self.fmt.format.render(&display_apps));
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,19 +146,20 @@ impl crate::commands::AsyncCliCommand for CmdAppLogs {
|
|||||||
let mut rem = self.max;
|
let mut rem = self.max;
|
||||||
|
|
||||||
while let Some(logs) = logs_stream.next().await {
|
while let Some(logs) = logs_stream.next().await {
|
||||||
let logs = logs?;
|
let mut logs = logs?;
|
||||||
|
|
||||||
let limit = std::cmp::max(logs.len(), rem);
|
let limit = std::cmp::min(logs.len(), rem);
|
||||||
|
|
||||||
|
let logs: Vec<_> = logs.drain(..limit).collect();
|
||||||
|
|
||||||
let logs = &logs[..limit];
|
|
||||||
if !logs.is_empty() {
|
if !logs.is_empty() {
|
||||||
let rendered = self.fmt.format.render(logs);
|
let rendered = self.fmt.format.render(&logs);
|
||||||
println!("{rendered}");
|
println!("{rendered}");
|
||||||
|
|
||||||
rem -= limit;
|
rem -= limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if !self.watch && rem == 0 {
|
if !self.watch || rem == 0 {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -673,7 +673,7 @@ impl PrefixMapCompilation {
|
|||||||
|
|
||||||
fn split_prefix(s: &str) -> Vec<String> {
|
fn split_prefix(s: &str) -> Vec<String> {
|
||||||
let regex =
|
let regex =
|
||||||
regex::Regex::new(r#"^([a-zA-Z0-9\-_]+)(:([a-zA-Z0-9\.\-_]+))?(:(.+*))?"#).unwrap();
|
regex::Regex::new(r"^([a-zA-Z0-9\-_]+)(:([a-zA-Z0-9\.\-_]+))?(:(.+*))?").unwrap();
|
||||||
let mut captures = regex
|
let mut captures = regex
|
||||||
.captures(s.trim())
|
.captures(s.trim())
|
||||||
.map(|c| {
|
.map(|c| {
|
||||||
@@ -1480,11 +1480,9 @@ fn generate_wasmer_main_c(
|
|||||||
.iter()
|
.iter()
|
||||||
.map(|v| utils::normalize_atom_name(&v.name).to_uppercase())
|
.map(|v| utils::normalize_atom_name(&v.name).to_uppercase())
|
||||||
.map(|uppercase| {
|
.map(|uppercase| {
|
||||||
vec![
|
format!(
|
||||||
format!("extern size_t {uppercase}_LENGTH asm(\"{uppercase}_LENGTH\");"),
|
"extern size_t {uppercase}_LENGTH asm(\"{uppercase}_LENGTH\");\r\nextern char {uppercase}_DATA asm(\"{uppercase}_DATA\");"
|
||||||
format!("extern char {uppercase}_DATA asm(\"{uppercase}_DATA\");"),
|
)
|
||||||
]
|
|
||||||
.join("\r\n")
|
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
|||||||
@@ -561,7 +561,7 @@ impl Wasi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !self.no_tty {
|
if !self.no_tty {
|
||||||
let tty = Arc::new(SysTty::default());
|
let tty = Arc::new(SysTty);
|
||||||
tty.reset();
|
tty.reset();
|
||||||
rt.set_tty(tty);
|
rt.set_tty(tty);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -351,7 +351,7 @@ impl ToString for CompilerType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(feature = "compiler"))]
|
#[cfg(feature = "compiler")]
|
||||||
impl StoreOptions {
|
impl StoreOptions {
|
||||||
/// Gets the store for the host target, with the compiler name selected
|
/// Gets the store for the host target, with the compiler name selected
|
||||||
pub fn get_store(&self) -> Result<(Store, CompilerType)> {
|
pub fn get_store(&self) -> Result<(Store, CompilerType)> {
|
||||||
|
|||||||
@@ -2998,7 +2998,7 @@ impl<'a, M: Machine> FuncGen<'a, M> {
|
|||||||
self.release_locations_value(stack_depth)?;
|
self.release_locations_value(stack_depth)?;
|
||||||
self.value_stack.truncate(stack_depth);
|
self.value_stack.truncate(stack_depth);
|
||||||
self.fp_stack.truncate(fp_depth);
|
self.fp_stack.truncate(fp_depth);
|
||||||
let mut frame = &mut self.control_stack.last_mut().unwrap();
|
let frame = &mut self.control_stack.last_mut().unwrap();
|
||||||
|
|
||||||
match frame.if_else {
|
match frame.if_else {
|
||||||
IfElseState::If(label) => {
|
IfElseState::If(label) => {
|
||||||
|
|||||||
@@ -689,235 +689,217 @@ fn move_src_to_dst(emitter: &mut AssemblerX64, precision: Precision, src: XMM, d
|
|||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! avx_fn {
|
macro_rules! avx_fn {
|
||||||
($ins:ident) => {
|
($ins:ident, $emitter:ident, $src1:ident, $src2:ident, $dst:ident) => {
|
||||||
|emitter: &mut AssemblerX64, src1: XMM, src2: XMMOrMemory, dst: XMM| {
|
// Dynasm bug: AVX instructions are not encoded correctly.
|
||||||
// Dynasm bug: AVX instructions are not encoded correctly.
|
match $src2 {
|
||||||
match src2 {
|
XMMOrMemory::XMM(x) => match $src1 {
|
||||||
XMMOrMemory::XMM(x) => match src1 {
|
XMM::XMM0 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm0, Rx((x as u8))),
|
||||||
XMM::XMM0 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm0, Rx((x as u8))),
|
XMM::XMM1 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm1, Rx((x as u8))),
|
||||||
XMM::XMM1 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm1, Rx((x as u8))),
|
XMM::XMM2 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm2, Rx((x as u8))),
|
||||||
XMM::XMM2 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm2, Rx((x as u8))),
|
XMM::XMM4 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm4, Rx((x as u8))),
|
||||||
XMM::XMM3 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm3, Rx((x as u8))),
|
XMM::XMM3 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm3, Rx((x as u8))),
|
||||||
XMM::XMM4 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm4, Rx((x as u8))),
|
XMM::XMM5 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm5, Rx((x as u8))),
|
||||||
XMM::XMM5 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm5, Rx((x as u8))),
|
XMM::XMM6 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm6, Rx((x as u8))),
|
||||||
XMM::XMM6 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm6, Rx((x as u8))),
|
XMM::XMM7 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm7, Rx((x as u8))),
|
||||||
XMM::XMM7 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm7, Rx((x as u8))),
|
XMM::XMM8 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm8, Rx((x as u8))),
|
||||||
XMM::XMM8 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm8, Rx((x as u8))),
|
XMM::XMM9 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm9, Rx((x as u8))),
|
||||||
XMM::XMM9 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm9, Rx((x as u8))),
|
XMM::XMM10 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm10, Rx((x as u8))),
|
||||||
XMM::XMM10 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm10, Rx((x as u8))),
|
XMM::XMM11 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm11, Rx((x as u8))),
|
||||||
XMM::XMM11 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm11, Rx((x as u8))),
|
XMM::XMM12 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm12, Rx((x as u8))),
|
||||||
XMM::XMM12 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm12, Rx((x as u8))),
|
XMM::XMM13 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm13, Rx((x as u8))),
|
||||||
XMM::XMM13 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm13, Rx((x as u8))),
|
XMM::XMM14 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm14, Rx((x as u8))),
|
||||||
XMM::XMM14 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm14, Rx((x as u8))),
|
XMM::XMM15 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm15, Rx((x as u8))),
|
||||||
XMM::XMM15 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm15, Rx((x as u8))),
|
},
|
||||||
},
|
XMMOrMemory::Memory(base, disp) => match $src1 {
|
||||||
XMMOrMemory::Memory(base, disp) => match src1 {
|
XMM::XMM0 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm0, [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM0 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm0, [Rq((base as u8)) + disp]),
|
XMM::XMM1 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm1, [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM1 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm1, [Rq((base as u8)) + disp]),
|
XMM::XMM2 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm2, [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM2 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm2, [Rq((base as u8)) + disp]),
|
XMM::XMM3 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm3, [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM3 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm3, [Rq((base as u8)) + disp]),
|
XMM::XMM4 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm4, [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM4 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm4, [Rq((base as u8)) + disp]),
|
XMM::XMM5 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm5, [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM5 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm5, [Rq((base as u8)) + disp]),
|
XMM::XMM6 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm6, [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM6 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm6, [Rq((base as u8)) + disp]),
|
XMM::XMM7 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm7, [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM7 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm7, [Rq((base as u8)) + disp]),
|
XMM::XMM8 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm8, [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM8 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm8, [Rq((base as u8)) + disp]),
|
XMM::XMM9 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm9, [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM9 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm9, [Rq((base as u8)) + disp]),
|
XMM::XMM10 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm10, [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM10 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm10, [Rq((base as u8)) + disp]),
|
XMM::XMM11 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm11, [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM11 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm11, [Rq((base as u8)) + disp]),
|
XMM::XMM12 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm12, [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM12 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm12, [Rq((base as u8)) + disp]),
|
XMM::XMM13 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm13, [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM13 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm13, [Rq((base as u8)) + disp]),
|
XMM::XMM14 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm14, [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM14 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm14, [Rq((base as u8)) + disp]),
|
XMM::XMM15 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm15, [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM15 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm15, [Rq((base as u8)) + disp]),
|
},
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! sse_fn {
|
macro_rules! sse_fn {
|
||||||
($ins:ident) => {
|
($ins:ident, $emitter:ident, $precision:expr, $src1:ident, $src2:ident, $dst:ident) => {
|
||||||
|emitter: &mut AssemblerX64, precision: Precision, src1: XMM, src2: XMMOrMemory, dst: XMM| {
|
match $src2 {
|
||||||
match src2 {
|
XMMOrMemory::XMM(x) => {
|
||||||
XMMOrMemory::XMM(x) => {
|
if x == $dst {
|
||||||
if x == dst {
|
dynasm!($emitter ; $ins Rx(($dst as u8)), Rx(($src1 as u8)))
|
||||||
dynasm!(emitter ; $ins Rx((dst as u8)), Rx((src1 as u8)))
|
} else {
|
||||||
} else {
|
move_src_to_dst($emitter, $precision, $src1, $dst);
|
||||||
move_src_to_dst(emitter, precision, src1, dst);
|
dynasm!($emitter ; $ins Rx(($dst as u8)), Rx((x as u8)))
|
||||||
dynasm!(emitter ; $ins Rx((dst as u8)), Rx((x as u8)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
XMMOrMemory::Memory(base, disp) => {
|
|
||||||
move_src_to_dst(emitter, precision, src1, dst);
|
|
||||||
dynasm!(emitter ; $ins Rx((dst as u8)), [Rq((base as u8)) + disp])
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
XMMOrMemory::Memory(base, disp) => {
|
||||||
|
move_src_to_dst($emitter, $precision, $src1, $dst);
|
||||||
|
dynasm!($emitter ; $ins Rx(($dst as u8)), [Rq((base as u8)) + disp])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
($ins:ident, $mode:expr) => {
|
($ins:ident, $mode:expr, $emitter:ident, $precision:expr, $src1:ident, $src2:ident, $dst:ident) => {
|
||||||
|emitter: &mut AssemblerX64, precision: Precision, src1: XMM, src2: XMMOrMemory, dst: XMM| {
|
match $src2 {
|
||||||
match src2 {
|
XMMOrMemory::XMM(x) => {
|
||||||
XMMOrMemory::XMM(x) => {
|
move_src_to_dst($emitter, $precision, $src1, $dst);
|
||||||
move_src_to_dst(emitter, precision, src1, dst);
|
dynasm!($emitter ; $ins Rx(($dst as u8)), Rx((x as u8)), $mode)
|
||||||
dynasm!(emitter ; $ins Rx((dst as u8)), Rx((x as u8)), $mode)
|
}
|
||||||
}
|
XMMOrMemory::Memory(base, disp) => {
|
||||||
XMMOrMemory::Memory(base, disp) => {
|
move_src_to_dst($emitter, $precision, $src1, $dst);
|
||||||
move_src_to_dst(emitter, precision, src1, dst);
|
dynasm!($emitter ; $ins Rx(($dst as u8)), [Rq((base as u8)) + disp], $mode)
|
||||||
dynasm!(emitter ; $ins Rx((dst as u8)), [Rq((base as u8)) + disp], $mode)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! avx_i2f_64_fn {
|
macro_rules! avx_i2f_64_fn {
|
||||||
($ins:ident) => {
|
($ins:ident, $emitter:ident, $src1:ident, $src2:ident, $dst:ident) => {
|
||||||
|emitter: &mut AssemblerX64, src1: XMM, src2: GPROrMemory, dst: XMM| {
|
match $src2 {
|
||||||
match src2 {
|
GPROrMemory::GPR(x) => match $src1 {
|
||||||
GPROrMemory::GPR(x) => match src1 {
|
XMM::XMM0 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm0, Rq((x as u8))),
|
||||||
XMM::XMM0 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm0, Rq((x as u8))),
|
XMM::XMM1 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm1, Rq((x as u8))),
|
||||||
XMM::XMM1 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm1, Rq((x as u8))),
|
XMM::XMM2 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm2, Rq((x as u8))),
|
||||||
XMM::XMM2 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm2, Rq((x as u8))),
|
XMM::XMM3 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm3, Rq((x as u8))),
|
||||||
XMM::XMM3 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm3, Rq((x as u8))),
|
XMM::XMM4 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm4, Rq((x as u8))),
|
||||||
XMM::XMM4 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm4, Rq((x as u8))),
|
XMM::XMM5 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm5, Rq((x as u8))),
|
||||||
XMM::XMM5 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm5, Rq((x as u8))),
|
XMM::XMM6 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm6, Rq((x as u8))),
|
||||||
XMM::XMM6 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm6, Rq((x as u8))),
|
XMM::XMM7 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm7, Rq((x as u8))),
|
||||||
XMM::XMM7 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm7, Rq((x as u8))),
|
XMM::XMM8 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm8, Rq((x as u8))),
|
||||||
XMM::XMM8 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm8, Rq((x as u8))),
|
XMM::XMM9 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm9, Rq((x as u8))),
|
||||||
XMM::XMM9 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm9, Rq((x as u8))),
|
XMM::XMM10 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm10, Rq((x as u8))),
|
||||||
XMM::XMM10 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm10, Rq((x as u8))),
|
XMM::XMM11 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm11, Rq((x as u8))),
|
||||||
XMM::XMM11 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm11, Rq((x as u8))),
|
XMM::XMM12 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm12, Rq((x as u8))),
|
||||||
XMM::XMM12 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm12, Rq((x as u8))),
|
XMM::XMM13 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm13, Rq((x as u8))),
|
||||||
XMM::XMM13 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm13, Rq((x as u8))),
|
XMM::XMM14 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm14, Rq((x as u8))),
|
||||||
XMM::XMM14 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm14, Rq((x as u8))),
|
XMM::XMM15 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm15, Rq((x as u8))),
|
||||||
XMM::XMM15 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm15, Rq((x as u8))),
|
},
|
||||||
},
|
GPROrMemory::Memory(base, disp) => match $src1 {
|
||||||
GPROrMemory::Memory(base, disp) => match src1 {
|
XMM::XMM0 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm0, QWORD [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM0 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm0, QWORD [Rq((base as u8)) + disp]),
|
XMM::XMM1 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm1, QWORD [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM1 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm1, QWORD [Rq((base as u8)) + disp]),
|
XMM::XMM2 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm2, QWORD [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM2 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm2, QWORD [Rq((base as u8)) + disp]),
|
XMM::XMM3 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm3, QWORD [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM3 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm3, QWORD [Rq((base as u8)) + disp]),
|
XMM::XMM4 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm4, QWORD [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM4 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm4, QWORD [Rq((base as u8)) + disp]),
|
XMM::XMM5 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm5, QWORD [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM5 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm5, QWORD [Rq((base as u8)) + disp]),
|
XMM::XMM6 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm6, QWORD [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM6 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm6, QWORD [Rq((base as u8)) + disp]),
|
XMM::XMM7 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm7, QWORD [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM7 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm7, QWORD [Rq((base as u8)) + disp]),
|
XMM::XMM8 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm8, QWORD [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM8 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm8, QWORD [Rq((base as u8)) + disp]),
|
XMM::XMM9 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm9, QWORD [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM9 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm9, QWORD [Rq((base as u8)) + disp]),
|
XMM::XMM10 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm10, QWORD [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM10 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm10, QWORD [Rq((base as u8)) + disp]),
|
XMM::XMM11 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm11, QWORD [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM11 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm11, QWORD [Rq((base as u8)) + disp]),
|
XMM::XMM12 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm12, QWORD [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM12 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm12, QWORD [Rq((base as u8)) + disp]),
|
XMM::XMM13 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm13, QWORD [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM13 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm13, QWORD [Rq((base as u8)) + disp]),
|
XMM::XMM14 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm14, QWORD [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM14 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm14, QWORD [Rq((base as u8)) + disp]),
|
XMM::XMM15 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm15, QWORD [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM15 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm15, QWORD [Rq((base as u8)) + disp]),
|
},
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! sse_i2f_64_fn {
|
macro_rules! sse_i2f_64_fn {
|
||||||
($ins:ident) => {
|
($ins:ident, $emitter:ident, $precision:expr, $src1:ident, $src2:ident, $dst:ident) => {
|
||||||
|emitter: &mut AssemblerX64, precision: Precision, src1: XMM, src2: GPROrMemory, dst: XMM| {
|
match $src2 {
|
||||||
match src2 {
|
GPROrMemory::GPR(x) => {
|
||||||
GPROrMemory::GPR(x) => {
|
move_src_to_dst($emitter, $precision, $src1, $dst);
|
||||||
move_src_to_dst(emitter, precision, src1, dst);
|
dynasm!($emitter ; $ins Rx(($dst as u8)), Rq((x as u8)))
|
||||||
dynasm!(emitter ; $ins Rx((dst as u8)), Rq((x as u8)))
|
},
|
||||||
},
|
GPROrMemory::Memory(base, disp) => {
|
||||||
GPROrMemory::Memory(base, disp) => {
|
move_src_to_dst($emitter, $precision, $src1, $dst);
|
||||||
move_src_to_dst(emitter, precision, src1, dst);
|
dynasm!($emitter ; $ins Rx(($dst as u8)), QWORD [Rq((base as u8)) + disp])
|
||||||
dynasm!(emitter ; $ins Rx((dst as u8)), QWORD [Rq((base as u8)) + disp])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! avx_i2f_32_fn {
|
macro_rules! avx_i2f_32_fn {
|
||||||
($ins:ident) => {
|
($ins:ident, $emitter:ident, $src1:ident, $src2:ident, $dst:ident) => {
|
||||||
|emitter: &mut AssemblerX64, src1: XMM, src2: GPROrMemory, dst: XMM| {
|
match $src2 {
|
||||||
match src2 {
|
GPROrMemory::GPR(x) => match $src1 {
|
||||||
GPROrMemory::GPR(x) => match src1 {
|
XMM::XMM0 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm0, Rd((x as u8))),
|
||||||
XMM::XMM0 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm0, Rd((x as u8))),
|
XMM::XMM1 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm1, Rd((x as u8))),
|
||||||
XMM::XMM1 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm1, Rd((x as u8))),
|
XMM::XMM2 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm2, Rd((x as u8))),
|
||||||
XMM::XMM2 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm2, Rd((x as u8))),
|
XMM::XMM3 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm3, Rd((x as u8))),
|
||||||
XMM::XMM3 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm3, Rd((x as u8))),
|
XMM::XMM4 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm4, Rd((x as u8))),
|
||||||
XMM::XMM4 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm4, Rd((x as u8))),
|
XMM::XMM5 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm5, Rd((x as u8))),
|
||||||
XMM::XMM5 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm5, Rd((x as u8))),
|
XMM::XMM6 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm6, Rd((x as u8))),
|
||||||
XMM::XMM6 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm6, Rd((x as u8))),
|
XMM::XMM7 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm7, Rd((x as u8))),
|
||||||
XMM::XMM7 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm7, Rd((x as u8))),
|
XMM::XMM8 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm8, Rd((x as u8))),
|
||||||
XMM::XMM8 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm8, Rd((x as u8))),
|
XMM::XMM9 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm9, Rd((x as u8))),
|
||||||
XMM::XMM9 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm9, Rd((x as u8))),
|
XMM::XMM10 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm10, Rd((x as u8))),
|
||||||
XMM::XMM10 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm10, Rd((x as u8))),
|
XMM::XMM11 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm11, Rd((x as u8))),
|
||||||
XMM::XMM11 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm11, Rd((x as u8))),
|
XMM::XMM12 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm12, Rd((x as u8))),
|
||||||
XMM::XMM12 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm12, Rd((x as u8))),
|
XMM::XMM13 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm13, Rd((x as u8))),
|
||||||
XMM::XMM13 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm13, Rd((x as u8))),
|
XMM::XMM14 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm14, Rd((x as u8))),
|
||||||
XMM::XMM14 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm14, Rd((x as u8))),
|
XMM::XMM15 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm15, Rd((x as u8))),
|
||||||
XMM::XMM15 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm15, Rd((x as u8))),
|
},
|
||||||
},
|
GPROrMemory::Memory(base, disp) => match $src1 {
|
||||||
GPROrMemory::Memory(base, disp) => match src1 {
|
XMM::XMM0 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm0, DWORD [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM0 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm0, DWORD [Rq((base as u8)) + disp]),
|
XMM::XMM1 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm1, DWORD [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM1 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm1, DWORD [Rq((base as u8)) + disp]),
|
XMM::XMM2 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm2, DWORD [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM2 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm2, DWORD [Rq((base as u8)) + disp]),
|
XMM::XMM3 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm3, DWORD [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM3 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm3, DWORD [Rq((base as u8)) + disp]),
|
XMM::XMM4 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm4, DWORD [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM4 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm4, DWORD [Rq((base as u8)) + disp]),
|
XMM::XMM5 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm5, DWORD [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM5 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm5, DWORD [Rq((base as u8)) + disp]),
|
XMM::XMM6 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm6, DWORD [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM6 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm6, DWORD [Rq((base as u8)) + disp]),
|
XMM::XMM7 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm7, DWORD [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM7 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm7, DWORD [Rq((base as u8)) + disp]),
|
XMM::XMM8 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm8, DWORD [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM8 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm8, DWORD [Rq((base as u8)) + disp]),
|
XMM::XMM9 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm9, DWORD [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM9 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm9, DWORD [Rq((base as u8)) + disp]),
|
XMM::XMM10 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm10, DWORD [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM10 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm10, DWORD [Rq((base as u8)) + disp]),
|
XMM::XMM11 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm11, DWORD [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM11 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm11, DWORD [Rq((base as u8)) + disp]),
|
XMM::XMM12 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm12, DWORD [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM12 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm12, DWORD [Rq((base as u8)) + disp]),
|
XMM::XMM13 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm13, DWORD [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM13 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm13, DWORD [Rq((base as u8)) + disp]),
|
XMM::XMM14 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm14, DWORD [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM14 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm14, DWORD [Rq((base as u8)) + disp]),
|
XMM::XMM15 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm15, DWORD [Rq((base as u8)) + disp]),
|
||||||
XMM::XMM15 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm15, DWORD [Rq((base as u8)) + disp]),
|
},
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! sse_i2f_32_fn {
|
macro_rules! sse_i2f_32_fn {
|
||||||
($ins:ident) => {
|
($ins:ident, $emitter:ident, $precision:expr, $src1:ident, $src2:ident, $dst:ident) => {
|
||||||
|emitter: &mut AssemblerX64, precision: Precision, src1: XMM, src2: GPROrMemory, dst: XMM| {
|
match $src2 {
|
||||||
match src2 {
|
GPROrMemory::GPR(x) => {
|
||||||
GPROrMemory::GPR(x) => {
|
move_src_to_dst($emitter, $precision, $src1, $dst);
|
||||||
move_src_to_dst(emitter, precision, src1, dst);
|
dynasm!($emitter; $ins Rx(($src1 as u8)), Rd((x as u8)))
|
||||||
dynasm!(emitter; $ins Rx((src1 as u8)), Rd((x as u8)))
|
},
|
||||||
},
|
GPROrMemory::Memory(base, disp) => {
|
||||||
GPROrMemory::Memory(base, disp) => {
|
move_src_to_dst($emitter, $precision, $src1, $dst);
|
||||||
move_src_to_dst(emitter, precision, src1, dst);
|
dynasm!($emitter; $ins Rx(($dst as u8)), DWORD [Rq((base as u8)) + disp])
|
||||||
dynasm!(emitter ; $ins Rx((dst as u8)), DWORD [Rq((base as u8)) + disp])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! avx_round_fn {
|
macro_rules! avx_round_fn {
|
||||||
($ins:ident, $mode:expr) => {
|
($ins:ident, $mode:expr, $emitter:ident, $src1:ident, $src2:ident, $dst:ident) => {
|
||||||
|emitter: &mut AssemblerX64, src1: XMM, src2: XMMOrMemory, dst: XMM| {
|
match $src2 {
|
||||||
match src2 {
|
XMMOrMemory::XMM(x) => dynasm!($emitter ; $ins Rx(($dst as u8)), Rx(($src1 as u8)), Rx((x as u8)), $mode),
|
||||||
XMMOrMemory::XMM(x) => dynasm!(emitter ; $ins Rx((dst as u8)), Rx((src1 as u8)), Rx((x as u8)), $mode),
|
XMMOrMemory::Memory(base, disp) => dynasm!($emitter ; $ins Rx(($dst as u8)), Rx(($src1 as u8)), [Rq((base as u8)) + disp], $mode),
|
||||||
XMMOrMemory::Memory(base, disp) => dynasm!(emitter ; $ins Rx((dst as u8)), Rx((src1 as u8)), [Rq((base as u8)) + disp], $mode),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! sse_round_fn {
|
macro_rules! sse_round_fn {
|
||||||
($ins:ident, $mode:expr) => {
|
($ins:ident, $mode:expr, $emitter:ident, $precision:expr, $src1:ident, $src2:ident, $dst:ident) => {
|
||||||
|emitter: &mut AssemblerX64, precision: Precision, src1: XMM, src2: XMMOrMemory, dst: XMM| {
|
match $src2 {
|
||||||
match src2 {
|
XMMOrMemory::XMM(x) => {
|
||||||
XMMOrMemory::XMM(x) => {
|
if x != $dst {
|
||||||
if x != dst {
|
move_src_to_dst($emitter, $precision, $src1, $dst);
|
||||||
move_src_to_dst(emitter, precision, src1, dst);
|
|
||||||
}
|
|
||||||
dynasm!(emitter ; $ins Rx((x as u8)), Rx((dst as u8)), $mode)
|
|
||||||
}
|
}
|
||||||
XMMOrMemory::Memory(base, disp) => {
|
dynasm!($emitter ; $ins Rx((x as u8)), Rx(($dst as u8)), $mode)
|
||||||
dynasm!(emitter ; $ins Rx((dst as u8)), [Rq((base as u8)) + disp], $mode)
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
XMMOrMemory::Memory(base, disp) => {
|
||||||
|
dynasm!($emitter ; $ins Rx(($dst as u8)), [Rq((base as u8)) + disp], $mode)
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1719,112 +1701,112 @@ impl EmitterX64 for AssemblerX64 {
|
|||||||
}
|
}
|
||||||
fn emit_vxorps(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
|
fn emit_vxorps(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_fn!(vxorps)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_fn!(vxorps, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => sse_fn!(xorps)(self, Precision::Single, src1, src2, dst),
|
Some(CpuFeature::SSE42) => sse_fn!(xorps, self, Precision::Single, src1, src2, dst),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
fn emit_vxorpd(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
|
fn emit_vxorpd(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_fn!(vxorpd)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_fn!(vxorpd, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => sse_fn!(xorpd)(self, Precision::Double, src1, src2, dst),
|
Some(CpuFeature::SSE42) => sse_fn!(xorpd, self, Precision::Double, src1, src2, dst),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
fn emit_vaddss(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
|
fn emit_vaddss(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_fn!(vaddss)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_fn!(vaddss, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => sse_fn!(addss)(self, Precision::Single, src1, src2, dst),
|
Some(CpuFeature::SSE42) => sse_fn!(addss, self, Precision::Single, src1, src2, dst),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
fn emit_vaddsd(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
|
fn emit_vaddsd(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_fn!(vaddsd)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_fn!(vaddsd, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => sse_fn!(addsd)(self, Precision::Double, src1, src2, dst),
|
Some(CpuFeature::SSE42) => sse_fn!(addsd, self, Precision::Double, src1, src2, dst),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
fn emit_vsubss(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
|
fn emit_vsubss(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_fn!(vsubss)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_fn!(vsubss, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => sse_fn!(subss)(self, Precision::Single, src1, src2, dst),
|
Some(CpuFeature::SSE42) => sse_fn!(subss, self, Precision::Single, src1, src2, dst),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
fn emit_vsubsd(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
|
fn emit_vsubsd(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_fn!(vsubsd)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_fn!(vsubsd, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => sse_fn!(subsd)(self, Precision::Double, src1, src2, dst),
|
Some(CpuFeature::SSE42) => sse_fn!(subsd, self, Precision::Double, src1, src2, dst),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
fn emit_vmulss(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
|
fn emit_vmulss(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_fn!(vmulss)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_fn!(vmulss, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => sse_fn!(mulss)(self, Precision::Single, src1, src2, dst),
|
Some(CpuFeature::SSE42) => sse_fn!(mulss, self, Precision::Single, src1, src2, dst),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
fn emit_vmulsd(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
|
fn emit_vmulsd(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_fn!(vmulsd)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_fn!(vmulsd, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => sse_fn!(mulsd)(self, Precision::Double, src1, src2, dst),
|
Some(CpuFeature::SSE42) => sse_fn!(mulsd, self, Precision::Double, src1, src2, dst),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
fn emit_vdivss(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
|
fn emit_vdivss(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_fn!(vdivss)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_fn!(vdivss, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => sse_fn!(divss)(self, Precision::Single, src1, src2, dst),
|
Some(CpuFeature::SSE42) => sse_fn!(divss, self, Precision::Single, src1, src2, dst),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
fn emit_vdivsd(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
|
fn emit_vdivsd(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_fn!(vdivsd)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_fn!(vdivsd, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => sse_fn!(divsd)(self, Precision::Double, src1, src2, dst),
|
Some(CpuFeature::SSE42) => sse_fn!(divsd, self, Precision::Double, src1, src2, dst),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
fn emit_vmaxss(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
|
fn emit_vmaxss(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_fn!(vmaxss)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_fn!(vmaxss, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => sse_fn!(maxss)(self, Precision::Single, src1, src2, dst),
|
Some(CpuFeature::SSE42) => sse_fn!(maxss, self, Precision::Single, src1, src2, dst),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
fn emit_vmaxsd(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
|
fn emit_vmaxsd(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_fn!(vmaxsd)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_fn!(vmaxsd, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => sse_fn!(maxsd)(self, Precision::Double, src1, src2, dst),
|
Some(CpuFeature::SSE42) => sse_fn!(maxsd, self, Precision::Double, src1, src2, dst),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
fn emit_vminss(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
|
fn emit_vminss(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_fn!(vminss)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_fn!(vminss, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => sse_fn!(minss)(self, Precision::Single, src1, src2, dst),
|
Some(CpuFeature::SSE42) => sse_fn!(minss, self, Precision::Single, src1, src2, dst),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
fn emit_vminsd(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
|
fn emit_vminsd(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_fn!(vminsd)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_fn!(vminsd, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => sse_fn!(minsd)(self, Precision::Double, src1, src2, dst),
|
Some(CpuFeature::SSE42) => sse_fn!(minsd, self, Precision::Double, src1, src2, dst),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -1836,8 +1818,8 @@ impl EmitterX64 for AssemblerX64 {
|
|||||||
dst: XMM,
|
dst: XMM,
|
||||||
) -> Result<(), CompileError> {
|
) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_fn!(vcmpeqss)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_fn!(vcmpeqss, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => sse_fn!(cmpss, 0)(self, Precision::Single, src1, src2, dst),
|
Some(CpuFeature::SSE42) => sse_fn!(cmpss, 0, self, Precision::Single, src1, src2, dst),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -1849,8 +1831,8 @@ impl EmitterX64 for AssemblerX64 {
|
|||||||
dst: XMM,
|
dst: XMM,
|
||||||
) -> Result<(), CompileError> {
|
) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_fn!(vcmpeqsd)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_fn!(vcmpeqsd, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => sse_fn!(cmpsd, 0)(self, Precision::Double, src1, src2, dst),
|
Some(CpuFeature::SSE42) => sse_fn!(cmpsd, 0, self, Precision::Double, src1, src2, dst),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -1862,8 +1844,8 @@ impl EmitterX64 for AssemblerX64 {
|
|||||||
dst: XMM,
|
dst: XMM,
|
||||||
) -> Result<(), CompileError> {
|
) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_fn!(vcmpneqss)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_fn!(vcmpneqss, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => sse_fn!(cmpss, 4)(self, Precision::Single, src1, src2, dst),
|
Some(CpuFeature::SSE42) => sse_fn!(cmpss, 4, self, Precision::Single, src1, src2, dst),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -1875,8 +1857,8 @@ impl EmitterX64 for AssemblerX64 {
|
|||||||
dst: XMM,
|
dst: XMM,
|
||||||
) -> Result<(), CompileError> {
|
) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_fn!(vcmpneqsd)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_fn!(vcmpneqsd, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => sse_fn!(cmpsd, 4)(self, Precision::Double, src1, src2, dst),
|
Some(CpuFeature::SSE42) => sse_fn!(cmpsd, 4, self, Precision::Double, src1, src2, dst),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -1888,8 +1870,8 @@ impl EmitterX64 for AssemblerX64 {
|
|||||||
dst: XMM,
|
dst: XMM,
|
||||||
) -> Result<(), CompileError> {
|
) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_fn!(vcmpltss)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_fn!(vcmpltss, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => sse_fn!(cmpss, 1)(self, Precision::Single, src1, src2, dst),
|
Some(CpuFeature::SSE42) => sse_fn!(cmpss, 1, self, Precision::Single, src1, src2, dst),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -1901,8 +1883,8 @@ impl EmitterX64 for AssemblerX64 {
|
|||||||
dst: XMM,
|
dst: XMM,
|
||||||
) -> Result<(), CompileError> {
|
) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_fn!(vcmpltsd)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_fn!(vcmpltsd, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => sse_fn!(cmpsd, 1)(self, Precision::Double, src1, src2, dst),
|
Some(CpuFeature::SSE42) => sse_fn!(cmpsd, 1, self, Precision::Double, src1, src2, dst),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -1914,8 +1896,8 @@ impl EmitterX64 for AssemblerX64 {
|
|||||||
dst: XMM,
|
dst: XMM,
|
||||||
) -> Result<(), CompileError> {
|
) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_fn!(vcmpless)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_fn!(vcmpless, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => sse_fn!(cmpss, 2)(self, Precision::Single, src1, src2, dst),
|
Some(CpuFeature::SSE42) => sse_fn!(cmpss, 2, self, Precision::Single, src1, src2, dst),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -1927,8 +1909,8 @@ impl EmitterX64 for AssemblerX64 {
|
|||||||
dst: XMM,
|
dst: XMM,
|
||||||
) -> Result<(), CompileError> {
|
) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_fn!(vcmplesd)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_fn!(vcmplesd, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => sse_fn!(cmpsd, 2)(self, Precision::Double, src1, src2, dst),
|
Some(CpuFeature::SSE42) => sse_fn!(cmpsd, 2, self, Precision::Double, src1, src2, dst),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -1940,8 +1922,8 @@ impl EmitterX64 for AssemblerX64 {
|
|||||||
dst: XMM,
|
dst: XMM,
|
||||||
) -> Result<(), CompileError> {
|
) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_fn!(vcmpgtss)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_fn!(vcmpgtss, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => sse_fn!(cmpss, 6)(self, Precision::Single, src1, src2, dst),
|
Some(CpuFeature::SSE42) => sse_fn!(cmpss, 6, self, Precision::Single, src1, src2, dst),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -1953,8 +1935,8 @@ impl EmitterX64 for AssemblerX64 {
|
|||||||
dst: XMM,
|
dst: XMM,
|
||||||
) -> Result<(), CompileError> {
|
) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_fn!(vcmpgtsd)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_fn!(vcmpgtsd, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => sse_fn!(cmpsd, 6)(self, Precision::Double, src1, src2, dst),
|
Some(CpuFeature::SSE42) => sse_fn!(cmpsd, 6, self, Precision::Double, src1, src2, dst),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -1966,8 +1948,8 @@ impl EmitterX64 for AssemblerX64 {
|
|||||||
dst: XMM,
|
dst: XMM,
|
||||||
) -> Result<(), CompileError> {
|
) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_fn!(vcmpgess)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_fn!(vcmpgess, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => sse_fn!(cmpss, 5)(self, Precision::Single, src1, src2, dst),
|
Some(CpuFeature::SSE42) => sse_fn!(cmpss, 5, self, Precision::Single, src1, src2, dst),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -1979,8 +1961,8 @@ impl EmitterX64 for AssemblerX64 {
|
|||||||
dst: XMM,
|
dst: XMM,
|
||||||
) -> Result<(), CompileError> {
|
) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_fn!(vcmpgesd)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_fn!(vcmpgesd, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => sse_fn!(cmpsd, 5)(self, Precision::Double, src1, src2, dst),
|
Some(CpuFeature::SSE42) => sse_fn!(cmpsd, 5, self, Precision::Double, src1, src2, dst),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -1992,8 +1974,8 @@ impl EmitterX64 for AssemblerX64 {
|
|||||||
dst: XMM,
|
dst: XMM,
|
||||||
) -> Result<(), CompileError> {
|
) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_fn!(vcmpunordss)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_fn!(vcmpunordss, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => sse_fn!(cmpss, 3)(self, Precision::Single, src1, src2, dst),
|
Some(CpuFeature::SSE42) => sse_fn!(cmpss, 3, self, Precision::Single, src1, src2, dst),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -2005,8 +1987,8 @@ impl EmitterX64 for AssemblerX64 {
|
|||||||
dst: XMM,
|
dst: XMM,
|
||||||
) -> Result<(), CompileError> {
|
) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_fn!(vcmpunordsd)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_fn!(vcmpunordsd, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => sse_fn!(cmpsd, 3)(self, Precision::Double, src1, src2, dst),
|
Some(CpuFeature::SSE42) => sse_fn!(cmpsd, 3, self, Precision::Double, src1, src2, dst),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -2018,8 +2000,8 @@ impl EmitterX64 for AssemblerX64 {
|
|||||||
dst: XMM,
|
dst: XMM,
|
||||||
) -> Result<(), CompileError> {
|
) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_fn!(vcmpordss)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_fn!(vcmpordss, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => sse_fn!(cmpss, 7)(self, Precision::Single, src1, src2, dst),
|
Some(CpuFeature::SSE42) => sse_fn!(cmpss, 7, self, Precision::Single, src1, src2, dst),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -2031,24 +2013,24 @@ impl EmitterX64 for AssemblerX64 {
|
|||||||
dst: XMM,
|
dst: XMM,
|
||||||
) -> Result<(), CompileError> {
|
) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_fn!(vcmpordsd)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_fn!(vcmpordsd, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => sse_fn!(cmpsd, 7)(self, Precision::Double, src1, src2, dst),
|
Some(CpuFeature::SSE42) => sse_fn!(cmpsd, 7, self, Precision::Double, src1, src2, dst),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
fn emit_vsqrtss(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
|
fn emit_vsqrtss(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_fn!(vsqrtss)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_fn!(vsqrtss, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => sse_fn!(sqrtss)(self, Precision::Single, src1, src2, dst),
|
Some(CpuFeature::SSE42) => sse_fn!(sqrtss, self, Precision::Single, src1, src2, dst),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
fn emit_vsqrtsd(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
|
fn emit_vsqrtsd(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_fn!(vsqrtsd)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_fn!(vsqrtsd, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => sse_fn!(sqrtsd)(self, Precision::Double, src1, src2, dst),
|
Some(CpuFeature::SSE42) => sse_fn!(sqrtsd, self, Precision::Double, src1, src2, dst),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -2060,8 +2042,8 @@ impl EmitterX64 for AssemblerX64 {
|
|||||||
dst: XMM,
|
dst: XMM,
|
||||||
) -> Result<(), CompileError> {
|
) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_fn!(vcvtss2sd)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_fn!(vcvtss2sd, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => sse_fn!(cvtss2sd)(self, Precision::Single, src1, src2, dst),
|
Some(CpuFeature::SSE42) => sse_fn!(cvtss2sd, self, Precision::Single, src1, src2, dst),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -2073,8 +2055,8 @@ impl EmitterX64 for AssemblerX64 {
|
|||||||
dst: XMM,
|
dst: XMM,
|
||||||
) -> Result<(), CompileError> {
|
) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_fn!(vcvtsd2ss)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_fn!(vcvtsd2ss, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => sse_fn!(cvtsd2ss)(self, Precision::Double, src1, src2, dst),
|
Some(CpuFeature::SSE42) => sse_fn!(cvtsd2ss, self, Precision::Double, src1, src2, dst),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -2086,9 +2068,9 @@ impl EmitterX64 for AssemblerX64 {
|
|||||||
dst: XMM,
|
dst: XMM,
|
||||||
) -> Result<(), CompileError> {
|
) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_round_fn!(vroundss, 0)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_round_fn!(vroundss, 0, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => {
|
Some(CpuFeature::SSE42) => {
|
||||||
sse_round_fn!(roundss, 0)(self, Precision::Single, src1, src2, dst)
|
sse_round_fn!(roundss, 0, self, Precision::Single, src1, src2, dst)
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
@@ -2101,9 +2083,9 @@ impl EmitterX64 for AssemblerX64 {
|
|||||||
dst: XMM,
|
dst: XMM,
|
||||||
) -> Result<(), CompileError> {
|
) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_round_fn!(vroundsd, 0)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_round_fn!(vroundsd, 0, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => {
|
Some(CpuFeature::SSE42) => {
|
||||||
sse_round_fn!(roundsd, 0)(self, Precision::Double, src1, src2, dst)
|
sse_round_fn!(roundsd, 0, self, Precision::Double, src1, src2, dst)
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
@@ -2116,9 +2098,9 @@ impl EmitterX64 for AssemblerX64 {
|
|||||||
dst: XMM,
|
dst: XMM,
|
||||||
) -> Result<(), CompileError> {
|
) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_round_fn!(vroundss, 1)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_round_fn!(vroundss, 1, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => {
|
Some(CpuFeature::SSE42) => {
|
||||||
sse_round_fn!(roundss, 1)(self, Precision::Single, src1, src2, dst)
|
sse_round_fn!(roundss, 1, self, Precision::Single, src1, src2, dst)
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
@@ -2131,9 +2113,9 @@ impl EmitterX64 for AssemblerX64 {
|
|||||||
dst: XMM,
|
dst: XMM,
|
||||||
) -> Result<(), CompileError> {
|
) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_round_fn!(vroundsd, 1)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_round_fn!(vroundsd, 1, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => {
|
Some(CpuFeature::SSE42) => {
|
||||||
sse_round_fn!(roundsd, 1)(self, Precision::Double, src1, src2, dst)
|
sse_round_fn!(roundsd, 1, self, Precision::Double, src1, src2, dst)
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
@@ -2146,9 +2128,9 @@ impl EmitterX64 for AssemblerX64 {
|
|||||||
dst: XMM,
|
dst: XMM,
|
||||||
) -> Result<(), CompileError> {
|
) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_round_fn!(vroundss, 2)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_round_fn!(vroundss, 2, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => {
|
Some(CpuFeature::SSE42) => {
|
||||||
sse_round_fn!(roundss, 2)(self, Precision::Single, src1, src2, dst)
|
sse_round_fn!(roundss, 2, self, Precision::Single, src1, src2, dst)
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
@@ -2161,9 +2143,9 @@ impl EmitterX64 for AssemblerX64 {
|
|||||||
dst: XMM,
|
dst: XMM,
|
||||||
) -> Result<(), CompileError> {
|
) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_round_fn!(vroundsd, 2)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_round_fn!(vroundsd, 2, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => {
|
Some(CpuFeature::SSE42) => {
|
||||||
sse_round_fn!(roundsd, 2)(self, Precision::Double, src1, src2, dst)
|
sse_round_fn!(roundsd, 2, self, Precision::Double, src1, src2, dst)
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
@@ -2176,9 +2158,9 @@ impl EmitterX64 for AssemblerX64 {
|
|||||||
dst: XMM,
|
dst: XMM,
|
||||||
) -> Result<(), CompileError> {
|
) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_round_fn!(vroundss, 3)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_round_fn!(vroundss, 3, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => {
|
Some(CpuFeature::SSE42) => {
|
||||||
sse_round_fn!(roundss, 3)(self, Precision::Single, src1, src2, dst)
|
sse_round_fn!(roundss, 3, self, Precision::Single, src1, src2, dst)
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
@@ -2191,9 +2173,9 @@ impl EmitterX64 for AssemblerX64 {
|
|||||||
dst: XMM,
|
dst: XMM,
|
||||||
) -> Result<(), CompileError> {
|
) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_round_fn!(vroundsd, 3)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_round_fn!(vroundsd, 3, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => {
|
Some(CpuFeature::SSE42) => {
|
||||||
sse_round_fn!(roundsd, 3)(self, Precision::Double, src1, src2, dst)
|
sse_round_fn!(roundsd, 3, self, Precision::Double, src1, src2, dst)
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
@@ -2206,9 +2188,9 @@ impl EmitterX64 for AssemblerX64 {
|
|||||||
dst: XMM,
|
dst: XMM,
|
||||||
) -> Result<(), CompileError> {
|
) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_i2f_32_fn!(vcvtsi2ss)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_i2f_32_fn!(vcvtsi2ss, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => {
|
Some(CpuFeature::SSE42) => {
|
||||||
sse_i2f_32_fn!(cvtsi2ss)(self, Precision::Single, src1, src2, dst)
|
sse_i2f_32_fn!(cvtsi2ss, self, Precision::Single, src1, src2, dst)
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
@@ -2221,9 +2203,9 @@ impl EmitterX64 for AssemblerX64 {
|
|||||||
dst: XMM,
|
dst: XMM,
|
||||||
) -> Result<(), CompileError> {
|
) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_i2f_32_fn!(vcvtsi2sd)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_i2f_32_fn!(vcvtsi2sd, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => {
|
Some(CpuFeature::SSE42) => {
|
||||||
sse_i2f_32_fn!(cvtsi2sd)(self, Precision::Double, src1, src2, dst)
|
sse_i2f_32_fn!(cvtsi2sd, self, Precision::Double, src1, src2, dst)
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
@@ -2236,9 +2218,9 @@ impl EmitterX64 for AssemblerX64 {
|
|||||||
dst: XMM,
|
dst: XMM,
|
||||||
) -> Result<(), CompileError> {
|
) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_i2f_64_fn!(vcvtsi2ss)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_i2f_64_fn!(vcvtsi2ss, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => {
|
Some(CpuFeature::SSE42) => {
|
||||||
sse_i2f_64_fn!(cvtsi2ss)(self, Precision::Single, src1, src2, dst)
|
sse_i2f_64_fn!(cvtsi2ss, self, Precision::Single, src1, src2, dst)
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
@@ -2251,9 +2233,9 @@ impl EmitterX64 for AssemblerX64 {
|
|||||||
dst: XMM,
|
dst: XMM,
|
||||||
) -> Result<(), CompileError> {
|
) -> Result<(), CompileError> {
|
||||||
match self.get_simd_arch() {
|
match self.get_simd_arch() {
|
||||||
Some(CpuFeature::AVX) => avx_i2f_64_fn!(vcvtsi2sd)(self, src1, src2, dst),
|
Some(CpuFeature::AVX) => avx_i2f_64_fn!(vcvtsi2sd, self, src1, src2, dst),
|
||||||
Some(CpuFeature::SSE42) => {
|
Some(CpuFeature::SSE42) => {
|
||||||
sse_i2f_64_fn!(cvtsi2sd)(self, Precision::Double, src1, src2, dst)
|
sse_i2f_64_fn!(cvtsi2sd, self, Precision::Double, src1, src2, dst)
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ impl<'a> ArtifactCreate<'a> for ArtifactBuild {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn set_module_info_name(&mut self, name: String) -> bool {
|
fn set_module_info_name(&mut self, name: String) -> bool {
|
||||||
Arc::get_mut(&mut self.serializable.compile_info.module).map_or(false, |mut module_info| {
|
Arc::get_mut(&mut self.serializable.compile_info.module).map_or(false, |module_info| {
|
||||||
module_info.name = Some(name.to_string());
|
module_info.name = Some(name.to_string());
|
||||||
true
|
true
|
||||||
})
|
})
|
||||||
@@ -414,7 +414,7 @@ impl<'a> ArtifactCreate<'a> for ArtifactBuildFromArchive {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn set_module_info_name(&mut self, name: String) -> bool {
|
fn set_module_info_name(&mut self, name: String) -> bool {
|
||||||
Arc::get_mut(&mut self.compile_info.module).map_or(false, |mut module_info| {
|
Arc::get_mut(&mut self.compile_info.module).map_or(false, |module_info| {
|
||||||
module_info.name = Some(name.to_string());
|
module_info.name = Some(name.to_string());
|
||||||
true
|
true
|
||||||
})
|
})
|
||||||
|
|||||||
4
lib/emscripten/src/env/mod.rs
vendored
4
lib/emscripten/src/env/mod.rs
vendored
@@ -139,7 +139,7 @@ pub fn _pathconf(ctx: FunctionEnvMut<EmEnv>, path_addr: c_int, name: c_int) -> c
|
|||||||
let _path = emscripten_memory_pointer!(memory.view(&ctx), path_addr) as *const c_char;
|
let _path = emscripten_memory_pointer!(memory.view(&ctx), path_addr) as *const c_char;
|
||||||
match name {
|
match name {
|
||||||
0 => 32000,
|
0 => 32000,
|
||||||
1 | 2 | 3 => 255,
|
1..=3 => 255,
|
||||||
4 | 5 | 16 | 17 | 18 => 4096,
|
4 | 5 | 16 | 17 | 18 => 4096,
|
||||||
6 | 7 | 20 => 1,
|
6 | 7 | 20 => 1,
|
||||||
8 => 0,
|
8 => 0,
|
||||||
@@ -156,7 +156,7 @@ pub fn _fpathconf(_ctx: FunctionEnvMut<EmEnv>, _fildes: c_int, name: c_int) -> c
|
|||||||
debug!("emscripten::_fpathconf {} {}", _fildes, name);
|
debug!("emscripten::_fpathconf {} {}", _fildes, name);
|
||||||
match name {
|
match name {
|
||||||
0 => 32000,
|
0 => 32000,
|
||||||
1 | 2 | 3 => 255,
|
1..=3 => 255,
|
||||||
4 | 5 | 16 | 17 | 18 => 4096,
|
4 | 5 | 16 | 17 | 18 => 4096,
|
||||||
6 | 7 | 20 => 1,
|
6 | 7 | 20 => 1,
|
||||||
8 => 0,
|
8 => 0,
|
||||||
|
|||||||
@@ -183,8 +183,8 @@ unsafe fn fmt_time(ctx: FunctionEnvMut<EmEnv>, time: u32) -> *const c_char {
|
|||||||
let memory = ctx.data().memory(0);
|
let memory = ctx.data().memory(0);
|
||||||
let date = &*(emscripten_memory_pointer!(memory.view(&ctx), time) as *mut guest_tm);
|
let date = &*(emscripten_memory_pointer!(memory.view(&ctx), time) as *mut guest_tm);
|
||||||
|
|
||||||
let days = vec!["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
let days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
||||||
let months = vec![
|
let months = [
|
||||||
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
|
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
|
||||||
];
|
];
|
||||||
let year = 1900 + date.tm_year;
|
let year = 1900 + date.tm_year;
|
||||||
@@ -426,7 +426,8 @@ pub fn _strftime(
|
|||||||
) else {
|
) else {
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
let Ok(rust_time) = time::Time::from_hms(tm.tm_hour as u8, tm.tm_min as u8, tm.tm_sec as u8) else {
|
let Ok(rust_time) = time::Time::from_hms(tm.tm_hour as u8, tm.tm_min as u8, tm.tm_sec as u8)
|
||||||
|
else {
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
let rust_datetime = time::PrimitiveDateTime::new(rust_date, rust_time);
|
let rust_datetime = time::PrimitiveDateTime::new(rust_date, rust_time);
|
||||||
|
|||||||
@@ -363,7 +363,7 @@ impl WritableJournal for CompactingJournalTx {
|
|||||||
state
|
state
|
||||||
.descriptors
|
.descriptors
|
||||||
.entry(lookup)
|
.entry(lookup)
|
||||||
.or_insert_with(Default::default)
|
.or_default()
|
||||||
.events
|
.events
|
||||||
.push(event_index);
|
.push(event_index);
|
||||||
|
|
||||||
@@ -394,10 +394,7 @@ impl WritableJournal for CompactingJournalTx {
|
|||||||
.or_else(|| state.stdio_descriptors.get(fd).cloned());
|
.or_else(|| state.stdio_descriptors.get(fd).cloned());
|
||||||
|
|
||||||
if let Some(lookup) = lookup {
|
if let Some(lookup) = lookup {
|
||||||
let state = state
|
let state = state.descriptors.entry(lookup).or_default();
|
||||||
.descriptors
|
|
||||||
.entry(lookup)
|
|
||||||
.or_insert_with(Default::default);
|
|
||||||
state.events.push(event_index);
|
state.events.push(event_index);
|
||||||
} else {
|
} else {
|
||||||
state.whitelist.insert(event_index);
|
state.whitelist.insert(event_index);
|
||||||
@@ -425,10 +422,7 @@ impl WritableJournal for CompactingJournalTx {
|
|||||||
|
|
||||||
// Update the state
|
// Update the state
|
||||||
if let Some(lookup) = lookup {
|
if let Some(lookup) = lookup {
|
||||||
let state = state
|
let state = state.descriptors.entry(lookup).or_default();
|
||||||
.descriptors
|
|
||||||
.entry(lookup)
|
|
||||||
.or_insert_with(Default::default);
|
|
||||||
if let JournalEntry::FileDescriptorWriteV1 { offset, data, .. } = &entry {
|
if let JournalEntry::FileDescriptorWriteV1 { offset, data, .. } = &entry {
|
||||||
state.write_map.insert(
|
state.write_map.insert(
|
||||||
MemoryRange {
|
MemoryRange {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use std::{fmt, str::FromStr};
|
|||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
const REGEX_PACKAGE_WITH_VERSION: &str =
|
const REGEX_PACKAGE_WITH_VERSION: &str =
|
||||||
r#"^([a-zA-Z0-9\-_]+)/([a-zA-Z0-9\-_]+)(@([a-zA-Z0-9\.\-_]+*))?$"#;
|
r"^([a-zA-Z0-9\-_]+)/([a-zA-Z0-9\-_]+)(@([a-zA-Z0-9\.\-_]+*))?$";
|
||||||
|
|
||||||
lazy_static::lazy_static! {
|
lazy_static::lazy_static! {
|
||||||
static ref PACKAGE_WITH_VERSION: Regex = regex::Regex::new(REGEX_PACKAGE_WITH_VERSION).unwrap();
|
static ref PACKAGE_WITH_VERSION: Regex = regex::Regex::new(REGEX_PACKAGE_WITH_VERSION).unwrap();
|
||||||
|
|||||||
@@ -4,12 +4,7 @@
|
|||||||
// This file contains code from external sources.
|
// This file contains code from external sources.
|
||||||
// Attributions: https://github.com/wasmerio/wasmer/blob/master/ATTRIBUTIONS.md
|
// Attributions: https://github.com/wasmerio/wasmer/blob/master/ATTRIBUTIONS.md
|
||||||
|
|
||||||
use std::{
|
use std::{cell::UnsafeCell, convert::TryInto, ptr::NonNull, rc::Rc, sync::RwLock};
|
||||||
cell::UnsafeCell,
|
|
||||||
convert::TryInto,
|
|
||||||
ptr::NonNull,
|
|
||||||
sync::{Arc, RwLock},
|
|
||||||
};
|
|
||||||
|
|
||||||
use wasmer::{Bytes, MemoryError, MemoryType, Pages};
|
use wasmer::{Bytes, MemoryError, MemoryType, Pages};
|
||||||
use wasmer_types::{MemoryStyle, WASM_PAGE_SIZE};
|
use wasmer_types::{MemoryStyle, WASM_PAGE_SIZE};
|
||||||
@@ -315,7 +310,7 @@ impl VMOwnedMemory {
|
|||||||
/// Converts this owned memory into shared memory
|
/// Converts this owned memory into shared memory
|
||||||
pub fn to_shared(self) -> VMSharedMemory {
|
pub fn to_shared(self) -> VMSharedMemory {
|
||||||
VMSharedMemory {
|
VMSharedMemory {
|
||||||
mmap: Arc::new(RwLock::new(self.mmap)),
|
mmap: Rc::new(RwLock::new(self.mmap)),
|
||||||
config: self.config,
|
config: self.config,
|
||||||
conditions: ThreadConditions::new(),
|
conditions: ThreadConditions::new(),
|
||||||
}
|
}
|
||||||
@@ -387,7 +382,7 @@ impl LinearMemory for VMOwnedMemory {
|
|||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct VMSharedMemory {
|
pub struct VMSharedMemory {
|
||||||
// The underlying allocation.
|
// The underlying allocation.
|
||||||
mmap: Arc<RwLock<WasmMmap>>,
|
mmap: Rc<RwLock<WasmMmap>>,
|
||||||
// Configuration of this memory
|
// Configuration of this memory
|
||||||
config: VMMemoryConfig,
|
config: VMMemoryConfig,
|
||||||
conditions: ThreadConditions,
|
conditions: ThreadConditions,
|
||||||
@@ -424,7 +419,7 @@ impl VMSharedMemory {
|
|||||||
pub fn copy(&mut self) -> Result<Self, MemoryError> {
|
pub fn copy(&mut self) -> Result<Self, MemoryError> {
|
||||||
let mut guard = self.mmap.write().unwrap();
|
let mut guard = self.mmap.write().unwrap();
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
mmap: Arc::new(RwLock::new(guard.copy()?)),
|
mmap: Rc::new(RwLock::new(guard.copy()?)),
|
||||||
config: self.config.clone(),
|
config: self.config.clone(),
|
||||||
conditions: ThreadConditions::new(),
|
conditions: ThreadConditions::new(),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ pub use target_lexicon::{
|
|||||||
///
|
///
|
||||||
/// [`cpuid` crate]: https://docs.rs/cpuid/0.1.1/cpuid/enum.CpuFeature.html
|
/// [`cpuid` crate]: https://docs.rs/cpuid/0.1.1/cpuid/enum.CpuFeature.html
|
||||||
/// [`cranelift-native`]: https://github.com/bytecodealliance/cranelift/blob/6988545fd20249b084c53f4761b8c861266f5d31/cranelift-native/src/lib.rs#L51-L92
|
/// [`cranelift-native`]: https://github.com/bytecodealliance/cranelift/blob/6988545fd20249b084c53f4761b8c861266f5d31/cranelift-native/src/lib.rs#L51-L92
|
||||||
#[allow(missing_docs, clippy::derive_hash_xor_eq)]
|
#[allow(missing_docs, clippy::derived_hash_with_manual_eq)]
|
||||||
#[derive(EnumSetType, Debug, Hash)]
|
#[derive(EnumSetType, Debug, Hash)]
|
||||||
pub enum CpuFeature {
|
pub enum CpuFeature {
|
||||||
// X86 features
|
// X86 features
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ pub struct MetadataHeader {
|
|||||||
impl MetadataHeader {
|
impl MetadataHeader {
|
||||||
/// Current ABI version. Increment this any time breaking changes are made
|
/// Current ABI version. Increment this any time breaking changes are made
|
||||||
/// to the format of the serialized data.
|
/// to the format of the serialized data.
|
||||||
pub const CURRENT_VERSION: u32 = 5;
|
pub const CURRENT_VERSION: u32 = 6;
|
||||||
|
|
||||||
/// Magic number to identify wasmer metadata.
|
/// Magic number to identify wasmer metadata.
|
||||||
const MAGIC: [u8; 8] = *b"WASMER\0\0";
|
const MAGIC: [u8; 8] = *b"WASMER\0\0";
|
||||||
|
|||||||
@@ -1,24 +1,24 @@
|
|||||||
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
|
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
|
||||||
|
|
||||||
#[cfg(any(feature = "remote"))]
|
#[cfg(feature = "remote")]
|
||||||
pub mod client;
|
pub mod client;
|
||||||
#[cfg(feature = "host-net")]
|
#[cfg(feature = "host-net")]
|
||||||
pub mod host;
|
pub mod host;
|
||||||
pub mod meta;
|
pub mod meta;
|
||||||
#[cfg(any(feature = "remote"))]
|
#[cfg(feature = "remote")]
|
||||||
pub mod rx_tx;
|
pub mod rx_tx;
|
||||||
#[cfg(any(feature = "remote"))]
|
#[cfg(feature = "remote")]
|
||||||
pub mod server;
|
pub mod server;
|
||||||
#[cfg(feature = "tokio")]
|
#[cfg(feature = "tokio")]
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
#[cfg(any(feature = "remote"))]
|
#[cfg(feature = "remote")]
|
||||||
pub use client::{RemoteNetworkingClient, RemoteNetworkingClientDriver};
|
pub use client::{RemoteNetworkingClient, RemoteNetworkingClientDriver};
|
||||||
use pin_project_lite::pin_project;
|
use pin_project_lite::pin_project;
|
||||||
#[cfg(feature = "rkyv")]
|
#[cfg(feature = "rkyv")]
|
||||||
use rkyv::{Archive, CheckBytes, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize};
|
use rkyv::{Archive, CheckBytes, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize};
|
||||||
#[cfg(any(feature = "remote"))]
|
#[cfg(feature = "remote")]
|
||||||
pub use server::{RemoteNetworkingServer, RemoteNetworkingServerDriver};
|
pub use server::{RemoteNetworkingServer, RemoteNetworkingServerDriver};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::mem::MaybeUninit;
|
use std::mem::MaybeUninit;
|
||||||
|
|||||||
@@ -1084,27 +1084,27 @@ impl VMInstance {
|
|||||||
|
|
||||||
ptr::copy(
|
ptr::copy(
|
||||||
vmshared_signatures.values().as_slice().as_ptr(),
|
vmshared_signatures.values().as_slice().as_ptr(),
|
||||||
instance.signature_ids_ptr() as *mut VMSharedSignatureIndex,
|
instance.signature_ids_ptr(),
|
||||||
vmshared_signatures.len(),
|
vmshared_signatures.len(),
|
||||||
);
|
);
|
||||||
ptr::copy(
|
ptr::copy(
|
||||||
imports.functions.values().as_slice().as_ptr(),
|
imports.functions.values().as_slice().as_ptr(),
|
||||||
instance.imported_functions_ptr() as *mut VMFunctionImport,
|
instance.imported_functions_ptr(),
|
||||||
imports.functions.len(),
|
imports.functions.len(),
|
||||||
);
|
);
|
||||||
ptr::copy(
|
ptr::copy(
|
||||||
imports.tables.values().as_slice().as_ptr(),
|
imports.tables.values().as_slice().as_ptr(),
|
||||||
instance.imported_tables_ptr() as *mut VMTableImport,
|
instance.imported_tables_ptr(),
|
||||||
imports.tables.len(),
|
imports.tables.len(),
|
||||||
);
|
);
|
||||||
ptr::copy(
|
ptr::copy(
|
||||||
imports.memories.values().as_slice().as_ptr(),
|
imports.memories.values().as_slice().as_ptr(),
|
||||||
instance.imported_memories_ptr() as *mut VMMemoryImport,
|
instance.imported_memories_ptr(),
|
||||||
imports.memories.len(),
|
imports.memories.len(),
|
||||||
);
|
);
|
||||||
ptr::copy(
|
ptr::copy(
|
||||||
imports.globals.values().as_slice().as_ptr(),
|
imports.globals.values().as_slice().as_ptr(),
|
||||||
instance.imported_globals_ptr() as *mut VMGlobalImport,
|
instance.imported_globals_ptr(),
|
||||||
imports.globals.len(),
|
imports.globals.len(),
|
||||||
);
|
);
|
||||||
// these should already be set, add asserts here? for:
|
// these should already be set, add asserts here? for:
|
||||||
@@ -1116,7 +1116,7 @@ impl VMInstance {
|
|||||||
vmctx_globals.len(),
|
vmctx_globals.len(),
|
||||||
);
|
);
|
||||||
ptr::write(
|
ptr::write(
|
||||||
instance.builtin_functions_ptr() as *mut VMBuiltinFunctionsArray,
|
instance.builtin_functions_ptr(),
|
||||||
VMBuiltinFunctionsArray::initialized(),
|
VMBuiltinFunctionsArray::initialized(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,9 @@ use more_asserts::assert_ge;
|
|||||||
use std::cell::UnsafeCell;
|
use std::cell::UnsafeCell;
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
|
use std::rc::Rc;
|
||||||
use std::slice;
|
use std::slice;
|
||||||
use std::sync::{Arc, RwLock};
|
use std::sync::RwLock;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use wasmer_types::{Bytes, MemoryError, MemoryStyle, MemoryType, Pages, WASM_PAGE_SIZE};
|
use wasmer_types::{Bytes, MemoryError, MemoryStyle, MemoryType, Pages, WASM_PAGE_SIZE};
|
||||||
|
|
||||||
@@ -305,7 +306,7 @@ impl VMOwnedMemory {
|
|||||||
/// Converts this owned memory into shared memory
|
/// Converts this owned memory into shared memory
|
||||||
pub fn to_shared(self) -> VMSharedMemory {
|
pub fn to_shared(self) -> VMSharedMemory {
|
||||||
VMSharedMemory {
|
VMSharedMemory {
|
||||||
mmap: Arc::new(RwLock::new(self.mmap)),
|
mmap: Rc::new(RwLock::new(self.mmap)),
|
||||||
config: self.config,
|
config: self.config,
|
||||||
conditions: ThreadConditions::new(),
|
conditions: ThreadConditions::new(),
|
||||||
}
|
}
|
||||||
@@ -378,7 +379,7 @@ impl LinearMemory for VMOwnedMemory {
|
|||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct VMSharedMemory {
|
pub struct VMSharedMemory {
|
||||||
// The underlying allocation.
|
// The underlying allocation.
|
||||||
mmap: Arc<RwLock<WasmMmap>>,
|
mmap: Rc<RwLock<WasmMmap>>,
|
||||||
// Configuration of this memory
|
// Configuration of this memory
|
||||||
config: VMMemoryConfig,
|
config: VMMemoryConfig,
|
||||||
// waiters list for this memory
|
// waiters list for this memory
|
||||||
@@ -416,7 +417,7 @@ impl VMSharedMemory {
|
|||||||
pub fn copy(&mut self) -> Result<Self, MemoryError> {
|
pub fn copy(&mut self) -> Result<Self, MemoryError> {
|
||||||
let mut guard = self.mmap.write().unwrap();
|
let mut guard = self.mmap.write().unwrap();
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
mmap: Arc::new(RwLock::new(guard.copy()?)),
|
mmap: Rc::new(RwLock::new(guard.copy()?)),
|
||||||
config: self.config.clone(),
|
config: self.config.clone(),
|
||||||
conditions: ThreadConditions::new(),
|
conditions: ThreadConditions::new(),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -90,14 +90,10 @@ impl ThreadConditions {
|
|||||||
if self.inner.map.len() >= 1 << 32 {
|
if self.inner.map.len() >= 1 << 32 {
|
||||||
return Err(WaiterError::TooManyWaiters);
|
return Err(WaiterError::TooManyWaiters);
|
||||||
}
|
}
|
||||||
self.inner
|
self.inner.map.entry(dst).or_default().push(NotifyWaiter {
|
||||||
.map
|
thread: current(),
|
||||||
.entry(dst)
|
notified: false,
|
||||||
.or_insert_with(Vec::new)
|
});
|
||||||
.push(NotifyWaiter {
|
|
||||||
thread: current(),
|
|
||||||
notified: false,
|
|
||||||
});
|
|
||||||
if let Some(timeout) = timeout {
|
if let Some(timeout) = timeout {
|
||||||
park_timeout(timeout);
|
park_timeout(timeout);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ impl Trap {
|
|||||||
pub fn downcast<T: Error + 'static>(self) -> Result<T, Self> {
|
pub fn downcast<T: Error + 'static>(self) -> Result<T, Self> {
|
||||||
match self {
|
match self {
|
||||||
// We only try to downcast user errors
|
// We only try to downcast user errors
|
||||||
Trap::User(err) if err.is::<T>() => Ok(*err.downcast::<T>().unwrap()),
|
Self::User(err) if err.is::<T>() => Ok(*err.downcast::<T>().unwrap()),
|
||||||
_ => Err(self),
|
_ => Err(self),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -100,7 +100,7 @@ impl Trap {
|
|||||||
pub fn downcast_ref<T: Error + 'static>(&self) -> Option<&T> {
|
pub fn downcast_ref<T: Error + 'static>(&self) -> Option<&T> {
|
||||||
match &self {
|
match &self {
|
||||||
// We only try to downcast user errors
|
// We only try to downcast user errors
|
||||||
Trap::User(err) if err.is::<T>() => err.downcast_ref::<T>(),
|
Self::User(err) if err.is::<T>() => err.downcast_ref::<T>(),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,7 +108,7 @@ impl Trap {
|
|||||||
/// Returns true if the `Trap` is the same as T
|
/// Returns true if the `Trap` is the same as T
|
||||||
pub fn is<T: Error + 'static>(&self) -> bool {
|
pub fn is<T: Error + 'static>(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Trap::User(err) => err.is::<T>(),
|
Self::User(err) => err.is::<T>(),
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -117,7 +117,7 @@ impl Trap {
|
|||||||
impl std::error::Error for Trap {
|
impl std::error::Error for Trap {
|
||||||
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
||||||
match &self {
|
match &self {
|
||||||
Trap::User(err) => Some(&**err),
|
Self::User(err) => Some(&**err),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -724,8 +724,6 @@ fn import_object_for_all_wasi_versions(
|
|||||||
} else {
|
} else {
|
||||||
Box::new(stub_initializer) as ModuleInitializer
|
Box::new(stub_initializer) as ModuleInitializer
|
||||||
};
|
};
|
||||||
|
|
||||||
let init = init;
|
|
||||||
} else {
|
} else {
|
||||||
// Prevents unused warning.
|
// Prevents unused warning.
|
||||||
let _ = module;
|
let _ = module;
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ where
|
|||||||
|
|
||||||
/// A package loader.
|
/// A package loader.
|
||||||
fn package_loader(&self) -> Arc<dyn PackageLoader + Send + Sync> {
|
fn package_loader(&self) -> Arc<dyn PackageLoader + Send + Sync> {
|
||||||
Arc::new(UnsupportedPackageLoader::default())
|
Arc::new(UnsupportedPackageLoader)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A cache for compiled modules.
|
/// A cache for compiled modules.
|
||||||
@@ -221,7 +221,7 @@ impl PluggableRuntime {
|
|||||||
let http_client =
|
let http_client =
|
||||||
crate::http::default_http_client().map(|client| Arc::new(client) as DynHttpClient);
|
crate::http::default_http_client().map(|client| Arc::new(client) as DynHttpClient);
|
||||||
|
|
||||||
let loader = UnsupportedPackageLoader::default();
|
let loader = UnsupportedPackageLoader;
|
||||||
|
|
||||||
let mut source = MultiSource::new();
|
let mut source = MultiSource::new();
|
||||||
if let Some(client) = &http_client {
|
if let Some(client) = &http_client {
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ pub unsafe fn restore_snapshot(
|
|||||||
stderr_fds.insert(2 as WasiFd);
|
stderr_fds.insert(2 as WasiFd);
|
||||||
|
|
||||||
// Loop through all the events and process them
|
// Loop through all the events and process them
|
||||||
let cur_module_hash = Some(ctx.data().process.module_hash.as_bytes());
|
let cur_module_hash = ctx.data().process.module_hash.as_bytes();
|
||||||
let mut journal_module_hash = None;
|
let mut journal_module_hash = None;
|
||||||
let mut rewind = None;
|
let mut rewind = None;
|
||||||
while let Some(next) = journal.read().map_err(anyhow_err_to_runtime_err)? {
|
while let Some(next) = journal.read().map_err(anyhow_err_to_runtime_err)? {
|
||||||
@@ -155,7 +155,7 @@ pub unsafe fn restore_snapshot(
|
|||||||
.map_err(anyhow_err_to_runtime_err)?;
|
.map_err(anyhow_err_to_runtime_err)?;
|
||||||
}
|
}
|
||||||
crate::journal::JournalEntry::UpdateMemoryRegionV1 { region, data } => {
|
crate::journal::JournalEntry::UpdateMemoryRegionV1 { region, data } => {
|
||||||
if cur_module_hash != journal_module_hash {
|
if Some(cur_module_hash) != journal_module_hash {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,7 +201,7 @@ pub unsafe fn restore_snapshot(
|
|||||||
store_data,
|
store_data,
|
||||||
is_64bit,
|
is_64bit,
|
||||||
} => {
|
} => {
|
||||||
if cur_module_hash != journal_module_hash {
|
if Some(cur_module_hash) != journal_module_hash {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,7 +272,7 @@ pub unsafe fn restore_snapshot(
|
|||||||
.map_err(anyhow_err_to_runtime_err)?;
|
.map_err(anyhow_err_to_runtime_err)?;
|
||||||
}
|
}
|
||||||
crate::journal::JournalEntry::SnapshotV1 { when: _, trigger } => {
|
crate::journal::JournalEntry::SnapshotV1 { when: _, trigger } => {
|
||||||
if cur_module_hash != journal_module_hash {
|
if Some(cur_module_hash) != journal_module_hash {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ctx.data_mut().pop_snapshot_trigger(trigger);
|
ctx.data_mut().pop_snapshot_trigger(trigger);
|
||||||
@@ -596,11 +596,11 @@ pub unsafe fn restore_snapshot(
|
|||||||
// If we are not in the same module then we fire off an exit
|
// If we are not in the same module then we fire off an exit
|
||||||
// that simulates closing the process (hence keeps everything
|
// that simulates closing the process (hence keeps everything
|
||||||
// in a clean state)
|
// in a clean state)
|
||||||
if journal_module_hash.is_some() && cur_module_hash != journal_module_hash {
|
if journal_module_hash.is_some() && Some(cur_module_hash) != journal_module_hash {
|
||||||
tracing::error!(
|
tracing::error!(
|
||||||
"The WASM module hash does not match the journal module hash (journal_hash={:x?} vs module_hash{:x?}) - forcing a restart",
|
"The WASM module hash does not match the journal module hash (journal_hash={:x?} vs module_hash{:x?}) - forcing a restart",
|
||||||
journal_module_hash.unwrap(),
|
journal_module_hash.unwrap(),
|
||||||
cur_module_hash.unwrap()
|
cur_module_hash
|
||||||
);
|
);
|
||||||
if bootstrapping {
|
if bootstrapping {
|
||||||
rewind = None;
|
rewind = None;
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ pub mod types {
|
|||||||
target_vendor = "apple"
|
target_vendor = "apple"
|
||||||
))]
|
))]
|
||||||
pub mod unix;
|
pub mod unix;
|
||||||
#[cfg(any(target_family = "wasm"))]
|
#[cfg(target_family = "wasm")]
|
||||||
pub mod wasm;
|
pub mod wasm;
|
||||||
#[cfg(any(target_os = "windows"))]
|
#[cfg(target_os = "windows")]
|
||||||
pub mod windows;
|
pub mod windows;
|
||||||
|
|
||||||
pub mod journal;
|
pub mod journal;
|
||||||
@@ -65,7 +65,7 @@ pub(crate) use tracing::{debug, error, trace, warn};
|
|||||||
target_vendor = "apple"
|
target_vendor = "apple"
|
||||||
))]
|
))]
|
||||||
pub use unix::*;
|
pub use unix::*;
|
||||||
#[cfg(any(target_family = "wasm"))]
|
#[cfg(target_family = "wasm")]
|
||||||
pub use wasm::*;
|
pub use wasm::*;
|
||||||
|
|
||||||
pub(crate) use virtual_fs::{
|
pub(crate) use virtual_fs::{
|
||||||
@@ -78,7 +78,7 @@ pub(crate) use wasmer::{
|
|||||||
OnCalledAction, Pages, RuntimeError, Store, TypedFunction, Value, WasmPtr, WasmSlice,
|
OnCalledAction, Pages, RuntimeError, Store, TypedFunction, Value, WasmPtr, WasmSlice,
|
||||||
};
|
};
|
||||||
pub(crate) use wasmer_wasix_types::{asyncify::__wasi_asyncify_t, wasi::EventUnion};
|
pub(crate) use wasmer_wasix_types::{asyncify::__wasi_asyncify_t, wasi::EventUnion};
|
||||||
#[cfg(any(target_os = "windows"))]
|
#[cfg(target_os = "windows")]
|
||||||
pub use windows::*;
|
pub use windows::*;
|
||||||
|
|
||||||
pub(crate) use self::types::{
|
pub(crate) use self::types::{
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ pub fn clock_time_set_internal(
|
|||||||
|
|
||||||
let precision = 1 as Timestamp;
|
let precision = 1 as Timestamp;
|
||||||
let t_now = wasi_try!(platform_clock_time_get(clock_id, precision));
|
let t_now = wasi_try!(platform_clock_time_get(clock_id, precision));
|
||||||
let t_now = t_now;
|
|
||||||
|
|
||||||
let t_target = time as i64;
|
let t_target = time as i64;
|
||||||
let t_offset = t_target - t_now;
|
let t_offset = t_target - t_now;
|
||||||
|
|||||||
@@ -116,8 +116,6 @@ pub(super) fn proc_join_internal<M: MemorySize + 'static>(
|
|||||||
let pid = match option_pid {
|
let pid = match option_pid {
|
||||||
None => {
|
None => {
|
||||||
let mut process = ctx.data_mut().process.clone();
|
let mut process = ctx.data_mut().process.clone();
|
||||||
let pid_ptr = pid_ptr;
|
|
||||||
let status_ptr = status_ptr;
|
|
||||||
|
|
||||||
// We wait for any process to exit (if it takes too long
|
// We wait for any process to exit (if it takes too long
|
||||||
// then we go into a deep sleep)
|
// then we go into a deep sleep)
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
1.70
|
1.73
|
||||||
|
|||||||
BIN
sm64.us.f3dex2e.wasm
Normal file
BIN
sm64.us.f3dex2e.wasm
Normal file
Binary file not shown.
@@ -20,7 +20,40 @@ fn artifact_serialization_roundtrip() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This test is just here to update the compiled objects to their
|
||||||
|
// latest version, so we can commit them to the repo.
|
||||||
#[test]
|
#[test]
|
||||||
|
#[ignore = "Please enable it when tests fail, so we can generate new versions of the .wasmu files"]
|
||||||
|
fn artifact_serialization_build() {
|
||||||
|
use std::str::FromStr;
|
||||||
|
use wasmer::sys::{get_default_compiler_config, Features, NativeEngineExt};
|
||||||
|
use wasmer::{CpuFeature, Target, Triple};
|
||||||
|
|
||||||
|
let file_names = ["bash.wasm", "cowsay.wasm", "python-3.11.3.wasm"];
|
||||||
|
let operating_systems = ["linux", "windows"];
|
||||||
|
let chipset = "x86_64";
|
||||||
|
|
||||||
|
for os in operating_systems {
|
||||||
|
let triple = Triple::from_str(&format!("{}-{}", chipset, os)).unwrap();
|
||||||
|
let mut cpu_feature = CpuFeature::set();
|
||||||
|
cpu_feature.insert(CpuFeature::from_str("sse2").unwrap());
|
||||||
|
let target = Target::new(triple, cpu_feature);
|
||||||
|
for file_name in file_names {
|
||||||
|
let path = PathBuf::from("tests/integration/cli/tests/wasm").join(file_name);
|
||||||
|
let wasm_module = fs::read(path).unwrap();
|
||||||
|
let config = get_default_compiler_config().unwrap();
|
||||||
|
let engine = Engine::new(config, target.clone(), Features::default());
|
||||||
|
|
||||||
|
let module = Module::new(&engine, wasm_module).unwrap();
|
||||||
|
let serialized_bytes = module.serialize().unwrap();
|
||||||
|
let path = PathBuf::from(&format!("tests/compilers/wasmu/{}/{}u", os, file_name));
|
||||||
|
std::fs::write(path, serialized_bytes).unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(target_arch = "x86_64")]
|
||||||
fn artifact_deserialization_roundtrip() {
|
fn artifact_deserialization_roundtrip() {
|
||||||
// This test is included to make sure we don't break the serialized format
|
// This test is included to make sure we don't break the serialized format
|
||||||
// by mistake. Otherwise, everything in this test is already tested in
|
// by mistake. Otherwise, everything in this test is already tested in
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user