Merge branch 'master' into add-log-streams-options

This commit is contained in:
M.Amin Rayej
2024-02-22 01:57:02 +03:30
52 changed files with 578 additions and 522 deletions

View File

@@ -28,7 +28,7 @@ RUN apt-get update && \
# install rust tools
RUN curl --proto "=https" --tlsv1.2 --retry 3 -sSfL https://sh.rustup.rs | sh -s -- -y
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
COPY 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 \
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!
COPY build_openssl.sh /

View File

@@ -7,7 +7,7 @@ on:
env:
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: git
MSRV: "1.70"
MSRV: "1.73"
jobs:
run_benchmark:

View File

@@ -3,7 +3,7 @@ name: Builds
env:
RUST_BACKTRACE: 1
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: git
MSRV: "1.70"
MSRV: "1.73"
on:
push:
@@ -60,7 +60,7 @@ jobs:
use_llvm: true
build_wasm: false
- build: macos-arm64
os: macos-11.0
os: macos-14
target: aarch64-apple-darwin
artifact_name: 'wasmer-darwin-arm64'
use_sccache: false
@@ -98,11 +98,6 @@ jobs:
with:
toolchain: ${{ env.MSRV }}
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
if: matrix.use_sccache != true
- name: Install LLVM (macOS Apple Silicon)
@@ -191,17 +186,9 @@ jobs:
echo 'RUSTC_WRAPPER=${{ runner.tool_cache }}/cargo-sccache/bin/sccache' >> $GITHUB_ENV
shell: bash
- name: Build C API headless
if: matrix.build != 'macos-arm64'
shell: bash
run: |
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
shell: bash
run: |
@@ -224,9 +211,10 @@ jobs:
# run: |
# make build-wasmer-wasm
- name: Install Nightly Rust for Headless
if: matrix.build != 'linux-musl-x64'
uses: dtolnay/rust-toolchain@master
with:
toolchain: "nightly-2023-05-25"
toolchain: "nightly-2023-10-05"
target: ${{ matrix.target }}
components: "rust-src"
- name: Build Minimal Wasmer Headless
@@ -244,20 +232,12 @@ jobs:
echo "incremental = false" >> Cargo.toml
echo "codegen-units = 1" >> 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
rustup override unset
- name: Dist
if: matrix.build != 'macos-arm64'
run: |
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
uses: actions/upload-artifact@v3
with:
@@ -278,11 +258,6 @@ jobs:
- uses: dtolnay/rust-toolchain@stable
with:
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
shell: bash
run: |

View File

@@ -2,7 +2,7 @@ name: Release cloudcompiler.wasm
env:
RUST_BACKTRACE: 1
MSRV: "1.70"
MSRV: "1.73"
on:
push:

View File

@@ -8,7 +8,7 @@ on:
- 'lib/**'
env:
MSRV: "1.70"
MSRV: "1.73"
jobs:
documentation:

View File

