mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-12 08:31:21 +00:00
Cargo fmt
This commit is contained in:
@ -212,16 +212,18 @@ fn get_callbacks() -> Callbacks {
|
||||
}
|
||||
}
|
||||
|
||||
unsafe extern "C" fn vm_breakpoint(_ctx: &mut vm::Ctx, breakpoints: *const Vec<Box<Fn(BkptInfo) + Send + Sync + 'static>>, index: u32) -> i32 {
|
||||
unsafe extern "C" fn vm_breakpoint(
|
||||
_ctx: &mut vm::Ctx,
|
||||
breakpoints: *const Vec<Box<Fn(BkptInfo) + Send + Sync + 'static>>,
|
||||
index: u32,
|
||||
) -> i32 {
|
||||
unsafe extern "C" fn do_throw() -> ! {
|
||||
let ptr: *mut i32 = ::std::ptr::null_mut();
|
||||
*ptr = 42;
|
||||
::std::process::abort();
|
||||
}
|
||||
let breakpoints: &Vec<_> = &*breakpoints;
|
||||
breakpoints[index as usize](BkptInfo {
|
||||
throw: do_throw,
|
||||
});
|
||||
breakpoints[index as usize](BkptInfo { throw: do_throw });
|
||||
0
|
||||
}
|
||||
|
||||
@ -251,7 +253,11 @@ pub struct LLVMBackend {
|
||||
}
|
||||
|
||||
impl LLVMBackend {
|
||||
pub fn new(module: Module, _intrinsics: Intrinsics, breakpoints: Box<Vec<Box<Fn(BkptInfo) + Send + Sync + 'static>>>) -> (Self, LLVMCache) {
|
||||
pub fn new(
|
||||
module: Module,
|
||||
_intrinsics: Intrinsics,
|
||||
breakpoints: Box<Vec<Box<Fn(BkptInfo) + Send + Sync + 'static>>>,
|
||||
) -> (Self, LLVMCache) {
|
||||
Target::initialize_x86(&InitializationConfig {
|
||||
asm_parser: true,
|
||||
asm_printer: true,
|
||||
@ -312,7 +318,10 @@ impl LLVMBackend {
|
||||
)
|
||||
}
|
||||
|
||||
pub unsafe fn from_buffer(memory: Memory, breakpoints: Box<Vec<Box<Fn(BkptInfo) + Send + Sync + 'static>>>) -> Result<(Self, LLVMCache), String> {
|
||||
pub unsafe fn from_buffer(
|
||||
memory: Memory,
|
||||
breakpoints: Box<Vec<Box<Fn(BkptInfo) + Send + Sync + 'static>>>,
|
||||
) -> Result<(Self, LLVMCache), String> {
|
||||
let callbacks = get_callbacks();
|
||||
let mut module: *mut LLVMModule = ptr::null_mut();
|
||||
|
||||
|
@ -472,7 +472,8 @@ impl FunctionCodeGenerator<CodegenError> for LLVMFunctionCodeGenerator {
|
||||
|
||||
fn feed_event(&mut self, event: Event, module_info: &ModuleInfo) -> Result<(), CodegenError> {
|
||||
match event {
|
||||
Event::Internal(InternalEvent::FunctionBegin(_)) | Event::Internal(InternalEvent::FunctionEnd) => {
|
||||
Event::Internal(InternalEvent::FunctionBegin(_))
|
||||
| Event::Internal(InternalEvent::FunctionEnd) => {
|
||||
return Ok(());
|
||||
}
|
||||
_ => {}
|
||||
@ -533,13 +534,17 @@ impl FunctionCodeGenerator<CodegenError> for LLVMFunctionCodeGenerator {
|
||||
.as_basic_value_enum();
|
||||
builder.build_call(
|
||||
intrinsics.breakpoint,
|
||||
&[ctx.basic(), ptr_const, intrinsics
|
||||
.i32_ty
|
||||
.const_int((breakpoints.len() - 1) as u64, false)
|
||||
.as_basic_value_enum()],
|
||||
&[
|
||||
ctx.basic(),
|
||||
ptr_const,
|
||||
intrinsics
|
||||
.i32_ty
|
||||
.const_int((breakpoints.len() - 1) as u64, false)
|
||||
.as_basic_value_enum(),
|
||||
],
|
||||
&state.var_name(),
|
||||
);
|
||||
},
|
||||
}
|
||||
InternalEvent::GetInternal(index) => {
|
||||
let ptr = ctx.internal_pointer(index as usize, intrinsics);
|
||||
let value = builder.build_load(ptr, "internal_value");
|
||||
@ -2678,7 +2683,8 @@ impl ModuleCodeGenerator<LLVMFunctionCodeGenerator, LLVMBackend, CodegenError>
|
||||
|
||||
// self.module.print_to_stderr();
|
||||
|
||||
let (backend, cache_gen) = LLVMBackend::new(self.module, self.intrinsics.take().unwrap(), breakpoints);
|
||||
let (backend, cache_gen) =
|
||||
LLVMBackend::new(self.module, self.intrinsics.take().unwrap(), breakpoints);
|
||||
Ok((backend, Box::new(cache_gen)))
|
||||
}
|
||||
|
||||
@ -2711,7 +2717,9 @@ impl ModuleCodeGenerator<LLVMFunctionCodeGenerator, LLVMBackend, CodegenError>
|
||||
}
|
||||
|
||||
unsafe fn from_cache(_artifact: Artifact, _: Token) -> Result<ModuleInner, CacheError> {
|
||||
Err(CacheError::Unknown("caching is broken for LLVM backend".into()))
|
||||
Err(CacheError::Unknown(
|
||||
"caching is broken for LLVM backend".into(),
|
||||
))
|
||||
/*
|
||||
let (info, _, memory) = artifact.consume();
|
||||
let (backend, cache_gen) =
|
||||
|
@ -252,7 +252,10 @@ impl Intrinsics {
|
||||
|
||||
let ret_i1_take_i1_i1 = i1_ty.fn_type(&[i1_ty_basic, i1_ty_basic], false);
|
||||
|
||||
let ret_i32_take_ctx_i64_i32 = i32_ty.fn_type(&[ctx_ptr_ty.as_basic_type_enum(), i64_ty_basic, i32_ty_basic], false);
|
||||
let ret_i32_take_ctx_i64_i32 = i32_ty.fn_type(
|
||||
&[ctx_ptr_ty.as_basic_type_enum(), i64_ty_basic, i32_ty_basic],
|
||||
false,
|
||||
);
|
||||
|
||||
Self {
|
||||
ctlz_i32: module.add_function("llvm.ctlz.i32", ret_i32_take_i32_i1, None),
|
||||
@ -386,11 +389,7 @@ impl Intrinsics {
|
||||
ret_i32_take_ctx_i32,
|
||||
None,
|
||||
),
|
||||
breakpoint: module.add_function(
|
||||
"vm.breakpoint",
|
||||
ret_i32_take_ctx_i64_i32,
|
||||
None,
|
||||
),
|
||||
breakpoint: module.add_function("vm.breakpoint", ret_i32_take_ctx_i64_i32, None),
|
||||
throw_trap: module.add_function(
|
||||
"vm.exception.trap",
|
||||
void_ty.fn_type(&[i32_ty_basic], false),
|
||||
@ -706,15 +705,11 @@ impl<'a> CtxType<'a> {
|
||||
"internals_array_ptr_ptr",
|
||||
)
|
||||
};
|
||||
let array_ptr = cache_builder.build_load(array_ptr_ptr, "internals_array_ptr").into_pointer_value();
|
||||
let array_ptr = cache_builder
|
||||
.build_load(array_ptr_ptr, "internals_array_ptr")
|
||||
.into_pointer_value();
|
||||
let const_index = intrinsics.i32_ty.const_int(index as u64, false);
|
||||
unsafe {
|
||||
cache_builder.build_in_bounds_gep(
|
||||
array_ptr,
|
||||
&[const_index],
|
||||
"element_ptr",
|
||||
)
|
||||
}
|
||||
unsafe { cache_builder.build_in_bounds_gep(array_ptr, &[const_index], "element_ptr") }
|
||||
})
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user