mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-29 08:31:32 +00:00
Support emitting inline breakpoints in singlepass.
This commit is contained in:
@ -1904,11 +1904,12 @@ impl FunctionCodeGenerator<CodegenError> for X64FunctionCode {
|
|||||||
Event::Internal(x) => {
|
Event::Internal(x) => {
|
||||||
match x {
|
match x {
|
||||||
InternalEvent::Breakpoint(callback) => {
|
InternalEvent::Breakpoint(callback) => {
|
||||||
a.emit_bkpt();
|
use wasmer_runtime_core::backend::InlineBreakpointType;
|
||||||
self.breakpoints
|
self.breakpoints
|
||||||
.as_mut()
|
.as_mut()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.insert(a.get_offset(), callback);
|
.insert(a.get_offset(), callback);
|
||||||
|
a.emit_inline_breakpoint(InlineBreakpointType::Middleware);
|
||||||
}
|
}
|
||||||
InternalEvent::FunctionBegin(_) | InternalEvent::FunctionEnd => {}
|
InternalEvent::FunctionBegin(_) | InternalEvent::FunctionEnd => {}
|
||||||
InternalEvent::GetInternal(idx) => {
|
InternalEvent::GetInternal(idx) => {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
use dynasmrt::{x64::Assembler, AssemblyOffset, DynamicLabel, DynasmApi, DynasmLabelApi};
|
use dynasmrt::{x64::Assembler, AssemblyOffset, DynamicLabel, DynasmApi, DynasmLabelApi};
|
||||||
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 {
|
||||||
@ -171,6 +172,7 @@ pub trait Emitter {
|
|||||||
fn emit_bkpt(&mut self);
|
fn emit_bkpt(&mut self);
|
||||||
|
|
||||||
fn emit_homomorphic_host_redirection(&mut self, target: GPR);
|
fn emit_homomorphic_host_redirection(&mut self, target: GPR);
|
||||||
|
fn emit_inline_breakpoint(&mut self, ty: InlineBreakpointType);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn _dummy(a: &mut Assembler) {
|
fn _dummy(a: &mut Assembler) {
|
||||||
@ -951,4 +953,13 @@ impl Emitter for Assembler {
|
|||||||
fn emit_homomorphic_host_redirection(&mut self, target: GPR) {
|
fn emit_homomorphic_host_redirection(&mut self, target: GPR) {
|
||||||
self.emit_jmp_location(Location::GPR(target));
|
self.emit_jmp_location(Location::GPR(target));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn emit_inline_breakpoint(&mut self, ty: InlineBreakpointType) {
|
||||||
|
dynasm!(self
|
||||||
|
; ud2
|
||||||
|
; .byte 0x0f ; .byte (0xb9u8 as i8) // ud
|
||||||
|
; int -1
|
||||||
|
; .byte (ty as u8 as i8)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +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};
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
|
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
|
||||||
pub struct AX(pub u32);
|
pub struct AX(pub u32);
|
||||||
@ -1474,6 +1475,14 @@ impl Emitter for Assembler {
|
|||||||
; br x_tmp1
|
; br x_tmp1
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn emit_inline_breakpoint(&mut self, ty: InlineBreakpointType) {
|
||||||
|
dynasm!(self
|
||||||
|
; .dword 0
|
||||||
|
; .dword -1
|
||||||
|
; .dword (ty as u8 as i32)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
|
Reference in New Issue
Block a user