mirror of
https://github.com/fluencelabs/wasmer
synced 2025-07-01 01:21:32 +00:00
Merge branch 'master' into feature/debug-prototype2
This commit is contained in:
@ -24,13 +24,13 @@ use std::{
|
||||
use wasmer_runtime_core::{
|
||||
backend::{
|
||||
sys::{Memory, Protect},
|
||||
CacheGen, RunnableModule,
|
||||
CacheGen, ExceptionCode, RunnableModule,
|
||||
},
|
||||
cache::Error as CacheError,
|
||||
module::ModuleInfo,
|
||||
state::ModuleStateMap,
|
||||
structures::TypedIndex,
|
||||
typed_func::{Trampoline, Wasm, WasmTrapInfo},
|
||||
typed_func::{Trampoline, Wasm},
|
||||
types::{LocalFuncIndex, SigIndex},
|
||||
vm, vmcalls,
|
||||
};
|
||||
@ -59,18 +59,55 @@ extern "C" {
|
||||
fn throw_any(data: *mut dyn Any) -> !;
|
||||
|
||||
#[allow(improper_ctypes)]
|
||||
fn invoke_trampoline(
|
||||
fn cxx_invoke_trampoline(
|
||||
trampoline: Trampoline,
|
||||
vmctx_ptr: *mut vm::Ctx,
|
||||
func_ptr: NonNull<vm::Func>,
|
||||
params: *const u64,
|
||||
results: *mut u64,
|
||||
trap_out: *mut WasmTrapInfo,
|
||||
user_error: *mut Option<Box<dyn Any + Send>>,
|
||||
trap_out: *mut i32,
|
||||
error_out: *mut Option<Box<dyn Any + Send>>,
|
||||
invoke_env: Option<NonNull<c_void>>,
|
||||
) -> bool;
|
||||
}
|
||||
|
||||
/// `invoke_trampoline` is a wrapper around `cxx_invoke_trampoline`, for fixing up the obsoleted
|
||||
/// `trap_out` in the C++ part.
|
||||
unsafe extern "C" fn invoke_trampoline(
|
||||
trampoline: Trampoline,
|
||||
vmctx_ptr: *mut vm::Ctx,
|
||||
func_ptr: NonNull<vm::Func>,
|
||||
params: *const u64,
|
||||
results: *mut u64,
|
||||
error_out: *mut Option<Box<dyn Any + Send>>,
|
||||
invoke_env: Option<NonNull<c_void>>,
|
||||
) -> bool {
|
||||
let mut trap_out: i32 = -1;
|
||||
let ret = cxx_invoke_trampoline(
|
||||
trampoline,
|
||||
vmctx_ptr,
|
||||
func_ptr,
|
||||
params,
|
||||
results,
|
||||
&mut trap_out,
|
||||
error_out,
|
||||
invoke_env,
|
||||
);
|
||||
// Translate trap code if an error occurred.
|
||||
if !ret && (*error_out).is_none() && trap_out != -1 {
|
||||
*error_out = Some(Box::new(match trap_out {
|
||||
0 => ExceptionCode::Unreachable,
|
||||
1 => ExceptionCode::IncorrectCallIndirectSignature,
|
||||
2 => ExceptionCode::MemoryOutOfBounds,
|
||||
3 => ExceptionCode::CallIndirectOOB,
|
||||
4 => ExceptionCode::IllegalArithmetic,
|
||||
5 => ExceptionCode::MisalignedAtomicAccess,
|
||||
_ => return ret,
|
||||
}));
|
||||
}
|
||||
ret
|
||||
}
|
||||
|
||||
static SIGNAL_HANDLER_INSTALLED: Once = Once::new();
|
||||
|
||||
fn get_callbacks() -> Callbacks {
|
||||
@ -206,7 +243,10 @@ impl LLVMBackend {
|
||||
|
||||
let buffer = Arc::new(Buffer::LlvmMemory(memory_buffer));
|
||||
|
||||
#[cfg(all(any(target_os = "linux", target_os = "macos"), target_arch = "x86_64"))]
|
||||
#[cfg(all(
|
||||
any(target_os = "freebsd", target_os = "linux", target_os = "macos"),
|
||||
target_arch = "x86_64"
|
||||
))]
|
||||
{
|
||||
use super::stackmap::{self, StkMapRecord, StkSizeRecord};
|
||||
use std::collections::BTreeMap;
|
||||
|
@ -1,3 +1,9 @@
|
||||
//! Code for dealing with [LLVM][llvm-intrinsics] and VM intrinsics.
|
||||
//!
|
||||
//! VM intrinsics are used to interact with the host VM.
|
||||
//!
|
||||
//! [llvm-intrinsics]: https://llvm.org/docs/LangRef.html#intrinsic-functions
|
||||
|
||||
use inkwell::{
|
||||
attributes::{Attribute, AttributeLoc},
|
||||
builder::Builder,
|
||||
@ -34,6 +40,7 @@ fn type_to_llvm_ptr<'ctx>(intrinsics: &Intrinsics<'ctx>, ty: Type) -> PointerTyp
|
||||
}
|
||||
}
|
||||
|
||||
/// Struct containing LLVM and VM intrinsics.
|
||||
pub struct Intrinsics<'ctx> {
|
||||
pub ctlz_i32: FunctionValue<'ctx>,
|
||||
pub ctlz_i64: FunctionValue<'ctx>,
|
||||
@ -151,6 +158,7 @@ pub struct Intrinsics<'ctx> {
|
||||
}
|
||||
|
||||
impl<'ctx> Intrinsics<'ctx> {
|
||||
/// Create an [`Intrinsics`] for the given [`Context`].
|
||||
pub fn declare(module: &Module<'ctx>, context: &'ctx Context) -> Self {
|
||||
let void_ty = context.void_type();
|
||||
let i1_ty = context.bool_type();
|
||||
|
@ -53,7 +53,10 @@ pub enum StackmapEntryKind {
|
||||
}
|
||||
|
||||
impl StackmapEntry {
|
||||
#[cfg(all(any(target_os = "linux", target_os = "macos"), target_arch = "x86_64"))]
|
||||
#[cfg(all(
|
||||
any(target_os = "freebsd", target_os = "linux", target_os = "macos"),
|
||||
target_arch = "x86_64"
|
||||
))]
|
||||
pub fn populate_msm(
|
||||
&self,
|
||||
module_info: &ModuleInfo,
|
||||
|
Reference in New Issue
Block a user