mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-13 14:25:32 +00:00
Run cargo fmt on everything.
This commit is contained in:
parent
c18bdd52cc
commit
5499a69ddc
@ -1,8 +1,11 @@
|
|||||||
|
use std::sync::{
|
||||||
|
atomic::{AtomicU32, Ordering},
|
||||||
|
Arc,
|
||||||
|
};
|
||||||
use wasmer_runtime_core::{
|
use wasmer_runtime_core::{
|
||||||
codegen::{Event, EventSink, FunctionMiddleware, InternalEvent},
|
codegen::{Event, EventSink, FunctionMiddleware, InternalEvent},
|
||||||
module::ModuleInfo,
|
module::ModuleInfo,
|
||||||
};
|
};
|
||||||
use std::sync::{Arc, atomic::{Ordering, AtomicU32}};
|
|
||||||
|
|
||||||
pub struct CallTrace {
|
pub struct CallTrace {
|
||||||
counter: Arc<AtomicU32>,
|
counter: Arc<AtomicU32>,
|
||||||
|
@ -94,11 +94,15 @@ pub fn get_inline_breakpoint_size(arch: Architecture, backend: Backend) -> Optio
|
|||||||
match (arch, backend) {
|
match (arch, backend) {
|
||||||
(Architecture::X64, Backend::Singlepass) => Some(7),
|
(Architecture::X64, Backend::Singlepass) => Some(7),
|
||||||
(Architecture::Aarch64, Backend::Singlepass) => Some(12),
|
(Architecture::Aarch64, Backend::Singlepass) => Some(12),
|
||||||
_ => None
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read_inline_breakpoint(arch: Architecture, backend: Backend, code: &[u8]) -> Option<InlineBreakpoint> {
|
pub fn read_inline_breakpoint(
|
||||||
|
arch: Architecture,
|
||||||
|
backend: Backend,
|
||||||
|
code: &[u8],
|
||||||
|
) -> Option<InlineBreakpoint> {
|
||||||
match arch {
|
match arch {
|
||||||
Architecture::X64 => match backend {
|
Architecture::X64 => match backend {
|
||||||
Backend::Singlepass => {
|
Backend::Singlepass => {
|
||||||
@ -118,7 +122,7 @@ pub fn read_inline_breakpoint(arch: Architecture, backend: Backend, code: &[u8])
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => None
|
_ => None,
|
||||||
},
|
},
|
||||||
Architecture::Aarch64 => match backend {
|
Architecture::Aarch64 => match backend {
|
||||||
Backend::Singlepass => {
|
Backend::Singlepass => {
|
||||||
@ -131,14 +135,14 @@ pub fn read_inline_breakpoint(arch: Architecture, backend: Backend, code: &[u8])
|
|||||||
0 => InlineBreakpointType::Trace,
|
0 => InlineBreakpointType::Trace,
|
||||||
1 => InlineBreakpointType::Middleware,
|
1 => InlineBreakpointType::Middleware,
|
||||||
_ => InlineBreakpointType::Unknown,
|
_ => InlineBreakpointType::Unknown,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,7 +244,9 @@ extern "C" fn signal_trap_handler(
|
|||||||
siginfo: *mut siginfo_t,
|
siginfo: *mut siginfo_t,
|
||||||
ucontext: *mut c_void,
|
ucontext: *mut c_void,
|
||||||
) {
|
) {
|
||||||
use crate::backend::{Architecture, InlineBreakpointType, get_inline_breakpoint_size, read_inline_breakpoint};
|
use crate::backend::{
|
||||||
|
get_inline_breakpoint_size, read_inline_breakpoint, Architecture, InlineBreakpointType,
|
||||||
|
};
|
||||||
|
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
static ARCH: Architecture = Architecture::X64;
|
static ARCH: Architecture = Architecture::X64;
|
||||||
@ -260,30 +262,35 @@ extern "C" fn signal_trap_handler(
|
|||||||
let magic_size = if let Some(x) = get_inline_breakpoint_size(ARCH, v.backend) {
|
let magic_size = if let Some(x) = get_inline_breakpoint_size(ARCH, v.backend) {
|
||||||
x
|
x
|
||||||
} else {
|
} else {
|
||||||
continue
|
continue;
|
||||||
};
|
};
|
||||||
let ip = fault.ip.get();
|
let ip = fault.ip.get();
|
||||||
let end = v.base + v.msm.total_size;
|
let end = v.base + v.msm.total_size;
|
||||||
if ip >= v.base && ip < end && ip + magic_size <= end {
|
if ip >= v.base && ip < end && ip + magic_size <= end {
|
||||||
if let Some(ib) = read_inline_breakpoint(ARCH, v.backend, std::slice::from_raw_parts(ip as *const u8, magic_size)) {
|
if let Some(ib) = read_inline_breakpoint(
|
||||||
|
ARCH,
|
||||||
|
v.backend,
|
||||||
|
std::slice::from_raw_parts(ip as *const u8, magic_size),
|
||||||
|
) {
|
||||||
fault.ip.set(ip + magic_size);
|
fault.ip.set(ip + magic_size);
|
||||||
|
|
||||||
match ib.ty {
|
match ib.ty {
|
||||||
InlineBreakpointType::Trace => {},
|
InlineBreakpointType::Trace => {}
|
||||||
InlineBreakpointType::Middleware => {
|
InlineBreakpointType::Middleware => {
|
||||||
let out: Option<Result<(), Box<dyn Any>>> = with_breakpoint_map(|bkpt_map| {
|
let out: Option<Result<(), Box<dyn Any>>> =
|
||||||
bkpt_map.and_then(|x| x.get(&ip)).map(|x| {
|
with_breakpoint_map(|bkpt_map| {
|
||||||
x(BreakpointInfo {
|
bkpt_map.and_then(|x| x.get(&ip)).map(|x| {
|
||||||
fault: Some(&fault),
|
x(BreakpointInfo {
|
||||||
|
fault: Some(&fault),
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
});
|
||||||
});
|
|
||||||
if let Some(Ok(())) = out {
|
if let Some(Ok(())) = out {
|
||||||
} else {
|
} else {
|
||||||
println!("Failed calling middleware: {:?}", out);
|
println!("Failed calling middleware: {:?}", out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => println!("Unknown breakpoint type: {:?}", ib.ty)
|
_ => println!("Unknown breakpoint type: {:?}", ib.ty),
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
use crate::backend::Backend;
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::ops::Bound::{Included, Unbounded};
|
use std::ops::Bound::{Included, Unbounded};
|
||||||
use crate::backend::Backend;
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
|
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
|
||||||
pub struct RegisterIndex(pub usize);
|
pub struct RegisterIndex(pub usize);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use dynasmrt::{x64::Assembler, AssemblyOffset, DynamicLabel, DynasmApi, DynasmLabelApi};
|
use dynasmrt::{x64::Assembler, AssemblyOffset, DynamicLabel, DynasmApi, DynasmLabelApi};
|
||||||
|
use wasmer_runtime_core::backend::InlineBreakpointType;
|
||||||
pub use wasmer_runtime_core::state::x64_decl::{GPR, XMM};
|
pub use wasmer_runtime_core::state::x64_decl::{GPR, XMM};
|
||||||
use wasmer_runtime_core::backend::{InlineBreakpointType};
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
||||||
pub enum Location {
|
pub enum Location {
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
use crate::codegen_x64::*;
|
use crate::codegen_x64::*;
|
||||||
use crate::emitter_x64::*;
|
use crate::emitter_x64::*;
|
||||||
use dynasmrt::{aarch64::Assembler, AssemblyOffset, DynamicLabel, DynasmApi, DynasmLabelApi};
|
use dynasmrt::{aarch64::Assembler, AssemblyOffset, DynamicLabel, DynasmApi, DynasmLabelApi};
|
||||||
use wasmer_runtime_core::backend::{InlineBreakpointType};
|
use wasmer_runtime_core::backend::InlineBreakpointType;
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
|
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
|
||||||
pub struct AX(pub u32);
|
pub struct AX(pub u32);
|
||||||
@ -558,7 +558,7 @@ impl Emitter for Assembler {
|
|||||||
}
|
}
|
||||||
dynasm!(self ; str D(map_xmm(src).v()), [x_tmp3] );
|
dynasm!(self ; str D(map_xmm(src).v()), [x_tmp3] );
|
||||||
}
|
}
|
||||||
_ => panic!("NOT IMPL: {:?} {:?} {:?}", sz, src, dst)
|
_ => panic!("NOT IMPL: {:?} {:?} {:?}", sz, src, dst),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -844,7 +844,7 @@ impl Emitter for Assembler {
|
|||||||
; ldr w_tmp1, [x_tmp3]
|
; ldr w_tmp1, [x_tmp3]
|
||||||
; cmp w_tmp1, W(map_gpr(left).x())
|
; cmp w_tmp1, W(map_gpr(left).x())
|
||||||
)
|
)
|
||||||
},
|
}
|
||||||
(Size::S64, Location::GPR(left), Location::Memory(base, disp)) => {
|
(Size::S64, Location::GPR(left), Location::Memory(base, disp)) => {
|
||||||
if disp >= 0 {
|
if disp >= 0 {
|
||||||
dynasm!(self ; add x_tmp3, X(map_gpr(base).x()), disp as u32);
|
dynasm!(self ; add x_tmp3, X(map_gpr(base).x()), disp as u32);
|
||||||
@ -856,7 +856,7 @@ impl Emitter for Assembler {
|
|||||||
; ldr x_tmp1, [x_tmp3]
|
; ldr x_tmp1, [x_tmp3]
|
||||||
; cmp x_tmp1, X(map_gpr(left).x())
|
; cmp x_tmp1, X(map_gpr(left).x())
|
||||||
)
|
)
|
||||||
},
|
}
|
||||||
(Size::S32, Location::Memory(base, disp), Location::GPR(right)) => {
|
(Size::S32, Location::Memory(base, disp), Location::GPR(right)) => {
|
||||||
if disp >= 0 {
|
if disp >= 0 {
|
||||||
dynasm!(self ; add x_tmp3, X(map_gpr(base).x()), disp as u32);
|
dynasm!(self ; add x_tmp3, X(map_gpr(base).x()), disp as u32);
|
||||||
@ -868,7 +868,7 @@ impl Emitter for Assembler {
|
|||||||
; ldr w_tmp1, [x_tmp3]
|
; ldr w_tmp1, [x_tmp3]
|
||||||
; cmp W(map_gpr(right).x()), w_tmp1
|
; cmp W(map_gpr(right).x()), w_tmp1
|
||||||
)
|
)
|
||||||
},
|
}
|
||||||
(Size::S64, Location::Memory(base, disp), Location::GPR(right)) => {
|
(Size::S64, Location::Memory(base, disp), Location::GPR(right)) => {
|
||||||
if disp >= 0 {
|
if disp >= 0 {
|
||||||
dynasm!(self ; add x_tmp3, X(map_gpr(base).x()), disp as u32);
|
dynasm!(self ; add x_tmp3, X(map_gpr(base).x()), disp as u32);
|
||||||
@ -880,7 +880,7 @@ impl Emitter for Assembler {
|
|||||||
; ldr x_tmp1, [x_tmp3]
|
; ldr x_tmp1, [x_tmp3]
|
||||||
; cmp X(map_gpr(right).x()), x_tmp1
|
; cmp X(map_gpr(right).x()), x_tmp1
|
||||||
)
|
)
|
||||||
},
|
}
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -927,7 +927,7 @@ impl Emitter for Assembler {
|
|||||||
; ldr w_tmp1, [x_tmp3]
|
; ldr w_tmp1, [x_tmp3]
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
_ => unreachable!()
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
dynasm!(
|
dynasm!(
|
||||||
self
|
self
|
||||||
@ -953,7 +953,7 @@ impl Emitter for Assembler {
|
|||||||
; ldr x_tmp1, [x_tmp3]
|
; ldr x_tmp1, [x_tmp3]
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
_ => unreachable!()
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
dynasm!(
|
dynasm!(
|
||||||
self
|
self
|
||||||
@ -962,7 +962,7 @@ impl Emitter for Assembler {
|
|||||||
; msub X(map_gpr(GPR::RDX).x()), X(map_gpr(GPR::RAX).x()), x_tmp1, x_tmp2
|
; msub X(map_gpr(GPR::RDX).x()), X(map_gpr(GPR::RAX).x()), x_tmp1, x_tmp2
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
_ => unreachable!()
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn emit_idiv(&mut self, sz: Size, divisor: Location) {
|
fn emit_idiv(&mut self, sz: Size, divisor: Location) {
|
||||||
@ -984,7 +984,7 @@ impl Emitter for Assembler {
|
|||||||
; ldr w_tmp1, [x_tmp3]
|
; ldr w_tmp1, [x_tmp3]
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
_ => unreachable!()
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
dynasm!(
|
dynasm!(
|
||||||
self
|
self
|
||||||
@ -1010,7 +1010,7 @@ impl Emitter for Assembler {
|
|||||||
; ldr x_tmp1, [x_tmp3]
|
; ldr x_tmp1, [x_tmp3]
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
_ => unreachable!()
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
dynasm!(
|
dynasm!(
|
||||||
self
|
self
|
||||||
@ -1019,7 +1019,7 @@ impl Emitter for Assembler {
|
|||||||
; msub X(map_gpr(GPR::RDX).x()), X(map_gpr(GPR::RAX).x()), x_tmp1, x_tmp2
|
; msub X(map_gpr(GPR::RDX).x()), X(map_gpr(GPR::RAX).x()), x_tmp1, x_tmp2
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
_ => unreachable!()
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn emit_shl(&mut self, sz: Size, src: Location, dst: Location) {
|
fn emit_shl(&mut self, sz: Size, src: Location, dst: Location) {
|
||||||
@ -1034,43 +1034,42 @@ impl Emitter for Assembler {
|
|||||||
fn emit_rol(&mut self, sz: Size, src: Location, dst: Location) {
|
fn emit_rol(&mut self, sz: Size, src: Location, dst: Location) {
|
||||||
// TODO: We are changing content of `src` (possibly RCX) here. Will this break any assumptions?
|
// TODO: We are changing content of `src` (possibly RCX) here. Will this break any assumptions?
|
||||||
match sz {
|
match sz {
|
||||||
Size::S32 => {
|
Size::S32 => match src {
|
||||||
match src {
|
Location::Imm8(x) => {
|
||||||
Location::Imm8(x) => {
|
assert!(x < 32);
|
||||||
assert!(x < 32);
|
binop_shift!(ror, self, sz, Location::Imm8(32 - x), dst, {
|
||||||
binop_shift!(ror, self, sz, Location::Imm8(32 - x), dst, { unreachable!("rol") });
|
unreachable!("rol")
|
||||||
}
|
});
|
||||||
Location::GPR(GPR::RCX) => {
|
|
||||||
dynasm!(
|
|
||||||
self
|
|
||||||
; mov w_tmp1, 32
|
|
||||||
; sub W(map_gpr(GPR::RCX).x()), w_tmp1, W(map_gpr(GPR::RCX).x())
|
|
||||||
);
|
|
||||||
binop_shift!(ror, self, sz, src, dst, { unreachable!("rol") });
|
|
||||||
}
|
|
||||||
_ => unreachable!()
|
|
||||||
}
|
}
|
||||||
}
|
Location::GPR(GPR::RCX) => {
|
||||||
Size::S64 => {
|
dynasm!(
|
||||||
match src {
|
self
|
||||||
Location::Imm8(x) => {
|
; mov w_tmp1, 32
|
||||||
assert!(x < 64);
|
; sub W(map_gpr(GPR::RCX).x()), w_tmp1, W(map_gpr(GPR::RCX).x())
|
||||||
binop_shift!(ror, self, sz, Location::Imm8(64 - x), dst, { unreachable!("rol") });
|
);
|
||||||
}
|
binop_shift!(ror, self, sz, src, dst, { unreachable!("rol") });
|
||||||
Location::GPR(GPR::RCX) => {
|
|
||||||
dynasm!(
|
|
||||||
self
|
|
||||||
; mov x_tmp1, 64
|
|
||||||
; sub X(map_gpr(GPR::RCX).x()), x_tmp1, X(map_gpr(GPR::RCX).x())
|
|
||||||
);
|
|
||||||
binop_shift!(ror, self, sz, src, dst, { unreachable!("rol") });
|
|
||||||
}
|
|
||||||
_ => unreachable!()
|
|
||||||
}
|
}
|
||||||
}
|
_ => unreachable!(),
|
||||||
_ => unreachable!()
|
},
|
||||||
|
Size::S64 => match src {
|
||||||
|
Location::Imm8(x) => {
|
||||||
|
assert!(x < 64);
|
||||||
|
binop_shift!(ror, self, sz, Location::Imm8(64 - x), dst, {
|
||||||
|
unreachable!("rol")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Location::GPR(GPR::RCX) => {
|
||||||
|
dynasm!(
|
||||||
|
self
|
||||||
|
; mov x_tmp1, 64
|
||||||
|
; sub X(map_gpr(GPR::RCX).x()), x_tmp1, X(map_gpr(GPR::RCX).x())
|
||||||
|
);
|
||||||
|
binop_shift!(ror, self, sz, src, dst, { unreachable!("rol") });
|
||||||
|
}
|
||||||
|
_ => unreachable!(),
|
||||||
|
},
|
||||||
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
fn emit_ror(&mut self, sz: Size, src: Location, dst: Location) {
|
fn emit_ror(&mut self, sz: Size, src: Location, dst: Location) {
|
||||||
binop_shift!(ror, self, sz, src, dst, { unreachable!("ror") });
|
binop_shift!(ror, self, sz, src, dst, { unreachable!("ror") });
|
||||||
@ -1485,76 +1484,78 @@ impl Emitter for Assembler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn emit_clz_variant(assembler: &mut Assembler, sz: Size, src: &Location, dst: &Location, reversed: bool) {
|
fn emit_clz_variant(
|
||||||
|
assembler: &mut Assembler,
|
||||||
|
sz: Size,
|
||||||
|
src: &Location,
|
||||||
|
dst: &Location,
|
||||||
|
reversed: bool,
|
||||||
|
) {
|
||||||
match sz {
|
match sz {
|
||||||
Size::S32 => {
|
Size::S32 => {
|
||||||
match *src {
|
match *src {
|
||||||
Location::GPR(src) => {
|
Location::GPR(src) => dynasm!(
|
||||||
dynasm!(
|
assembler
|
||||||
assembler
|
; mov w_tmp1, W(map_gpr(src).x())
|
||||||
; mov w_tmp1, W(map_gpr(src).x())
|
),
|
||||||
)
|
Location::Memory(base, disp) => {
|
||||||
|
if disp >= 0 {
|
||||||
|
dynasm!(assembler ; add x_tmp3, X(map_gpr(base).x()), disp as u32);
|
||||||
|
} else {
|
||||||
|
dynasm!(assembler ; sub x_tmp3, X(map_gpr(base).x()), (-disp) as u32);
|
||||||
}
|
}
|
||||||
Location::Memory(base, disp) => {
|
dynasm!(
|
||||||
if disp >= 0 {
|
assembler
|
||||||
dynasm!(assembler ; add x_tmp3, X(map_gpr(base).x()), disp as u32);
|
; ldr w_tmp1, [x_tmp3]
|
||||||
} else {
|
)
|
||||||
dynasm!(assembler ; sub x_tmp3, X(map_gpr(base).x()), (-disp) as u32);
|
|
||||||
}
|
|
||||||
dynasm!(
|
|
||||||
assembler
|
|
||||||
; ldr w_tmp1, [x_tmp3]
|
|
||||||
)
|
|
||||||
}
|
|
||||||
_ => unreachable!()
|
|
||||||
}
|
|
||||||
match *dst {
|
|
||||||
Location::GPR(dst) => {
|
|
||||||
if reversed {
|
|
||||||
dynasm!(assembler ; rbit w_tmp1, w_tmp1);
|
|
||||||
}
|
|
||||||
dynasm!(
|
|
||||||
assembler
|
|
||||||
; clz W(map_gpr(dst).x()), w_tmp1
|
|
||||||
);
|
|
||||||
}
|
|
||||||
_ => unreachable!()
|
|
||||||
}
|
}
|
||||||
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
Size::S64 => {
|
match *dst {
|
||||||
match *src {
|
Location::GPR(dst) => {
|
||||||
Location::GPR(src) => {
|
if reversed {
|
||||||
dynasm!(
|
dynasm!(assembler ; rbit w_tmp1, w_tmp1);
|
||||||
assembler
|
|
||||||
; mov x_tmp1, X(map_gpr(src).x())
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
Location::Memory(base, disp) => {
|
dynasm!(
|
||||||
if disp >= 0 {
|
assembler
|
||||||
dynasm!(assembler ; add x_tmp3, X(map_gpr(base).x()), disp as u32);
|
; clz W(map_gpr(dst).x()), w_tmp1
|
||||||
} else {
|
);
|
||||||
dynasm!(assembler ; sub x_tmp3, X(map_gpr(base).x()), (-disp) as u32);
|
|
||||||
}
|
|
||||||
dynasm!(
|
|
||||||
assembler
|
|
||||||
; ldr x_tmp1, [x_tmp3]
|
|
||||||
)
|
|
||||||
}
|
|
||||||
_ => unreachable!()
|
|
||||||
}
|
|
||||||
match *dst {
|
|
||||||
Location::GPR(dst) => {
|
|
||||||
if reversed {
|
|
||||||
dynasm!(assembler ; rbit x_tmp1, x_tmp1)
|
|
||||||
}
|
|
||||||
dynasm!(
|
|
||||||
assembler
|
|
||||||
; clz X(map_gpr(dst).x()), x_tmp1
|
|
||||||
);
|
|
||||||
}
|
|
||||||
_ => unreachable!()
|
|
||||||
}
|
}
|
||||||
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
_ => unreachable!()
|
|
||||||
}
|
}
|
||||||
}
|
Size::S64 => {
|
||||||
|
match *src {
|
||||||
|
Location::GPR(src) => dynasm!(
|
||||||
|
assembler
|
||||||
|
; mov x_tmp1, X(map_gpr(src).x())
|
||||||
|
),
|
||||||
|
Location::Memory(base, disp) => {
|
||||||
|
if disp >= 0 {
|
||||||
|
dynasm!(assembler ; add x_tmp3, X(map_gpr(base).x()), disp as u32);
|
||||||
|
} else {
|
||||||
|
dynasm!(assembler ; sub x_tmp3, X(map_gpr(base).x()), (-disp) as u32);
|
||||||
|
}
|
||||||
|
dynasm!(
|
||||||
|
assembler
|
||||||
|
; ldr x_tmp1, [x_tmp3]
|
||||||
|
)
|
||||||
|
}
|
||||||
|
_ => unreachable!(),
|
||||||
|
}
|
||||||
|
match *dst {
|
||||||
|
Location::GPR(dst) => {
|
||||||
|
if reversed {
|
||||||
|
dynasm!(assembler ; rbit x_tmp1, x_tmp1)
|
||||||
|
}
|
||||||
|
dynasm!(
|
||||||
|
assembler
|
||||||
|
; clz X(map_gpr(dst).x()), x_tmp1
|
||||||
|
);
|
||||||
|
}
|
||||||
|
_ => unreachable!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => unreachable!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -621,10 +621,17 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
|
|||||||
options
|
options
|
||||||
.optimized_backends
|
.optimized_backends
|
||||||
.iter()
|
.iter()
|
||||||
.map(|&backend| -> (Backend, Box<dyn Fn() -> Box<dyn Compiler> + Send>) {
|
.map(
|
||||||
let options = options.clone();
|
|&backend| -> (Backend, Box<dyn Fn() -> Box<dyn Compiler> + Send>) {
|
||||||
(backend, Box::new(move || get_compiler_by_backend(backend, &options).unwrap()))
|
let options = options.clone();
|
||||||
})
|
(
|
||||||
|
backend,
|
||||||
|
Box::new(move || {
|
||||||
|
get_compiler_by_backend(backend, &options).unwrap()
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
},
|
||||||
|
)
|
||||||
.collect(),
|
.collect(),
|
||||||
interactive_shell,
|
interactive_shell,
|
||||||
)?
|
)?
|
||||||
@ -635,13 +642,17 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
|
|||||||
{
|
{
|
||||||
use wasmer_runtime::error::RuntimeError;
|
use wasmer_runtime::error::RuntimeError;
|
||||||
use wasmer_runtime_core::{
|
use wasmer_runtime_core::{
|
||||||
fault::{push_code_version, pop_code_version},
|
fault::{pop_code_version, push_code_version},
|
||||||
state::CodeVersion
|
state::CodeVersion,
|
||||||
};
|
};
|
||||||
|
|
||||||
push_code_version(CodeVersion {
|
push_code_version(CodeVersion {
|
||||||
baseline: true,
|
baseline: true,
|
||||||
msm: instance.module.runnable_module.get_module_state_map().unwrap(),
|
msm: instance
|
||||||
|
.module
|
||||||
|
.runnable_module
|
||||||
|
.get_module_state_map()
|
||||||
|
.unwrap(),
|
||||||
base: instance.module.runnable_module.get_code().unwrap().as_ptr() as usize,
|
base: instance.module.runnable_module.get_code().unwrap().as_ptr() as usize,
|
||||||
backend: options.backend,
|
backend: options.backend,
|
||||||
});
|
});
|
||||||
@ -815,7 +826,7 @@ fn validate(validate: Validate) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_compiler_by_backend(backend: Backend, opts: &Run) -> Option<Box<dyn Compiler>> {
|
fn get_compiler_by_backend(backend: Backend, opts: &Run) -> Option<Box<dyn Compiler>> {
|
||||||
use wasmer_runtime_core::codegen::{MiddlewareChain};
|
use wasmer_runtime_core::codegen::MiddlewareChain;
|
||||||
let opts = opts.clone();
|
let opts = opts.clone();
|
||||||
let middlewares_gen = move || {
|
let middlewares_gen = move || {
|
||||||
let mut middlewares = MiddlewareChain::new();
|
let mut middlewares = MiddlewareChain::new();
|
||||||
@ -825,14 +836,15 @@ fn get_compiler_by_backend(backend: Backend, opts: &Run) -> Option<Box<dyn Compi
|
|||||||
}
|
}
|
||||||
middlewares
|
middlewares
|
||||||
};
|
};
|
||||||
|
|
||||||
Some(match backend {
|
Some(match backend {
|
||||||
#[cfg(feature = "backend-singlepass")]
|
#[cfg(feature = "backend-singlepass")]
|
||||||
Backend::Singlepass => {
|
Backend::Singlepass => {
|
||||||
|
use wasmer_runtime_core::codegen::StreamingCompiler;
|
||||||
use wasmer_singlepass_backend::ModuleCodeGenerator as SinglePassMCG;
|
use wasmer_singlepass_backend::ModuleCodeGenerator as SinglePassMCG;
|
||||||
use wasmer_runtime_core::codegen::{StreamingCompiler};
|
|
||||||
|
|
||||||
let c: StreamingCompiler<SinglePassMCG, _, _, _, _> = StreamingCompiler::new(middlewares_gen);
|
let c: StreamingCompiler<SinglePassMCG, _, _, _, _> =
|
||||||
|
StreamingCompiler::new(middlewares_gen);
|
||||||
Box::new(c)
|
Box::new(c)
|
||||||
}
|
}
|
||||||
#[cfg(not(feature = "backend-singlepass"))]
|
#[cfg(not(feature = "backend-singlepass"))]
|
||||||
|
Loading…
Reference in New Issue
Block a user