mirror of
https://github.com/fluencelabs/wasmer
synced 2025-04-01 23:41:03 +00:00
Emit state information for internal breakpoints.
This commit is contained in:
parent
ba7e2b70ed
commit
a525907c60
@ -18,7 +18,8 @@ use std::{
|
|||||||
};
|
};
|
||||||
use wasmer_runtime_core::{
|
use wasmer_runtime_core::{
|
||||||
backend::{
|
backend::{
|
||||||
sys::Memory, Backend, CacheGen, CompilerConfig, MemoryBoundCheckMode, RunnableModule, Token,
|
get_inline_breakpoint_size, sys::Memory, Architecture, Backend, CacheGen, CompilerConfig,
|
||||||
|
MemoryBoundCheckMode, RunnableModule, Token,
|
||||||
},
|
},
|
||||||
cache::{Artifact, Error as CacheError},
|
cache::{Artifact, Error as CacheError},
|
||||||
codegen::*,
|
codegen::*,
|
||||||
@ -40,6 +41,11 @@ use wasmer_runtime_core::{
|
|||||||
};
|
};
|
||||||
use wasmparser::{Operator, Type as WpType, TypeOrFuncType as WpTypeOrFuncType};
|
use wasmparser::{Operator, Type as WpType, TypeOrFuncType as WpTypeOrFuncType};
|
||||||
|
|
||||||
|
#[cfg(target_arch = "aarch64")]
|
||||||
|
static ARCH: Architecture = Architecture::Aarch64;
|
||||||
|
#[cfg(target_arch = "x86_64")]
|
||||||
|
static ARCH: Architecture = Architecture::X64;
|
||||||
|
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
/// Performs a System V call to `target` with [stack_top..stack_base] as the argument list, from right to left.
|
/// Performs a System V call to `target` with [stack_top..stack_base] as the argument list, from right to left.
|
||||||
@ -687,6 +693,28 @@ impl X64FunctionCode {
|
|||||||
.insert(m.state.wasm_inst_offset, SuspendOffset::Trappable(offset));
|
.insert(m.state.wasm_inst_offset, SuspendOffset::Trappable(offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn mark_inline_breakpoint(
|
||||||
|
a: &mut Assembler,
|
||||||
|
m: &Machine,
|
||||||
|
fsm: &mut FunctionStateMap,
|
||||||
|
control_stack: &mut [ControlFrame],
|
||||||
|
) {
|
||||||
|
let state_diff_id = Self::get_state_diff(m, fsm, control_stack);
|
||||||
|
let offset = a.get_offset().0;
|
||||||
|
fsm.trappable_offsets.insert(
|
||||||
|
offset,
|
||||||
|
OffsetInfo {
|
||||||
|
end_offset: offset
|
||||||
|
+ get_inline_breakpoint_size(ARCH, Backend::Singlepass)
|
||||||
|
.expect("cannot get inline breakpoint size"),
|
||||||
|
activate_offset: offset,
|
||||||
|
diff_id: state_diff_id,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
fsm.wasm_offset_to_target_offset
|
||||||
|
.insert(m.state.wasm_inst_offset, SuspendOffset::Trappable(offset));
|
||||||
|
}
|
||||||
|
|
||||||
/// Moves `loc` to a valid location for `div`/`idiv`.
|
/// Moves `loc` to a valid location for `div`/`idiv`.
|
||||||
fn emit_relaxed_xdiv(
|
fn emit_relaxed_xdiv(
|
||||||
a: &mut Assembler,
|
a: &mut Assembler,
|
||||||
@ -1909,6 +1937,7 @@ impl FunctionCodeGenerator<CodegenError> for X64FunctionCode {
|
|||||||
.as_mut()
|
.as_mut()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.insert(a.get_offset(), callback);
|
.insert(a.get_offset(), callback);
|
||||||
|
Self::mark_trappable(a, &self.machine, &mut self.fsm, &mut self.control_stack);
|
||||||
a.emit_inline_breakpoint(InlineBreakpointType::Middleware);
|
a.emit_inline_breakpoint(InlineBreakpointType::Middleware);
|
||||||
}
|
}
|
||||||
InternalEvent::FunctionBegin(_) | InternalEvent::FunctionEnd => {}
|
InternalEvent::FunctionBegin(_) | InternalEvent::FunctionEnd => {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user