Merge branch 'master' into feat-c-api-cross-compilation-2

This commit is contained in:
Ivan Enderlin
2021-02-02 09:51:01 +01:00
10 changed files with 38 additions and 37 deletions

View File

@@ -3,7 +3,7 @@ name: Run Benchmarks and upload results
on: on:
push: push:
branches: branches:
- master - benchmark # TODO: change it back to master once we really track the results. We commented this as speed.wasmer.io is failing
jobs: jobs:
run_benchmark: run_benchmark:

View File

@@ -43,14 +43,14 @@ jobs:
- build: linux-x64 - build: linux-x64
os: ubuntu-18.04 os: ubuntu-18.04
rust: 1.48 rust: 1.48
llvm_url: 'https://github.com/wasmerio/llvm-custom-builds/releases/download/10.x/linux-amd64.tar.gz' llvm_url: 'https://github.com/wasmerio/llvm-custom-builds/releases/download/11.x/linux-amd64.tar.gz'
artifact_name: 'wasmer-linux-amd64' artifact_name: 'wasmer-linux-amd64'
cross_compilation_artifact_name: 'cross_compiled_from_linux' cross_compilation_artifact_name: 'cross_compiled_from_linux'
run_integration_tests: true run_integration_tests: true
- build: macos-x64 - build: macos-x64
os: macos-latest os: macos-latest
rust: 1.48 rust: 1.48
llvm_url: 'https://github.com/wasmerio/llvm-custom-builds/releases/download/10.x/darwin-amd64.tar.gz' llvm_url: 'https://github.com/wasmerio/llvm-custom-builds/releases/download/11.x/darwin-amd64.tar.gz'
artifact_name: 'wasmer-darwin-amd64' artifact_name: 'wasmer-darwin-amd64'
cross_compilation_artifact_name: 'cross_compiled_from_mac' cross_compilation_artifact_name: 'cross_compiled_from_mac'
run_integration_tests: true run_integration_tests: true
@@ -62,7 +62,7 @@ jobs:
- build: windows-x64 - build: windows-x64
os: windows-latest os: windows-latest
rust: 1.48 rust: 1.48
# llvm_url: 'https://github.com/wasmerio/llvm-custom-builds/releases/download/10.x/windows-amd64.tar.gz' # llvm_url: 'https://github.com/wasmerio/llvm-custom-builds/releases/download/11.x/windows-amd64.tar.gz'
artifact_name: 'wasmer-windows-amd64' artifact_name: 'wasmer-windows-amd64'
cross_compilation_artifact_name: 'cross_compiled_from_win' cross_compilation_artifact_name: 'cross_compiled_from_win'
run_integration_tests: true run_integration_tests: true
@@ -70,7 +70,7 @@ jobs:
os: [self-hosted, linux, ARM64] os: [self-hosted, linux, ARM64]
random_sccache_port: true random_sccache_port: true
rust: 1.48 rust: 1.48
llvm_url: 'https://github.com/wasmerio/llvm-custom-builds/releases/download/10.x/linux-aarch64.tar.gz' llvm_url: 'https://github.com/wasmerio/llvm-custom-builds/releases/download/11.x/linux-aarch64.tar.gz'
artifact_name: 'wasmer-linux-aarch64' artifact_name: 'wasmer-linux-aarch64'
run_integration_tests: false run_integration_tests: false
env: env:
@@ -108,9 +108,9 @@ jobs:
mkdir ${{ env.LLVM_DIR }} mkdir ${{ env.LLVM_DIR }}
tar xf llvm.tar.gz --strip-components=1 -C ${{ env.LLVM_DIR }} tar xf llvm.tar.gz --strip-components=1 -C ${{ env.LLVM_DIR }}
echo "${{ env.LLVM_DIR }}/bin" >> $GITHUB_PATH echo "${{ env.LLVM_DIR }}/bin" >> $GITHUB_PATH
echo "LLVM_SYS_100_PREFIX=${{ env.LLVM_DIR }}" >> $GITHUB_ENV echo "LLVM_SYS_110_PREFIX=${{ env.LLVM_DIR }}" >> $GITHUB_ENV
env: env:
LLVM_DIR: ${{ github.workspace }}/llvm-10 LLVM_DIR: ${{ github.workspace }}/llvm-11
- name: Set up dependencies for Mac OS - name: Set up dependencies for Mac OS
run: | run: |
brew install automake brew install automake