@@ -24,7 +24,7 @@ env:
# Rust, but it's not stable on 1.69 yet. By explicitly setting the protocol we
# can override that behaviour
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: git
MSRV: "1.70"
MSRV: "1.73"
NEXTEST_PROFILE: "ci"
jobs:
@@ -161,7 +161,7 @@ jobs:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
toolchain: "nightly-2023-05-25"
toolchain: "nightly-2023-10-05"
target: x86_64-unknown-linux-gnu
- run: cargo install toml-cli # toml-cli is required to run `make test-build-docs-rs`
- name: make test-build-docs-rs-ci
@@ -369,11 +369,6 @@ jobs:
with:
toolchain: ${{ env.MSRV }}
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
uses: taiki-e/install-action@nextest
- name: Install Windows-GNU linker
@@ -556,6 +551,12 @@ jobs:
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'
},
{
build: macos-arm64,
os: macos-14,
target: aarch64-apple-darwin,
exe: '',
},
{
build: windows-x64,
os: windows-2019,

View File

@@ -81,7 +81,7 @@ edition = "2021"
homepage = "https://wasmer.io/"
license = "MIT"
repository = "https://github.com/wasmerio/wasmer"
rust-version = "1.70"
rust-version = "1.73"
version = "4.2.5"
[workspace.dependencies]

View File

@@ -468,10 +468,10 @@ test-build-docs-rs-ci:
fi; \
printf "*** Building doc for package with manifest $$manifest_path ***\n\n"; \
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 \
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; \
done

View File

@@ -25,7 +25,7 @@
<br />
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.
- **Pluggable**. supports [**WASIX**](https://wasix.org/), [WASI](https://github.com/WebAssembly/WASI) and [Emscripten](https://emscripten.org/) out of the box.

View File

@@ -44,8 +44,7 @@ impl From<FromUtf8Error> for MemoryAccessError {
/// trait which guarantees that reading and writing such a value to untrusted
/// memory is safe.
///
/// The address is not required to be aligned: unaligned accesses are fully
/// supported.
/// The address is required to be aligned: unaligned accesses cause undefined behavior.
///
/// This wrapper safely handles concurrent modifications of the data by another
/// thread.
@@ -86,7 +85,7 @@ impl<'a, T: ValueType> WasmRef<'a, T> {
WasmPtr::new(self.offset)
}
/// Get a `WasmPtr` fror this `WasmRef`.
/// Get a `WasmPtr` for this `WasmRef`.
#[inline]
pub fn as_ptr<M: MemorySize>(self) -> WasmPtr<T, M> {
let offset: M::Offset = self

View File

@@ -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> {
fn clone(&self) -> Self {
Self {
offset: self.offset,
_phantom: PhantomData,
}
*self
}
}

View File

@@ -8,42 +8,36 @@ pub use wasmer_compiler::{
use wasmer_types::Features;
use wasmer_types::{DeserializeError, Target};
/// Returns the default engine for the Sys engine
pub(crate) fn default_engine() -> Engine {
// We store them on a function that returns to make
// sure this function doesn't emit a compile error even if
// more than one compiler is enabled.
#[allow(unreachable_code)]
#[cfg(any(feature = "cranelift", feature = "llvm", feature = "singlepass"))]
fn get_config() -> impl wasmer_compiler::CompilerConfig + 'static {
/// Get the default config for the sys Engine
#[allow(unreachable_code)]
pub fn get_default_compiler_config() -> Option<Box<dyn wasmer_compiler::CompilerConfig>> {
cfg_if::cfg_if! {
if #[cfg(feature = "cranelift")] {
wasmer_compiler_cranelift::Cranelift::default()
Some(Box::<wasmer_compiler_cranelift::Cranelift>::default())
} else if #[cfg(feature = "llvm")] {
wasmer_compiler_llvm::LLVM::default()
Some(Box::<wasmer_compiler_llvm::LLVM>::default())
} else if #[cfg(feature = "singlepass")] {
wasmer_compiler_singlepass::Singlepass::default()
} else {
compile_error!("No default compiler chosen")
}
Some(Box::<wasmer_compiler_singlepass::Singlepass>::default())
}
else {
None
}
}
}
/// Returns the default engine for the Sys engine
pub(crate) fn default_engine() -> Engine {
#[allow(unreachable_code, unused_mut)]
fn get_engine() -> Engine {
cfg_if::cfg_if! {
if #[cfg(feature = "compiler")] {
cfg_if::cfg_if! {
if #[cfg(any(feature = "cranelift", feature = "llvm", feature = "singlepass"))]
{
let config = get_config();
EngineBuilder::new(Box::new(config) as Box<dyn wasmer_compiler::CompilerConfig>)
if let Some(config) = get_default_compiler_config() {
EngineBuilder::new(config)
.engine()
} else {
EngineBuilder::headless()
.engine()
}
}
} else {
EngineBuilder::headless().engine()
}

View File

@@ -120,7 +120,6 @@ impl Table {
"cross-`Store` table copies are not supported",
));
}
let store = store;
if dst_table.handle.internal_handle() == src_table.handle.internal_handle() {
let table = dst_table.handle.get_mut(store.objects_mut());
table.copy_within(dst_index, src_index, len)

View File

@@ -8,7 +8,7 @@ pub(crate) mod module;
pub(super) mod tunables;
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;
#[cfg(feature = "compiler")]
pub use wasmer_compiler::{

View File

@@ -1,9 +1,9 @@
use std::{collections::HashSet, time::Duration};
use std::{collections::HashSet, pin::Pin, time::Duration};
use anyhow::{bail, Context};
use cynic::{MutationBuilder, QueryBuilder};
use edge_schema::schema::{NetworkTokenV1, WebcIdent};
use futures::StreamExt;
use futures::{Stream, StreamExt};
use time::OffsetDateTime;
use tracing::Instrument;
use url::Url;
@@ -11,8 +11,9 @@ use url::Url;
use crate::{
types::{
self, CreateNamespaceVars, DeployApp, DeployAppConnection, DeployAppVersion,
DeployAppVersionConnection, GetDeployAppAndVersion, GetDeployAppVersionsVars,
GetNamespaceAppsVars, Log, LogStream, PackageVersionConnection, PublishDeployAppVars,
DeployAppVersionConnection, GetCurrentUserWithAppsVars, GetDeployAppAndVersion,
GetDeployAppVersionsVars, GetNamespaceAppsVars, Log, LogStream, PackageVersionConnection,
PublishDeployAppVars,
},
GraphQLApiFailure, WasmerClient,
};
@@ -275,17 +276,31 @@ pub async fn get_app_by_id(
client: &WasmerClient,
app_id: String,
) -> 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(
types::GetDeployAppByIdVars {
app_id: app_id.into(),
},
))
.await?
.app
.context("app not found")?
.into_deploy_app()
.context("app conversion failed")
.app;
if let Some(app) = app_opt {
let app = app.into_deploy_app().context("app conversion failed")?;
Ok(Some(app))
} else {
Ok(None)
}
}
/// Retrieve an app together with a specific version.
@@ -366,14 +381,19 @@ pub async fn get_app_version_by_id_with_app(
/// List all apps that are accessible by the current user.
///
/// 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(
client: &WasmerClient,
) -> impl futures::Stream<Item = Result<Vec<types::DeployApp>, anyhow::Error>> + '_ {
futures::stream::try_unfold(None, move |cursor| async move {
let user = client
.run_graphql(types::GetCurrentUserWithApps::build(()))
.run_graphql(types::GetCurrentUserWithApps::build(
GetCurrentUserWithAppsVars { after: cursor },
))
.await?
.viewer
.context("not logged in")?;
let apps = user
let apps: Vec<_> = user
.apps
.edges
.into_iter()
@@ -381,23 +401,25 @@ pub async fn user_apps(client: &WasmerClient) -> Result<Vec<types::DeployApp>, a
.filter_map(|x| x.node)
.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.
///
/// NOTE: this does not currently do full pagination properly.
// TODO(theduke): fix pagination
pub async fn user_accessible_apps(
client: &WasmerClient,
) -> Result<Vec<types::DeployApp>, anyhow::Error> {
let mut apps = Vec::new();
// Get user apps.
let user_apps = user_apps(client).await?;
apps.extend(user_apps);
) -> Result<
impl futures::Stream<Item = Result<Vec<types::DeployApp>, anyhow::Error>> + '_,
anyhow::Error,
> {
let apps: Pin<Box<dyn Stream<Item = Result<Vec<DeployApp>, anyhow::Error>> + Send + Sync>> =
Box::pin(user_apps(client).await);
// Get all aps in user-accessible namespaces.
let namespace_res = client
@@ -415,18 +437,16 @@ pub async fn user_accessible_apps(
.map(|node| node.name.clone())
.collect::<Vec<_>>();
for namespace in namespace_names {
let out = client
.run_graphql(types::GetNamespaceApps::build(GetNamespaceAppsVars {
name: namespace.to_string(),
}))
.await?;
let mut all_apps = vec![apps];
for ns in namespace_names {
let apps: Pin<Box<dyn Stream<Item = Result<Vec<DeployApp>, anyhow::Error>> + Send + Sync>> =
Box::pin(namespace_apps(client, ns).await);
if let Some(ns) = out.get_namespace {
let ns_apps = ns.apps.edges.into_iter().flatten().filter_map(|x| x.node);
apps.extend(ns_apps);
}
all_apps.push(apps);
}
let apps = futures::stream::select_all(all_apps);
Ok(apps)
}
@@ -435,11 +455,15 @@ pub async fn user_accessible_apps(
/// NOTE: only retrieves the first page and does not do pagination.
pub async fn namespace_apps(
client: &WasmerClient,
namespace: &str,
) -> Result<Vec<types::DeployApp>, anyhow::Error> {
namespace: String,
) -> impl futures::Stream<Item = Result<Vec<types::DeployApp>, anyhow::Error>> + '_ {
let namespace = namespace.clone();
futures::stream::try_unfold((None, namespace), move |(cursor, namespace)| async move {
let res = client
.run_graphql(types::GetNamespaceApps::build(GetNamespaceAppsVars {
name: namespace.to_string(),
after: cursor,
}))
.await?;
@@ -447,7 +471,7 @@ pub async fn namespace_apps(
.get_namespace
.with_context(|| format!("failed to get namespace '{}'", namespace))?;
let apps = ns
let apps: Vec<_> = ns
.apps
.edges
.into_iter()
@@ -455,7 +479,14 @@ pub async fn namespace_apps(
.filter_map(|x| x.node)
.collect();
Ok(apps)
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).
@@ -692,10 +723,7 @@ fn get_app_logs(
name: name.clone(),
owner: owner.clone(),
version: tag.clone(),
// TODO: increase pagination size
// See https://github.com/wasmerio/edge/issues/460
// first: Some(500),
first: Some(10),
first: Some(100),
starting_from: unix_timestamp(start),
until: end.map(unix_timestamp),
streams: streams.clone(),

View File

@@ -180,17 +180,24 @@ mod queries {
pub get_deploy_app: Option<DeployApp>,
}
#[derive(cynic::QueryVariables, Debug)]
pub struct GetCurrentUserWithAppsVars {
pub after: Option<String>,
}
#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "Query")]
#[cynic(graphql_type = "Query", variables = "GetCurrentUserWithAppsVars")]
pub struct GetCurrentUserWithApps {
pub viewer: Option<UserWithApps>,
}
#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "User")]
#[cynic(variables = "GetCurrentUserWithAppsVars")]
pub struct UserWithApps {
pub id: cynic::Id,
pub username: String,
#[arguments(after: $after)]
pub apps: DeployAppConnection,
}
@@ -537,6 +544,7 @@ mod queries {
#[derive(cynic::QueryVariables, Debug)]
pub struct GetNamespaceAppsVars {
pub name: String,
pub after: Option<String>,
}
#[derive(cynic::QueryFragment, Debug)]
@@ -548,9 +556,11 @@ mod queries {
#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "Namespace")]
#[cynic(variables = "GetNamespaceAppsVars")]
pub struct NamespaceWithApps {
pub id: cynic::Id,
pub name: String,
#[arguments(after: $after)]
pub apps: DeployAppConnection,
}

View File

@@ -1,11 +1,11 @@
use super::engine::wasm_engine_t;
use std::cell::UnsafeCell;
use std::sync::Arc;
use std::rc::Rc;
use wasmer_api::{AsStoreMut, AsStoreRef, Store, StoreMut, StoreRef as BaseStoreRef};
#[derive(Clone)]
pub struct StoreRef {
inner: Arc<UnsafeCell<Store>>,
inner: Rc<UnsafeCell<Store>>,
}
impl StoreRef {
@@ -38,7 +38,7 @@ pub unsafe extern "C" fn wasm_store_new(
Some(Box::new(wasm_store_t {
inner: StoreRef {
inner: Arc::new(UnsafeCell::new(store)),
inner: Rc::new(UnsafeCell::new(store)),
},
}))
}

View File

@@ -1,5 +1,10 @@
//! List Edge apps.
use std::pin::Pin;
use futures::{Stream, StreamExt};
use wasmer_api::types::DeployApp;
use crate::{
commands::AsyncCliCommand,
opts::{ApiOpts, ListFormatOpts},
@@ -23,6 +28,14 @@ pub struct CmdAppList {
/// directly owned by the user and apps in namespaces the user can access.
#[clap(short = 'a', long)]
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]
@@ -32,16 +45,60 @@ impl AsyncCliCommand for CmdAppList {
async fn run_async(self) -> Result<(), anyhow::Error> {
let client = self.api.client()?;
let apps = if let Some(ns) = self.namespace {
wasmer_api::query::namespace_apps(&client, &ns).await?
let apps_stream: Pin<
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 {
wasmer_api::query::user_accessible_apps(&client).await?
Box::pin(wasmer_api::query::user_accessible_apps(&client).await?)
} else {
wasmer_api::query::user_apps(&client).await?
Box::pin(wasmer_api::query::user_apps(&client).await)
};
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(())
}
}

View File

@@ -146,19 +146,20 @@ impl crate::commands::AsyncCliCommand for CmdAppLogs {
let mut rem = self.max;
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() {
let rendered = self.fmt.format.render(logs);
let rendered = self.fmt.format.render(&logs);
println!("{rendered}");
rem -= limit;
}
if !self.watch && rem == 0 {
if !self.watch || rem == 0 {
break;
}
}

View File

@@ -673,7 +673,7 @@ impl PrefixMapCompilation {
fn split_prefix(s: &str) -> Vec<String> {
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
.captures(s.trim())
.map(|c| {
@@ -1480,11 +1480,9 @@ fn generate_wasmer_main_c(
.iter()
.map(|v| utils::normalize_atom_name(&v.name).to_uppercase())
.map(|uppercase| {
vec![
format!("extern size_t {uppercase}_LENGTH asm(\"{uppercase}_LENGTH\");"),
format!("extern char {uppercase}_DATA asm(\"{uppercase}_DATA\");"),
]
.join("\r\n")
format!(
"extern size_t {uppercase}_LENGTH asm(\"{uppercase}_LENGTH\");\r\nextern char {uppercase}_DATA asm(\"{uppercase}_DATA\");"
)
})
.collect::<Vec<_>>();

View File

@@ -561,7 +561,7 @@ impl Wasi {
}
if !self.no_tty {
let tty = Arc::new(SysTty::default());
let tty = Arc::new(SysTty);
tty.reset();
rt.set_tty(tty);
}

View File

@@ -351,7 +351,7 @@ impl ToString for CompilerType {
}
}
#[cfg(all(feature = "compiler"))]
#[cfg(feature = "compiler")]
impl StoreOptions {
/// Gets the store for the host target, with the compiler name selected
pub fn get_store(&self) -> Result<(Store, CompilerType)> {

View File

@@ -2998,7 +2998,7 @@ impl<'a, M: Machine> FuncGen<'a, M> {
self.release_locations_value(stack_depth)?;
self.value_stack.truncate(stack_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 {
IfElseState::If(label) => {

View File

@@ -689,237 +689,219 @@ fn move_src_to_dst(emitter: &mut AssemblerX64, precision: Precision, src: XMM, d
}
macro_rules! avx_fn {
($ins:ident) => {
|emitter: &mut AssemblerX64, src1: XMM, src2: XMMOrMemory, dst: XMM| {
($ins:ident, $emitter:ident, $src1:ident, $src2:ident, $dst:ident) => {
// Dynasm bug: AVX instructions are not encoded correctly.
match src2 {
XMMOrMemory::XMM(x) => match src1 {
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::XMM2 => dynasm!(emitter ; $ins Rx((dst as u8)), xmm2, 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::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::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::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::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::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))),
match $src2 {
XMMOrMemory::XMM(x) => match $src1 {
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::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::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::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::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::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::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::XMM15 => dynasm!($emitter ; $ins Rx(($dst as u8)), xmm15, Rx((x as u8))),
},
XMMOrMemory::Memory(base, disp) => match src1 {
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::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::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::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::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::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::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::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]),
XMMOrMemory::Memory(base, disp) => match $src1 {
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::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::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::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::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::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::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::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]),
},
}
}
}
}
macro_rules! sse_fn {
($ins:ident) => {
|emitter: &mut AssemblerX64, precision: Precision, src1: XMM, src2: XMMOrMemory, dst: XMM| {
match src2 {
($ins:ident, $emitter:ident, $precision:expr, $src1:ident, $src2:ident, $dst:ident) => {
match $src2 {
XMMOrMemory::XMM(x) => {
if x == dst {
dynasm!(emitter ; $ins Rx((dst as u8)), Rx((src1 as u8)))
if x == $dst {
dynasm!($emitter ; $ins Rx(($dst as u8)), Rx(($src1 as u8)))
} else {
move_src_to_dst(emitter, precision, src1, dst);
dynasm!(emitter ; $ins Rx((dst as u8)), Rx((x as u8)))
move_src_to_dst($emitter, $precision, $src1, $dst);
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])
}
move_src_to_dst($emitter, $precision, $src1, $dst);
dynasm!($emitter ; $ins Rx(($dst as u8)), [Rq((base as u8)) + disp])
}
}
};
($ins:ident, $mode:expr) => {
|emitter: &mut AssemblerX64, precision: Precision, src1: XMM, src2: XMMOrMemory, dst: XMM| {
match src2 {
($ins:ident, $mode:expr, $emitter:ident, $precision:expr, $src1:ident, $src2:ident, $dst:ident) => {
match $src2 {
XMMOrMemory::XMM(x) => {
move_src_to_dst(emitter, precision, src1, dst);
dynasm!(emitter ; $ins Rx((dst as u8)), Rx((x as u8)), $mode)
move_src_to_dst($emitter, $precision, $src1, $dst);
dynasm!($emitter ; $ins Rx(($dst as u8)), Rx((x as u8)), $mode)
}
XMMOrMemory::Memory(base, disp) => {
move_src_to_dst(emitter, precision, src1, dst);
dynasm!(emitter ; $ins Rx((dst as u8)), [Rq((base as u8)) + disp], $mode)
}
move_src_to_dst($emitter, $precision, $src1, $dst);
dynasm!($emitter ; $ins Rx(($dst as u8)), [Rq((base as u8)) + disp], $mode)
}
}
};
}
macro_rules! avx_i2f_64_fn {
($ins:ident) => {
|emitter: &mut AssemblerX64, src1: XMM, src2: GPROrMemory, dst: XMM| {
match src2 {
GPROrMemory::GPR(x) => match src1 {
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::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::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::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::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::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::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::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))),
($ins:ident, $emitter:ident, $src1:ident, $src2:ident, $dst:ident) => {
match $src2 {
GPROrMemory::GPR(x) => match $src1 {
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::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::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::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::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::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::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::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))),
},
GPROrMemory::Memory(base, disp) => match src1 {
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::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::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::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::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::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::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::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]),
GPROrMemory::Memory(base, disp) => match $src1 {
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::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::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::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::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::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::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::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]),
},
}
}
}
}
macro_rules! sse_i2f_64_fn {
($ins:ident) => {
|emitter: &mut AssemblerX64, precision: Precision, src1: XMM, src2: GPROrMemory, dst: XMM| {
match src2 {
($ins:ident, $emitter:ident, $precision:expr, $src1:ident, $src2:ident, $dst:ident) => {
match $src2 {
GPROrMemory::GPR(x) => {
move_src_to_dst(emitter, precision, src1, dst);
dynasm!(emitter ; $ins Rx((dst as u8)), Rq((x as u8)))
move_src_to_dst($emitter, $precision, $src1, $dst);
dynasm!($emitter ; $ins Rx(($dst as u8)), Rq((x as u8)))
},
GPROrMemory::Memory(base, disp) => {
move_src_to_dst(emitter, precision, src1, dst);
dynasm!(emitter ; $ins Rx((dst as u8)), QWORD [Rq((base as u8)) + disp])
}
move_src_to_dst($emitter, $precision, $src1, $dst);
dynasm!($emitter ; $ins Rx(($dst as u8)), QWORD [Rq((base as u8)) + disp])
}
}
}
}
macro_rules! avx_i2f_32_fn {
($ins:ident) => {
|emitter: &mut AssemblerX64, src1: XMM, src2: GPROrMemory, dst: XMM| {
match src2 {
GPROrMemory::GPR(x) => match src1 {
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::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::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::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::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::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::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::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))),
($ins:ident, $emitter:ident, $src1:ident, $src2:ident, $dst:ident) => {
match $src2 {
GPROrMemory::GPR(x) => match $src1 {
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::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::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::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::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::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::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::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))),
},
GPROrMemory::Memory(base, disp) => match src1 {
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::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::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::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::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::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::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::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]),
GPROrMemory::Memory(base, disp) => match $src1 {
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::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::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::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::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::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::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::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]),
},
}
}
}
}
macro_rules! sse_i2f_32_fn {
($ins:ident) => {
|emitter: &mut AssemblerX64, precision: Precision, src1: XMM, src2: GPROrMemory, dst: XMM| {
match src2 {
($ins:ident, $emitter:ident, $precision:expr, $src1:ident, $src2:ident, $dst:ident) => {
match $src2 {
GPROrMemory::GPR(x) => {
move_src_to_dst(emitter, precision, src1, dst);
dynasm!(emitter; $ins Rx((src1 as u8)), Rd((x as u8)))
move_src_to_dst($emitter, $precision, $src1, $dst);
dynasm!($emitter; $ins Rx(($src1 as u8)), Rd((x as u8)))
},
GPROrMemory::Memory(base, disp) => {
move_src_to_dst(emitter, precision, src1, dst);
dynasm!(emitter ; $ins Rx((dst as u8)), DWORD [Rq((base as u8)) + disp])
}
move_src_to_dst($emitter, $precision, $src1, $dst);
dynasm!($emitter; $ins Rx(($dst as u8)), DWORD [Rq((base as u8)) + disp])
}
}
}
}
macro_rules! avx_round_fn {
($ins:ident, $mode:expr) => {
|emitter: &mut AssemblerX64, src1: XMM, src2: XMMOrMemory, dst: XMM| {
match src2 {
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),
}
($ins:ident, $mode:expr, $emitter:ident, $src1:ident, $src2:ident, $dst:ident) => {
match $src2 {
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),
}
}
}
macro_rules! sse_round_fn {
($ins:ident, $mode:expr) => {
|emitter: &mut AssemblerX64, precision: Precision, src1: XMM, src2: XMMOrMemory, dst: XMM| {
match src2 {
($ins:ident, $mode:expr, $emitter:ident, $precision:expr, $src1:ident, $src2:ident, $dst:ident) => {
match $src2 {
XMMOrMemory::XMM(x) => {
if x != dst {
move_src_to_dst(emitter, precision, src1, dst);
if x != $dst {
move_src_to_dst($emitter, $precision, $src1, $dst);
}
dynasm!(emitter ; $ins Rx((x as u8)), Rx((dst as u8)), $mode)
dynasm!($emitter ; $ins Rx((x as u8)), Rx(($dst as u8)), $mode)
}
XMMOrMemory::Memory(base, disp) => {
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)
},
}
}
}
}
impl EmitterX64 for AssemblerX64 {
@@ -1719,112 +1701,112 @@ impl EmitterX64 for AssemblerX64 {
}
fn emit_vxorps(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
match self.get_simd_arch() {
Some(CpuFeature::AVX) => avx_fn!(vxorps)(self, src1, src2, dst),
Some(CpuFeature::SSE42) => sse_fn!(xorps)(self, Precision::Single, 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),
_ => {}
}
Ok(())
}
fn emit_vxorpd(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
match self.get_simd_arch() {
Some(CpuFeature::AVX) => avx_fn!(vxorpd)(self, src1, src2, dst),
Some(CpuFeature::SSE42) => sse_fn!(xorpd)(self, Precision::Double, 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),
_ => {}
}
Ok(())
}
fn emit_vaddss(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
match self.get_simd_arch() {
Some(CpuFeature::AVX) => avx_fn!(vaddss)(self, src1, src2, dst),
Some(CpuFeature::SSE42) => sse_fn!(addss)(self, Precision::Single, 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),
_ => {}
}
Ok(())
}
fn emit_vaddsd(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
match self.get_simd_arch() {
Some(CpuFeature::AVX) => avx_fn!(vaddsd)(self, src1, src2, dst),
Some(CpuFeature::SSE42) => sse_fn!(addsd)(self, Precision::Double, 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),
_ => {}
}
Ok(())
}
fn emit_vsubss(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
match self.get_simd_arch() {
Some(CpuFeature::AVX) => avx_fn!(vsubss)(self, src1, src2, dst),
Some(CpuFeature::SSE42) => sse_fn!(subss)(self, Precision::Single, 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),
_ => {}
}
Ok(())
}
fn emit_vsubsd(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
match self.get_simd_arch() {
Some(CpuFeature::AVX) => avx_fn!(vsubsd)(self, src1, src2, dst),
Some(CpuFeature::SSE42) => sse_fn!(subsd)(self, Precision::Double, 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),
_ => {}
}
Ok(())
}
fn emit_vmulss(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
match self.get_simd_arch() {
Some(CpuFeature::AVX) => avx_fn!(vmulss)(self, src1, src2, dst),
Some(CpuFeature::SSE42) => sse_fn!(mulss)(self, Precision::Single, 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),
_ => {}
}
Ok(())
}
fn emit_vmulsd(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
match self.get_simd_arch() {
Some(CpuFeature::AVX) => avx_fn!(vmulsd)(self, src1, src2, dst),
Some(CpuFeature::SSE42) => sse_fn!(mulsd)(self, Precision::Double, 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),
_ => {}
}
Ok(())
}
fn emit_vdivss(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
match self.get_simd_arch() {
Some(CpuFeature::AVX) => avx_fn!(vdivss)(self, src1, src2, dst),
Some(CpuFeature::SSE42) => sse_fn!(divss)(self, Precision::Single, 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),
_ => {}
}
Ok(())
}
fn emit_vdivsd(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
match self.get_simd_arch() {
Some(CpuFeature::AVX) => avx_fn!(vdivsd)(self, src1, src2, dst),
Some(CpuFeature::SSE42) => sse_fn!(divsd)(self, Precision::Double, 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),
_ => {}
}
Ok(())
}
fn emit_vmaxss(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
match self.get_simd_arch() {
Some(CpuFeature::AVX) => avx_fn!(vmaxss)(self, src1, src2, dst),
Some(CpuFeature::SSE42) => sse_fn!(maxss)(self, Precision::Single, 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),
_ => {}
}
Ok(())
}
fn emit_vmaxsd(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
match self.get_simd_arch() {
Some(CpuFeature::AVX) => avx_fn!(vmaxsd)(self, src1, src2, dst),
Some(CpuFeature::SSE42) => sse_fn!(maxsd)(self, Precision::Double, 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),
_ => {}
}
Ok(())
}
fn emit_vminss(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
match self.get_simd_arch() {
Some(CpuFeature::AVX) => avx_fn!(vminss)(self, src1, src2, dst),
Some(CpuFeature::SSE42) => sse_fn!(minss)(self, Precision::Single, 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),
_ => {}
}
Ok(())
}
fn emit_vminsd(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
match self.get_simd_arch() {
Some(CpuFeature::AVX) => avx_fn!(vminsd)(self, src1, src2, dst),
Some(CpuFeature::SSE42) => sse_fn!(minsd)(self, Precision::Double, 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),
_ => {}
}
Ok(())
@@ -1836,8 +1818,8 @@ impl EmitterX64 for AssemblerX64 {
dst: XMM,
) -> Result<(), CompileError> {
match self.get_simd_arch() {
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::AVX) => avx_fn!(vcmpeqss, self, src1, src2, dst),
Some(CpuFeature::SSE42) => sse_fn!(cmpss, 0, self, Precision::Single, src1, src2, dst),
_ => {}
}
Ok(())
@@ -1849,8 +1831,8 @@ impl EmitterX64 for AssemblerX64 {
dst: XMM,
) -> Result<(), CompileError> {
match self.get_simd_arch() {
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::AVX) => avx_fn!(vcmpeqsd, self, src1, src2, dst),
Some(CpuFeature::SSE42) => sse_fn!(cmpsd, 0, self, Precision::Double, src1, src2, dst),
_ => {}
}
Ok(())
@@ -1862,8 +1844,8 @@ impl EmitterX64 for AssemblerX64 {
dst: XMM,
) -> Result<(), CompileError> {
match self.get_simd_arch() {
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::AVX) => avx_fn!(vcmpneqss, self, src1, src2, dst),
Some(CpuFeature::SSE42) => sse_fn!(cmpss, 4, self, Precision::Single, src1, src2, dst),
_ => {}
}
Ok(())
@@ -1875,8 +1857,8 @@ impl EmitterX64 for AssemblerX64 {
dst: XMM,
) -> Result<(), CompileError> {
match self.get_simd_arch() {
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::AVX) => avx_fn!(vcmpneqsd, self, src1, src2, dst),
Some(CpuFeature::SSE42) => sse_fn!(cmpsd, 4, self, Precision::Double, src1, src2, dst),
_ => {}
}
Ok(())
@@ -1888,8 +1870,8 @@ impl EmitterX64 for AssemblerX64 {
dst: XMM,
) -> Result<(), CompileError> {
match self.get_simd_arch() {
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::AVX) => avx_fn!(vcmpltss, self, src1, src2, dst),
Some(CpuFeature::SSE42) => sse_fn!(cmpss, 1, self, Precision::Single, src1, src2, dst),
_ => {}
}
Ok(())
@@ -1901,8 +1883,8 @@ impl EmitterX64 for AssemblerX64 {
dst: XMM,
) -> Result<(), CompileError> {
match self.get_simd_arch() {
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::AVX) => avx_fn!(vcmpltsd, self, src1, src2, dst),
Some(CpuFeature::SSE42) => sse_fn!(cmpsd, 1, self, Precision::Double, src1, src2, dst),
_ => {}
}
Ok(())
@@ -1914,8 +1896,8 @@ impl EmitterX64 for AssemblerX64 {
dst: XMM,
) -> Result<(), CompileError> {
match self.get_simd_arch() {
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::AVX) => avx_fn!(vcmpless, self, src1, src2, dst),
Some(CpuFeature::SSE42) => sse_fn!(cmpss, 2, self, Precision::Single, src1, src2, dst),
_ => {}
}
Ok(())
@@ -1927,8 +1909,8 @@ impl EmitterX64 for AssemblerX64 {
dst: XMM,
) -> Result<(), CompileError> {
match self.get_simd_arch() {
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::AVX) => avx_fn!(vcmplesd, self, src1, src2, dst),
Some(CpuFeature::SSE42) => sse_fn!(cmpsd, 2, self, Precision::Double, src1, src2, dst),
_ => {}
}
Ok(())
@@ -1940,8 +1922,8 @@ impl EmitterX64 for AssemblerX64 {
dst: XMM,
) -> Result<(), CompileError> {
match self.get_simd_arch() {
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::AVX) => avx_fn!(vcmpgtss, self, src1, src2, dst),
Some(CpuFeature::SSE42) => sse_fn!(cmpss, 6, self, Precision::Single, src1, src2, dst),
_ => {}
}
Ok(())
@@ -1953,8 +1935,8 @@ impl EmitterX64 for AssemblerX64 {
dst: XMM,
) -> Result<(), CompileError> {
match self.get_simd_arch() {
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::AVX) => avx_fn!(vcmpgtsd, self, src1, src2, dst),
Some(CpuFeature::SSE42) => sse_fn!(cmpsd, 6, self, Precision::Double, src1, src2, dst),
_ => {}
}
Ok(())
@@ -1966,8 +1948,8 @@ impl EmitterX64 for AssemblerX64 {
dst: XMM,
) -> Result<(), CompileError> {
match self.get_simd_arch() {
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::AVX) => avx_fn!(vcmpgess, self, src1, src2, dst),
Some(CpuFeature::SSE42) => sse_fn!(cmpss, 5, self, Precision::Single, src1, src2, dst),
_ => {}
}
Ok(())
@@ -1979,8 +1961,8 @@ impl EmitterX64 for AssemblerX64 {
dst: XMM,
) -> Result<(), CompileError> {
match self.get_simd_arch() {
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::AVX) => avx_fn!(vcmpgesd, self, src1, src2, dst),
Some(CpuFeature::SSE42) => sse_fn!(cmpsd, 5, self, Precision::Double, src1, src2, dst),
_ => {}
}
Ok(())
@@ -1992,8 +1974,8 @@ impl EmitterX64 for AssemblerX64 {
dst: XMM,
) -> Result<(), CompileError> {
match self.get_simd_arch() {
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::AVX) => avx_fn!(vcmpunordss, self, src1, src2, dst),
Some(CpuFeature::SSE42) => sse_fn!(cmpss, 3, self, Precision::Single, src1, src2, dst),
_ => {}
}
Ok(())
@@ -2005,8 +1987,8 @@ impl EmitterX64 for AssemblerX64 {
dst: XMM,
) -> Result<(), CompileError> {
match self.get_simd_arch() {
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::AVX) => avx_fn!(vcmpunordsd, self, src1, src2, dst),
Some(CpuFeature::SSE42) => sse_fn!(cmpsd, 3, self, Precision::Double, src1, src2, dst),
_ => {}
}
Ok(())
@@ -2018,8 +2000,8 @@ impl EmitterX64 for AssemblerX64 {
dst: XMM,
) -> Result<(), CompileError> {
match self.get_simd_arch() {
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::AVX) => avx_fn!(vcmpordss, self, src1, src2, dst),
Some(CpuFeature::SSE42) => sse_fn!(cmpss, 7, self, Precision::Single, src1, src2, dst),
_ => {}
}
Ok(())
@@ -2031,24 +2013,24 @@ impl EmitterX64 for AssemblerX64 {
dst: XMM,
) -> Result<(), CompileError> {
match self.get_simd_arch() {
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::AVX) => avx_fn!(vcmpordsd, self, src1, src2, dst),
Some(CpuFeature::SSE42) => sse_fn!(cmpsd, 7, self, Precision::Double, src1, src2, dst),
_ => {}
}
Ok(())
}
fn emit_vsqrtss(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
match self.get_simd_arch() {
Some(CpuFeature::AVX) => avx_fn!(vsqrtss)(self, src1, src2, dst),
Some(CpuFeature::SSE42) => sse_fn!(sqrtss)(self, Precision::Single, 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),
_ => {}
}
Ok(())
}
fn emit_vsqrtsd(&mut self, src1: XMM, src2: XMMOrMemory, dst: XMM) -> Result<(), CompileError> {
match self.get_simd_arch() {
Some(CpuFeature::AVX) => avx_fn!(vsqrtsd)(self, src1, src2, dst),
Some(CpuFeature::SSE42) => sse_fn!(sqrtsd)(self, Precision::Double, 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),
_ => {}
}
Ok(())
@@ -2060,8 +2042,8 @@ impl EmitterX64 for AssemblerX64 {
dst: XMM,
) -> Result<(), CompileError> {
match self.get_simd_arch() {
Some(CpuFeature::AVX) => avx_fn!(vcvtss2sd)(self, src1, src2, dst),
Some(CpuFeature::SSE42) => sse_fn!(cvtss2sd)(self, Precision::Single, 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),
_ => {}
}
Ok(())
@@ -2073,8 +2055,8 @@ impl EmitterX64 for AssemblerX64 {
dst: XMM,
) -> Result<(), CompileError> {
match self.get_simd_arch() {
Some(CpuFeature::AVX) => avx_fn!(vcvtsd2ss)(self, src1, src2, dst),
Some(CpuFeature::SSE42) => sse_fn!(cvtsd2ss)(self, Precision::Double, 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),
_ => {}
}
Ok(())
@@ -2086,9 +2068,9 @@ impl EmitterX64 for AssemblerX64 {
dst: XMM,
) -> Result<(), CompileError> {
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) => {
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,
) -> Result<(), CompileError> {
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) => {
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,
) -> Result<(), CompileError> {
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) => {
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,
) -> Result<(), CompileError> {
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) => {
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,
) -> Result<(), CompileError> {
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) => {
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,
) -> Result<(), CompileError> {
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) => {
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,
) -> Result<(), CompileError> {
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) => {
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,
) -> Result<(), CompileError> {
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) => {
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,
) -> Result<(), CompileError> {
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) => {
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,
) -> Result<(), CompileError> {
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) => {
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,
) -> Result<(), CompileError> {
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) => {
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,
) -> Result<(), CompileError> {
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) => {
sse_i2f_64_fn!(cvtsi2sd)(self, Precision::Double, src1, src2, dst)
sse_i2f_64_fn!(cvtsi2sd, self, Precision::Double, src1, src2, dst)
}
_ => {}
}

View File

@@ -213,7 +213,7 @@ impl<'a> ArtifactCreate<'a> for ArtifactBuild {
}
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());
true
})
@@ -414,7 +414,7 @@ impl<'a> ArtifactCreate<'a> for ArtifactBuildFromArchive {
}
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());
true
})

View File

@@ -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;
match name {
0 => 32000,
1 | 2 | 3 => 255,
1..=3 => 255,
4 | 5 | 16 | 17 | 18 => 4096,
6 | 7 | 20 => 1,
8 => 0,
@@ -156,7 +156,7 @@ pub fn _fpathconf(_ctx: FunctionEnvMut<EmEnv>, _fildes: c_int, name: c_int) -> c
debug!("emscripten::_fpathconf {} {}", _fildes, name);
match name {
0 => 32000,
1 | 2 | 3 => 255,
1..=3 => 255,
4 | 5 | 16 | 17 | 18 => 4096,
6 | 7 | 20 => 1,
8 => 0,

View File

@@ -183,8 +183,8 @@ unsafe fn fmt_time(ctx: FunctionEnvMut<EmEnv>, time: u32) -> *const c_char {
let memory = ctx.data().memory(0);
let date = &*(emscripten_memory_pointer!(memory.view(&ctx), time) as *mut guest_tm);
let days = vec!["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
let months = vec![
let days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
let months = [
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
];
let year = 1900 + date.tm_year;
@@ -426,7 +426,8 @@ pub fn _strftime(
) else {
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;
};
let rust_datetime = time::PrimitiveDateTime::new(rust_date, rust_time);

View File

@@ -363,7 +363,7 @@ impl WritableJournal for CompactingJournalTx {
state
.descriptors
.entry(lookup)
.or_insert_with(Default::default)
.or_default()
.events
.push(event_index);
@@ -394,10 +394,7 @@ impl WritableJournal for CompactingJournalTx {
.or_else(|| state.stdio_descriptors.get(fd).cloned());
if let Some(lookup) = lookup {
let state = state
.descriptors
.entry(lookup)
.or_insert_with(Default::default);
let state = state.descriptors.entry(lookup).or_default();
state.events.push(event_index);
} else {
state.whitelist.insert(event_index);
@@ -425,10 +422,7 @@ impl WritableJournal for CompactingJournalTx {
// Update the state
if let Some(lookup) = lookup {
let state = state
.descriptors
.entry(lookup)
.or_insert_with(Default::default);
let state = state.descriptors.entry(lookup).or_default();
if let JournalEntry::FileDescriptorWriteV1 { offset, data, .. } = &entry {
state.write_map.insert(
MemoryRange {

View File

@@ -8,7 +8,7 @@ use std::{fmt, str::FromStr};
use url::Url;
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! {
static ref PACKAGE_WITH_VERSION: Regex = regex::Regex::new(REGEX_PACKAGE_WITH_VERSION).unwrap();

View File

@@ -4,12 +4,7 @@
// This file contains code from external sources.
// Attributions: https://github.com/wasmerio/wasmer/blob/master/ATTRIBUTIONS.md
use std::{
cell::UnsafeCell,
convert::TryInto,
ptr::NonNull,
sync::{Arc, RwLock},
};
use std::{cell::UnsafeCell, convert::TryInto, ptr::NonNull, rc::Rc, sync::RwLock};
use wasmer::{Bytes, MemoryError, MemoryType, Pages};
use wasmer_types::{MemoryStyle, WASM_PAGE_SIZE};
@@ -315,7 +310,7 @@ impl VMOwnedMemory {
/// Converts this owned memory into shared memory
pub fn to_shared(self) -> VMSharedMemory {
VMSharedMemory {
mmap: Arc::new(RwLock::new(self.mmap)),
mmap: Rc::new(RwLock::new(self.mmap)),
config: self.config,
conditions: ThreadConditions::new(),
}
@@ -387,7 +382,7 @@ impl LinearMemory for VMOwnedMemory {
#[derive(Debug, Clone)]
pub struct VMSharedMemory {
// The underlying allocation.
mmap: Arc<RwLock<WasmMmap>>,
mmap: Rc<RwLock<WasmMmap>>,
// Configuration of this memory
config: VMMemoryConfig,
conditions: ThreadConditions,
@@ -424,7 +419,7 @@ impl VMSharedMemory {
pub fn copy(&mut self) -> Result<Self, MemoryError> {
let mut guard = self.mmap.write().unwrap();
Ok(Self {
mmap: Arc::new(RwLock::new(guard.copy()?)),
mmap: Rc::new(RwLock::new(guard.copy()?)),
config: self.config.clone(),
conditions: ThreadConditions::new(),
})

View File

@@ -29,7 +29,7 @@ pub use target_lexicon::{
///
/// [`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
#[allow(missing_docs, clippy::derive_hash_xor_eq)]
#[allow(missing_docs, clippy::derived_hash_with_manual_eq)]
#[derive(EnumSetType, Debug, Hash)]
pub enum CpuFeature {
// X86 features

View File

@@ -211,7 +211,7 @@ pub struct MetadataHeader {
impl MetadataHeader {
/// Current ABI version. Increment this any time breaking changes are made
/// 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.
const MAGIC: [u8; 8] = *b"WASMER\0\0";

View File

@@ -1,24 +1,24 @@
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#[cfg(any(feature = "remote"))]
#[cfg(feature = "remote")]
pub mod client;
#[cfg(feature = "host-net")]
pub mod host;
pub mod meta;
#[cfg(any(feature = "remote"))]
#[cfg(feature = "remote")]
pub mod rx_tx;
#[cfg(any(feature = "remote"))]
#[cfg(feature = "remote")]
pub mod server;
#[cfg(feature = "tokio")]
#[cfg(test)]
mod tests;
#[cfg(any(feature = "remote"))]
#[cfg(feature = "remote")]
pub use client::{RemoteNetworkingClient, RemoteNetworkingClientDriver};
use pin_project_lite::pin_project;
#[cfg(feature = "rkyv")]
use rkyv::{Archive, CheckBytes, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize};
#[cfg(any(feature = "remote"))]
#[cfg(feature = "remote")]
pub use server::{RemoteNetworkingServer, RemoteNetworkingServerDriver};
use std::fmt;
use std::mem::MaybeUninit;

View File

@@ -1084,27 +1084,27 @@ impl VMInstance {
ptr::copy(
vmshared_signatures.values().as_slice().as_ptr(),
instance.signature_ids_ptr() as *mut VMSharedSignatureIndex,
instance.signature_ids_ptr(),
vmshared_signatures.len(),
);
ptr::copy(
imports.functions.values().as_slice().as_ptr(),
instance.imported_functions_ptr() as *mut VMFunctionImport,
instance.imported_functions_ptr(),
imports.functions.len(),
);
ptr::copy(
imports.tables.values().as_slice().as_ptr(),
instance.imported_tables_ptr() as *mut VMTableImport,
instance.imported_tables_ptr(),
imports.tables.len(),
);
ptr::copy(
imports.memories.values().as_slice().as_ptr(),
instance.imported_memories_ptr() as *mut VMMemoryImport,
instance.imported_memories_ptr(),
imports.memories.len(),
);
ptr::copy(
imports.globals.values().as_slice().as_ptr(),
instance.imported_globals_ptr() as *mut VMGlobalImport,
instance.imported_globals_ptr(),
imports.globals.len(),
);
// these should already be set, add asserts here? for:
@@ -1116,7 +1116,7 @@ impl VMInstance {
vmctx_globals.len(),
);
ptr::write(
instance.builtin_functions_ptr() as *mut VMBuiltinFunctionsArray,
instance.builtin_functions_ptr(),
VMBuiltinFunctionsArray::initialized(),
);

View File

@@ -13,8 +13,9 @@ use more_asserts::assert_ge;
use std::cell::UnsafeCell;
use std::convert::TryInto;
use std::ptr::NonNull;
use std::rc::Rc;
use std::slice;
use std::sync::{Arc, RwLock};
use std::sync::RwLock;
use std::time::Duration;
use wasmer_types::{Bytes, MemoryError, MemoryStyle, MemoryType, Pages, WASM_PAGE_SIZE};
@@ -305,7 +306,7 @@ impl VMOwnedMemory {
/// Converts this owned memory into shared memory
pub fn to_shared(self) -> VMSharedMemory {
VMSharedMemory {
mmap: Arc::new(RwLock::new(self.mmap)),
mmap: Rc::new(RwLock::new(self.mmap)),
config: self.config,
conditions: ThreadConditions::new(),
}
@@ -378,7 +379,7 @@ impl LinearMemory for VMOwnedMemory {
#[derive(Debug, Clone)]
pub struct VMSharedMemory {
// The underlying allocation.
mmap: Arc<RwLock<WasmMmap>>,
mmap: Rc<RwLock<WasmMmap>>,
// Configuration of this memory
config: VMMemoryConfig,
// waiters list for this memory
@@ -416,7 +417,7 @@ impl VMSharedMemory {
pub fn copy(&mut self) -> Result<Self, MemoryError> {
let mut guard = self.mmap.write().unwrap();
Ok(Self {
mmap: Arc::new(RwLock::new(guard.copy()?)),
mmap: Rc::new(RwLock::new(guard.copy()?)),
config: self.config.clone(),
conditions: ThreadConditions::new(),
})

View File

@@ -90,11 +90,7 @@ impl ThreadConditions {
if self.inner.map.len() >= 1 << 32 {
return Err(WaiterError::TooManyWaiters);
}
self.inner
.map
.entry(dst)
.or_insert_with(Vec::new)
.push(NotifyWaiter {
self.inner.map.entry(dst).or_default().push(NotifyWaiter {
thread: current(),
notified: false,
});

View File

@@ -91,7 +91,7 @@ impl Trap {
pub fn downcast<T: Error + 'static>(self) -> Result<T, Self> {
match self {
// 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),
}
}
@@ -100,7 +100,7 @@ impl Trap {
pub fn downcast_ref<T: Error + 'static>(&self) -> Option<&T> {
match &self {
// 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,
}
}
@@ -108,7 +108,7 @@ impl Trap {
/// Returns true if the `Trap` is the same as T
pub fn is<T: Error + 'static>(&self) -> bool {
match self {
Trap::User(err) => err.is::<T>(),
Self::User(err) => err.is::<T>(),
_ => false,
}
}
@@ -117,7 +117,7 @@ impl Trap {
impl std::error::Error for Trap {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match &self {
Trap::User(err) => Some(&**err),
Self::User(err) => Some(&**err),
_ => None,
}
}

View File

@@ -724,8 +724,6 @@ fn import_object_for_all_wasi_versions(
} else {
Box::new(stub_initializer) as ModuleInitializer
};
let init = init;
} else {
// Prevents unused warning.
let _ = module;

View File

@@ -49,7 +49,7 @@ where
/// A package loader.
fn package_loader(&self) -> Arc<dyn PackageLoader + Send + Sync> {
Arc::new(UnsupportedPackageLoader::default())
Arc::new(UnsupportedPackageLoader)
}
/// A cache for compiled modules.
@@ -221,7 +221,7 @@ impl PluggableRuntime {
let http_client =
crate::http::default_http_client().map(|client| Arc::new(client) as DynHttpClient);
let loader = UnsupportedPackageLoader::default();
let loader = UnsupportedPackageLoader;
let mut source = MultiSource::new();
if let Some(client) = &http_client {

View File

@@ -102,7 +102,7 @@ pub unsafe fn restore_snapshot(
stderr_fds.insert(2 as WasiFd);
// 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 rewind = None;
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)?;
}
crate::journal::JournalEntry::UpdateMemoryRegionV1 { region, data } => {
if cur_module_hash != journal_module_hash {
if Some(cur_module_hash) != journal_module_hash {
continue;
}
@@ -201,7 +201,7 @@ pub unsafe fn restore_snapshot(
store_data,
is_64bit,
} => {
if cur_module_hash != journal_module_hash {
if Some(cur_module_hash) != journal_module_hash {
continue;
}
@@ -272,7 +272,7 @@ pub unsafe fn restore_snapshot(
.map_err(anyhow_err_to_runtime_err)?;
}
crate::journal::JournalEntry::SnapshotV1 { when: _, trigger } => {
if cur_module_hash != journal_module_hash {
if Some(cur_module_hash) != journal_module_hash {
continue;
}
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
// that simulates closing the process (hence keeps everything
// 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!(
"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(),
cur_module_hash.unwrap()
cur_module_hash
);
if bootstrapping {
rewind = None;

View File

@@ -11,9 +11,9 @@ pub mod types {
target_vendor = "apple"
))]
pub mod unix;
#[cfg(any(target_family = "wasm"))]
#[cfg(target_family = "wasm")]
pub mod wasm;
#[cfg(any(target_os = "windows"))]
#[cfg(target_os = "windows")]
pub mod windows;
pub mod journal;
@@ -65,7 +65,7 @@ pub(crate) use tracing::{debug, error, trace, warn};
target_vendor = "apple"
))]
pub use unix::*;
#[cfg(any(target_family = "wasm"))]
#[cfg(target_family = "wasm")]
pub use wasm::*;
pub(crate) use virtual_fs::{
@@ -78,7 +78,7 @@ pub(crate) use wasmer::{
OnCalledAction, Pages, RuntimeError, Store, TypedFunction, Value, WasmPtr, WasmSlice,
};
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(crate) use self::types::{

View File

@@ -39,7 +39,6 @@ pub fn clock_time_set_internal(
let precision = 1 as Timestamp;
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_offset = t_target - t_now;

View File

@@ -116,8 +116,6 @@ pub(super) fn proc_join_internal<M: MemorySize + 'static>(
let pid = match option_pid {
None => {
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
// then we go into a deep sleep)

View File

@@ -1 +1 @@
1.70
1.73

BIN
sm64.us.f3dex2e.wasm Normal file

Binary file not shown.

View File

@@ -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]
#[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() {
// 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