mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-05 02:20:19 +00:00
Add homomorphic host redirection abstraction for vm->host calls.
This commit is contained in:
parent
574e4c477f
commit
b57aba4ae7
12
Cargo.lock
generated
12
Cargo.lock
generated
@ -428,7 +428,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "dynasm"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -442,7 +442,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "dynasmrt"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -1692,8 +1692,8 @@ version = "0.6.0"
|
||||
dependencies = [
|
||||
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"colored 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"dynasm 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"dynasmrt 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"dynasm 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"dynasmrt 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"nix 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -1875,8 +1875,8 @@ dependencies = [
|
||||
"checksum csv-core 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9b5cadb6b25c77aeff80ba701712494213f4a8418fcda2ee11b6560c3ad0bf4c"
|
||||
"checksum ctor 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "5b6b2f4752cc29efbfd03474c532ce8f916f2d44ec5bb8c21f93bc76e5365528"
|
||||
"checksum digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5"
|
||||
"checksum dynasm 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "56607fba702a46df49ce4f6e1e7b7cc55df2c8c5066630a1b4e91939f8948795"
|
||||
"checksum dynasmrt 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "81c856c0e3505b907e0f07a70712daf717a204e8195e3f41d20badea3718762c"
|
||||
"checksum dynasm 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8654f63488a94cd11feac2a609fdcdecd09e02fb582731f635783689fbb429f3"
|
||||
"checksum dynasmrt 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b0046b083139885c38990f2fb9822d06f6c5902068d93a6ed9e56b63011b9932"
|
||||
"checksum either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5527cfe0d098f36e3f8839852688e63c8fff1c90b2b405aef730615f9a7bcf7b"
|
||||
"checksum enum-methods 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7798e7da2d4cb0d6d6fc467e8d6b5bf247e9e989f786dde1732d79899c32bb10"
|
||||
"checksum env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3"
|
||||
|
@ -644,7 +644,7 @@ impl ModuleCodeGenerator<X64FunctionCode, X64ExecutionContext, CodegenError>
|
||||
),
|
||||
Location::GPR(GPR::RAX),
|
||||
);
|
||||
a.emit_jmp_location(Location::GPR(GPR::RAX));
|
||||
a.emit_homomorphic_host_redirection(GPR::RAX);
|
||||
|
||||
self.func_import_count += 1;
|
||||
|
||||
|
@ -168,6 +168,8 @@ pub trait Emitter {
|
||||
fn emit_call_location(&mut self, loc: Location);
|
||||
|
||||
fn emit_bkpt(&mut self);
|
||||
|
||||
fn emit_homomorphic_host_redirection(&mut self, target: GPR);
|
||||
}
|
||||
|
||||
fn _dummy(a: &mut Assembler) {
|
||||
@ -940,4 +942,8 @@ impl Emitter for Assembler {
|
||||
fn emit_bkpt(&mut self) {
|
||||
dynasm!(self ; int 0x3);
|
||||
}
|
||||
|
||||
fn emit_homomorphic_host_redirection(&mut self, target: GPR) {
|
||||
self.emit_jmp_location(Location::GPR(target));
|
||||
}
|
||||
}
|
||||
|
@ -977,4 +977,40 @@ impl Emitter for Assembler {
|
||||
fn emit_bkpt(&mut self) {
|
||||
dynasm!(self ; brk 1)
|
||||
}
|
||||
|
||||
fn emit_homomorphic_host_redirection(&mut self, target: GPR) {
|
||||
let target = map_gpr(target);
|
||||
dynasm!(
|
||||
self
|
||||
; sub sp, sp, 16
|
||||
; str x30, [sp, 0] // LR
|
||||
; str X(target.x()), [sp, 8]
|
||||
; adr x30, >after
|
||||
|
||||
// Put parameters in correct order
|
||||
; sub sp, sp, 64
|
||||
; str X(map_gpr(GPR::RDI).x()), [sp, 0]
|
||||
; str X(map_gpr(GPR::RSI).x()), [sp, 8]
|
||||
; str X(map_gpr(GPR::RDX).x()), [sp, 16]
|
||||
; str X(map_gpr(GPR::RCX).x()), [sp, 24]
|
||||
; str X(map_gpr(GPR::R8).x()), [sp, 32]
|
||||
; str X(map_gpr(GPR::R9).x()), [sp, 40]
|
||||
; ldr x0, [sp, 0]
|
||||
; ldr x1, [sp, 8]
|
||||
; ldr x2, [sp, 16]
|
||||
; ldr x3, [sp, 24]
|
||||
; ldr x4, [sp, 32]
|
||||
; ldr x5, [sp, 40]
|
||||
; add sp, sp, 64
|
||||
|
||||
// Branch to saved target
|
||||
; ldr x8, [sp, 8]
|
||||
; br x8
|
||||
|
||||
; after:
|
||||
; ldr x30, [sp, 0] // LR
|
||||
; add sp, sp, 16
|
||||
; br x30
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user