View File

@@ -18,6 +18,7 @@
- [#2056](https://github.com/wasmerio/wasmer/pull/2056) Change back to depend on the `enumset` crate instead of `wasmer_enumset` - [#2056](https://github.com/wasmerio/wasmer/pull/2056) Change back to depend on the `enumset` crate instead of `wasmer_enumset`
### Fixed ### Fixed
- [#2084](https://github.com/wasmerio/wasmer/pull/2084) Avoid calling the function environment finalizer more than once when the environment has been cloned in the C API.
- [#2069](https://github.com/wasmerio/wasmer/pull/2069) Use the new documentation for `include/README.md` in the Wasmer package. - [#2069](https://github.com/wasmerio/wasmer/pull/2069) Use the new documentation for `include/README.md` in the Wasmer package.
- [#2042](https://github.com/wasmerio/wasmer/pull/2042) Parse more exotic environment variables in `wasmer run`. - [#2042](https://github.com/wasmerio/wasmer/pull/2042) Parse more exotic environment variables in `wasmer run`.
- [#2041](https://github.com/wasmerio/wasmer/pull/2041) Documentation diagrams now have a solid white background rather than a transparent background. - [#2041](https://github.com/wasmerio/wasmer/pull/2041) Documentation diagrams now have a solid white background rather than a transparent background.

14
Cargo.lock generated
View File

@@ -971,9 +971,9 @@ dependencies = [
[[package]] [[package]]
name = "inkwell" name = "inkwell"
version = "0.1.0-llvm10sample" version = "0.1.0-beta.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e079c12273d96e41481454a37ad968e607e1ce51b39b9facd3a802a12df6e9dc" checksum = "f5fe0be1e47c0c0f3da4397693e08f5d78329ae095c25d529e12ade78420fb41"
dependencies = [ dependencies = [
"either", "either",
"inkwell_internals", "inkwell_internals",
@@ -986,9 +986,9 @@ dependencies = [
[[package]] [[package]]
name = "inkwell_internals" name = "inkwell_internals"
version = "0.2.0" version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b22cf4eda09069b48204cce4b7cd9a25311da813780e95a038524f2210fab44e" checksum = "c2e1f71330ccec54ee62533ae88574c4169b67fb4b95cbb1196a1322582abd11"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@@ -1128,15 +1128,15 @@ dependencies = [
[[package]] [[package]]
name = "llvm-sys" name = "llvm-sys"
version = "100.2.0" version = "110.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9109e19fbfac3458f2970189719fa19f1007c6fd4e08c44fdebf4be0ddbe261d" checksum = "b0062a0c6635fb5d57c6ebba072dcae50e41651030363cf06d220b0d016840f2"
dependencies = [ dependencies = [
"cc", "cc",
"lazy_static", "lazy_static",
"libc", "libc",
"regex", "regex",
"semver 0.9.0", "semver 0.11.0",
] ]
[[package]] [[package]]

View File

@@ -163,7 +163,7 @@ build-docs:
build-docs-capi: build-docs-capi:
cd lib/c-api/doc/deprecated/ && doxygen doxyfile cd lib/c-api/doc/deprecated/ && doxygen doxyfile
cargo doc --manifest-path lib/c-api/Cargo.toml --no-deps --features wat,jit,object-file,native,cranelift,wasi cargo doc --manifest-path lib/c-api/Cargo.toml --no-deps --features wat,jit,object-file,native,cranelift,wasi $(capi_default_features)
# We use cranelift as the default backend for the capi for now # We use cranelift as the default backend for the capi for now
build-capi: build-capi-cranelift build-capi: build-capi-cranelift

View File

@@ -105,7 +105,7 @@ pub unsafe extern "C" fn wasm_func_new_with_env(
#[repr(C)] #[repr(C)]
struct WrapperEnv { struct WrapperEnv {
env: *mut c_void, env: *mut c_void,
finalizer: Option<wasm_env_finalizer_t>, finalizer: Arc<Option<wasm_env_finalizer_t>>,
} }
// Only relevant when using multiple threads in the C API; // Only relevant when using multiple threads in the C API;
@@ -115,8 +115,13 @@ pub unsafe extern "C" fn wasm_func_new_with_env(
impl Drop for WrapperEnv { impl Drop for WrapperEnv {
fn drop(&mut self) { fn drop(&mut self) {
if let Some(finalizer) = self.finalizer { if let Some(finalizer) = Arc::get_mut(&mut self.finalizer)
unsafe { (finalizer)(self.env as _) } .map(Option::take)
.flatten()
{
if !self.env.is_null() {
unsafe { (finalizer)(self.env as _) }
}
} }
} }
} }
@@ -160,7 +165,10 @@ pub unsafe extern "C" fn wasm_func_new_with_env(
let function = Function::new_with_env( let function = Function::new_with_env(
&store.inner, &store.inner,
func_sig, func_sig,
WrapperEnv { env, finalizer }, WrapperEnv {
env,
finalizer: Arc::new(finalizer),
},
inner_callback, inner_callback,
); );

View File

@@ -24,9 +24,9 @@ itertools = "0.9"
rayon = "1.5" rayon = "1.5"
[dependencies.inkwell] [dependencies.inkwell]
version = "=0.1.0-llvm10sample" version = "=0.1.0-beta.2"
default-features = false default-features = false
features = ["llvm10-0", "target-x86", "target-aarch64"] features = ["llvm11-0", "target-x86", "target-aarch64"]
[build-dependencies] [build-dependencies]
cc = "1.0" cc = "1.0"

View File

@@ -5674,13 +5674,7 @@ impl<'a> FuncGen<'a> {
); );
self.emit_call_sysv( self.emit_call_sysv(
|this| { |this| {
let label = this.assembler.get_label(); this.assembler.emit_call_register(GPR::RAX);
let after = this.assembler.get_label();
this.assembler.emit_jmp(Condition::None, after);
this.assembler.emit_label(label);
this.assembler.emit_host_redirection(GPR::RAX);
this.assembler.emit_label(after);
this.assembler.emit_call_label(label);
}, },
// [vmctx, memory_index] // [vmctx, memory_index]
iter::once(Location::Imm32(memory_index.index() as u32)), iter::once(Location::Imm32(memory_index.index() as u32)),
@@ -5719,13 +5713,7 @@ impl<'a> FuncGen<'a> {
self.emit_call_sysv( self.emit_call_sysv(
|this| { |this| {
let label = this.assembler.get_label(); this.assembler.emit_call_register(GPR::RAX);
let after = this.assembler.get_label();
this.assembler.emit_jmp(Condition::None, after);
this.assembler.emit_label(label);
this.assembler.emit_host_redirection(GPR::RAX);
this.assembler.emit_label(after);
this.assembler.emit_call_label(label);
}, },
// [vmctx, val, memory_index] // [vmctx, val, memory_index]
iter::once(param_pages) iter::once(param_pages)

View File

@@ -205,6 +205,8 @@ pub trait Emitter {
fn emit_call_label(&mut self, label: Self::Label); fn emit_call_label(&mut self, label: Self::Label);
fn emit_call_location(&mut self, loc: Location); fn emit_call_location(&mut self, loc: Location);
fn emit_call_register(&mut self, reg: GPR);
fn emit_bkpt(&mut self); fn emit_bkpt(&mut self);
fn emit_host_redirection(&mut self, target: GPR); fn emit_host_redirection(&mut self, target: GPR);
@@ -1389,6 +1391,10 @@ impl Emitter for Assembler {
} }
} }
fn emit_call_register(&mut self, reg: GPR) {
dynasm!(self ; call Rq(reg as u8));
}
fn emit_bkpt(&mut self) { fn emit_bkpt(&mut self) {
dynasm!(self ; int 0x3); dynasm!(self ; int 0x3);
} }

View File

@@ -20,8 +20,6 @@ let wasi_env = WasiState::new("command name")
let import_object = wasi_env.import_object(&module)?; let import_object = wasi_env.import_object(&module)?;
let instance = Instance::new(&module, &import_object)?; let instance = Instance::new(&module, &import_object)?;
wasi_env.set_memory(instance.exports.get_memory("memory")?.clone());
let start = instance.exports.get_function("_start")?; let start = instance.exports.get_function("_start")?;
start.call(&[])?; start.call(&[])?;
``` ```